summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-04-22 11:18:18 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-22 11:53:05 +0200
commitfc4127dd62bdd1d9bd9339797607615a250ba33f (patch)
treee2ad8461ac3d85c378999aaf6a365fb5a0359a21 /apps
parent570718fb6bbad4dfd721b1ef451580749e9e0bdd (diff)
downloadnextcloud-server-fc4127dd62bdd1d9bd9339797607615a250ba33f.tar.gz
nextcloud-server-fc4127dd62bdd1d9bd9339797607615a250ba33f.zip
add $encryptionModuleId to methods of Keys/IStorage
Diffstat (limited to 'apps')
-rw-r--r--apps/encryption/appinfo/application.php18
-rw-r--r--apps/encryption/lib/keymanager.php54
-rw-r--r--apps/encryption/settings/settings-personal.php2
-rw-r--r--apps/encryption_dummy/lib/dummymodule.php4
4 files changed, 46 insertions, 32 deletions
diff --git a/apps/encryption/appinfo/application.php b/apps/encryption/appinfo/application.php
index 243e227b6bb..fa620992c81 100644
--- a/apps/encryption/appinfo/application.php
+++ b/apps/encryption/appinfo/application.php
@@ -24,8 +24,10 @@
namespace OCA\Encryption\AppInfo;
-use OC\Files\Filesystem;
use OC\Files\View;
+use OCA\Encryption\Controller\RecoveryController;
+use OCA\Encryption\Controller\SettingsController;
+use OCA\Encryption\Controller\StatusController;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Crypto\Encryption;
use OCA\Encryption\HookManager;
@@ -126,11 +128,11 @@ class Application extends \OCP\AppFramework\App {
function (IAppContainer $c) {
$server = $c->getServer();
- return new KeyManager($server->getEncryptionKeyStorage(\OCA\Encryption\Crypto\Encryption::ID),
+ return new KeyManager($server->getEncryptionKeyStorage(),
$c->query('Crypt'),
$server->getConfig(),
$server->getUserSession(),
- new \OCA\Encryption\Session($server->getSession()),
+ new Session($server->getSession()),
$server->getLogger(),
$c->query('Util')
);
@@ -146,14 +148,14 @@ class Application extends \OCP\AppFramework\App {
$server->getSecureRandom(),
$c->query('KeyManager'),
$server->getConfig(),
- $server->getEncryptionKeyStorage(\OCA\Encryption\Crypto\Encryption::ID),
+ $server->getEncryptionKeyStorage(),
$server->getEncryptionFilesHelper(),
- new \OC\Files\View());
+ new View());
});
$container->registerService('RecoveryController', function (IAppContainer $c) {
$server = $c->getServer();
- return new \OCA\Encryption\Controller\RecoveryController(
+ return new RecoveryController(
$c->getAppName(),
$server->getRequest(),
$server->getConfig(),
@@ -163,7 +165,7 @@ class Application extends \OCP\AppFramework\App {
$container->registerService('StatusController', function (IAppContainer $c) {
$server = $c->getServer();
- return new \OCA\Encryption\Controller\StatusController(
+ return new StatusController(
$c->getAppName(),
$server->getRequest(),
$server->getL10N($c->getAppName()),
@@ -173,7 +175,7 @@ class Application extends \OCP\AppFramework\App {
$container->registerService('SettingsController', function (IAppContainer $c) {
$server = $c->getServer();
- return new \OCA\Encryption\Controller\SettingsController(
+ return new SettingsController(
$c->getAppName(),
$server->getRequest(),
$server->getL10N($c->getAppName()),
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index b451b5c25a9..1e6f3d29be8 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -23,6 +23,7 @@
namespace OCA\Encryption;
use OC\Encryption\Exceptions\DecryptionFailedException;
+use OCA\Encryption\Crypto\Encryption;
use OCA\Encryption\Exceptions\PrivateKeyMissingException;
use OCA\Encryption\Exceptions\PublicKeyMissingException;
use OCA\Encryption\Crypto\Crypt;
@@ -136,7 +137,8 @@ class KeyManager {
// Save public key
$this->keyStorage->setSystemUserKey(
- $this->publicShareKeyId . '.publicKey', $keyPair['publicKey']);
+ $this->publicShareKeyId . '.publicKey', $keyPair['publicKey'],
+ Encryption::ID);
// Encrypt private key empty passphrase
$encryptedKey = $this->crypt->symmetricEncryptFileContent($keyPair['privateKey'], '');
@@ -162,7 +164,7 @@ class KeyManager {
* @return string
*/
public function getRecoveryKey() {
- return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.publicKey');
+ return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.publicKey', Encryption::ID);
}
/**
@@ -179,7 +181,7 @@ class KeyManager {
* @return bool
*/
public function checkRecoveryPassword($password) {
- $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.privateKey');
+ $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.privateKey', Encryption::ID);
$decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey,
$password);
@@ -217,7 +219,10 @@ class KeyManager {
*/
public function setRecoveryKey($password, $keyPair) {
// Save Public Key
- $this->keyStorage->setSystemUserKey($this->getRecoveryKeyId(). '.publicKey', $keyPair['publicKey']);
+ $this->keyStorage->setSystemUserKey($this->getRecoveryKeyId().
+ '.publicKey',
+ $keyPair['publicKey'],
+ Encryption::ID);
$encryptedKey = $this->crypt->symmetricEncryptFileContent($keyPair['privateKey'],
$password);
@@ -236,7 +241,7 @@ class KeyManager {
* @return bool
*/
public function setPublicKey($userId, $key) {
- return $this->keyStorage->setUserKey($userId, $this->publicKeyId, $key);
+ return $this->keyStorage->setUserKey($userId, $this->publicKeyId, $key, Encryption::ID);
}
/**
@@ -247,7 +252,8 @@ class KeyManager {
public function setPrivateKey($userId, $key) {
return $this->keyStorage->setUserKey($userId,
$this->privateKeyId,
- $key);
+ $key,
+ Encryption::ID);
}
/**
@@ -258,7 +264,7 @@ class KeyManager {
* @return boolean
*/
public function setFileKey($path, $key) {
- return $this->keyStorage->setFileKey($path, $this->fileKeyId, $key);
+ return $this->keyStorage->setFileKey($path, $this->fileKeyId, $key, Encryption::ID);
}
/**
@@ -284,7 +290,7 @@ class KeyManager {
*/
public function setShareKey($path, $uid, $key) {
$keyId = $uid . '.' . $this->shareKeyId;
- return $this->keyStorage->setFileKey($path, $keyId, $key);
+ return $this->keyStorage->setFileKey($path, $keyId, $key, Encryption::ID);
}
/**
@@ -324,7 +330,7 @@ class KeyManager {
*/
public function getPrivateKey($userId) {
$privateKey = $this->keyStorage->getUserKey($userId,
- $this->privateKeyId);
+ $this->privateKeyId, Encryption::ID);
if (strlen($privateKey) !== 0) {
return $privateKey;
@@ -338,12 +344,12 @@ class KeyManager {
* @return string
*/
public function getFileKey($path, $uid) {
- $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId);
+ $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId, Encryption::ID);
if (is_null($uid)) {
$uid = $this->getPublicShareKeyId();
$shareKey = $this->getShareKey($path, $uid);
- $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey');
+ $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey', Encryption::ID);
$privateKey = $this->crypt->decryptPrivateKey($privateKey);
} else {
$shareKey = $this->getShareKey($path, $uid);
@@ -367,7 +373,7 @@ class KeyManager {
*/
public function getEncryptedFileKey($path) {
$encryptedFileKey = $this->keyStorage->getFileKey($path,
- $this->fileKeyId);
+ $this->fileKeyId, Encryption::ID);
return $encryptedFileKey;
}
@@ -380,7 +386,10 @@ class KeyManager {
* @return boolean
*/
public function deleteShareKey($path, $keyId) {
- return $this->keyStorage->deleteFileKey($path, $keyId . '.' . $this->shareKeyId);
+ return $this->keyStorage->deleteFileKey(
+ $path,
+ $keyId . '.' . $this->shareKeyId,
+ Encryption::ID);
}
@@ -391,7 +400,7 @@ class KeyManager {
*/
public function getShareKey($path, $uid) {
$keyId = $uid . '.' . $this->shareKeyId;
- return $this->keyStorage->getFileKey($path, $keyId);
+ return $this->keyStorage->getFileKey($path, $keyId, Encryption::ID);
}
/**
@@ -416,7 +425,7 @@ class KeyManager {
* @throws PublicKeyMissingException
*/
public function getPublicKey($userId) {
- $publicKey = $this->keyStorage->getUserKey($userId, $this->publicKeyId);
+ $publicKey = $this->keyStorage->getUserKey($userId, $this->publicKeyId, Encryption::ID);
if (strlen($publicKey) !== 0) {
return $publicKey;
@@ -434,7 +443,7 @@ class KeyManager {
* @return string
*/
public function getPublicShareKey() {
- return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.publicKey');
+ return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.publicKey', Encryption::ID);
}
/**
@@ -460,7 +469,7 @@ class KeyManager {
* @return bool
*/
public function deletePublicKey($uid) {
- return $this->keyStorage->deleteUserKey($uid, $this->publicKeyId);
+ return $this->keyStorage->deleteUserKey($uid, $this->publicKeyId, Encryption::ID);
}
/**
@@ -468,11 +477,11 @@ class KeyManager {
* @return bool
*/
private function deletePrivateKey($uid) {
- return $this->keyStorage->deleteUserKey($uid, $this->privateKeyId);
+ return $this->keyStorage->deleteUserKey($uid, $this->privateKeyId, Encryption::ID);
}
public function deleteAllFileKeys($path) {
- return $this->keyStorage->deleteAllFileKeys($path);
+ return $this->keyStorage->deleteAllFileKeys($path, Encryption::ID);
}
/**
@@ -500,7 +509,7 @@ class KeyManager {
* @return string returns openssl key
*/
public function getSystemPrivateKey($keyId) {
- return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId);
+ return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId, Encryption::ID);
}
/**
@@ -509,7 +518,10 @@ class KeyManager {
* @return string returns openssl key
*/
public function setSystemPrivateKey($keyId, $key) {
- return $this->keyStorage->setSystemUserKey($keyId . '.' . $this->privateKeyId, $key);
+ return $this->keyStorage->setSystemUserKey(
+ $keyId . '.' . $this->privateKeyId,
+ $key,
+ Encryption::ID);
}
/**
diff --git a/apps/encryption/settings/settings-personal.php b/apps/encryption/settings/settings-personal.php
index abbe62af615..01e1bdab0ea 100644
--- a/apps/encryption/settings/settings-personal.php
+++ b/apps/encryption/settings/settings-personal.php
@@ -38,7 +38,7 @@ $util = new \OCA\Encryption\Util(
\OC::$server->getConfig());
$keyManager = new \OCA\Encryption\KeyManager(
- \OC::$server->getEncryptionKeyStorage(\OCA\Encryption\Crypto\Encryption::ID),
+ \OC::$server->getEncryptionKeyStorage(),
$crypt,
\OC::$server->getConfig(),
$userSession,
diff --git a/apps/encryption_dummy/lib/dummymodule.php b/apps/encryption_dummy/lib/dummymodule.php
index 813b50edcbd..e974ee468e2 100644
--- a/apps/encryption_dummy/lib/dummymodule.php
+++ b/apps/encryption_dummy/lib/dummymodule.php
@@ -76,8 +76,8 @@ class DummyModule implements IEncryptionModule {
public function end($path) {
if ($this->isWriteOperation) {
- $storage = \OC::$server->getEncryptionKeyStorage($this->getId());
- $storage->setFileKey($path, 'fileKey', 'foo');
+ $storage = \OC::$server->getEncryptionKeyStorage();
+ $storage->setFileKey($path, 'fileKey', 'foo', $this->getId());
}
return '';
}