aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/stream.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-11-21 10:24:47 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2013-11-21 10:24:47 +0100
commit18c80e47b660d33650164f34889e5bc3dd7faa1f (patch)
tree6b905ec7f21471a6e921b711aa37f9ea77b4e3ca /apps/files_encryption/lib/stream.php
parentb27fc42e1f0fbd1edebb1eb1818de4b4e0c4ee4b (diff)
parent2b361ea085812a7b97102d026c421905549b5142 (diff)
downloadnextcloud-server-18c80e47b660d33650164f34889e5bc3dd7faa1f.tar.gz
nextcloud-server-18c80e47b660d33650164f34889e5bc3dd7faa1f.zip
Merge branch 'encryption_work_with_public_gallery' into encryption_enable_public_upload
Conflicts: apps/files_encryption/lib/stream.php
Diffstat (limited to 'apps/files_encryption/lib/stream.php')
-rw-r--r--apps/files_encryption/lib/stream.php31
1 files changed, 15 insertions, 16 deletions
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 3fbcf7db3e4..f2df7f4cd9f 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -55,6 +55,7 @@ class Stream {
private $rawPath; // The raw path relative to the data dir
private $relPath; // rel path to users file dir
private $userId;
+ private $keyId;
private $handle; // Resource returned by fopen
private $meta = array(); // Header / meta for source stream
private $writeCache;
@@ -90,20 +91,21 @@ class Stream {
$this->rootView = new \OC_FilesystemView('/');
}
- // rawPath is relative to the data directory
- $this->rawPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
$this->session = new \OCA\Encryption\Session($this->rootView);
$this->privateKey = $this->session->getPrivateKey();
- $userId = Helper::getUser($this->rawPath);
+ // rawPath is relative to the data directory
+ $this->rawPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
+
+ $this->userId = Helper::getUser($this->rawPath);
- $util = new Util($this->rootView, $userId);
+ $util = new Util($this->rootView, $this->userId);
- // need to get the userId once more from util, because now this can be the
- // public share key ID
- $this->userId = $util->getUserId();
+ // get the key ID which we want to use, canm be the users key or the
+ // public share key
+ $this->keyId = $util->getKeyId();
// Strip identifier text from path, this gives us the path relative to data/<user>/files
$this->relPath = Helper::stripUserFilesPath($this->rawPath);
@@ -254,14 +256,13 @@ class Stream {
// Fetch and decrypt keyfile
// Fetch existing keyfile
- $userId = Helper::getUser($this->rawPath);
- $util = new \OCA\Encryption\Util($this->rootView, $userId);
+ $util = new \OCA\Encryption\Util($this->rootView, $this->userId);
$this->encKeyfile = Keymanager::getFileKey($this->rootView, $util, $this->relPath);
// If a keyfile already exists
if ($this->encKeyfile) {
- $shareKey = Keymanager::getShareKey($this->rootView, $this->userId, $util, $this->relPath);
+ $shareKey = Keymanager::getShareKey($this->rootView, $this->keyId, $util, $this->relPath);
// if there is no valid private key return false
if ($this->privateKey === false) {
@@ -508,17 +509,15 @@ class Stream {
\OC_FileProxy::$enabled = false;
// Fetch user's public key
- $this->publicKey = Keymanager::getPublicKey($this->rootView, $this->userId);
+ $this->publicKey = Keymanager::getPublicKey($this->rootView, $this->keyId);
// Check if OC sharing api is enabled
$sharingEnabled = \OCP\Share::isEnabled();
- $userId = Helper::getUser($this->rawPath);
-
- $util = new Util($this->rootView, $userId);
+ $util = new Util($this->rootView, $this->userId);
// Get all users sharing the file includes current user
- $uniqueUserIds = $util->getSharingUsersArray($sharingEnabled, $this->relPath, $userId);
+ $uniqueUserIds = $util->getSharingUsersArray($sharingEnabled, $this->relPath, $this->userId);
$checkedUserIds = $util->filterShareReadyUsers($uniqueUserIds);
// Fetch public keys for all sharing users
@@ -528,7 +527,7 @@ class Stream {
$this->encKeyfiles = Crypt::multiKeyEncrypt($this->plainKey, $publicKeys);
// Save the new encrypted file key
- Keymanager::setFileKey($this->rootView, $util, $this->relPath, $userId, $this->encKeyfiles['data']);
+ Keymanager::setFileKey($this->rootView, $util, $this->relPath, $this->keyId, $this->encKeyfiles['data']);
// Save the sharekeys
Keymanager::setShareKeys($this->rootView, $util, $this->relPath, $this->encKeyfiles['keys']);