]> source.dussan.org Git - nextcloud-server.git/commitdiff
Made Keymanager::getFileKey() dependencies explicit, fixed client code and tests...
authorSam Tuke <samtuke@owncloud.com>
Sun, 6 Jan 2013 13:56:45 +0000 (13:56 +0000)
committerSam Tuke <samtuke@owncloud.com>
Sun, 6 Jan 2013 13:56:45 +0000 (13:56 +0000)
apps/files_encryption/lib/keymanager.php
apps/files_encryption/lib/proxy.php
apps/files_encryption/lib/stream.php
apps/files_encryption/tests/crypt.php

index 818cd1a154d635e76a740e8b468aad712b10aafa..e6c08ee2b7f9537a310bfd3c6478643aff913a95 100755 (executable)
@@ -149,7 +149,7 @@ class Keymanager {
         * @note The keyfile returned is asymmetrically encrypted. Decryption\r
         * of the keyfile must be performed by client code\r
         */\r
-       public static function getFileKey( $view, $userId, $filePath ) {\r
+       public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {\r
                \r
                $filePath_f = ltrim( $filePath, '/' );\r
 \r
@@ -166,8 +166,8 @@ class Keymanager {
 //                     $keypath = str_replace( '/' . $userId . '/files/', '', $keypath );\r
 //                     \r
 //             }\r
-               \r
-               return $this->view->file_get_contents( '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f );\r
+//             trigger_error(var_export($view, 1));\r
+               return $view->file_get_contents( '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f . '.key' );\r
                \r
        }\r
        \r
index 272d0a5509fd30c84bf8d7a8877b6297d7e30639..0084af94c779d0f568399380bb6870d5ad16f9db 100644 (file)
@@ -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();
                        
index fc1b9808cc5af594dbc216c8e756a1a406ace7b3..a98f5bec83320d7022e0852a520affe3975b489c 100644 (file)
@@ -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();
                        
index 446af7cfa09c26e77e24288b387bcde120f00a6d..4ac53a646b12aef9d7e75b286be045beda5a47bf 100755 (executable)
@@ -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 );