summaryrefslogtreecommitdiffstats
path: root/lib/base.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-26 21:14:59 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-26 21:14:59 +0100
commit232518ac548a1d8f99c51fe391eb6132c1154dba (patch)
treedcf369f169b600028bdb2d55d577fc7ffe781b32 /lib/base.php
parent0cb133003ced4e3d2486b6301459ea0e998ef2ec (diff)
parentff9c85ce60aac1098c741b7ea630d9fc545e3d96 (diff)
downloadnextcloud-server-232518ac548a1d8f99c51fe391eb6132c1154dba.tar.gz
nextcloud-server-232518ac548a1d8f99c51fe391eb6132c1154dba.zip
Merge pull request #15234 from owncloud/encryption2_core
core part of encryption 2.0
Diffstat (limited to 'lib/base.php')
-rw-r--r--lib/base.php45
1 files changed, 43 insertions, 2 deletions
diff --git a/lib/base.php b/lib/base.php
index 66dd4f20f04..b441d5f1927 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -178,7 +178,7 @@ class OC {
// search the 3rdparty folder
OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', null);
OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', null);
-
+
if (empty(OC::$THIRDPARTYROOT) && empty(OC::$THIRDPARTYWEBROOT)) {
if (file_exists(OC::$SERVERROOT . '/3rdparty')) {
OC::$THIRDPARTYROOT = OC::$SERVERROOT;
@@ -193,7 +193,7 @@ class OC {
. ' folder in the ownCloud folder or the folder above.'
. ' You can also configure the location in the config.php file.');
}
-
+
// search the apps folder
$config_paths = OC_Config::getValue('apps_paths', array());
if (!empty($config_paths)) {
@@ -642,6 +642,8 @@ class OC {
self::registerShareHooks();
self::registerLogRotate();
self::registerLocalAddressBook();
+ self::registerEncryptionWrapper();
+ self::registerEncryptionHooks();
//make sure temporary files are cleaned up
$tmpManager = \OC::$server->getTempManager();
@@ -698,6 +700,45 @@ class OC {
});
}
+ private static function registerEncryptionWrapper() {
+ $enabled = self::$server->getEncryptionManager()->isEnabled();
+ if ($enabled) {
+ \OC\Files\Filesystem::addStorageWrapper('oc_encryption', function ($mountPoint, $storage) {
+ $parameters = array('storage' => $storage, 'mountPoint' => $mountPoint);
+ $manager = \OC::$server->getEncryptionManager();
+ $util = new \OC\Encryption\Util(new \OC\Files\View(), \OC::$server->getUserManager());
+ $user = \OC::$server->getUserSession()->getUser();
+ $logger = \OC::$server->getLogger();
+ $uid = $user ? $user->getUID() : null;
+ return new \OC\Files\Storage\Wrapper\Encryption($parameters, $manager,$util, $logger, $uid);
+ });
+ }
+
+ }
+
+ private static function registerEncryptionHooks() {
+ $enabled = self::$server->getEncryptionManager()->isEnabled();
+ if ($enabled) {
+ $user = \OC::$server->getUserSession()->getUser();
+ $uid = '';
+ if ($user) {
+ $uid = $user->getUID();
+ }
+ $updater = new \OC\Encryption\Update(
+ new \OC\Files\View(),
+ new \OC\Encryption\Util(new \OC\Files\View(), \OC::$server->getUserManager()),
+ \OC\Files\Filesystem::getMountManager(),
+ \OC::$server->getEncryptionManager(),
+ $uid
+ );
+ \OCP\Util::connectHook('OCP\Share', 'post_shared', $updater, 'postShared');
+ \OCP\Util::connectHook('OCP\Share', 'post_unshare', $updater, 'postUnshared');
+
+ //\OCP\Util::connectHook('OC_Filesystem', 'post_umount', 'OCA\Files_Encryption\Hooks', 'postUnmount');
+ //\OCP\Util::connectHook('OC_Filesystem', 'umount', 'OCA\Files_Encryption\Hooks', 'preUnmount');
+ }
+ }
+
/**
* register hooks for the cache
*/