@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | $path = '/files_encryption/keys'; |
138 | 138 | $this->renameFileKeys($user, $path); |
139 | 139 | $trashPath = '/files_trashbin/keys'; |
140 | - if (\OC_App::isEnabled('files_trashbin') && $this->view->is_dir($user . '/' . $trashPath)) { |
|
140 | + if (\OC_App::isEnabled('files_trashbin') && $this->view->is_dir($user.'/'.$trashPath)) { |
|
141 | 141 | $this->renameFileKeys($user, $trashPath, true); |
142 | 142 | $this->view->deleteAll($trashPath); |
143 | 143 | } |
144 | 144 | // delete old folders |
145 | 145 | $this->deleteOldKeys($user); |
146 | - $this->view->getMount('/' . $user)->getStorage()->getScanner()->scan('files_encryption'); |
|
146 | + $this->view->getMount('/'.$user)->getStorage()->getScanner()->scan('files_encryption'); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | while ($row = $appSettings->fetch()) { |
174 | 174 | // 'installed_version' gets deleted at the end of the migration process |
175 | - if ($row['configkey'] !== 'installed_version' ) { |
|
175 | + if ($row['configkey'] !== 'installed_version') { |
|
176 | 176 | $this->config->setAppValue('encryption', $row['configkey'], $row['configvalue']); |
177 | 177 | $this->config->deleteAppValue('files_encryption', $row['configkey']); |
178 | 178 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * create backup of system-wide keys |
196 | 196 | */ |
197 | 197 | private function backupSystemWideKeys() { |
198 | - $backupDir = 'encryption_migration_backup_' . date("Y-m-d_H-i-s"); |
|
198 | + $backupDir = 'encryption_migration_backup_'.date("Y-m-d_H-i-s"); |
|
199 | 199 | $this->view->mkdir($backupDir); |
200 | - $this->view->copy('files_encryption', $backupDir . '/files_encryption'); |
|
200 | + $this->view->copy('files_encryption', $backupDir.'/files_encryption'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @return bool |
208 | 208 | */ |
209 | 209 | private function backupUserKeys($user) { |
210 | - $encryptionDir = $user . '/files_encryption'; |
|
210 | + $encryptionDir = $user.'/files_encryption'; |
|
211 | 211 | if ($this->view->is_dir($encryptionDir)) { |
212 | - $backupDir = $user . '/encryption_migration_backup_' . date("Y-m-d_H-i-s"); |
|
212 | + $backupDir = $user.'/encryption_migration_backup_'.date("Y-m-d_H-i-s"); |
|
213 | 213 | $this->view->mkdir($backupDir); |
214 | 214 | $this->view->copy($encryptionDir, $backupDir); |
215 | 215 | return true; |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | */ |
223 | 223 | private function renameSystemPrivateKeys() { |
224 | 224 | $dh = $this->view->opendir('files_encryption'); |
225 | - $this->createPathForKeys('/files_encryption/' . $this->moduleId ); |
|
225 | + $this->createPathForKeys('/files_encryption/'.$this->moduleId); |
|
226 | 226 | if (is_resource($dh)) { |
227 | 227 | while (($privateKey = readdir($dh)) !== false) { |
228 | - if (!\OC\Files\Filesystem::isIgnoredDir($privateKey) ) { |
|
229 | - if (!$this->view->is_dir('/files_encryption/' . $privateKey)) { |
|
230 | - $this->view->rename('files_encryption/' . $privateKey, 'files_encryption/' . $this->moduleId . '/' . $privateKey); |
|
228 | + if (!\OC\Files\Filesystem::isIgnoredDir($privateKey)) { |
|
229 | + if (!$this->view->is_dir('/files_encryption/'.$privateKey)) { |
|
230 | + $this->view->rename('files_encryption/'.$privateKey, 'files_encryption/'.$this->moduleId.'/'.$privateKey); |
|
231 | 231 | $this->renameSystemPublicKey($privateKey); |
232 | 232 | } |
233 | 233 | } |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * @param string $privateKey private key for which we want to rename the corresponding public key |
243 | 243 | */ |
244 | 244 | private function renameSystemPublicKey($privateKey) { |
245 | - $publicKey = substr($privateKey,0 , strrpos($privateKey, '.privateKey')) . '.publicKey'; |
|
246 | - $this->view->rename('files_encryption/public_keys/' . $publicKey, 'files_encryption/' . $this->moduleId . '/' . $publicKey); |
|
245 | + $publicKey = substr($privateKey, 0, strrpos($privateKey, '.privateKey')).'.publicKey'; |
|
246 | + $this->view->rename('files_encryption/public_keys/'.$publicKey, 'files_encryption/'.$this->moduleId.'/'.$publicKey); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param string $user |
253 | 253 | */ |
254 | 254 | private function renameUsersPrivateKey($user) { |
255 | - $oldPrivateKey = $user . '/files_encryption/' . $user . '.privateKey'; |
|
256 | - $newPrivateKey = $user . '/files_encryption/' . $this->moduleId . '/' . $user . '.privateKey'; |
|
255 | + $oldPrivateKey = $user.'/files_encryption/'.$user.'.privateKey'; |
|
256 | + $newPrivateKey = $user.'/files_encryption/'.$this->moduleId.'/'.$user.'.privateKey'; |
|
257 | 257 | if ($this->view->file_exists($oldPrivateKey)) { |
258 | 258 | $this->createPathForKeys(dirname($newPrivateKey)); |
259 | 259 | $this->view->rename($oldPrivateKey, $newPrivateKey); |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param string $user |
267 | 267 | */ |
268 | 268 | private function renameUsersPublicKey($user) { |
269 | - $oldPublicKey = '/files_encryption/public_keys/' . $user . '.publicKey'; |
|
270 | - $newPublicKey = $user . '/files_encryption/' . $this->moduleId . '/' . $user . '.publicKey'; |
|
269 | + $oldPublicKey = '/files_encryption/public_keys/'.$user.'.publicKey'; |
|
270 | + $newPublicKey = $user.'/files_encryption/'.$this->moduleId.'/'.$user.'.publicKey'; |
|
271 | 271 | if ($this->view->file_exists($oldPublicKey)) { |
272 | 272 | $this->createPathForKeys(dirname($newPublicKey)); |
273 | 273 | $this->view->rename($oldPublicKey, $newPublicKey); |
@@ -283,27 +283,27 @@ discard block |
||
283 | 283 | */ |
284 | 284 | private function renameFileKeys($user, $path, $trash = false) { |
285 | 285 | |
286 | - if ($this->view->is_dir($user . '/' . $path) === false) { |
|
287 | - $this->logger->info('Skip dir /' . $user . '/' . $path . ': does not exist'); |
|
286 | + if ($this->view->is_dir($user.'/'.$path) === false) { |
|
287 | + $this->logger->info('Skip dir /'.$user.'/'.$path.': does not exist'); |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | - $dh = $this->view->opendir($user . '/' . $path); |
|
291 | + $dh = $this->view->opendir($user.'/'.$path); |
|
292 | 292 | |
293 | 293 | if (is_resource($dh)) { |
294 | 294 | while (($file = readdir($dh)) !== false) { |
295 | 295 | if (!\OC\Files\Filesystem::isIgnoredDir($file)) { |
296 | - if ($this->view->is_dir($user . '/' . $path . '/' . $file)) { |
|
297 | - $this->renameFileKeys($user, $path . '/' . $file, $trash); |
|
296 | + if ($this->view->is_dir($user.'/'.$path.'/'.$file)) { |
|
297 | + $this->renameFileKeys($user, $path.'/'.$file, $trash); |
|
298 | 298 | } else { |
299 | 299 | $target = $this->getTargetDir($user, $path, $file, $trash); |
300 | 300 | if ($target !== false) { |
301 | 301 | $this->createPathForKeys(dirname($target)); |
302 | - $this->view->rename($user . '/' . $path . '/' . $file, $target); |
|
302 | + $this->view->rename($user.'/'.$path.'/'.$file, $target); |
|
303 | 303 | } else { |
304 | 304 | $this->logger->warning( |
305 | - 'did not move key "' . $file |
|
306 | - . '" could not find the corresponding file in /data/' . $user . '/files.' |
|
305 | + 'did not move key "'.$file |
|
306 | + . '" could not find the corresponding file in /data/'.$user.'/files.' |
|
307 | 307 | . 'Most likely the key was already moved in a previous migration run and is already on the right place.'); |
308 | 308 | } |
309 | 309 | } |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | private function getTargetDir($user, $keyPath, $filename, $trash) { |
337 | 337 | if ($trash) { |
338 | 338 | $filePath = substr($keyPath, strlen('/files_trashbin/keys/')); |
339 | - $targetDir = $user . '/files_encryption/keys/files_trashbin/' . $filePath . '/' . $this->moduleId . '/' . $filename; |
|
339 | + $targetDir = $user.'/files_encryption/keys/files_trashbin/'.$filePath.'/'.$this->moduleId.'/'.$filename; |
|
340 | 340 | } else { |
341 | 341 | $filePath = substr($keyPath, strlen('/files_encryption/keys/')); |
342 | - $targetDir = $user . '/files_encryption/keys/files/' . $filePath . '/' . $this->moduleId . '/' . $filename; |
|
342 | + $targetDir = $user.'/files_encryption/keys/files/'.$filePath.'/'.$this->moduleId.'/'.$filename; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | if ($user === '') { |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | $normalized = \OC\Files\Filesystem::normalizePath($filePath); |
348 | 348 | $systemMountPoints = $this->getSystemMountPoints(); |
349 | 349 | foreach ($systemMountPoints as $mountPoint) { |
350 | - $normalizedMountPoint = \OC\Files\Filesystem::normalizePath($mountPoint['mountpoint']) . '/'; |
|
350 | + $normalizedMountPoint = \OC\Files\Filesystem::normalizePath($mountPoint['mountpoint']).'/'; |
|
351 | 351 | if (strpos($normalized, $normalizedMountPoint) === 0) |
352 | 352 | return $targetDir; |
353 | 353 | } |
354 | - } else if ($trash === false && $this->view->file_exists('/' . $user. '/files/' . $filePath)) { |
|
354 | + } else if ($trash === false && $this->view->file_exists('/'.$user.'/files/'.$filePath)) { |
|
355 | 355 | return $targetDir; |
356 | - } else if ($trash === true && $this->view->file_exists('/' . $user. '/files_trashbin/' . $filePath)) { |
|
356 | + } else if ($trash === true && $this->view->file_exists('/'.$user.'/files_trashbin/'.$filePath)) { |
|
357 | 357 | return $targetDir; |
358 | 358 | } |
359 | 359 | |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | * @param string $user |
367 | 367 | */ |
368 | 368 | private function deleteOldKeys($user) { |
369 | - $this->view->deleteAll($user . '/files_encryption/keyfiles'); |
|
370 | - $this->view->deleteAll($user . '/files_encryption/share-keys'); |
|
369 | + $this->view->deleteAll($user.'/files_encryption/keyfiles'); |
|
370 | + $this->view->deleteAll($user.'/files_encryption/share-keys'); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $sub_dirs = explode('/', $path); |
381 | 381 | $dir = ''; |
382 | 382 | foreach ($sub_dirs as $sub_dir) { |
383 | - $dir .= '/' . $sub_dir; |
|
383 | + $dir .= '/'.$sub_dir; |
|
384 | 384 | if (!$this->view->is_dir($dir)) { |
385 | 385 | $this->view->mkdir($dir); |
386 | 386 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return bool |
164 | 164 | */ |
165 | 165 | public function userHasFiles($uid) { |
166 | - return $this->files->file_exists($uid . '/files'); |
|
166 | + return $this->files->file_exists($uid.'/files'); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | if (count($parts) > 1) { |
180 | 180 | $owner = $parts[1]; |
181 | 181 | if ($this->userManager->userExists($owner) === false) { |
182 | - throw new \BadMethodCallException('Unknown user: ' . |
|
182 | + throw new \BadMethodCallException('Unknown user: '. |
|
183 | 183 | 'method expects path to a user folder relative to the data folder'); |
184 | 184 | } |
185 | 185 |
@@ -128,7 +128,7 @@ |
||
128 | 128 | $encryptedKey = $this->crypt->encryptPrivateKey($decryptedKey, $newPassword, $uid); |
129 | 129 | $header = $this->crypt->generateHeader(); |
130 | 130 | if ($encryptedKey) { |
131 | - $this->keyManager->setPrivateKey($uid, $header . $encryptedKey); |
|
131 | + $this->keyManager->setPrivateKey($uid, $header.$encryptedKey); |
|
132 | 132 | $this->session->setPrivateKey($decryptedKey); |
133 | 133 | $result = true; |
134 | 134 | } |
@@ -63,28 +63,28 @@ |
||
63 | 63 | |
64 | 64 | $status = 'error'; |
65 | 65 | $message = 'no valid init status'; |
66 | - switch( $this->session->getStatus()) { |
|
66 | + switch ($this->session->getStatus()) { |
|
67 | 67 | case Session::RUN_MIGRATION: |
68 | 68 | $status = 'interactionNeeded'; |
69 | - $message = (string)$this->l->t( |
|
69 | + $message = (string) $this->l->t( |
|
70 | 70 | 'You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please run \'occ encryption:migrate\' or contact your administrator' |
71 | 71 | ); |
72 | 72 | break; |
73 | 73 | case Session::INIT_EXECUTED: |
74 | 74 | $status = 'interactionNeeded'; |
75 | - $message = (string)$this->l->t( |
|
75 | + $message = (string) $this->l->t( |
|
76 | 76 | 'Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files.' |
77 | 77 | ); |
78 | 78 | break; |
79 | 79 | case Session::NOT_INITIALIZED: |
80 | 80 | $status = 'interactionNeeded'; |
81 | - $message = (string)$this->l->t( |
|
81 | + $message = (string) $this->l->t( |
|
82 | 82 | 'Encryption app is enabled but your keys are not initialized, please log-out and log-in again' |
83 | 83 | ); |
84 | 84 | break; |
85 | 85 | case Session::INIT_SUCCESSFUL: |
86 | 86 | $status = 'success'; |
87 | - $message = (string)$this->l->t('Encryption app is enabled and ready'); |
|
87 | + $message = (string) $this->l->t('Encryption app is enabled and ready'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return new DataResponse( |
@@ -74,36 +74,36 @@ discard block |
||
74 | 74 | public function adminRecovery($recoveryPassword, $confirmPassword, $adminEnableRecovery) { |
75 | 75 | // Check if both passwords are the same |
76 | 76 | if (empty($recoveryPassword)) { |
77 | - $errorMessage = (string)$this->l->t('Missing recovery key password'); |
|
77 | + $errorMessage = (string) $this->l->t('Missing recovery key password'); |
|
78 | 78 | return new DataResponse(['data' => ['message' => $errorMessage]], |
79 | 79 | Http::STATUS_BAD_REQUEST); |
80 | 80 | } |
81 | 81 | |
82 | 82 | if (empty($confirmPassword)) { |
83 | - $errorMessage = (string)$this->l->t('Please repeat the recovery key password'); |
|
83 | + $errorMessage = (string) $this->l->t('Please repeat the recovery key password'); |
|
84 | 84 | return new DataResponse(['data' => ['message' => $errorMessage]], |
85 | 85 | Http::STATUS_BAD_REQUEST); |
86 | 86 | } |
87 | 87 | |
88 | 88 | if ($recoveryPassword !== $confirmPassword) { |
89 | - $errorMessage = (string)$this->l->t('Repeated recovery key password does not match the provided recovery key password'); |
|
89 | + $errorMessage = (string) $this->l->t('Repeated recovery key password does not match the provided recovery key password'); |
|
90 | 90 | return new DataResponse(['data' => ['message' => $errorMessage]], |
91 | 91 | Http::STATUS_BAD_REQUEST); |
92 | 92 | } |
93 | 93 | |
94 | 94 | if (isset($adminEnableRecovery) && $adminEnableRecovery === '1') { |
95 | 95 | if ($this->recovery->enableAdminRecovery($recoveryPassword)) { |
96 | - return new DataResponse(['data' => ['message' => (string)$this->l->t('Recovery key successfully enabled')]]); |
|
96 | + return new DataResponse(['data' => ['message' => (string) $this->l->t('Recovery key successfully enabled')]]); |
|
97 | 97 | } |
98 | - return new DataResponse(['data' => ['message' => (string)$this->l->t('Could not enable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST); |
|
98 | + return new DataResponse(['data' => ['message' => (string) $this->l->t('Could not enable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST); |
|
99 | 99 | } elseif (isset($adminEnableRecovery) && $adminEnableRecovery === '0') { |
100 | 100 | if ($this->recovery->disableAdminRecovery($recoveryPassword)) { |
101 | - return new DataResponse(['data' => ['message' => (string)$this->l->t('Recovery key successfully disabled')]]); |
|
101 | + return new DataResponse(['data' => ['message' => (string) $this->l->t('Recovery key successfully disabled')]]); |
|
102 | 102 | } |
103 | - return new DataResponse(['data' => ['message' => (string)$this->l->t('Could not disable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST); |
|
103 | + return new DataResponse(['data' => ['message' => (string) $this->l->t('Could not disable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST); |
|
104 | 104 | } |
105 | 105 | // this response should never be sent but just in case. |
106 | - return new DataResponse(['data' => ['message' => (string)$this->l->t('Missing parameters')]], Http::STATUS_BAD_REQUEST); |
|
106 | + return new DataResponse(['data' => ['message' => (string) $this->l->t('Missing parameters')]], Http::STATUS_BAD_REQUEST); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -115,22 +115,22 @@ discard block |
||
115 | 115 | public function changeRecoveryPassword($newPassword, $oldPassword, $confirmPassword) { |
116 | 116 | //check if both passwords are the same |
117 | 117 | if (empty($oldPassword)) { |
118 | - $errorMessage = (string)$this->l->t('Please provide the old recovery password'); |
|
118 | + $errorMessage = (string) $this->l->t('Please provide the old recovery password'); |
|
119 | 119 | return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST); |
120 | 120 | } |
121 | 121 | |
122 | 122 | if (empty($newPassword)) { |
123 | - $errorMessage = (string)$this->l->t('Please provide a new recovery password'); |
|
124 | - return new DataResponse (['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST); |
|
123 | + $errorMessage = (string) $this->l->t('Please provide a new recovery password'); |
|
124 | + return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if (empty($confirmPassword)) { |
128 | - $errorMessage = (string)$this->l->t('Please repeat the new recovery password'); |
|
128 | + $errorMessage = (string) $this->l->t('Please repeat the new recovery password'); |
|
129 | 129 | return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST); |
130 | 130 | } |
131 | 131 | |
132 | 132 | if ($newPassword !== $confirmPassword) { |
133 | - $errorMessage = (string)$this->l->t('Repeated recovery key password does not match the provided recovery key password'); |
|
133 | + $errorMessage = (string) $this->l->t('Repeated recovery key password does not match the provided recovery key password'); |
|
134 | 134 | return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST); |
135 | 135 | } |
136 | 136 | |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | return new DataResponse( |
142 | 142 | [ |
143 | 143 | 'data' => [ |
144 | - 'message' => (string)$this->l->t('Password successfully changed.')] |
|
144 | + 'message' => (string) $this->l->t('Password successfully changed.')] |
|
145 | 145 | ] |
146 | 146 | ); |
147 | 147 | } |
148 | 148 | return new DataResponse( |
149 | 149 | [ |
150 | 150 | 'data' => [ |
151 | - 'message' => (string)$this->l->t('Could not change the password. Maybe the old password was not correct.') |
|
151 | + 'message' => (string) $this->l->t('Could not change the password. Maybe the old password was not correct.') |
|
152 | 152 | ] |
153 | 153 | ], Http::STATUS_BAD_REQUEST); |
154 | 154 | } |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | return new DataResponse( |
170 | 170 | [ |
171 | 171 | 'data' => [ |
172 | - 'message' => (string)$this->l->t('Recovery Key disabled')] |
|
172 | + 'message' => (string) $this->l->t('Recovery Key disabled')] |
|
173 | 173 | ] |
174 | 174 | ); |
175 | 175 | } |
176 | 176 | return new DataResponse( |
177 | 177 | [ |
178 | 178 | 'data' => [ |
179 | - 'message' => (string)$this->l->t('Recovery Key enabled')] |
|
179 | + 'message' => (string) $this->l->t('Recovery Key enabled')] |
|
180 | 180 | ] |
181 | 181 | ); |
182 | 182 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | return new DataResponse( |
186 | 186 | [ |
187 | 187 | 'data' => [ |
188 | - 'message' => (string)$this->l->t('Could not enable the recovery key, please try again or contact your administrator') |
|
188 | + 'message' => (string) $this->l->t('Could not enable the recovery key, please try again or contact your administrator') |
|
189 | 189 | ] |
190 | 190 | ], Http::STATUS_BAD_REQUEST); |
191 | 191 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $this->recoveryKeyId = $this->config->getAppValue('encryption', |
127 | 127 | 'recoveryKeyId'); |
128 | 128 | if (empty($this->recoveryKeyId)) { |
129 | - $this->recoveryKeyId = 'recoveryKey_' . substr(md5(time()), 0, 8); |
|
129 | + $this->recoveryKeyId = 'recoveryKey_'.substr(md5(time()), 0, 8); |
|
130 | 130 | $this->config->setAppValue('encryption', |
131 | 131 | 'recoveryKeyId', |
132 | 132 | $this->recoveryKeyId); |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | $this->publicShareKeyId = $this->config->getAppValue('encryption', |
136 | 136 | 'publicShareKeyId'); |
137 | 137 | if (empty($this->publicShareKeyId)) { |
138 | - $this->publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8); |
|
138 | + $this->publicShareKeyId = 'pubShare_'.substr(md5(time()), 0, 8); |
|
139 | 139 | $this->config->setAppValue('encryption', 'publicShareKeyId', $this->publicShareKeyId); |
140 | 140 | } |
141 | 141 | |
142 | 142 | $this->masterKeyId = $this->config->getAppValue('encryption', |
143 | 143 | 'masterKeyId'); |
144 | 144 | if (empty($this->masterKeyId)) { |
145 | - $this->masterKeyId = 'master_' . substr(md5(time()), 0, 8); |
|
145 | + $this->masterKeyId = 'master_'.substr(md5(time()), 0, 8); |
|
146 | 146 | $this->config->setAppValue('encryption', 'masterKeyId', $this->masterKeyId); |
147 | 147 | } |
148 | 148 | |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | |
161 | 161 | // Save public key |
162 | 162 | $this->keyStorage->setSystemUserKey( |
163 | - $this->publicShareKeyId . '.publicKey', $keyPair['publicKey'], |
|
163 | + $this->publicShareKeyId.'.publicKey', $keyPair['publicKey'], |
|
164 | 164 | Encryption::ID); |
165 | 165 | |
166 | 166 | // Encrypt private key empty passphrase |
167 | 167 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], ''); |
168 | 168 | $header = $this->crypt->generateHeader(); |
169 | - $this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey); |
|
169 | + $this->setSystemPrivateKey($this->publicShareKeyId, $header.$encryptedKey); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | |
186 | 186 | // Save public key |
187 | 187 | $this->keyStorage->setSystemUserKey( |
188 | - $this->masterKeyId . '.publicKey', $keyPair['publicKey'], |
|
188 | + $this->masterKeyId.'.publicKey', $keyPair['publicKey'], |
|
189 | 189 | Encryption::ID); |
190 | 190 | |
191 | 191 | // Encrypt private key with system password |
192 | 192 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId); |
193 | 193 | $header = $this->crypt->generateHeader(); |
194 | - $this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey); |
|
194 | + $this->setSystemPrivateKey($this->masterKeyId, $header.$encryptedKey); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return string |
210 | 210 | */ |
211 | 211 | public function getRecoveryKey() { |
212 | - return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.publicKey', Encryption::ID); |
|
212 | + return $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.publicKey', Encryption::ID); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return bool |
227 | 227 | */ |
228 | 228 | public function checkRecoveryPassword($password) { |
229 | - $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.privateKey', Encryption::ID); |
|
229 | + $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.privateKey', Encryption::ID); |
|
230 | 230 | $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $password); |
231 | 231 | |
232 | 232 | if ($decryptedRecoveryKey) { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $header = $this->crypt->generateHeader(); |
251 | 251 | |
252 | 252 | if ($encryptedKey) { |
253 | - $this->setPrivateKey($uid, $header . $encryptedKey); |
|
253 | + $this->setPrivateKey($uid, $header.$encryptedKey); |
|
254 | 254 | return true; |
255 | 255 | } |
256 | 256 | return false; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $header = $this->crypt->generateHeader(); |
273 | 273 | |
274 | 274 | if ($encryptedKey) { |
275 | - $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header . $encryptedKey); |
|
275 | + $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header.$encryptedKey); |
|
276 | 276 | return true; |
277 | 277 | } |
278 | 278 | return false; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @return boolean |
333 | 333 | */ |
334 | 334 | public function setShareKey($path, $uid, $key) { |
335 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
335 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
336 | 336 | return $this->keyStorage->setFileKey($path, $keyId, $key, Encryption::ID); |
337 | 337 | } |
338 | 338 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $this->session->setStatus(Session::INIT_EXECUTED); |
349 | 349 | |
350 | 350 | try { |
351 | - if($this->util->isMasterKeyEnabled()) { |
|
351 | + if ($this->util->isMasterKeyEnabled()) { |
|
352 | 352 | $uid = $this->getMasterKeyId(); |
353 | 353 | $passPhrase = $this->getMasterKeyPassword(); |
354 | 354 | $privateKey = $this->getSystemPrivateKey($uid); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | return false; |
363 | 363 | } catch (\Exception $e) { |
364 | 364 | $this->log->warning( |
365 | - 'Could not decrypt the private key from user "' . $uid . '"" during login. ' . |
|
365 | + 'Could not decrypt the private key from user "'.$uid.'"" during login. '. |
|
366 | 366 | 'Assume password change on the user back-end. Error message: ' |
367 | 367 | . $e->getMessage() |
368 | 368 | ); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | if (is_null($uid)) { |
413 | 413 | $uid = $this->getPublicShareKeyId(); |
414 | 414 | $shareKey = $this->getShareKey($path, $uid); |
415 | - $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey', Encryption::ID); |
|
415 | + $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.privateKey', Encryption::ID); |
|
416 | 416 | $privateKey = $this->crypt->decryptPrivateKey($privateKey); |
417 | 417 | } else { |
418 | 418 | $shareKey = $this->getShareKey($path, $uid); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | */ |
438 | 438 | public function getVersion($path, View $view) { |
439 | 439 | $fileInfo = $view->getFileInfo($path); |
440 | - if($fileInfo === false) { |
|
440 | + if ($fileInfo === false) { |
|
441 | 441 | return 0; |
442 | 442 | } |
443 | 443 | return $fileInfo->getEncryptedVersion(); |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | * @param View $view |
452 | 452 | */ |
453 | 453 | public function setVersion($path, $version, View $view) { |
454 | - $fileInfo= $view->getFileInfo($path); |
|
454 | + $fileInfo = $view->getFileInfo($path); |
|
455 | 455 | |
456 | - if($fileInfo !== false) { |
|
456 | + if ($fileInfo !== false) { |
|
457 | 457 | $cache = $fileInfo->getStorage()->getCache(); |
458 | 458 | $cache->update($fileInfo->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]); |
459 | 459 | } |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | public function deleteShareKey($path, $keyId) { |
483 | 483 | return $this->keyStorage->deleteFileKey( |
484 | 484 | $path, |
485 | - $keyId . '.' . $this->shareKeyId, |
|
485 | + $keyId.'.'.$this->shareKeyId, |
|
486 | 486 | Encryption::ID); |
487 | 487 | } |
488 | 488 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * @return mixed |
494 | 494 | */ |
495 | 495 | public function getShareKey($path, $uid) { |
496 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
496 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
497 | 497 | return $this->keyStorage->getFileKey($path, $keyId, Encryption::ID); |
498 | 498 | } |
499 | 499 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | * @return string |
556 | 556 | */ |
557 | 557 | public function getPublicShareKey() { |
558 | - return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.publicKey', Encryption::ID); |
|
558 | + return $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.publicKey', Encryption::ID); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @return string returns openssl key |
626 | 626 | */ |
627 | 627 | public function getSystemPrivateKey($keyId) { |
628 | - return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId, Encryption::ID); |
|
628 | + return $this->keyStorage->getSystemUserKey($keyId.'.'.$this->privateKeyId, Encryption::ID); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | */ |
636 | 636 | public function setSystemPrivateKey($keyId, $key) { |
637 | 637 | return $this->keyStorage->setSystemUserKey( |
638 | - $keyId . '.' . $this->privateKeyId, |
|
638 | + $keyId.'.'.$this->privateKeyId, |
|
639 | 639 | $key, |
640 | 640 | Encryption::ID); |
641 | 641 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | */ |
676 | 676 | public function getMasterKeyPassword() { |
677 | 677 | $password = $this->config->getSystemValue('secret'); |
678 | - if (empty($password)){ |
|
678 | + if (empty($password)) { |
|
679 | 679 | throw new \Exception('Can not get secret from ownCloud instance'); |
680 | 680 | } |
681 | 681 | |
@@ -697,6 +697,6 @@ discard block |
||
697 | 697 | * @return string |
698 | 698 | */ |
699 | 699 | public function getPublicMasterKey() { |
700 | - return $this->keyStorage->getSystemUserKey($this->masterKeyId . '.publicKey', Encryption::ID); |
|
700 | + return $this->keyStorage->getSystemUserKey($this->masterKeyId.'.publicKey', Encryption::ID); |
|
701 | 701 | } |
702 | 702 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * @param string $userId |
30 | 30 | */ |
31 | 31 | public function __construct($userId) { |
32 | - if(empty($userId)) { |
|
32 | + if (empty($userId)) { |
|
33 | 33 | $userId = "<no-user-id-given>"; |
34 | 34 | } |
35 | 35 | parent::__construct("Public Key missing for user: $userId"); |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @param string $userId |
33 | 33 | */ |
34 | 34 | public function __construct($userId) { |
35 | - if(empty($userId)) { |
|
35 | + if (empty($userId)) { |
|
36 | 36 | $userId = "<no-user-id-given>"; |
37 | 37 | } |
38 | 38 | parent::__construct("Private Key missing for user: $userId"); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $this->encryptionManager = \OC::$server->getEncryptionManager(); |
63 | 63 | $this->config = \OC::$server->getConfig(); |
64 | 64 | $this->registerServices(); |
65 | - if($encryptionSystemReady === false) { |
|
65 | + if ($encryptionSystemReady === false) { |
|
66 | 66 | /** @var Session $session */ |
67 | 67 | $session = $this->getContainer()->query('Session'); |
68 | 68 | $session->setStatus(Session::RUN_MIGRATION); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $container = $this->getContainer(); |
134 | 134 | |
135 | 135 | $container->registerService('Crypt', |
136 | - function (IAppContainer $c) { |
|
136 | + function(IAppContainer $c) { |
|
137 | 137 | $server = $c->getServer(); |
138 | 138 | return new Crypt($server->getLogger(), |
139 | 139 | $server->getUserSession(), |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | }); |
143 | 143 | |
144 | 144 | $container->registerService('Session', |
145 | - function (IAppContainer $c) { |
|
145 | + function(IAppContainer $c) { |
|
146 | 146 | $server = $c->getServer(); |
147 | 147 | return new Session($server->getSession()); |
148 | 148 | } |
149 | 149 | ); |
150 | 150 | |
151 | 151 | $container->registerService('KeyManager', |
152 | - function (IAppContainer $c) { |
|
152 | + function(IAppContainer $c) { |
|
153 | 153 | $server = $c->getServer(); |
154 | 154 | |
155 | 155 | return new KeyManager($server->getEncryptionKeyStorage(), |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | }); |
164 | 164 | |
165 | 165 | $container->registerService('Recovery', |
166 | - function (IAppContainer $c) { |
|
166 | + function(IAppContainer $c) { |
|
167 | 167 | $server = $c->getServer(); |
168 | 168 | |
169 | 169 | return new Recovery( |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | new View()); |
178 | 178 | }); |
179 | 179 | |
180 | - $container->registerService('RecoveryController', function (IAppContainer $c) { |
|
180 | + $container->registerService('RecoveryController', function(IAppContainer $c) { |
|
181 | 181 | $server = $c->getServer(); |
182 | 182 | return new RecoveryController( |
183 | 183 | $c->getAppName(), |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $c->query('Recovery')); |
188 | 188 | }); |
189 | 189 | |
190 | - $container->registerService('StatusController', function (IAppContainer $c) { |
|
190 | + $container->registerService('StatusController', function(IAppContainer $c) { |
|
191 | 191 | $server = $c->getServer(); |
192 | 192 | return new StatusController( |
193 | 193 | $c->getAppName(), |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | ); |
198 | 198 | }); |
199 | 199 | |
200 | - $container->registerService('SettingsController', function (IAppContainer $c) { |
|
200 | + $container->registerService('SettingsController', function(IAppContainer $c) { |
|
201 | 201 | $server = $c->getServer(); |
202 | 202 | return new SettingsController( |
203 | 203 | $c->getAppName(), |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | }); |
215 | 215 | |
216 | 216 | $container->registerService('UserSetup', |
217 | - function (IAppContainer $c) { |
|
217 | + function(IAppContainer $c) { |
|
218 | 218 | $server = $c->getServer(); |
219 | 219 | return new Setup($server->getLogger(), |
220 | 220 | $server->getUserSession(), |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | }); |
224 | 224 | |
225 | 225 | $container->registerService('Util', |
226 | - function (IAppContainer $c) { |
|
226 | + function(IAppContainer $c) { |
|
227 | 227 | $server = $c->getServer(); |
228 | 228 | |
229 | 229 | return new Util( |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | }); |
237 | 237 | |
238 | 238 | $container->registerService('EncryptAll', |
239 | - function (IAppContainer $c) { |
|
239 | + function(IAppContainer $c) { |
|
240 | 240 | $server = $c->getServer(); |
241 | 241 | return new EncryptAll( |
242 | 242 | $c->query('UserSetup'), |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | ); |
255 | 255 | |
256 | 256 | $container->registerService('DecryptAll', |
257 | - function (IAppContainer $c) { |
|
257 | + function(IAppContainer $c) { |
|
258 | 258 | return new DecryptAll( |
259 | 259 | $c->query('Util'), |
260 | 260 | $c->query('KeyManager'), |