示例#1
0
文件: enable.php 项目: kenwi/core
 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);
             }
         }
     }
 }
示例#2
0
 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);
 }
示例#3
0
 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);
 }
示例#4
0
 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>');
         }
     }
 }
示例#5
0
 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()));
     });
 }
示例#6
0
 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');
     }
 }
示例#7
0
 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;
     }
 }
示例#8
0
	/**
	 * 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;
	}
示例#9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeArrayInOutputFormat($input, $output, ['enabled' => $this->encryptionManager->isEnabled(), 'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId()]);
 }