@@ -34,67 +34,67 @@ |
||
34 | 34 | */ |
35 | 35 | interface IManager { |
36 | 36 | |
37 | - /** |
|
38 | - * Check if encryption is available (at least one encryption module needs to be enabled) |
|
39 | - * |
|
40 | - * @return bool true if enabled, false if not |
|
41 | - * @since 8.1.0 |
|
42 | - */ |
|
43 | - public function isEnabled(); |
|
37 | + /** |
|
38 | + * Check if encryption is available (at least one encryption module needs to be enabled) |
|
39 | + * |
|
40 | + * @return bool true if enabled, false if not |
|
41 | + * @since 8.1.0 |
|
42 | + */ |
|
43 | + public function isEnabled(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * Registers an callback function which must return an encryption module instance |
|
47 | - * |
|
48 | - * @param string $id |
|
49 | - * @param string $displayName |
|
50 | - * @param callable $callback |
|
51 | - * @throws ModuleAlreadyExistsException |
|
52 | - * @since 8.1.0 |
|
53 | - */ |
|
54 | - public function registerEncryptionModule($id, $displayName, callable $callback); |
|
45 | + /** |
|
46 | + * Registers an callback function which must return an encryption module instance |
|
47 | + * |
|
48 | + * @param string $id |
|
49 | + * @param string $displayName |
|
50 | + * @param callable $callback |
|
51 | + * @throws ModuleAlreadyExistsException |
|
52 | + * @since 8.1.0 |
|
53 | + */ |
|
54 | + public function registerEncryptionModule($id, $displayName, callable $callback); |
|
55 | 55 | |
56 | - /** |
|
57 | - * Unregisters an encryption module |
|
58 | - * |
|
59 | - * @param string $moduleId |
|
60 | - * @since 8.1.0 |
|
61 | - */ |
|
62 | - public function unregisterEncryptionModule($moduleId); |
|
56 | + /** |
|
57 | + * Unregisters an encryption module |
|
58 | + * |
|
59 | + * @param string $moduleId |
|
60 | + * @since 8.1.0 |
|
61 | + */ |
|
62 | + public function unregisterEncryptionModule($moduleId); |
|
63 | 63 | |
64 | - /** |
|
65 | - * get a list of all encryption modules |
|
66 | - * |
|
67 | - * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
68 | - * @since 8.1.0 |
|
69 | - */ |
|
70 | - public function getEncryptionModules(); |
|
64 | + /** |
|
65 | + * get a list of all encryption modules |
|
66 | + * |
|
67 | + * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
68 | + * @since 8.1.0 |
|
69 | + */ |
|
70 | + public function getEncryptionModules(); |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * get a specific encryption module |
|
75 | - * |
|
76 | - * @param string $moduleId Empty to get the default module |
|
77 | - * @return IEncryptionModule |
|
78 | - * @throws ModuleDoesNotExistsException |
|
79 | - * @since 8.1.0 |
|
80 | - */ |
|
81 | - public function getEncryptionModule($moduleId = ''); |
|
73 | + /** |
|
74 | + * get a specific encryption module |
|
75 | + * |
|
76 | + * @param string $moduleId Empty to get the default module |
|
77 | + * @return IEncryptionModule |
|
78 | + * @throws ModuleDoesNotExistsException |
|
79 | + * @since 8.1.0 |
|
80 | + */ |
|
81 | + public function getEncryptionModule($moduleId = ''); |
|
82 | 82 | |
83 | - /** |
|
84 | - * get default encryption module Id |
|
85 | - * |
|
86 | - * @return string |
|
87 | - * @since 8.1.0 |
|
88 | - */ |
|
89 | - public function getDefaultEncryptionModuleId(); |
|
83 | + /** |
|
84 | + * get default encryption module Id |
|
85 | + * |
|
86 | + * @return string |
|
87 | + * @since 8.1.0 |
|
88 | + */ |
|
89 | + public function getDefaultEncryptionModuleId(); |
|
90 | 90 | |
91 | - /** |
|
92 | - * set default encryption module Id |
|
93 | - * |
|
94 | - * @param string $moduleId |
|
95 | - * @return string |
|
96 | - * @since 8.1.0 |
|
97 | - */ |
|
98 | - public function setDefaultEncryptionModule($moduleId); |
|
91 | + /** |
|
92 | + * set default encryption module Id |
|
93 | + * |
|
94 | + * @param string $moduleId |
|
95 | + * @return string |
|
96 | + * @since 8.1.0 |
|
97 | + */ |
|
98 | + public function setDefaultEncryptionModule($moduleId); |
|
99 | 99 | |
100 | 100 | } |
@@ -33,151 +33,151 @@ |
||
33 | 33 | */ |
34 | 34 | interface IStorage { |
35 | 35 | |
36 | - /** |
|
37 | - * get user specific key |
|
38 | - * |
|
39 | - * @param string $uid ID if the user for whom we want the key |
|
40 | - * @param string $keyId id of the key |
|
41 | - * @param string $encryptionModuleId |
|
42 | - * |
|
43 | - * @return mixed key |
|
44 | - * @since 8.1.0 |
|
45 | - */ |
|
46 | - public function getUserKey($uid, $keyId, $encryptionModuleId); |
|
36 | + /** |
|
37 | + * get user specific key |
|
38 | + * |
|
39 | + * @param string $uid ID if the user for whom we want the key |
|
40 | + * @param string $keyId id of the key |
|
41 | + * @param string $encryptionModuleId |
|
42 | + * |
|
43 | + * @return mixed key |
|
44 | + * @since 8.1.0 |
|
45 | + */ |
|
46 | + public function getUserKey($uid, $keyId, $encryptionModuleId); |
|
47 | 47 | |
48 | - /** |
|
49 | - * get file specific key |
|
50 | - * |
|
51 | - * @param string $path path to file |
|
52 | - * @param string $keyId id of the key |
|
53 | - * @param string $encryptionModuleId |
|
54 | - * |
|
55 | - * @return mixed key |
|
56 | - * @since 8.1.0 |
|
57 | - */ |
|
58 | - public function getFileKey($path, $keyId, $encryptionModuleId); |
|
48 | + /** |
|
49 | + * get file specific key |
|
50 | + * |
|
51 | + * @param string $path path to file |
|
52 | + * @param string $keyId id of the key |
|
53 | + * @param string $encryptionModuleId |
|
54 | + * |
|
55 | + * @return mixed key |
|
56 | + * @since 8.1.0 |
|
57 | + */ |
|
58 | + public function getFileKey($path, $keyId, $encryptionModuleId); |
|
59 | 59 | |
60 | - /** |
|
61 | - * get system-wide encryption keys not related to a specific user, |
|
62 | - * e.g something like a key for public link shares |
|
63 | - * |
|
64 | - * @param string $keyId id of the key |
|
65 | - * @param string $encryptionModuleId |
|
66 | - * |
|
67 | - * @return mixed key |
|
68 | - * @since 8.1.0 |
|
69 | - */ |
|
70 | - public function getSystemUserKey($keyId, $encryptionModuleId); |
|
60 | + /** |
|
61 | + * get system-wide encryption keys not related to a specific user, |
|
62 | + * e.g something like a key for public link shares |
|
63 | + * |
|
64 | + * @param string $keyId id of the key |
|
65 | + * @param string $encryptionModuleId |
|
66 | + * |
|
67 | + * @return mixed key |
|
68 | + * @since 8.1.0 |
|
69 | + */ |
|
70 | + public function getSystemUserKey($keyId, $encryptionModuleId); |
|
71 | 71 | |
72 | - /** |
|
73 | - * set user specific key |
|
74 | - * |
|
75 | - * @param string $uid ID if the user for whom we want the key |
|
76 | - * @param string $keyId id of the key |
|
77 | - * @param mixed $key |
|
78 | - * @param string $encryptionModuleId |
|
79 | - * @since 8.1.0 |
|
80 | - */ |
|
81 | - public function setUserKey($uid, $keyId, $key, $encryptionModuleId); |
|
72 | + /** |
|
73 | + * set user specific key |
|
74 | + * |
|
75 | + * @param string $uid ID if the user for whom we want the key |
|
76 | + * @param string $keyId id of the key |
|
77 | + * @param mixed $key |
|
78 | + * @param string $encryptionModuleId |
|
79 | + * @since 8.1.0 |
|
80 | + */ |
|
81 | + public function setUserKey($uid, $keyId, $key, $encryptionModuleId); |
|
82 | 82 | |
83 | - /** |
|
84 | - * set file specific key |
|
85 | - * |
|
86 | - * @param string $path path to file |
|
87 | - * @param string $keyId id of the key |
|
88 | - * @param mixed $key |
|
89 | - * @param string $encryptionModuleId |
|
90 | - * @since 8.1.0 |
|
91 | - */ |
|
92 | - public function setFileKey($path, $keyId, $key, $encryptionModuleId); |
|
83 | + /** |
|
84 | + * set file specific key |
|
85 | + * |
|
86 | + * @param string $path path to file |
|
87 | + * @param string $keyId id of the key |
|
88 | + * @param mixed $key |
|
89 | + * @param string $encryptionModuleId |
|
90 | + * @since 8.1.0 |
|
91 | + */ |
|
92 | + public function setFileKey($path, $keyId, $key, $encryptionModuleId); |
|
93 | 93 | |
94 | - /** |
|
95 | - * set system-wide encryption keys not related to a specific user, |
|
96 | - * e.g something like a key for public link shares |
|
97 | - * |
|
98 | - * @param string $keyId id of the key |
|
99 | - * @param mixed $key |
|
100 | - * @param string $encryptionModuleId |
|
101 | - * |
|
102 | - * @return mixed key |
|
103 | - * @since 8.1.0 |
|
104 | - */ |
|
105 | - public function setSystemUserKey($keyId, $key, $encryptionModuleId); |
|
94 | + /** |
|
95 | + * set system-wide encryption keys not related to a specific user, |
|
96 | + * e.g something like a key for public link shares |
|
97 | + * |
|
98 | + * @param string $keyId id of the key |
|
99 | + * @param mixed $key |
|
100 | + * @param string $encryptionModuleId |
|
101 | + * |
|
102 | + * @return mixed key |
|
103 | + * @since 8.1.0 |
|
104 | + */ |
|
105 | + public function setSystemUserKey($keyId, $key, $encryptionModuleId); |
|
106 | 106 | |
107 | - /** |
|
108 | - * delete user specific key |
|
109 | - * |
|
110 | - * @param string $uid ID if the user for whom we want to delete the key |
|
111 | - * @param string $keyId id of the key |
|
112 | - * @param string $encryptionModuleId |
|
113 | - * |
|
114 | - * @return boolean False when the key could not be deleted |
|
115 | - * @since 8.1.0 |
|
116 | - */ |
|
117 | - public function deleteUserKey($uid, $keyId, $encryptionModuleId); |
|
107 | + /** |
|
108 | + * delete user specific key |
|
109 | + * |
|
110 | + * @param string $uid ID if the user for whom we want to delete the key |
|
111 | + * @param string $keyId id of the key |
|
112 | + * @param string $encryptionModuleId |
|
113 | + * |
|
114 | + * @return boolean False when the key could not be deleted |
|
115 | + * @since 8.1.0 |
|
116 | + */ |
|
117 | + public function deleteUserKey($uid, $keyId, $encryptionModuleId); |
|
118 | 118 | |
119 | - /** |
|
120 | - * delete file specific key |
|
121 | - * |
|
122 | - * @param string $path path to file |
|
123 | - * @param string $keyId id of the key |
|
124 | - * @param string $encryptionModuleId |
|
125 | - * |
|
126 | - * @return boolean False when the key could not be deleted |
|
127 | - * @since 8.1.0 |
|
128 | - */ |
|
129 | - public function deleteFileKey($path, $keyId, $encryptionModuleId); |
|
119 | + /** |
|
120 | + * delete file specific key |
|
121 | + * |
|
122 | + * @param string $path path to file |
|
123 | + * @param string $keyId id of the key |
|
124 | + * @param string $encryptionModuleId |
|
125 | + * |
|
126 | + * @return boolean False when the key could not be deleted |
|
127 | + * @since 8.1.0 |
|
128 | + */ |
|
129 | + public function deleteFileKey($path, $keyId, $encryptionModuleId); |
|
130 | 130 | |
131 | - /** |
|
132 | - * delete all file keys for a given file |
|
133 | - * |
|
134 | - * @param string $path to the file |
|
135 | - * |
|
136 | - * @return boolean False when the keys could not be deleted |
|
137 | - * @since 8.1.0 |
|
138 | - */ |
|
139 | - public function deleteAllFileKeys($path); |
|
131 | + /** |
|
132 | + * delete all file keys for a given file |
|
133 | + * |
|
134 | + * @param string $path to the file |
|
135 | + * |
|
136 | + * @return boolean False when the keys could not be deleted |
|
137 | + * @since 8.1.0 |
|
138 | + */ |
|
139 | + public function deleteAllFileKeys($path); |
|
140 | 140 | |
141 | - /** |
|
142 | - * delete system-wide encryption keys not related to a specific user, |
|
143 | - * e.g something like a key for public link shares |
|
144 | - * |
|
145 | - * @param string $keyId id of the key |
|
146 | - * @param string $encryptionModuleId |
|
147 | - * |
|
148 | - * @return boolean False when the key could not be deleted |
|
149 | - * @since 8.1.0 |
|
150 | - */ |
|
151 | - public function deleteSystemUserKey($keyId, $encryptionModuleId); |
|
141 | + /** |
|
142 | + * delete system-wide encryption keys not related to a specific user, |
|
143 | + * e.g something like a key for public link shares |
|
144 | + * |
|
145 | + * @param string $keyId id of the key |
|
146 | + * @param string $encryptionModuleId |
|
147 | + * |
|
148 | + * @return boolean False when the key could not be deleted |
|
149 | + * @since 8.1.0 |
|
150 | + */ |
|
151 | + public function deleteSystemUserKey($keyId, $encryptionModuleId); |
|
152 | 152 | |
153 | - /** |
|
154 | - * copy keys if a file was renamed |
|
155 | - * |
|
156 | - * @param string $source |
|
157 | - * @param string $target |
|
158 | - * @return boolean |
|
159 | - * @since 8.1.0 |
|
160 | - */ |
|
161 | - public function renameKeys($source, $target); |
|
153 | + /** |
|
154 | + * copy keys if a file was renamed |
|
155 | + * |
|
156 | + * @param string $source |
|
157 | + * @param string $target |
|
158 | + * @return boolean |
|
159 | + * @since 8.1.0 |
|
160 | + */ |
|
161 | + public function renameKeys($source, $target); |
|
162 | 162 | |
163 | - /** |
|
164 | - * move keys if a file was renamed |
|
165 | - * |
|
166 | - * @param string $source |
|
167 | - * @param string $target |
|
168 | - * @return boolean |
|
169 | - * @since 8.1.0 |
|
170 | - */ |
|
171 | - public function copyKeys($source, $target); |
|
163 | + /** |
|
164 | + * move keys if a file was renamed |
|
165 | + * |
|
166 | + * @param string $source |
|
167 | + * @param string $target |
|
168 | + * @return boolean |
|
169 | + * @since 8.1.0 |
|
170 | + */ |
|
171 | + public function copyKeys($source, $target); |
|
172 | 172 | |
173 | - /** |
|
174 | - * backup keys of a given encryption module |
|
175 | - * |
|
176 | - * @param string $encryptionModuleId |
|
177 | - * @param string $purpose |
|
178 | - * @param string $uid |
|
179 | - * @return bool |
|
180 | - * @since 12.0.0 |
|
181 | - */ |
|
182 | - public function backupUserKeys($encryptionModuleId, $purpose, $uid); |
|
173 | + /** |
|
174 | + * backup keys of a given encryption module |
|
175 | + * |
|
176 | + * @param string $encryptionModuleId |
|
177 | + * @param string $purpose |
|
178 | + * @param string $uid |
|
179 | + * @return bool |
|
180 | + * @since 12.0.0 |
|
181 | + */ |
|
182 | + public function backupUserKeys($encryptionModuleId, $purpose, $uid); |
|
183 | 183 | } |
@@ -28,45 +28,45 @@ |
||
28 | 28 | |
29 | 29 | class Credentials implements ICredentials { |
30 | 30 | |
31 | - /** @var string */ |
|
32 | - private $uid; |
|
31 | + /** @var string */ |
|
32 | + private $uid; |
|
33 | 33 | |
34 | - /** @var string */ |
|
35 | - private $loginName; |
|
34 | + /** @var string */ |
|
35 | + private $loginName; |
|
36 | 36 | |
37 | - /** @var string */ |
|
38 | - private $password; |
|
37 | + /** @var string */ |
|
38 | + private $password; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $uid |
|
42 | - * @param string $loginName |
|
43 | - * @param string $password |
|
44 | - */ |
|
45 | - public function __construct($uid, $loginName, $password) { |
|
46 | - $this->uid = $uid; |
|
47 | - $this->loginName = $loginName; |
|
48 | - $this->password = $password; |
|
49 | - } |
|
40 | + /** |
|
41 | + * @param string $uid |
|
42 | + * @param string $loginName |
|
43 | + * @param string $password |
|
44 | + */ |
|
45 | + public function __construct($uid, $loginName, $password) { |
|
46 | + $this->uid = $uid; |
|
47 | + $this->loginName = $loginName; |
|
48 | + $this->password = $password; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function getUID() { |
|
55 | - return $this->uid; |
|
56 | - } |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function getUID() { |
|
55 | + return $this->uid; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function getLoginName() { |
|
62 | - return $this->loginName; |
|
63 | - } |
|
58 | + /** |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function getLoginName() { |
|
62 | + return $this->loginName; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getPassword() { |
|
69 | - return $this->password; |
|
70 | - } |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getPassword() { |
|
69 | + return $this->password; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | } |
@@ -34,93 +34,93 @@ |
||
34 | 34 | */ |
35 | 35 | class CredentialsManager implements ICredentialsManager { |
36 | 36 | |
37 | - const DB_TABLE = 'credentials'; |
|
37 | + const DB_TABLE = 'credentials'; |
|
38 | 38 | |
39 | - /** @var ICrypto */ |
|
40 | - protected $crypto; |
|
39 | + /** @var ICrypto */ |
|
40 | + protected $crypto; |
|
41 | 41 | |
42 | - /** @var IDBConnection */ |
|
43 | - protected $dbConnection; |
|
42 | + /** @var IDBConnection */ |
|
43 | + protected $dbConnection; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param ICrypto $crypto |
|
47 | - * @param IDBConnection $dbConnection |
|
48 | - */ |
|
49 | - public function __construct(ICrypto $crypto, IDBConnection $dbConnection) { |
|
50 | - $this->crypto = $crypto; |
|
51 | - $this->dbConnection = $dbConnection; |
|
52 | - } |
|
45 | + /** |
|
46 | + * @param ICrypto $crypto |
|
47 | + * @param IDBConnection $dbConnection |
|
48 | + */ |
|
49 | + public function __construct(ICrypto $crypto, IDBConnection $dbConnection) { |
|
50 | + $this->crypto = $crypto; |
|
51 | + $this->dbConnection = $dbConnection; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Store a set of credentials |
|
56 | - * |
|
57 | - * @param string|null $userId Null for system-wide credentials |
|
58 | - * @param string $identifier |
|
59 | - * @param mixed $credentials |
|
60 | - */ |
|
61 | - public function store($userId, $identifier, $credentials) { |
|
62 | - $value = $this->crypto->encrypt(json_encode($credentials)); |
|
54 | + /** |
|
55 | + * Store a set of credentials |
|
56 | + * |
|
57 | + * @param string|null $userId Null for system-wide credentials |
|
58 | + * @param string $identifier |
|
59 | + * @param mixed $credentials |
|
60 | + */ |
|
61 | + public function store($userId, $identifier, $credentials) { |
|
62 | + $value = $this->crypto->encrypt(json_encode($credentials)); |
|
63 | 63 | |
64 | - $this->dbConnection->setValues(self::DB_TABLE, [ |
|
65 | - 'user' => $userId, |
|
66 | - 'identifier' => $identifier, |
|
67 | - ], [ |
|
68 | - 'credentials' => $value, |
|
69 | - ]); |
|
70 | - } |
|
64 | + $this->dbConnection->setValues(self::DB_TABLE, [ |
|
65 | + 'user' => $userId, |
|
66 | + 'identifier' => $identifier, |
|
67 | + ], [ |
|
68 | + 'credentials' => $value, |
|
69 | + ]); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Retrieve a set of credentials |
|
74 | - * |
|
75 | - * @param string|null $userId Null for system-wide credentials |
|
76 | - * @param string $identifier |
|
77 | - * @return mixed |
|
78 | - */ |
|
79 | - public function retrieve($userId, $identifier) { |
|
80 | - $qb = $this->dbConnection->getQueryBuilder(); |
|
81 | - $qb->select('credentials') |
|
82 | - ->from(self::DB_TABLE) |
|
83 | - ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) |
|
84 | - ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) |
|
85 | - ; |
|
86 | - $result = $qb->execute()->fetch(); |
|
72 | + /** |
|
73 | + * Retrieve a set of credentials |
|
74 | + * |
|
75 | + * @param string|null $userId Null for system-wide credentials |
|
76 | + * @param string $identifier |
|
77 | + * @return mixed |
|
78 | + */ |
|
79 | + public function retrieve($userId, $identifier) { |
|
80 | + $qb = $this->dbConnection->getQueryBuilder(); |
|
81 | + $qb->select('credentials') |
|
82 | + ->from(self::DB_TABLE) |
|
83 | + ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) |
|
84 | + ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) |
|
85 | + ; |
|
86 | + $result = $qb->execute()->fetch(); |
|
87 | 87 | |
88 | - if (!$result) { |
|
89 | - return null; |
|
90 | - } |
|
91 | - $value = $result['credentials']; |
|
88 | + if (!$result) { |
|
89 | + return null; |
|
90 | + } |
|
91 | + $value = $result['credentials']; |
|
92 | 92 | |
93 | - return json_decode($this->crypto->decrypt($value), true); |
|
94 | - } |
|
93 | + return json_decode($this->crypto->decrypt($value), true); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Delete a set of credentials |
|
98 | - * |
|
99 | - * @param string|null $userId Null for system-wide credentials |
|
100 | - * @param string $identifier |
|
101 | - * @return int rows removed |
|
102 | - */ |
|
103 | - public function delete($userId, $identifier) { |
|
104 | - $qb = $this->dbConnection->getQueryBuilder(); |
|
105 | - $qb->delete(self::DB_TABLE) |
|
106 | - ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) |
|
107 | - ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) |
|
108 | - ; |
|
109 | - return $qb->execute(); |
|
110 | - } |
|
96 | + /** |
|
97 | + * Delete a set of credentials |
|
98 | + * |
|
99 | + * @param string|null $userId Null for system-wide credentials |
|
100 | + * @param string $identifier |
|
101 | + * @return int rows removed |
|
102 | + */ |
|
103 | + public function delete($userId, $identifier) { |
|
104 | + $qb = $this->dbConnection->getQueryBuilder(); |
|
105 | + $qb->delete(self::DB_TABLE) |
|
106 | + ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) |
|
107 | + ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) |
|
108 | + ; |
|
109 | + return $qb->execute(); |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * Erase all credentials stored for a user |
|
114 | - * |
|
115 | - * @param string $userId |
|
116 | - * @return int rows removed |
|
117 | - */ |
|
118 | - public function erase($userId) { |
|
119 | - $qb = $this->dbConnection->getQueryBuilder(); |
|
120 | - $qb->delete(self::DB_TABLE) |
|
121 | - ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) |
|
122 | - ; |
|
123 | - return $qb->execute(); |
|
124 | - } |
|
112 | + /** |
|
113 | + * Erase all credentials stored for a user |
|
114 | + * |
|
115 | + * @param string $userId |
|
116 | + * @return int rows removed |
|
117 | + */ |
|
118 | + public function erase($userId) { |
|
119 | + $qb = $this->dbConnection->getQueryBuilder(); |
|
120 | + $qb->delete(self::DB_TABLE) |
|
121 | + ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) |
|
122 | + ; |
|
123 | + return $qb->execute(); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | } |
@@ -27,104 +27,104 @@ |
||
27 | 27 | use OCP\ICertificate; |
28 | 28 | |
29 | 29 | class Certificate implements ICertificate { |
30 | - protected $name; |
|
31 | - |
|
32 | - protected $commonName; |
|
33 | - |
|
34 | - protected $organization; |
|
35 | - |
|
36 | - protected $serial; |
|
37 | - |
|
38 | - protected $issueDate; |
|
39 | - |
|
40 | - protected $expireDate; |
|
41 | - |
|
42 | - protected $issuerName; |
|
43 | - |
|
44 | - protected $issuerOrganization; |
|
45 | - |
|
46 | - /** |
|
47 | - * @param string $data base64 encoded certificate |
|
48 | - * @param string $name |
|
49 | - * @throws \Exception If the certificate could not get parsed |
|
50 | - */ |
|
51 | - public function __construct($data, $name) { |
|
52 | - $this->name = $name; |
|
53 | - $gmt = new \DateTimeZone('GMT'); |
|
54 | - |
|
55 | - // If string starts with "file://" ignore the certificate |
|
56 | - $query = 'file://'; |
|
57 | - if(strtolower(substr($data, 0, strlen($query))) === $query) { |
|
58 | - throw new \Exception('Certificate could not get parsed.'); |
|
59 | - } |
|
60 | - |
|
61 | - $info = openssl_x509_parse($data); |
|
62 | - if(!is_array($info)) { |
|
63 | - throw new \Exception('Certificate could not get parsed.'); |
|
64 | - } |
|
65 | - |
|
66 | - $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; |
|
67 | - $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; |
|
68 | - $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); |
|
69 | - $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); |
|
70 | - $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; |
|
71 | - $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getName() { |
|
78 | - return $this->name; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return string|null |
|
83 | - */ |
|
84 | - public function getCommonName() { |
|
85 | - return $this->commonName; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function getOrganization() { |
|
92 | - return $this->organization; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @return \DateTime |
|
97 | - */ |
|
98 | - public function getIssueDate() { |
|
99 | - return $this->issueDate; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @return \DateTime |
|
104 | - */ |
|
105 | - public function getExpireDate() { |
|
106 | - return $this->expireDate; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function isExpired() { |
|
113 | - $now = new \DateTime(); |
|
114 | - return $this->issueDate > $now or $now > $this->expireDate; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @return string|null |
|
119 | - */ |
|
120 | - public function getIssuerName() { |
|
121 | - return $this->issuerName; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @return string|null |
|
126 | - */ |
|
127 | - public function getIssuerOrganization() { |
|
128 | - return $this->issuerOrganization; |
|
129 | - } |
|
30 | + protected $name; |
|
31 | + |
|
32 | + protected $commonName; |
|
33 | + |
|
34 | + protected $organization; |
|
35 | + |
|
36 | + protected $serial; |
|
37 | + |
|
38 | + protected $issueDate; |
|
39 | + |
|
40 | + protected $expireDate; |
|
41 | + |
|
42 | + protected $issuerName; |
|
43 | + |
|
44 | + protected $issuerOrganization; |
|
45 | + |
|
46 | + /** |
|
47 | + * @param string $data base64 encoded certificate |
|
48 | + * @param string $name |
|
49 | + * @throws \Exception If the certificate could not get parsed |
|
50 | + */ |
|
51 | + public function __construct($data, $name) { |
|
52 | + $this->name = $name; |
|
53 | + $gmt = new \DateTimeZone('GMT'); |
|
54 | + |
|
55 | + // If string starts with "file://" ignore the certificate |
|
56 | + $query = 'file://'; |
|
57 | + if(strtolower(substr($data, 0, strlen($query))) === $query) { |
|
58 | + throw new \Exception('Certificate could not get parsed.'); |
|
59 | + } |
|
60 | + |
|
61 | + $info = openssl_x509_parse($data); |
|
62 | + if(!is_array($info)) { |
|
63 | + throw new \Exception('Certificate could not get parsed.'); |
|
64 | + } |
|
65 | + |
|
66 | + $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; |
|
67 | + $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; |
|
68 | + $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); |
|
69 | + $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); |
|
70 | + $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; |
|
71 | + $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getName() { |
|
78 | + return $this->name; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return string|null |
|
83 | + */ |
|
84 | + public function getCommonName() { |
|
85 | + return $this->commonName; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function getOrganization() { |
|
92 | + return $this->organization; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @return \DateTime |
|
97 | + */ |
|
98 | + public function getIssueDate() { |
|
99 | + return $this->issueDate; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @return \DateTime |
|
104 | + */ |
|
105 | + public function getExpireDate() { |
|
106 | + return $this->expireDate; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function isExpired() { |
|
113 | + $now = new \DateTime(); |
|
114 | + return $this->issueDate > $now or $now > $this->expireDate; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @return string|null |
|
119 | + */ |
|
120 | + public function getIssuerName() { |
|
121 | + return $this->issuerName; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @return string|null |
|
126 | + */ |
|
127 | + public function getIssuerOrganization() { |
|
128 | + return $this->issuerOrganization; |
|
129 | + } |
|
130 | 130 | } |
@@ -35,46 +35,46 @@ |
||
35 | 35 | */ |
36 | 36 | class HintException extends \Exception { |
37 | 37 | |
38 | - private $hint; |
|
38 | + private $hint; |
|
39 | 39 | |
40 | - /** |
|
41 | - * HintException constructor. |
|
42 | - * |
|
43 | - * @param string $message The error message. It will be not revealed to the |
|
44 | - * the user (unless the hint is empty) and thus |
|
45 | - * should be not translated. |
|
46 | - * @param string $hint A useful message that is presented to the end |
|
47 | - * user. It should be translated, but must not |
|
48 | - * contain sensitive data. |
|
49 | - * @param int $code |
|
50 | - * @param \Exception|null $previous |
|
51 | - */ |
|
52 | - public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
53 | - $this->hint = $hint; |
|
54 | - parent::__construct($message, $code, $previous); |
|
55 | - } |
|
40 | + /** |
|
41 | + * HintException constructor. |
|
42 | + * |
|
43 | + * @param string $message The error message. It will be not revealed to the |
|
44 | + * the user (unless the hint is empty) and thus |
|
45 | + * should be not translated. |
|
46 | + * @param string $hint A useful message that is presented to the end |
|
47 | + * user. It should be translated, but must not |
|
48 | + * contain sensitive data. |
|
49 | + * @param int $code |
|
50 | + * @param \Exception|null $previous |
|
51 | + */ |
|
52 | + public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
53 | + $this->hint = $hint; |
|
54 | + parent::__construct($message, $code, $previous); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Returns a string representation of this Exception that includes the error |
|
59 | - * code, the message and the hint. |
|
60 | - * |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - public function __toString() { |
|
64 | - return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
65 | - } |
|
57 | + /** |
|
58 | + * Returns a string representation of this Exception that includes the error |
|
59 | + * code, the message and the hint. |
|
60 | + * |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + public function __toString() { |
|
64 | + return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Returns the hint with the intention to be presented to the end user. If |
|
69 | - * an empty hint was specified upon instatiation, the message is returned |
|
70 | - * instead. |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getHint() { |
|
75 | - if (empty($this->hint)) { |
|
76 | - return $this->message; |
|
77 | - } |
|
78 | - return $this->hint; |
|
79 | - } |
|
67 | + /** |
|
68 | + * Returns the hint with the intention to be presented to the end user. If |
|
69 | + * an empty hint was specified upon instatiation, the message is returned |
|
70 | + * instead. |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getHint() { |
|
75 | + if (empty($this->hint)) { |
|
76 | + return $this->message; |
|
77 | + } |
|
78 | + return $this->hint; |
|
79 | + } |
|
80 | 80 | } |
@@ -26,79 +26,79 @@ |
||
26 | 26 | use OCP\Diagnostics\IEvent; |
27 | 27 | |
28 | 28 | class Event implements IEvent { |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $id; |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $id; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var float |
|
36 | - */ |
|
37 | - protected $start; |
|
34 | + /** |
|
35 | + * @var float |
|
36 | + */ |
|
37 | + protected $start; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var float |
|
41 | - */ |
|
42 | - protected $end; |
|
39 | + /** |
|
40 | + * @var float |
|
41 | + */ |
|
42 | + protected $end; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $description; |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $description; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $id |
|
51 | - * @param string $description |
|
52 | - * @param float $start |
|
53 | - */ |
|
54 | - public function __construct($id, $description, $start) { |
|
55 | - $this->id = $id; |
|
56 | - $this->description = $description; |
|
57 | - $this->start = $start; |
|
58 | - } |
|
49 | + /** |
|
50 | + * @param string $id |
|
51 | + * @param string $description |
|
52 | + * @param float $start |
|
53 | + */ |
|
54 | + public function __construct($id, $description, $start) { |
|
55 | + $this->id = $id; |
|
56 | + $this->description = $description; |
|
57 | + $this->start = $start; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param float $time |
|
62 | - */ |
|
63 | - public function end($time) { |
|
64 | - $this->end = $time; |
|
65 | - } |
|
60 | + /** |
|
61 | + * @param float $time |
|
62 | + */ |
|
63 | + public function end($time) { |
|
64 | + $this->end = $time; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return float |
|
69 | - */ |
|
70 | - public function getStart() { |
|
71 | - return $this->start; |
|
72 | - } |
|
67 | + /** |
|
68 | + * @return float |
|
69 | + */ |
|
70 | + public function getStart() { |
|
71 | + return $this->start; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getId() { |
|
78 | - return $this->id; |
|
79 | - } |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getId() { |
|
78 | + return $this->id; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function getDescription() { |
|
85 | - return $this->description; |
|
86 | - } |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function getDescription() { |
|
85 | + return $this->description; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return float |
|
90 | - */ |
|
91 | - public function getEnd() { |
|
92 | - return $this->end; |
|
93 | - } |
|
88 | + /** |
|
89 | + * @return float |
|
90 | + */ |
|
91 | + public function getEnd() { |
|
92 | + return $this->end; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @return float |
|
97 | - */ |
|
98 | - public function getDuration() { |
|
99 | - if (!$this->end) { |
|
100 | - $this->end = microtime(true); |
|
101 | - } |
|
102 | - return $this->end - $this->start; |
|
103 | - } |
|
95 | + /** |
|
96 | + * @return float |
|
97 | + */ |
|
98 | + public function getDuration() { |
|
99 | + if (!$this->end) { |
|
100 | + $this->end = microtime(true); |
|
101 | + } |
|
102 | + return $this->end - $this->start; |
|
103 | + } |
|
104 | 104 | } |
@@ -37,54 +37,54 @@ |
||
37 | 37 | */ |
38 | 38 | class Tag extends Entity { |
39 | 39 | |
40 | - protected $owner; |
|
41 | - protected $type; |
|
42 | - protected $name; |
|
40 | + protected $owner; |
|
41 | + protected $type; |
|
42 | + protected $name; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor. |
|
46 | - * |
|
47 | - * @param string $owner The tag's owner |
|
48 | - * @param string $type The type of item this tag is used for |
|
49 | - * @param string $name The tag's name |
|
50 | - */ |
|
51 | - public function __construct($owner = null, $type = null, $name = null) { |
|
52 | - $this->setOwner($owner); |
|
53 | - $this->setType($type); |
|
54 | - $this->setName($name); |
|
55 | - } |
|
44 | + /** |
|
45 | + * Constructor. |
|
46 | + * |
|
47 | + * @param string $owner The tag's owner |
|
48 | + * @param string $type The type of item this tag is used for |
|
49 | + * @param string $name The tag's name |
|
50 | + */ |
|
51 | + public function __construct($owner = null, $type = null, $name = null) { |
|
52 | + $this->setOwner($owner); |
|
53 | + $this->setType($type); |
|
54 | + $this->setName($name); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Transform a database columnname to a property |
|
59 | - * |
|
60 | - * @param string $columnName the name of the column |
|
61 | - * @return string the property name |
|
62 | - * @todo migrate existing database columns to the correct names |
|
63 | - * to be able to drop this direct mapping |
|
64 | - */ |
|
65 | - public function columnToProperty($columnName){ |
|
66 | - if ($columnName === 'category') { |
|
67 | - return 'name'; |
|
68 | - } elseif ($columnName === 'uid') { |
|
69 | - return 'owner'; |
|
70 | - } else { |
|
71 | - return parent::columnToProperty($columnName); |
|
72 | - } |
|
73 | - } |
|
57 | + /** |
|
58 | + * Transform a database columnname to a property |
|
59 | + * |
|
60 | + * @param string $columnName the name of the column |
|
61 | + * @return string the property name |
|
62 | + * @todo migrate existing database columns to the correct names |
|
63 | + * to be able to drop this direct mapping |
|
64 | + */ |
|
65 | + public function columnToProperty($columnName){ |
|
66 | + if ($columnName === 'category') { |
|
67 | + return 'name'; |
|
68 | + } elseif ($columnName === 'uid') { |
|
69 | + return 'owner'; |
|
70 | + } else { |
|
71 | + return parent::columnToProperty($columnName); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Transform a property to a database column name |
|
77 | - * |
|
78 | - * @param string $property the name of the property |
|
79 | - * @return string the column name |
|
80 | - */ |
|
81 | - public function propertyToColumn($property){ |
|
82 | - if ($property === 'name') { |
|
83 | - return 'category'; |
|
84 | - } elseif ($property === 'owner') { |
|
85 | - return 'uid'; |
|
86 | - } else { |
|
87 | - return parent::propertyToColumn($property); |
|
88 | - } |
|
89 | - } |
|
75 | + /** |
|
76 | + * Transform a property to a database column name |
|
77 | + * |
|
78 | + * @param string $property the name of the property |
|
79 | + * @return string the column name |
|
80 | + */ |
|
81 | + public function propertyToColumn($property){ |
|
82 | + if ($property === 'name') { |
|
83 | + return 'category'; |
|
84 | + } elseif ($property === 'owner') { |
|
85 | + return 'uid'; |
|
86 | + } else { |
|
87 | + return parent::propertyToColumn($property); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | } |
@@ -25,14 +25,14 @@ |
||
25 | 25 | namespace OC; |
26 | 26 | |
27 | 27 | class NaturalSort_DefaultCollator { |
28 | - public function compare($a, $b) { |
|
29 | - $result = strcasecmp($a, $b); |
|
30 | - if ($result === 0) { |
|
31 | - if ($a === $b) { |
|
32 | - return 0; |
|
33 | - } |
|
34 | - return ($a > $b) ? -1 : 1; |
|
35 | - } |
|
36 | - return ($result < 0) ? -1 : 1; |
|
37 | - } |
|
28 | + public function compare($a, $b) { |
|
29 | + $result = strcasecmp($a, $b); |
|
30 | + if ($result === 0) { |
|
31 | + if ($a === $b) { |
|
32 | + return 0; |
|
33 | + } |
|
34 | + return ($a > $b) ? -1 : 1; |
|
35 | + } |
|
36 | + return ($result < 0) ? -1 : 1; |
|
37 | + } |
|
38 | 38 | } |