protected function execute(InputInterface $input, OutputInterface $output) { if ($this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes') { $output->writeln('Encryption is already enabled'); } else { $this->config->setAppValue('core', 'encryption_enabled', 'yes'); $output->writeln('<info>Encryption enabled</info>'); } $output->writeln(''); $modules = $this->encryptionManager->getEncryptionModules(); if (empty($modules)) { $output->writeln('<error>No encryption module is loaded</error>'); } else { $defaultModule = $this->config->getAppValue('core', 'default_encryption_module', null); if ($defaultModule === null) { $output->writeln('<error>No default module is set</error>'); } else { if (!isset($modules[$defaultModule])) { $output->writeln('<error>The current default module does not exist: ' . $defaultModule . '</error>'); } else { $output->writeln('Default module: ' . $defaultModule); } } } }
public function registerEncryptionModule() { $container = $this->getContainer(); $container->registerService('EncryptionModule', function (IAppContainer $c) { return new \OCA\Encryption\Crypto\Encryption($c->query('Crypt'), $c->query('KeyManager'), $c->query('Util')); }); $module = $container->query('EncryptionModule'); $this->encryptionManager->registerEncryptionModule($module); }
protected function execute(InputInterface $input, OutputInterface $output) { $encryptionModules = $this->encryptionManager->getEncryptionModules(); $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); $encModules = array(); foreach ($encryptionModules as $module) { $encModules[$module['id']]['displayName'] = $module['displayName']; $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; } $this->writeModuleList($input, $output, $encModules); }
protected function execute(InputInterface $input, OutputInterface $output) { $moduleId = $input->getArgument('module'); if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { $output->writeln('"' . $moduleId . '"" is already the default module'); } else { if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); } else { $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); } } }
public function registerEncryptionModule() { $container = $this->getContainer(); $this->encryptionManager->registerEncryptionModule(Encryption::ID, Encryption::DISPLAY_NAME, function () use($container) { return new Encryption($container->query('Crypt'), $container->query('KeyManager'), $container->query('Util'), $container->query('Session'), $container->query('EncryptAll'), $container->query('DecryptAll'), $container->getServer()->getLogger(), $container->getServer()->getL10N($container->getAppName())); }); }
protected function execute(InputInterface $input, OutputInterface $output) { if ($this->encryptionManager->isEnabled() === false) { throw new \Exception('Server side encryption is not enabled'); } $output->writeln("\n"); $output->writeln('You are about to start to encrypt all files stored in your ownCloud.'); $output->writeln('It will depend on the encryption module you use which files get encrypted.'); $output->writeln('Depending on the number and size of your files this can take some time'); $output->writeln('Please make sure that no user access his files during this process!'); $output->writeln(''); $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); if ($this->questionHelper->ask($input, $output, $question)) { $this->forceSingleUserAndTrashbin(); try { $defaultModule = $this->encryptionManager->getEncryptionModule(); $defaultModule->encryptAll($input, $output); } catch (\Exception $ex) { $this->resetSingleUserAndTrashbin(); throw $ex; } $this->resetSingleUserAndTrashbin(); } else { $output->writeln('aborted'); } }
protected function execute(InputInterface $input, OutputInterface $output) { try { if ($this->encryptionManager->isEnabled() === true) { $output->write('Disable server side encryption... '); $this->config->setAppValue('core', 'encryption_enabled', 'no'); $output->writeln('done.'); } else { $output->writeln('Server side encryption not enabled. Nothing to do.'); return; } $uid = $input->getArgument('user'); if ($uid === '') { $message = 'your ownCloud'; } else { $message = "{$uid}'s account"; } $output->writeln("\n"); $output->writeln("You are about to start to decrypt all files stored in {$message}."); $output->writeln('It will depend on the encryption module and your setup if this is possible.'); $output->writeln('Depending on the number and size of your files this can take some time'); $output->writeln('Please make sure that no user access his files during this process!'); $output->writeln(''); $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); if ($this->questionHelper->ask($input, $output, $question)) { $this->forceSingleUserAndTrashbin(); $user = $input->getArgument('user'); $result = $this->decryptAll->decryptAll($input, $output, $user); if ($result === false) { $output->writeln(' aborted.'); $output->writeln('Server side encryption remains enabled'); $this->config->setAppValue('core', 'encryption_enabled', 'yes'); } else { if ($uid !== '') { $output->writeln('Server side encryption remains enabled'); $this->config->setAppValue('core', 'encryption_enabled', 'yes'); } } $this->resetSingleUserAndTrashbin(); } else { $output->write('Enable server side encryption... '); $this->config->setAppValue('core', 'encryption_enabled', 'yes'); $output->writeln('done.'); $output->writeln('aborted'); } } catch (\Exception $e) { // enable server side encryption again if something went wrong $this->config->setAppValue('core', 'encryption_enabled', 'yes'); $this->resetSingleUserAndTrashbin(); throw $e; } }
/** * read encryption module needed to read/write the file located at $path * * @param string $path * @return null|\OCP\Encryption\IEncryptionModule * @throws ModuleDoesNotExistsException * @throws \Exception */ protected function getEncryptionModule($path) { $encryptionModule = null; $header = $this->getHeader($path); $encryptionModuleId = $this->util->getEncryptionModuleId($header); if (!empty($encryptionModuleId)) { try { $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId); } catch (ModuleDoesNotExistsException $e) { $this->logger->critical('Encryption module defined in "' . $path . '" not loaded!'); throw $e; } } return $encryptionModule; }
protected function execute(InputInterface $input, OutputInterface $output) { $this->writeArrayInOutputFormat($input, $output, ['enabled' => $this->encryptionManager->isEnabled(), 'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId()]); }