summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2012-07-26 17:19:55 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2012-07-26 17:19:55 +0200
commitbb229f729114bcd20b861e8b118fd6c805b96b73 (patch)
tree2f5e1eb5c78e16541dad903864cc5e78252a6ec9 /apps/files_encryption
parente5c84488ffd5031936825d42f9d81a222a53a40b (diff)
downloadnextcloud-server-bb229f729114bcd20b861e8b118fd6c805b96b73.tar.gz
nextcloud-server-bb229f729114bcd20b861e8b118fd6c805b96b73.zip
write private/public key from the client to the server
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/lib/keymanager.php31
1 files changed, 25 insertions, 6 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index f48047a692a..0bef3b74928 100644
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -73,8 +73,16 @@ class Keymanager {
* @return bool true/false
*/
public static function setPrivateKey($user, $key) {
- $view = new \OC_FilesystemView('/'.$user.'/files_encryption/');
- return $view->file_put_contents($user.'.private.key', $key);
+
+ \OC_FileProxy::$enabled = false;
+
+ $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;
}
@@ -86,8 +94,16 @@ class Keymanager {
* @return bool true/false
*/
public static function setPublicKey($user, $key) {
- $view = new \OC_FilesystemView('/public-keys/');
- return $view->file_put_contents($user.'.public.key', $key);
+
+ \OC_FileProxy::$enabled = false;
+
+ $view = new \OC_FilesystemView('/public-keys');
+ if (!$view->file_exists('')) $view->mkdir('');
+ $result = $view->file_put_contents($user.'.public.key', $key);
+
+ \OC_FileProxy::$enabled = true;
+
+ return $result;
}
/**
@@ -103,10 +119,13 @@ class Keymanager {
\OC_FileProxy::$enabled = false;
$view = new \OC_FilesystemView( '/' . $userId . '/' . 'files_encryption' );
-
- return $view->file_put_contents( '/' . $path . '.key', $key );
+ $path_parts = pathinfo($path);
+ if (!$view->file_exists($path_parts['dirname'])) $view->mkdir($path_parts['dirname']);
+ $result = $view->file_put_contents( '/' . $path . '.key', $key );
\OC_FileProxy::$enabled = true;
+
+ return $result;
}
} \ No newline at end of file