|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LeKoala\Encrypt\Test; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Assets\File; |
|
6
|
|
|
use SilverStripe\Dev\TestOnly; |
|
7
|
|
|
use SilverStripe\ORM\DataObject; |
|
8
|
|
|
use LeKoala\Encrypt\EncryptedDBText; |
|
9
|
|
|
use LeKoala\Encrypt\EncryptedDBField; |
|
10
|
|
|
use LeKoala\Encrypt\EncryptedDBVarchar; |
|
11
|
|
|
use LeKoala\Encrypt\HasEncryptedFields; |
|
12
|
|
|
use LeKoala\Encrypt\EncryptedDBHTMLText; |
|
13
|
|
|
use LeKoala\Encrypt\EncryptedNumberField; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* A test model for our encryption |
|
17
|
|
|
* |
|
18
|
|
|
* @property string $Name |
|
19
|
|
|
* @property string $MyText |
|
20
|
|
|
* @property string $MyHTMLText |
|
21
|
|
|
* @property string $MyVarchar |
|
22
|
|
|
* @property string $MyNumber |
|
23
|
|
|
* @property string $MyVarcharWithIndex |
|
24
|
|
|
* @property int $RegularFileID |
|
25
|
|
|
* @property int $EncryptedFileID |
|
26
|
|
|
*/ |
|
27
|
|
|
class Test_EncryptedModel extends DataObject implements TestOnly |
|
28
|
|
|
{ |
|
29
|
|
|
use HasEncryptedFields; |
|
30
|
|
|
|
|
31
|
|
|
private static $table_name = 'EncryptedModel'; |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
private static $db = [ |
|
|
|
|
|
|
34
|
|
|
"Name" => 'Varchar', |
|
35
|
|
|
"MyText" => EncryptedDBText::class, |
|
36
|
|
|
"MyHTMLText" => EncryptedDBHTMLText::class, |
|
37
|
|
|
"MyVarchar" => EncryptedDBVarchar::class, |
|
38
|
|
|
"MyNumber" => EncryptedNumberField::class, |
|
39
|
|
|
"MyIndexedVarchar" => EncryptedDBField::class, |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
|
|
private static $has_one = [ |
|
|
|
|
|
|
43
|
|
|
"RegularFile" => File::class, |
|
44
|
|
|
"EncryptedFile" => File::class, |
|
45
|
|
|
]; |
|
46
|
|
|
|
|
47
|
|
|
private static $indexes = [ |
|
|
|
|
|
|
48
|
|
|
'MyIndexedVarcharBlindIndex' => true, |
|
49
|
|
|
'MyNumberBlindIndex' => true, |
|
50
|
|
|
'MyNumberLastFourBlindIndex' => true, |
|
51
|
|
|
]; |
|
52
|
|
|
|
|
53
|
|
|
public function getField($field) |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->getEncryptedField($field); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function setField($fieldName, $val) |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->setEncryptedField($fieldName, $val); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|