]> source.dussan.org Git - nextcloud-server.git/commitdiff
implement rename and delete of encryption keys
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 26 Mar 2015 08:24:28 +0000 (09:24 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 7 Apr 2015 11:30:27 +0000 (13:30 +0200)
lib/private/encryption/keys/storage.php
lib/private/files/storage/wrapper/encryption.php

index 8f1822ca4922340f24aa1393ddfd4daf88182736..c8afcbbd213235c67245d2497a4b7a61742aef0d 100644 (file)
@@ -161,6 +161,17 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
                return $this->view->unlink($keyDir . $keyId);
        }
 
+       /**
+        * 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
@@ -264,6 +275,29 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
                return \OC\Files\Filesystem::normalizePath($keyPath . $this->encryptionModuleId . '/', false);
        }
 
+       /**
+        * 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
         *
index 0e70c99c8d73d3649357e87297c3578e7b4df981..2a5b9926f68f88cd07813efb9cfa3fab507af170 100644 (file)
@@ -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;