summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-03-26 09:24:28 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:27 +0200
commit810ca9105ca7b25c98d7bc265dfb4c8e37b9b8e8 (patch)
tree0cf6f892dec69611a494c62097246b619d56d7d8 /lib
parent0c2f9ca849ef41232511cf576cc9a9de2caa43f0 (diff)
downloadnextcloud-server-810ca9105ca7b25c98d7bc265dfb4c8e37b9b8e8.tar.gz
nextcloud-server-810ca9105ca7b25c98d7bc265dfb4c8e37b9b8e8.zip
implement rename and delete of encryption keys
Diffstat (limited to 'lib')
-rw-r--r--lib/private/encryption/keys/storage.php34
-rw-r--r--lib/private/files/storage/wrapper/encryption.php1
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php
index 8f1822ca492..c8afcbbd213 100644
--- a/lib/private/encryption/keys/storage.php
+++ b/lib/private/encryption/keys/storage.php
@@ -162,6 +162,17 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
}
/**
+ * delete all file keys for a given file
+ *
+ * @param string $path to the file
+ * @return boolean
+ */
+ public function deleteAllFileKeys($path) {
+ $keyDir = $this->getFileKeyDir($path);
+ return $this->view->deleteAll(dirname($keyDir));
+ }
+
+ /**
* delete system-wide encryption keys not related to a specific user,
* e.g something like a key for public link shares
*
@@ -265,6 +276,29 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
}
/**
+ * move keys if a file was renamed
+ *
+ * @param string $source
+ * @param string $target
+ * @param string $owner
+ * @param bool $systemWide
+ */
+ public function renameKeys($source, $target, $owner, $systemWide) {
+ if ($systemWide) {
+ $sourcePath = $this->keys_base_dir . $source . '/';
+ $targetPath = $this->keys_base_dir . $target . '/';
+ } else {
+ $sourcePath = '/' . $owner . $this->keys_base_dir . $source . '/';
+ $targetPath = '/' . $owner . $this->keys_base_dir . $target . '/';
+ }
+
+ if ($this->view->file_exists($sourcePath)) {
+ $this->keySetPreparation(dirname($targetPath));
+ $this->view->rename($sourcePath, $targetPath);
+ }
+ }
+
+ /**
* Make preparations to filesystem for saving a keyfile
*
* @param string $path relative to the views root
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index 0e70c99c8d7..2a5b9926f68 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -62,6 +62,7 @@ class Encryption extends Wrapper {
$this->mountPoint = $parameters['mountPoint'];
$this->encryptionManager = $encryptionManager;
+ $this->keyStorage = $keyStorage;
$this->util = $util;
$this->logger = $logger;
$this->uid = $uid;