diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-03-26 09:24:28 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:27 +0200 |
commit | 810ca9105ca7b25c98d7bc265dfb4c8e37b9b8e8 (patch) | |
tree | 0cf6f892dec69611a494c62097246b619d56d7d8 /lib | |
parent | 0c2f9ca849ef41232511cf576cc9a9de2caa43f0 (diff) | |
download | nextcloud-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.php | 34 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 1 |
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; |