summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/session.php
diff options
context:
space:
mode:
authorSam Tuke <samtuke@owncloud.com>2013-04-09 19:11:38 +0200
committerSam Tuke <samtuke@owncloud.com>2013-04-09 19:11:38 +0200
commit400cf5beb30de7475520192e840ddb899d0f742e (patch)
tree1f746cdd69ec0235c249b310802bc16a04b0d973 /apps/files_encryption/lib/session.php
parent14451bdaf07f88c6ac46092c74b987a360b04547 (diff)
downloadnextcloud-server-400cf5beb30de7475520192e840ddb899d0f742e.tar.gz
nextcloud-server-400cf5beb30de7475520192e840ddb899d0f742e.zip
Fixed naming bug of public owncloud key dir, which caused new keypair to be generated on each pageload
Diffstat (limited to 'apps/files_encryption/lib/session.php')
-rw-r--r--apps/files_encryption/lib/session.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index 171a6900f0f..7bfea7bed48 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -27,32 +27,44 @@ namespace OCA\Encryption;
*/
class Session {
+
+ private $view;
/**
* @brief if session is started, check if ownCloud key pair is set up, if not create it
*
* The ownCloud key pair is used to allow public link sharing even if encryption is enabled
*/
- public function __construct() {
+ public function __construct( \OC_FilesystemView $view ) {
+
+ $this->view = $view;
+
+ if ( ! $this->view->is_dir( 'owncloud_private_key' ) ) {
- $view = new \OC\Files\View('/');
- if (!$view->is_dir('owncloud_private_key')) {
- $view->mkdir('owncloud_private_key');
+ $this->view->mkdir('owncloud_private_key');
}
- if (!$view->file_exists("/public-keys/owncloud.public.key") || !$view->file_exists("/owncloud_private_key/owncloud.private.key") ) {
+
+ if (
+ ! $this->view->file_exists("/public-keys/owncloud.public.key")
+ || ! $this->view->file_exists("/owncloud_private_key/owncloud.private.key" )
+ ) {
$keypair = Crypt::createKeypair();
\OC_FileProxy::$enabled = false;
+
// Save public key
- $view->file_put_contents( '/public-keys/ownCloud.public.key', $keypair['publicKey'] );
+ $this->view->file_put_contents( '/public-keys/owncloud.public.key', $keypair['publicKey'] );
+
// Encrypt private key empthy passphrase
$encryptedPrivateKey = Crypt::symmetricEncryptFileContent( $keypair['privateKey'], '' );
+
// Save private key
- $view->file_put_contents( '/owncloud_private_key/ownCloud.private.key', $encryptedPrivateKey );
+ $this->view->file_put_contents( '/owncloud_private_key/owncloud.private.key', $encryptedPrivateKey );
\OC_FileProxy::$enabled = true;
+
}
}