summaryrefslogtreecommitdiffstats
path: root/lib/private/encryption
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-03-18 10:58:02 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:27 +0200
commite2f714263f50a27ed0894710faead3e9f9d1d9d6 (patch)
tree22b21f81b9b7d6ee244de2b1fbf9db768a879be3 /lib/private/encryption
parent5bc9ababeb06c3e901b7d11b8c2c1d44865d3339 (diff)
downloadnextcloud-server-e2f714263f50a27ed0894710faead3e9f9d1d9d6.tar.gz
nextcloud-server-e2f714263f50a27ed0894710faead3e9f9d1d9d6.zip
fix encryption manager to handle more than one encryption module
Diffstat (limited to 'lib/private/encryption')
-rw-r--r--lib/private/encryption/manager.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php
index 5164025239c..fa50d32218d 100644
--- a/lib/private/encryption/manager.php
+++ b/lib/private/encryption/manager.php
@@ -106,12 +106,24 @@ class Manager implements \OCP\Encryption\IManager {
* @return IEncryptionModule
* @throws Exceptions\ModuleDoesNotExistsException
*/
- public function getEncryptionModule($moduleId) {
- if (isset($this->encryptionModules[$moduleId])) {
- return $this->encryptionModules[$moduleId];
- } else {
- $message = "Module with id: $moduleId does not exists.";
- throw new Exceptions\ModuleDoesNotExistsException($message);
+ public function getEncryptionModule($moduleId = '') {
+ if (!empty($moduleId)) {
+ if (isset($this->encryptionModules[$moduleId])) {
+ return $this->encryptionModules[$moduleId];
+ } else {
+ $message = "Module with id: $moduleId does not exists.";
+ throw new Exceptions\ModuleDoesNotExistsException($message);
+ }
+ } else { // get default module and return this
+ // For now we simply return the first module until we have a way
+ // to enable multiple modules and define a default module
+ $module = reset($this->encryptionModules);
+ if ($module) {
+ return $module;
+ } else {
+ $message = 'No encryption module registered';
+ throw new Exceptions\ModuleDoesNotExistsException($message);
+ }
}
}