@@ -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'), |
@@ -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 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $output->writeln("Reorganize system folder structure"); |
| 99 | 99 | $migration->reorganizeSystemFolderStructure(); |
| 100 | 100 | $migration->updateDB(); |
| 101 | - foreach($this->userManager->getBackends() as $backend) { |
|
| 101 | + foreach ($this->userManager->getBackends() as $backend) { |
|
| 102 | 102 | $name = get_class($backend); |
| 103 | 103 | |
| 104 | 104 | if ($backend instanceof IUserBackend) { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $migration->reorganizeFolderStructureForUser($user); |
| 117 | 117 | } |
| 118 | 118 | $offset += $limit; |
| 119 | - } while(count($users) >= $limit); |
|
| 119 | + } while (count($users) >= $limit); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -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 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $this->input = $input; |
| 134 | 134 | $this->output = $output; |
| 135 | 135 | |
| 136 | - $headline = 'Encrypt all files with the ' . Encryption::DISPLAY_NAME; |
|
| 136 | + $headline = 'Encrypt all files with the '.Encryption::DISPLAY_NAME; |
|
| 137 | 137 | $this->output->writeln("\n"); |
| 138 | 138 | $this->output->writeln($headline); |
| 139 | 139 | $this->output->writeln(str_pad('', strlen($headline), '=')); |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | $progress->setFormat(" %message% \n [%bar%]"); |
| 180 | 180 | $progress->start(); |
| 181 | 181 | |
| 182 | - foreach($this->userManager->getBackends() as $backend) { |
|
| 182 | + foreach ($this->userManager->getBackends() as $backend) { |
|
| 183 | 183 | $limit = 500; |
| 184 | 184 | $offset = 0; |
| 185 | 185 | do { |
| 186 | 186 | $users = $backend->getUsers('', $limit, $offset); |
| 187 | 187 | foreach ($users as $user) { |
| 188 | 188 | if ($this->keyManager->userHasKeys($user) === false) { |
| 189 | - $progress->setMessage('Create key-pair for ' . $user); |
|
| 189 | + $progress->setMessage('Create key-pair for '.$user); |
|
| 190 | 190 | $progress->advance(); |
| 191 | 191 | $this->setupUserFS($user); |
| 192 | 192 | $password = $this->generateOneTimePassword($user); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | $offset += $limit; |
| 201 | - } while(count($users) >= $limit); |
|
| 201 | + } while (count($users) >= $limit); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | $progress->setMessage('Key-pair created for all users'); |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function encryptAllUserFilesWithMasterKey(ProgressBar $progress) { |
| 238 | 238 | $userNo = 1; |
| 239 | - foreach($this->userManager->getBackends() as $backend) { |
|
| 239 | + foreach ($this->userManager->getBackends() as $backend) { |
|
| 240 | 240 | $limit = 500; |
| 241 | 241 | $offset = 0; |
| 242 | 242 | do { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $userNo++; |
| 248 | 248 | } |
| 249 | 249 | $offset += $limit; |
| 250 | - } while(count($users) >= $limit); |
|
| 250 | + } while (count($users) >= $limit); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
@@ -262,19 +262,19 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | $this->setupUserFS($uid); |
| 264 | 264 | $directories = array(); |
| 265 | - $directories[] = '/' . $uid . '/files'; |
|
| 265 | + $directories[] = '/'.$uid.'/files'; |
|
| 266 | 266 | |
| 267 | - while($root = array_pop($directories)) { |
|
| 267 | + while ($root = array_pop($directories)) { |
|
| 268 | 268 | $content = $this->rootView->getDirectoryContent($root); |
| 269 | 269 | foreach ($content as $file) { |
| 270 | - $path = $root . '/' . $file['name']; |
|
| 270 | + $path = $root.'/'.$file['name']; |
|
| 271 | 271 | if ($this->rootView->is_dir($path)) { |
| 272 | 272 | $directories[] = $path; |
| 273 | 273 | continue; |
| 274 | 274 | } else { |
| 275 | 275 | $progress->setMessage("encrypt files for user $userCount: $path"); |
| 276 | 276 | $progress->advance(); |
| 277 | - if($this->encryptFile($path) === false) { |
|
| 277 | + if ($this->encryptFile($path) === false) { |
|
| 278 | 278 | $progress->setMessage("encrypt files for user $userCount: $path (already encrypted)"); |
| 279 | 279 | $progress->advance(); |
| 280 | 280 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | protected function encryptFile($path) { |
| 293 | 293 | |
| 294 | 294 | $source = $path; |
| 295 | - $target = $path . '.encrypted.' . time(); |
|
| 295 | + $target = $path.'.encrypted.'.time(); |
|
| 296 | 296 | |
| 297 | 297 | try { |
| 298 | 298 | $this->rootView->copy($source, $target); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | continue; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $subject = (string)$this->l->t('one-time password for server-side-encryption'); |
|
| 417 | + $subject = (string) $this->l->t('one-time password for server-side-encryption'); |
|
| 418 | 418 | list($htmlBody, $textBody) = $this->createMailBody($password); |
| 419 | 419 | |
| 420 | 420 | // send it out now |
@@ -462,11 +462,11 @@ discard block |
||
| 462 | 462 | protected function createMailBody($password) { |
| 463 | 463 | |
| 464 | 464 | $html = new \OC_Template("encryption", "mail", ""); |
| 465 | - $html->assign ('password', $password); |
|
| 465 | + $html->assign('password', $password); |
|
| 466 | 466 | $htmlMail = $html->fetchPage(); |
| 467 | 467 | |
| 468 | 468 | $plainText = new \OC_Template("encryption", "altmail", ""); |
| 469 | - $plainText->assign ('password', $password); |
|
| 469 | + $plainText->assign('password', $password); |
|
| 470 | 470 | $plainTextMail = $plainText->fetchPage(); |
| 471 | 471 | |
| 472 | 472 | return [$htmlMail, $plainTextMail]; |