implement rename and delete of encryption keys

This commit is contained in:
Bjoern Schiessle 2015-03-26 09:24:28 +01:00 committed by Thomas Müller
parent 0c2f9ca849
commit 810ca9105c
2 changed files with 35 additions and 0 deletions

View 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
*

View 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;