@@ -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 | } |
@@ -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 | } |
@@ -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"); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | if (!$keyManager->recoveryKeyExists()) { |
| 111 | 111 | $keyPair = $this->crypt->createKeyPair(); |
| 112 | - if(!is_array($keyPair)) { |
|
| 112 | + if (!is_array($keyPair)) { |
|
| 113 | 113 | return false; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | public function changeRecoveryKeyPassword($newPassword, $oldPassword) { |
| 135 | 135 | $recoveryKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId()); |
| 136 | 136 | $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $oldPassword); |
| 137 | - if($decryptedRecoveryKey === false) { |
|
| 137 | + if ($decryptedRecoveryKey === false) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | $encryptedRecoveryKey = $this->crypt->encryptPrivateKey($decryptedRecoveryKey, $newPassword); |
| 141 | 141 | $header = $this->crypt->generateHeader(); |
| 142 | 142 | if ($encryptedRecoveryKey) { |
| 143 | - $this->keyManager->setSystemPrivateKey($this->keyManager->getRecoveryKeyId(), $header . $encryptedRecoveryKey); |
|
| 143 | + $this->keyManager->setSystemPrivateKey($this->keyManager->getRecoveryKeyId(), $header.$encryptedRecoveryKey); |
|
| 144 | 144 | return true; |
| 145 | 145 | } |
| 146 | 146 | return false; |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | $value); |
| 203 | 203 | |
| 204 | 204 | if ($value === '1') { |
| 205 | - $this->addRecoveryKeys('/' . $this->user->getUID() . '/files/'); |
|
| 205 | + $this->addRecoveryKeys('/'.$this->user->getUID().'/files/'); |
|
| 206 | 206 | } else { |
| 207 | - $this->removeRecoveryKeys('/' . $this->user->getUID() . '/files/'); |
|
| 207 | + $this->removeRecoveryKeys('/'.$this->user->getUID().'/files/'); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | return true; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | foreach ($dirContent as $item) { |
| 223 | 223 | $filePath = $item->getPath(); |
| 224 | 224 | if ($item['type'] === 'dir') { |
| 225 | - $this->addRecoveryKeys($filePath . '/'); |
|
| 225 | + $this->addRecoveryKeys($filePath.'/'); |
|
| 226 | 226 | } else { |
| 227 | 227 | $fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID()); |
| 228 | 228 | if (!empty($fileKey)) { |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | foreach ($dirContent as $item) { |
| 251 | 251 | $filePath = $item->getPath(); |
| 252 | 252 | if ($item['type'] === 'dir') { |
| 253 | - $this->removeRecoveryKeys($filePath . '/'); |
|
| 253 | + $this->removeRecoveryKeys($filePath.'/'); |
|
| 254 | 254 | } else { |
| 255 | 255 | $this->keyManager->deleteShareKey($filePath, $this->keyManager->getRecoveryKeyId()); |
| 256 | 256 | } |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | $encryptedKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId()); |
| 268 | 268 | |
| 269 | 269 | $privateKey = $this->crypt->decryptPrivateKey($encryptedKey, $recoveryPassword); |
| 270 | - if($privateKey !== false) { |
|
| 271 | - $this->recoverAllFiles('/' . $user . '/files/', $privateKey, $user); |
|
| 270 | + if ($privateKey !== false) { |
|
| 271 | + $this->recoverAllFiles('/'.$user.'/files/', $privateKey, $user); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | // Get relative path from encryption/keyfiles |
| 287 | 287 | $filePath = $item->getPath(); |
| 288 | 288 | if ($this->view->is_dir($filePath)) { |
| 289 | - $this->recoverAllFiles($filePath . '/', $privateKey, $uid); |
|
| 289 | + $this->recoverAllFiles($filePath.'/', $privateKey, $uid); |
|
| 290 | 290 | } else { |
| 291 | 291 | $this->recoverFile($filePath, $privateKey, $uid); |
| 292 | 292 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | |
| 69 | 69 | $isAlreadyEnabled = $this->util->isMasterKeyEnabled(); |
| 70 | 70 | |
| 71 | - if($isAlreadyEnabled) { |
|
| 71 | + if ($isAlreadyEnabled) { |
|
| 72 | 72 | $output->writeln('Master key already enabled'); |
| 73 | 73 | } else { |
| 74 | 74 | $question = new ConfirmationQuestion( |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | // Save private key |
| 277 | 277 | if ($encryptedPrivateKey) { |
| 278 | 278 | $this->keyManager->setPrivateKey($this->user->getUser()->getUID(), |
| 279 | - $this->crypt->generateHeader() . $encryptedPrivateKey); |
|
| 279 | + $this->crypt->generateHeader().$encryptedPrivateKey); |
|
| 280 | 280 | } else { |
| 281 | 281 | $this->logger->error('Encryption could not update users encryption password'); |
| 282 | 282 | } |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $user); |
| 314 | 314 | |
| 315 | 315 | if ($encryptedKey) { |
| 316 | - $this->keyManager->setPrivateKey($user, $this->crypt->generateHeader() . $encryptedKey); |
|
| 316 | + $this->keyManager->setPrivateKey($user, $this->crypt->generateHeader().$encryptedKey); |
|
| 317 | 317 | |
| 318 | 318 | if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files |
| 319 | 319 | $this->recovery->recoverUsersFiles($recoveryPassword, $user); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $this->isWriteOperation = false; |
| 178 | 178 | $this->writeCache = ''; |
| 179 | 179 | |
| 180 | - if($this->session->isReady() === false) { |
|
| 180 | + if ($this->session->isReady() === false) { |
|
| 181 | 181 | // if the master key is enabled we can initialize encryption |
| 182 | 182 | // with a empty password and user name |
| 183 | 183 | if ($this->util->isMasterKeyEnabled()) { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | // always use the version from the original file, also part files |
| 199 | 199 | // need to have a correct version number if they get moved over to the |
| 200 | 200 | // final location |
| 201 | - $this->version = (int)$this->keyManager->getVersion($this->stripPartFileExtension($path), new View()); |
|
| 201 | + $this->version = (int) $this->keyManager->getVersion($this->stripPartFileExtension($path), new View()); |
|
| 202 | 202 | |
| 203 | 203 | if ( |
| 204 | 204 | $mode === 'w' |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | // if we read a part file we need to increase the version by 1 |
| 215 | 215 | // because the version number was also increased by writing |
| 216 | 216 | // the part file |
| 217 | - if(Scanner::isPartialFile($path)) { |
|
| 217 | + if (Scanner::isPartialFile($path)) { |
|
| 218 | 218 | $this->version = $this->version + 1; |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | if ($this->writeCache) { |
| 301 | 301 | |
| 302 | 302 | // Concat writeCache to start of $data |
| 303 | - $data = $this->writeCache . $data; |
|
| 303 | + $data = $this->writeCache.$data; |
|
| 304 | 304 | |
| 305 | 305 | // Clear the write cache, ready for reuse - it has been |
| 306 | 306 | // flushed and its old contents processed |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | try { |
| 403 | 403 | $publicKeys[$user] = $this->keyManager->getPublicKey($user); |
| 404 | 404 | } catch (PublicKeyMissingException $e) { |
| 405 | - $this->logger->warning('Could not encrypt file for ' . $user . ': ' . $e->getMessage()); |
|
| 405 | + $this->logger->warning('Could not encrypt file for '.$user.': '.$e->getMessage()); |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | } |
@@ -489,8 +489,8 @@ discard block |
||
| 489 | 489 | // error message because in this case it means that the file was |
| 490 | 490 | // shared with the user at a point where the user didn't had a |
| 491 | 491 | // valid private/public key |
| 492 | - $msg = 'Encryption module "' . $this->getDisplayName() . |
|
| 493 | - '" is not able to read ' . $path; |
|
| 492 | + $msg = 'Encryption module "'.$this->getDisplayName(). |
|
| 493 | + '" is not able to read '.$path; |
|
| 494 | 494 | $hint = $this->l->t('Can not read this file, probably this is a shared file. Please ask the file owner to reshare the file with you.'); |
| 495 | 495 | $this->logger->warning($msg); |
| 496 | 496 | throw new DecryptionFailedException($msg, $hint); |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | $realPath = $path; |
| 533 | 533 | $parts = explode('/', $path); |
| 534 | 534 | if ($parts[2] === 'files_versions') { |
| 535 | - $realPath = '/' . $parts[1] . '/files/' . implode('/', array_slice($parts, 3)); |
|
| 535 | + $realPath = '/'.$parts[1].'/files/'.implode('/', array_slice($parts, 3)); |
|
| 536 | 536 | $length = strrpos($realPath, '.'); |
| 537 | 537 | $realPath = substr($realPath, 0, $length); |
| 538 | 538 | } |