summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/encryption/manager.php27
-rw-r--r--lib/private/encryption/update.php2
-rw-r--r--lib/private/files/storage/wrapper/encryption.php6
-rw-r--r--lib/private/ocsclient.php1
-rw-r--r--lib/private/security/securerandom.php2
-rw-r--r--lib/public/encryption/imanager.php19
-rw-r--r--lib/public/security/isecurerandom.php2
7 files changed, 27 insertions, 32 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 5e96f50f914..e3458cb6bba 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -313,12 +313,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 {
$info = $this->getCache()->get($path);
diff --git a/lib/private/ocsclient.php b/lib/private/ocsclient.php
index b00772fb799..f10a97428e2 100644
--- a/lib/private/ocsclient.php
+++ b/lib/private/ocsclient.php
@@ -263,6 +263,7 @@ class OCSClient {
$tmp = $data->data->content;
if (is_null($tmp)) {
+ \OC_Log::write('core', 'No update found at the ownCloud appstore for app ' . $id, \OC_Log::INFO);
return null;
}
diff --git a/lib/private/security/securerandom.php b/lib/private/security/securerandom.php
index 348d04c9ccc..409285fd098 100644
--- a/lib/private/security/securerandom.php
+++ b/lib/private/security/securerandom.php
@@ -76,7 +76,7 @@ class SecureRandom implements ISecureRandom {
/**
* Generate a random string of specified length.
- * @param string $length The length of the generated string
+ * @param int $length The length of the generated string
* @param string $characters An optional list of characters to use if no characterlist is
* specified all valid base64 characters are used.
* @return string
diff --git a/lib/public/encryption/imanager.php b/lib/public/encryption/imanager.php
index 3a370710781..0b12c7524d2 100644
--- a/lib/public/encryption/imanager.php
+++ b/lib/public/encryption/imanager.php
@@ -37,7 +37,7 @@ interface IManager {
* @return bool true if enabled, false if not
* @since 8.1.0
*/
- function isEnabled();
+ public function isEnabled();
/**
* Registers an callback function which must return an encryption module instance
@@ -48,7 +48,7 @@ interface IManager {
* @throws ModuleAlreadyExistsException
* @since 8.1.0
*/
- function registerEncryptionModule($id, $displayName, callable $callback);
+ public function registerEncryptionModule($id, $displayName, callable $callback);
/**
* Unregisters an encryption module
@@ -56,7 +56,7 @@ interface IManager {
* @param string $moduleId
* @since 8.1.0
*/
- function unregisterEncryptionModule($moduleId);
+ public function unregisterEncryptionModule($moduleId);
/**
* get a list of all encryption modules
@@ -64,27 +64,26 @@ interface IManager {
* @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
* @since 8.1.0
*/
- function getEncryptionModules();
+ public function getEncryptionModules();
/**
* get a specific encryption module
*
- * @param string $moduleId
+ * @param string $moduleId Empty to get the default module
* @return IEncryptionModule
* @throws ModuleDoesNotExistsException
* @since 8.1.0
*/
- function getEncryptionModule($moduleId);
+ public function getEncryptionModule($moduleId = '');
/**
- * get default encryption module
+ * get default encryption module Id
*
- * @return \OCP\Encryption\IEncryptionModule
- * @throws ModuleDoesNotExistsException
+ * @return string
* @since 8.1.0
*/
- public function getDefaultEncryptionModule();
+ public function getDefaultEncryptionModuleId();
/**
* set default encryption module Id
diff --git a/lib/public/security/isecurerandom.php b/lib/public/security/isecurerandom.php
index 69e6ec21b13..cbe2d4e0d56 100644
--- a/lib/public/security/isecurerandom.php
+++ b/lib/public/security/isecurerandom.php
@@ -69,7 +69,7 @@ interface ISecureRandom {
/**
* Generate a random string of specified length.
- * @param string $length The length of the generated string
+ * @param int $length The length of the generated string
* @param string $characters An optional list of characters to use if no characterlist is
* specified all valid base64 characters are used.
* @return string