Made Keymanager::getFileKey() dependencies explicit, fixed client code and tests accordingly

This commit is contained in:
Sam Tuke 2013-01-06 13:56:45 +00:00
parent 69e86c0213
commit b024db9f98
4 changed files with 11 additions and 7 deletions

View File

@ -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' );
}

View 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();

View 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();

View File

@ -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 );