From 12628be38bd8a8225139c19c6725255fcebc3d93 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 10 Aug 2012 11:44:38 +0200 Subject: [PATCH] only call proxies for server side encryption --- apps/files_encryption/lib/keymanager.php | 31 +++--------------------- apps/files_encryption/lib/proxy.php | 2 +- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 43ac67f8cb..0705205682 100644 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -35,15 +35,11 @@ class Keymanager { * @return string private key or false */ public static function getPrivateKey() { - - \OC_FileProxy::$enabled = false; - + $user = \OCP\User::getUser(); $view = new \OC_FilesystemView( '/' . $user . '/' . 'files_encryption' ); $result = $view->file_get_contents( '/' . $user.'.private.key' ); - - \OC_FileProxy::$enabled = true; - + return $result; } @@ -80,8 +76,6 @@ class Keymanager { } } - \OC_FileProxy::$enabled = false; - $view = new \OC_FilesystemView( '/public-keys/' ); $keylist = array(); @@ -89,8 +83,6 @@ class Keymanager { foreach ($users as $user) { $keylist['key'.++$count] = $view->file_get_contents($user.'.public.key'); } - - \OC_FileProxy::$enabled = true; return $keylist; @@ -117,13 +109,9 @@ class Keymanager { $keypath = str_replace('/'.$user.'/files/', '', $keypath); } - \OC_FileProxy::$enabled = false; - $view = new \OC_FilesystemView('/'.$user.'/files_encryption/keyfiles/'); $result = $view->file_get_contents($keypath.'.key'); - - \OC_FileProxy::$enabled = true; - + return $result; } @@ -134,16 +122,12 @@ class Keymanager { * @return bool true/false */ public static function setPrivateKey($key) { - - \OC_FileProxy::$enabled = false; $user = \OCP\User::getUser(); $view = new \OC_FilesystemView('/'.$user.'/files_encryption'); if (!$view->file_exists('')) $view->mkdir(''); $result = $view->file_put_contents($user.'.private.key', $key); - \OC_FileProxy::$enabled = true; - return $result; } @@ -156,14 +140,10 @@ class Keymanager { */ public static function setPublicKey($key) { - \OC_FileProxy::$enabled = false; - $view = new \OC_FilesystemView('/public-keys'); if (!$view->file_exists('')) $view->mkdir(''); $result = $view->file_put_contents(\OCP\User::getUser().'.public.key', $key); - \OC_FileProxy::$enabled = true; - return $result; } @@ -174,8 +154,7 @@ class Keymanager { * @param string $key * @return bool true/false */ - public static function setFileKey( $path, $key, $view = Null, $dbClassName = '\OC_DB', $fileProxyClassName = '\OC_FileProxy') { - $fileProxyClassName::$enabled = false; + public static function setFileKey( $path, $key, $view = Null, $dbClassName = '\OC_DB') { $targetpath = ltrim( $path, '/' ); $user = \OCP\User::getUser(); @@ -209,8 +188,6 @@ class Keymanager { $result = $view->file_put_contents( '/' . $targetpath . '.key', $key ); - $fileProxyClassName::$enabled = true; - return $result; } diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 94f427f2f2..32b7a67e65 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -46,7 +46,7 @@ class Proxy extends \OC_FileProxy { if ( is_null( self::$enableEncryption ) ) { - self::$enableEncryption = ( \OCP\Config::getAppValue( 'files_encryption', 'enable_encryption', 'true' ) == 'true' ); + self::$enableEncryption = ( \OCP\Config::getAppValue( 'files_encryption', 'enable_encryption', 'true' ) == 'true' && Crypt::mode() == 'server' ); }