diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-03-31 11:15:47 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:28 +0200 |
commit | 0f28d538a0af769220bcba120f0a7340dd0aba5f (patch) | |
tree | 7c3dc65e4f1c9d7d4330563fb4c1eb7c6ed51827 /apps/encryption/lib/keymanager.php | |
parent | e0ab2c34eab970d82ddc6c9f5b3b752243fc716a (diff) | |
download | nextcloud-server-0f28d538a0af769220bcba120f0a7340dd0aba5f.tar.gz nextcloud-server-0f28d538a0af769220bcba120f0a7340dd0aba5f.zip |
add session class to handle all session operations
Diffstat (limited to 'apps/encryption/lib/keymanager.php')
-rw-r--r-- | apps/encryption/lib/keymanager.php | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php index cd983be17f9..6c5f2348027 100644 --- a/apps/encryption/lib/keymanager.php +++ b/apps/encryption/lib/keymanager.php @@ -30,14 +30,14 @@ use OCP\Encryption\Keys\IStorage; use OCP\IConfig; use OCP\ILogger; use OCP\IUserSession; -use \OCP\ISession; +use \OCA\Encryption\Session; class KeyManager { /** - * @var ISession + * @var Session */ - public static $session; + protected $session; /** * @var IStorage */ @@ -84,17 +84,13 @@ class KeyManager { * @var ILogger */ private $log; - /** - * @var Recovery - */ - private $recovery; /** * @param IStorage $keyStorage * @param Crypt $crypt * @param IConfig $config * @param IUserSession $userSession - * @param \OCP\ISession $session + * @param Session $session * @param ILogger $log * @param Recovery $recovery */ @@ -103,12 +99,12 @@ class KeyManager { Crypt $crypt, IConfig $config, IUserSession $userSession, - ISession $session, + Session $session, ILogger $log, Recovery $recovery ) { - self::$session = $session; + $this->session = $session; $this->keyStorage = $keyStorage; $this->crypt = $crypt; $this->config = $config; @@ -271,7 +267,6 @@ class KeyManager { * * @param string $uid userid * @param string $passPhrase users password - * @return ISession */ public function init($uid, $passPhrase) { try { @@ -284,11 +279,8 @@ class KeyManager { return false; } - - self::$session->set('privateKey', $privateKey); - self::$session->set('initStatus', true); - - return self::$session; + $this->session->setPrivateKey($privateKey); + $this->session->setStatus(Session::INIT_SUCCESSFUL); } /** @@ -316,7 +308,7 @@ class KeyManager { $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId); $shareKey = $this->getShareKey($path, $uid); - $privateKey = self::$session->get('privateKey'); + $privateKey = $this->session->getPrivateKey(); if ($encryptedFileKey && $shareKey && $privateKey) { $key = $this->crypt->multiKeyDecrypt($encryptedFileKey, @@ -348,7 +340,7 @@ class KeyManager { public function setPassphrase($params, IUserSession $user, Util $util) { // Get existing decrypted private key - $privateKey = self::$session->get('privateKey'); + $privateKey = $this->session->getPrivateKey(); if ($params['uid'] === $user->getUser()->getUID() && $privateKey) { |