summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/encryption/manager.php24
-rw-r--r--tests/lib/encryption/managertest.php2
2 files changed, 19 insertions, 7 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);
+ }
}
}
diff --git a/tests/lib/encryption/managertest.php b/tests/lib/encryption/managertest.php
index 5a0efa37b36..e5a1898515a 100644
--- a/tests/lib/encryption/managertest.php
+++ b/tests/lib/encryption/managertest.php
@@ -114,7 +114,7 @@ class ManagerTest extends TestCase {
/**
* @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException
- * @expectedExceptionMessage At the moment it is not allowed to register more than one encryption module
+ * @expectedExceptionMessage Id "0" already used by encryption module "TestDummyModule0"
*/
public function testModuleRegistration() {
$config = $this->getMock('\OCP\IConfig');