diff options
author | Sam Tuke <samtuke@owncloud.com> | 2013-01-06 13:56:45 +0000 |
---|---|---|
committer | Sam Tuke <samtuke@owncloud.com> | 2013-01-06 13:56:45 +0000 |
commit | b024db9f989098b6adea42fb5bde4a49bf7ec5de (patch) | |
tree | c2b82c7572903159e1eab84644e59795b67a503d /apps/files_encryption | |
parent | 69e86c0213317bbd58fcc0a5dfa29ef593d93541 (diff) | |
download | nextcloud-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-x | apps/files_encryption/lib/keymanager.php | 6 | ||||
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 6 | ||||
-rw-r--r-- | apps/files_encryption/lib/stream.php | 2 | ||||
-rwxr-xr-x | apps/files_encryption/tests/crypt.php | 4 |
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 ); |