summaryrefslogtreecommitdiffstats
path: root/lib/private/encryption/util.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-06-02 12:27:30 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-06-02 12:29:06 +0200
commit9a4040c7ca2c0e4fc3f213ba3f6144e80f687754 (patch)
tree9fc19fd59b76d251b932f1001549219cc2761bda /lib/private/encryption/util.php
parentd2f3710ede1fa72658a4c12264a90a1936faf9ca (diff)
downloadnextcloud-server-9a4040c7ca2c0e4fc3f213ba3f6144e80f687754.tar.gz
nextcloud-server-9a4040c7ca2c0e4fc3f213ba3f6144e80f687754.zip
Move the storage wrapping into a testable method
Diffstat (limited to 'lib/private/encryption/util.php')
-rw-r--r--lib/private/encryption/util.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/private/encryption/util.php b/lib/private/encryption/util.php
index b77672d2f6b..d233b715f88 100644
--- a/lib/private/encryption/util.php
+++ b/lib/private/encryption/util.php
@@ -26,8 +26,12 @@ use OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException;
use OC\Encryption\Exceptions\EncryptionHeaderToLargeException;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\Files\Filesystem;
+use OC\Files\Storage\Shared;
+use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
use OCP\Encryption\IEncryptionModule;
+use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Storage;
use OCP\IConfig;
class Util {
@@ -386,4 +390,49 @@ class Util {
return ($enabled === '1') ? true : false;
}
+ /**
+ * Wraps the given storage when it is not a shared storage
+ *
+ * @param string $mountPoint
+ * @param Storage $storage
+ * @param IMountPoint $mount
+ * @return Encryption|Storage
+ */
+ public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount) {
+ $parameters = [
+ 'storage' => $storage,
+ 'mountPoint' => $mountPoint,
+ 'mount' => $mount];
+
+ if (!($storage instanceof Shared)) {
+ $manager = \OC::$server->getEncryptionManager();
+ $user = \OC::$server->getUserSession()->getUser();
+ $logger = \OC::$server->getLogger();
+ $mountManager = Filesystem::getMountManager();
+ $uid = $user ? $user->getUID() : null;
+ $fileHelper = \OC::$server->getEncryptionFilesHelper();
+ $keyStorage = \OC::$server->getEncryptionKeyStorage();
+ $update = new Update(
+ new View(),
+ $this,
+ Filesystem::getMountManager(),
+ $manager,
+ $fileHelper,
+ $uid
+ );
+ return new Encryption(
+ $parameters,
+ $manager,
+ $this,
+ $logger,
+ $fileHelper,
+ $uid,
+ $keyStorage,
+ $update,
+ $mountManager
+ );
+ } else {
+ return $storage;
+ }
+ }
}