summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorSam Tuke <samtuke@owncloud.com>2013-01-06 13:56:45 +0000
committerSam Tuke <samtuke@owncloud.com>2013-01-06 13:56:45 +0000
commitb024db9f989098b6adea42fb5bde4a49bf7ec5de (patch)
treec2b82c7572903159e1eab84644e59795b67a503d /apps/files_encryption
parent69e86c0213317bbd58fcc0a5dfa29ef593d93541 (diff)
downloadnextcloud-server-b024db9f989098b6adea42fb5bde4a49bf7ec5de.tar.gz
nextcloud-server-b024db9f989098b6adea42fb5bde4a49bf7ec5de.zip
Made Keymanager::getFileKey() dependencies explicit, fixed client code and tests accordingly
Diffstat (limited to 'apps/files_encryption')
-rwxr-xr-xapps/files_encryption/lib/keymanager.php6
-rw-r--r--apps/files_encryption/lib/proxy.php6
-rw-r--r--apps/files_encryption/lib/stream.php2
-rwxr-xr-xapps/files_encryption/tests/crypt.php4
4 files changed, 11 insertions, 7 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 818cd1a154d..e6c08ee2b7f 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -149,7 +149,7 @@ class Keymanager {
* @note The keyfile returned is asymmetrically encrypted. Decryption
* of the keyfile must be performed by client code
*/
- public static function getFileKey( $view, $userId, $filePath ) {
+ public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {
$filePath_f = ltrim( $filePath, '/' );
@@ -166,8 +166,8 @@ class Keymanager {
// $keypath = str_replace( '/' . $userId . '/files/', '', $keypath );
//
// }
-
- return $this->view->file_get_contents( '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f );
+// trigger_error(var_export($view, 1));
+ return $view->file_get_contents( '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f . '.key' );
}
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 272d0a5509f..0084af94c77 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -156,7 +156,11 @@ class Proxy extends \OC_FileProxy {
//$cached = \OC_FileCache_Cached::get( $path, '' );
- $encryptedKeyfile = Keymanager::getFileKey( $filePath );
+ $view = new \OC_FilesystemView( '' );
+
+ $userId = \OCP\USER::getUser();
+
+ $encryptedKeyfile = Keymanager::getFileKey( $view, $userId, $filePath );
$session = new Session();
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index fc1b9808cc5..a98f5bec833 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -267,7 +267,7 @@ class Stream {
# TODO: add error handling for when file exists but no keyfile
// Fetch existing keyfile
- $this->encKeyfile = Keymanager::getFileKey( $this->rawPath );
+ $this->encKeyfile = Keymanager::getFileKey( $this->rootView, $this->userId, $this->rawPath );
$this->getUser();
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index 446af7cfa09..4ac53a646b1 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -242,7 +242,7 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
// Get keyfile
- $encryptedKeyfile = Encryption\Keymanager::getFileKey( $filename );
+ $encryptedKeyfile = Encryption\Keymanager::getFileKey( $this->view, $this->userId, $filename );
$decryptedKeyfile = Encryption\Crypt::keyDecrypt( $encryptedKeyfile, $decryptedPrivateKey );
@@ -298,7 +298,7 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
// Get keyfile
- $encryptedKeyfile = Encryption\Keymanager::getFileKey( $filename );
+ $encryptedKeyfile = Encryption\Keymanager::getFileKey( $this->view, $this->userId, $filename );
$decryptedKeyfile = Encryption\Crypt::keyDecrypt( $encryptedKeyfile, $decryptedPrivateKey );