diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-27 13:28:59 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-27 13:28:59 +0200 |
commit | 6a7b7caa810421593ec6725977f08f2d5138eacd (patch) | |
tree | a11660d1b7c908da68d4f780010abdb28a29d385 /lib/private | |
parent | 802f818c2770b8b52d050e8fbc7562295f995445 (diff) | |
parent | e4c24a6b5c01f26883d530fa13be8828f0ce08af (diff) | |
download | nextcloud-server-6a7b7caa810421593ec6725977f08f2d5138eacd.tar.gz nextcloud-server-6a7b7caa810421593ec6725977f08f2d5138eacd.zip |
Merge pull request #15681 from owncloud/issue/15667-occ-encryption
OCC commands to manage encryption
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/encryption/manager.php | 27 | ||||
-rw-r--r-- | lib/private/encryption/update.php | 2 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 6 |
3 files changed, 15 insertions, 20 deletions
diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php index 8e080507c81..1a42646daf6 100644 --- a/lib/private/encryption/manager.php +++ b/lib/private/encryption/manager.php @@ -101,17 +101,17 @@ class Manager implements IManager { throw new Exceptions\ModuleAlreadyExistsException($id, $displayName); } - $defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId(); - - if (empty($defaultEncryptionModuleId)) { - $this->setDefaultEncryptionModule($id); - } - $this->encryptionModules[$id] = [ 'id' => $id, 'displayName' => $displayName, 'callback' => $callback, ]; + + $defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId(); + + if (empty($defaultEncryptionModuleId)) { + $this->setDefaultEncryptionModule($id); + } } /** @@ -158,7 +158,7 @@ class Manager implements IManager { * @return \OCP\Encryption\IEncryptionModule * @throws Exceptions\ModuleDoesNotExistsException */ - public function getDefaultEncryptionModule() { + protected function getDefaultEncryptionModule() { $defaultModuleId = $this->getDefaultEncryptionModuleId(); if (!empty($defaultModuleId)) { if (isset($this->encryptionModules[$defaultModuleId])) { @@ -182,12 +182,13 @@ class Manager implements IManager { */ public function setDefaultEncryptionModule($moduleId) { try { - $this->config->setAppValue('core', 'default_encryption_module', $moduleId); - return true; + $this->getEncryptionModule($moduleId); } catch (\Exception $e) { return false; } + $this->config->setAppValue('core', 'default_encryption_module', $moduleId); + return true; } /** @@ -195,12 +196,8 @@ class Manager implements IManager { * * @return string */ - protected function getDefaultEncryptionModuleId() { - try { - return $this->config->getAppValue('core', 'default_encryption_module'); - } catch (\Exception $e) { - return ''; - } + public function getDefaultEncryptionModuleId() { + return $this->config->getAppValue('core', 'default_encryption_module'); } public static function setupStorage() { diff --git a/lib/private/encryption/update.php b/lib/private/encryption/update.php index f262099a3c5..a0b0af968c6 100644 --- a/lib/private/encryption/update.php +++ b/lib/private/encryption/update.php @@ -137,7 +137,7 @@ class Update { $allFiles = array($path); } - $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule(); + $encryptionModule = $this->encryptionManager->getEncryptionModule(); foreach ($allFiles as $file) { $usersSharing = $this->file->getAccessList($file); diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 0dc59cbb2a0..af48d3475c3 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -311,12 +311,10 @@ class Encryption extends Wrapper { || $mode === 'wb' || $mode === 'wb+' ) { - if (!empty($encryptionModuleId)) { + if ($encryptionEnabled) { + // if $encryptionModuleId is empty, the default module will be used $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId); $shouldEncrypt = $encryptionModule->shouldEncrypt($fullPath); - } elseif ($encryptionEnabled) { - $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule(); - $shouldEncrypt = $encryptionModule->shouldEncrypt($fullPath); } } else { // only get encryption module if we found one in the header |