1 | <?php |
||
18 | class PhpFile extends PublicKeyStore |
||
19 | { |
||
20 | /** |
||
21 | * PHP code used to prevent unauthorized access |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $fileBlocker = '<?php if (!isset($isMsgApiKeystore) || !$isMsgApiKeystore) die(\'Unauthorized access\');'; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $file; |
||
31 | |||
32 | /** |
||
33 | * cache of array |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | private $keystore = array(); |
||
38 | |||
39 | /** |
||
40 | * @param string $file path to a read and writable (empty) PHP file |
||
41 | * @throws Exception if the file does not exist, is not writable or no valid PHP file |
||
42 | */ |
||
43 | public function __construct($file) |
||
53 | |||
54 | /** |
||
55 | * return null if the public key not found in the store |
||
56 | * |
||
57 | * @param string $threemaId |
||
58 | * @return null|string |
||
59 | */ |
||
60 | public function findPublicKey($threemaId) |
||
86 | |||
87 | /** |
||
88 | * save a public key |
||
89 | * |
||
90 | * @param string $threemaId |
||
91 | * @param string $publicKey |
||
92 | * @throws Exception |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function savePublicKey($threemaId, $publicKey) |
||
117 | |||
118 | /** |
||
119 | * initiate a php file |
||
120 | * |
||
121 | * @param null|resource file handle for file opened in r+ mode |
||
122 | * @return bool |
||
123 | * @throws Exception |
||
124 | */ |
||
125 | private function initFile($fileHandle = null) |
||
166 | |||
167 | /** |
||
168 | * Initialize a new PhpFile Public Key Store |
||
169 | * @param string $path the file will be created if it does not exist |
||
170 | * @return PhpFile |
||
171 | */ |
||
172 | public static function create($path) { |
||
180 | } |
||
181 |