]> source.dussan.org Git - nextcloud-server.git/commitdiff
add helper class accessible for encryption modules to ask for a list of users with...
authorBjoern Schiessle <schiessle@owncloud.com>
Tue, 31 Mar 2015 14:23:31 +0000 (16:23 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 7 Apr 2015 11:30:29 +0000 (13:30 +0200)
16 files changed:
apps/encryption/appinfo/application.php
apps/encryption/appinfo/routes.php
apps/encryption/controller/recoverycontroller.php
apps/encryption/js/settings-personal.js
apps/encryption/lib/recovery.php
apps/encryption/settings/settings-personal.php
apps/encryption/templates/settings-personal.php
lib/base.php
lib/private/encryption/file.php [new file with mode: 0644]
lib/private/encryption/update.php
lib/private/encryption/util.php
lib/private/files/stream/encryption.php
lib/private/server.php
lib/public/encryption/ifile.php [new file with mode: 0644]
lib/public/encryption/imanager.php
lib/public/iservercontainer.php

index e8f10798bb479ff7fa9f5649a81f192cf8a31f14..372d49e5ef7c8efbd7877a6b641b76f7f111dfd1 100644 (file)
@@ -139,7 +139,9 @@ class Application extends \OCP\AppFramework\App {
                                        $server->getSecureRandom(),
                                        $c->query('KeyManager'),
                                        $server->getConfig(),
-                                       $server->getEncryptionKeyStorage(\OCA\Encryption\Crypto\Encryption::ID));
+                                       $server->getEncryptionKeyStorage(\OCA\Encryption\Crypto\Encryption::ID),
+                                       $server->getEncryptionFilesHelper(),
+                                       new \OC\Files\View());
                        });
 
                        $container->registerService('RecoveryController', function (IAppContainer $c) {
index 030e7617816856c047da032f8d48aefe27b6ea34..1a6cf18fbed9dba7b699afadd47fa1308b42f3e5 100644 (file)
@@ -38,6 +38,11 @@ namespace OCA\Encryption\AppInfo;
                'name' => 'Recovery#changeRecoveryPassword',
                'url' => '/ajax/changeRecoveryPassword',
                'verb' => 'POST'
+       ],
+               [
+               'name' => 'Recovery#userSetRecovery',
+               'url' => '/ajax/userSetRecovery',
+               'verb' => 'POST'
        ]
 
 
index e7bfd37490387690ac7de7d52c6cb39ac17aa544..d115feb8e39ceaccca0b866e6f417eb6068d7a22 100644 (file)
@@ -61,61 +61,72 @@ class RecoveryController extends Controller {
        public function adminRecovery($recoveryPassword, $confirmPassword, $adminEnableRecovery) {
                // Check if both passwords are the same
                if (empty($recoveryPassword)) {
-                       $errorMessage = $this->l->t('Missing recovery key password');
+                       $errorMessage = (string) $this->l->t('Missing recovery key password');
                        return new DataResponse(['data' => ['message' => $errorMessage]], 500);
                }
 
                if (empty($confirmPassword)) {
-                       $errorMessage = $this->l->t('Please repeat the recovery key password');
+                       $errorMessage = (string) $this->l->t('Please repeat the recovery key password');
                        return new DataResponse(['data' => ['message' => $errorMessage]], 500);
                }
 
                if ($recoveryPassword !== $confirmPassword) {
-                       $errorMessage = $this->l->t('Repeated recovery key password does not match the provided recovery key password');
+                       $errorMessage = (string) $this->l->t('Repeated recovery key password does not match the provided recovery key password');
                        return new DataResponse(['data' => ['message' => $errorMessage]], 500);
                }
 
                if (isset($adminEnableRecovery) && $adminEnableRecovery === '1') {
                        if ($this->recovery->enableAdminRecovery($recoveryPassword)) {
-                               return new DataResponse(['status'       =>'success', 'data' => array('message' => $this->l->t('Recovery key successfully enabled'))]);
+                               return new DataResponse(['status'       =>'success', 'data' => array('message' => (string) $this->l->t('Recovery key successfully enabled'))]);
                        }
-                       return new DataResponse(['data' => array('message' => $this->l->t('Could not enable recovery key. Please check your recovery key password!'))]);
+                       return new DataResponse(['data' => array('message' => (string) $this->l->t('Could not enable recovery key. Please check your recovery key password!'))]);
                } elseif (isset($adminEnableRecovery) && $adminEnableRecovery === '0') {
                        if ($this->recovery->disableAdminRecovery($recoveryPassword)) {
-                               return new DataResponse(['data' => array('message' => $this->l->t('Recovery key successfully disabled'))]);
+                               return new DataResponse(['data' => array('message' => (string) $this->l->t('Recovery key successfully disabled'))]);
                        }
-                       return new DataResponse(['data' => array('message' => $this->l->t('Could not disable recovery key. Please check your recovery key password!'))]);
+                       return new DataResponse(['data' => array('message' => (string) $this->l->t('Could not disable recovery key. Please check your recovery key password!'))]);
                }
        }
 
        public function changeRecoveryPassword($newPassword, $oldPassword, $confirmPassword) {
                //check if both passwords are the same
                if (empty($oldPassword)) {
-                       $errorMessage = $this->l->t('Please provide the old recovery password');
+                       $errorMessage = (string) $this->l->t('Please provide the old recovery password');
                        return new DataResponse(array('data' => array('message' => $errorMessage)));
                }
 
                if (empty($newPassword)) {
-                       $errorMessage = $this->l->t('Please provide a new recovery password');
+                       $errorMessage = (string) $this->l->t('Please provide a new recovery password');
                        return new DataResponse (array('data' => array('message' => $errorMessage)));
                }
 
                if (empty($confirmPassword)) {
-                       $errorMessage = $this->l->t('Please repeat the new recovery password');
+                       $errorMessage = (string) $this->l->t('Please repeat the new recovery password');
                        return new DataResponse(array('data' => array('message' => $errorMessage)));
                }
 
                if ($newPassword !== $confirmPassword) {
-                       $errorMessage = $this->l->t('Repeated recovery key password does not match the provided recovery key password');
+                       $errorMessage = (string) $this->l->t('Repeated recovery key password does not match the provided recovery key password');
                        return new DataResponse(array('data' => array('message' => $errorMessage)));
                }
 
                $result = $this->recovery->changeRecoveryKeyPassword($newPassword, $oldPassword);
 
                if ($result) {
-                       return new DataResponse(array('status' => 'success' ,'data' => array('message' => $this->l->t('Password successfully changed.'))));
+                       return new DataResponse(
+                               array(
+                                       'status' => 'success' ,
+                                       'data' => array(
+                                               'message' => (string) $this->l->t('Password successfully changed.'))
+                                       )
+                               );
                } else {
-                       return new DataResponse(array('data' => array('message' => $this->l->t('Could not change the password. Maybe the old password was not correct.'))));
+                       return new DataResponse(
+                               array(
+                                       'data' => array
+                                               ('message' => (string) $this->l->t('Could not change the password. Maybe the old password was not correct.'))
+                                       )
+                               );
                }
        }
 
@@ -131,4 +142,28 @@ class RecoveryController extends Controller {
                }
        }
 
+       public function userSetRecovery($userEnableRecovery) {
+               if ($userEnableRecovery === '0' || $userEnableRecovery === '1') {
+
+                       $result = $this->recovery->setRecoveryForUser($userEnableRecovery);
+
+                       if ($result) {
+                               return new DataResponse(
+                                       array(
+                                       'status' => 'success',
+                                       'data' => array(
+                                               'message' => (string) $this->l->t('Recovery Key enabled'))
+                                       )
+                               );
+                       } else {
+                               return new DataResponse(
+                                       array(
+                                       'data' => array
+                                               ('message' => (string) $this->l->t('Could not enable the recovery key, please try again or contact your administrator'))
+                                       )
+                               );
+                       }
+               }
+       }
+
 }
index b798ba7e4e16727f405f875b9419cd51d4a0c106..7f0f4c6c26d9dc7abf386af2596873440e72b07b 100644 (file)
@@ -29,7 +29,7 @@ $(document).ready(function(){
                        var recoveryStatus = $( this ).val();
                        OC.msg.startAction('#userEnableRecovery .msg', 'Updating recovery keys. This can take some time...');
                        $.post(
-                               OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
+                                       OC.generateUrl('/apps/encryption/ajax/userSetRecovery')
                                , { userEnableRecovery: recoveryStatus }
                                ,  function( data ) {
                                        OC.msg.finishedAction('#userEnableRecovery .msg', data);
@@ -40,33 +40,6 @@ $(document).ready(function(){
                }
        );
 
-       $("#encryptAll").click(
-               function(){
-
-                       // Hide feedback messages in case they're already visible
-                       $('#encryptAllSuccess').hide();
-                       $('#encryptAllError').hide();
-
-                       var userPassword = $( '#userPassword' ).val();
-                       var encryptAll = $( '#encryptAll' ).val();
-
-                       $.post(
-                               OC.filePath( 'files_encryption', 'ajax', 'encryptall.php' )
-                               , { encryptAll: encryptAll, userPassword: userPassword }
-                               ,  function( data ) {
-                                       if ( data.status == "success" ) {
-                                               $('#encryptAllSuccess').show();
-                                       } else {
-                                               $('#encryptAllError').show();
-                                       }
-                               }
-                       );
-                       // Ensure page is not reloaded on form submit
-                       return false;
-               }
-
-       );
-
        // update private key password
 
        $('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
index 0426c3746eda6dc748f276294f6484a53a7f95b8..701c0934c950f2843c9263598a6ed035a6009880 100644 (file)
@@ -29,7 +29,8 @@ use OCP\IUser;
 use OCP\IUserSession;
 use OCP\PreConditionNotMetException;
 use OCP\Security\ISecureRandom;
-use OCP\Share;
+use OC\Files\View;
+use OCP\Encryption\IFile;
 
 class Recovery {
 
@@ -58,7 +59,17 @@ class Recovery {
         * @var IStorage
         */
        private $keyStorage;
-
+       /**
+        * @var View
+        */
+       private $view;
+       /**
+        * @var IFile
+        */
+       private $file;
+       /**
+        * @var string
+        */
        private $recoveryKeyId;
 
        /**
@@ -68,19 +79,25 @@ class Recovery {
         * @param KeyManager $keyManager
         * @param IConfig $config
         * @param IStorage $keyStorage
+        * @param IFile $file
+        * @param View $view
         */
        public function __construct(IUserSession $user,
                                                                Crypt $crypt,
                                                                ISecureRandom $random,
                                                                KeyManager $keyManager,
                                                                IConfig $config,
-                                                               IStorage $keyStorage) {
+                                                               IStorage $keyStorage,
+                                                               IFile $file,
+                                                               View $view) {
                $this->user = $user && $user->isLoggedIn() ? $user->getUser() : false;
                $this->crypt = $crypt;
                $this->random = $random;
                $this->keyManager = $keyManager;
                $this->config = $config;
                $this->keyStorage = $keyStorage;
+               $this->view = $view;
+               $this->file = $file;
        }
 
        /**
@@ -138,14 +155,6 @@ class Recovery {
                return false;
        }
 
-       public function addRecoveryKeys($keyId) {
-               // No idea new way to do this....
-       }
-
-       public function removeRecoveryKeys() {
-               // No idea new way to do this....
-       }
-
        /**
         * @return bool
         */
@@ -159,23 +168,73 @@ class Recovery {
        }
 
        /**
-        * @param $enabled
+        * @param string $value
         * @return bool
         */
-       public function setRecoveryForUser($enabled) {
-               $value = $enabled ? '1' : '0';
+       public function setRecoveryForUser($value) {
 
                try {
                        $this->config->setUserValue($this->user->getUID(),
                                'encryption',
                                'recoveryEnabled',
                                $value);
+
+                       if ($value === '1') {
+                               $this->addRecoveryKeys('/' . $this->user . '/files/');
+                       } else {
+                               $this->removeRecoveryKeys();
+                       }
+
                        return true;
                } catch (PreConditionNotMetException $e) {
                        return false;
                }
        }
 
+       /**
+        * add recovery key to all encrypted files
+        */
+       private function addRecoveryKeys($path = '/') {
+               $dirContent = $this->view->getDirectoryContent($path);
+               foreach ($dirContent as $item) {
+                       // get relative path from files_encryption/keyfiles/
+                       $filePath = $item['path'];
+                       if ($item['type'] === 'dir') {
+                               $this->addRecoveryKeys($filePath . '/');
+                       } else {
+                               $fileKey = $this->keyManager->getFileKey($filePath, $this->user);
+                               if (!empty($fileKey)) {
+                                       $accessList = $this->file->getAccessList($path);
+                                       $publicKeys = array();
+                                       foreach ($accessList['users'] as $uid) {
+                                               $publicKeys[$uid] = $this->keymanager->getPublicKey($uid);
+                                       }
+
+                                       $encryptedKeyfiles = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys);
+                                       $this->keymanager->setAllFileKeys($path, $encryptedKeyfiles);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * remove recovery key to all encrypted files
+        */
+       private function removeRecoveryKeys($path = '/') {
+               $dirContent = $this->view->getDirectoryContent($this->keyfilesPath . $path);
+               foreach ($dirContent as $item) {
+                       // get relative path from files_encryption/keyfiles
+                       $filePath = substr($item['path'], strlen('files_encryption/keyfiles'));
+                       if ($item['type'] === 'dir') {
+                               $this->removeRecoveryKeys($filePath . '/');
+                       } else {
+                               // remove '.key' extension from path e.g. 'file.txt.key' to 'file.txt'
+                               $file = substr($filePath, 0, -4);
+                               $this->view->unlink($this->shareKeysPath . '/' . $file . '.' . $this->recoveryKeyId . '.shareKey');
+                       }
+               }
+       }
+
        /**
         * @param $recoveryPassword
         */
index a4173dbd40f1837e43b031e58889bbdfae6675b4..8caacbd19ca49320dfa0f73af24e6c8665d5fdeb 100644 (file)
@@ -29,7 +29,11 @@ $user = \OCP\User::getUser();
 $view = new \OC\Files\View('/');
 
 $util = new \OCA\Encryption\Util(
-       new \OC\Files\View(), $crypt, $keymanager, \OC::$server->getLogger(), \OC::$server->getUserSession(), \OC::$server->getConfig());
+       new \OC\Files\View(),
+       $crypt, $keymanager,
+       \OC::$server->getLogger(),
+       \OC::$server->getUserSession(),
+       \OC::$server->getConfig());
 
 $privateKeySet = $session->isPrivateKeySet();
 // did we tried to initialize the keys for this session?
index cefd6f4ad5c0fea50daa439a2f7e51cc505576e4..6b8821ca8a8770b837ea2200cf606e2686739f27 100644 (file)
@@ -1,6 +1,8 @@
 <?php
        /** @var array $_ */
        /** @var OC_L10N $l */
+script('encryption', 'settings-personal');
+script('core', 'multiselect');
 ?>
 <form id="encryption" class="section">
        <h2><?php p($l->t('ownCloud basic encryption module')); ?></h2>
index a5ca08123ac71258508e8e64c6de8cc7f1e678cc..1d536464153860654727f9f1846d9fe81bf0d0a1 100644 (file)
@@ -723,6 +723,7 @@ class OC {
                                        \OC::$server->getConfig()),
                                \OC\Files\Filesystem::getMountManager(),
                                \OC::$server->getEncryptionManager(),
+                               \OC::$server->getEncryptionFilesHelper(),
                                $uid
                        );
                        \OCP\Util::connectHook('OCP\Share', 'post_shared', $updater, 'postShared');
diff --git a/lib/private/encryption/file.php b/lib/private/encryption/file.php
new file mode 100644 (file)
index 0000000..f231500
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * ownCloud
+ *
+ * @copyright (C) 2015 ownCloud, Inc.
+ *
+ * @author Bjoern Schiessle <schiessle@owncloud.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace OC\Encryption;
+
+use OC\Encryption\Util;
+
+class File implements \OCP\Encryption\IFile {
+
+       /** @var Util */
+       protected $util;
+
+       public function __construct(Util $util) {
+               $this->util = $util;
+       }
+
+
+       /**
+        * get list of users with access to the file
+        *
+        * @param $path to the file
+        * @return array
+        */
+       public function getAccessList($path) {
+
+               // Make sure that a share key is generated for the owner too
+               list($owner, $ownerPath) = $this->util->getUidAndFilename($path);
+
+               // always add owner to the list of users with access to the file
+               $userIds = array($owner);
+
+               if (!$this->util->isFile($ownerPath)) {
+                       return array('users' => $userIds, 'public' => false);
+               }
+
+               $ownerPath = substr($ownerPath, strlen('/files'));
+               $ownerPath = $this->util->stripPartialFileExtension($ownerPath);
+
+               // Find out who, if anyone, is sharing the file
+               $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner);
+               $userIds = \array_merge($userIds, $result['users']);
+               $public = $result['public'] || $result['remote'];
+
+               // check if it is a group mount
+               if (\OCP\App::isEnabled("files_external")) {
+                       $mounts = \OC_Mount_Config::getSystemMountPoints();
+                       foreach ($mounts as $mount) {
+                               if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) {
+                                       $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']);
+                                       $userIds = array_merge($userIds, $mountedFor);
+                               }
+                       }
+               }
+
+               // Remove duplicate UIDs
+               $uniqueUserIds = array_unique($userIds);
+
+               return array('users' => $uniqueUserIds, 'public' => $public);
+       }
+
+}
\ No newline at end of file
index 06dc330151e7297aa0b5c6333f9778e5e14462c7..21cedde6140e8161aa35f332aa80bbef338a472c 100644 (file)
@@ -46,12 +46,16 @@ class Update {
        /** @var string */
        protected $uid;
 
+       /** @var \OC\Encryption\File */
+       protected $file;
+
        /**
         *
         * @param \OC\Files\View $view
         * @param \OC\Encryption\Util $util
         * @param \OC\Files\Mount\Manager $mountManager
         * @param \OC\Encryption\Manager $encryptionManager
+        * @param \OC\Encryption\File $file
         * @param string $uid
         */
        public function __construct(
@@ -59,6 +63,7 @@ class Update {
                        Util $util,
                        Mount\Manager $mountManager,
                        Manager $encryptionManager,
+                       File $file,
                        $uid
                ) {
 
@@ -66,6 +71,7 @@ class Update {
                $this->util = $util;
                $this->mountManager = $mountManager;
                $this->encryptionManager = $encryptionManager;
+               $this->file = $file;
                $this->uid = $uid;
        }
 
@@ -103,7 +109,7 @@ class Update {
                        $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule();
 
                        foreach ($allFiles as $path) {
-                               $usersSharing = $this->util->getSharingUsersArray($path);
+                               $usersSharing = $this->file->getAccessList($path);
                                $encryptionModule->update($absPath, $this->uid, $usersSharing);
                        }
        }
index 1308d27c924b1b09a1e306062d04420d812c71be..734da741fdd69f2abee3b4ea04bca65ea9b6dd6a 100644 (file)
@@ -162,49 +162,6 @@ class Util {
                return $paddedHeader;
        }
 
-       /**
-        * Find, sanitise and format users sharing a file
-        * @note This wraps other methods into a portable bundle
-        * @param string $path path relative to current users files folder
-        * @return array
-        */
-       public function getSharingUsersArray($path) {
-
-               // Make sure that a share key is generated for the owner too
-               list($owner, $ownerPath) = $this->getUidAndFilename($path);
-
-               // always add owner to the list of users with access to the file
-               $userIds = array($owner);
-
-               if (!$this->isFile($ownerPath)) {
-                       return array('users' => $userIds, 'public' => false);
-               }
-
-               $ownerPath = substr($ownerPath, strlen('/files'));
-               $ownerPath = $this->stripPartialFileExtension($ownerPath);
-
-               // Find out who, if anyone, is sharing the file
-               $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner);
-               $userIds = \array_merge($userIds, $result['users']);
-               $public = $result['public'] || $result['remote'];
-
-               // check if it is a group mount
-               if (\OCP\App::isEnabled("files_external")) {
-                       $mounts = \OC_Mount_Config::getSystemMountPoints();
-                       foreach ($mounts as $mount) {
-                               if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) {
-                                       $mountedFor = $this->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']);
-                                       $userIds = array_merge($userIds, $mountedFor);
-                               }
-                       }
-               }
-
-               // Remove duplicate UIDs
-               $uniqueUserIds = array_unique($userIds);
-
-               return array('users' => $uniqueUserIds, 'public' => $public);
-       }
-
        /**
         * go recursively through a dir and collect all files and sub files.
         *
@@ -243,7 +200,7 @@ class Util {
         * @param string $path
         * @return boolean
         */
-       protected function isFile($path) {
+       public function isFile($path) {
                if (substr($path, 0, strlen('/files/')) === '/files/') {
                        return true;
                }
@@ -361,7 +318,7 @@ class Util {
                }
        }
 
-       protected function getUserWithAccessToMountPoint($users, $groups) {
+       public function getUserWithAccessToMountPoint($users, $groups) {
                $result = array();
                if (in_array('all', $users)) {
                        $result = \OCP\User::getUsers();
index e3927edff2c96df950e2eec25f72b1057ec3f74b..a96d573723c66b85ebdc173c84693121b6a0c6e6 100644 (file)
@@ -31,6 +31,9 @@ class Encryption extends Wrapper {
        /** @var \OC\Encryption\Util */
        protected $util;
 
+       /** @var \OC\Encryption\File */
+       protected $file;
+
        /** @var \OCP\Encryption\IEncryptionModule */
        protected $encryptionModule;
 
@@ -97,6 +100,7 @@ class Encryption extends Wrapper {
                        'encryptionModule',
                        'header',
                        'uid',
+                       'file',
                        'util',
                        'size',
                        'unencryptedSize',
@@ -117,6 +121,7 @@ class Encryption extends Wrapper {
         * @param \OC\Files\Storage\Storage $storage
         * @param \OC\Files\Storage\Wrapper\Encryption $encStorage
         * @param \OC\Encryption\Util $util
+        * @param \OC\Encryption\File $file
         * @param string $mode
         * @param int $size
         * @param int $unencryptedSize
@@ -130,6 +135,7 @@ class Encryption extends Wrapper {
                                                                \OC\Files\Storage\Storage $storage,
                                                                \OC\Files\Storage\Wrapper\Encryption $encStorage,
                                                                \OC\Encryption\Util $util,
+                                                                \OC\Encryption\File $file,
                                                                $mode,
                                                                $size,
                                                                $unencryptedSize) {
@@ -144,6 +150,7 @@ class Encryption extends Wrapper {
                                'header' => $header,
                                'uid' => $uid,
                                'util' => $util,
+                               'file' => $file,
                                'size' => $size,
                                'unencryptedSize' => $unencryptedSize,
                                'encryptionStorage' => $encStorage
@@ -229,7 +236,7 @@ class Encryption extends Wrapper {
                        $sharePath = dirname($path);
                }
 
-               $accessList = $this->util->getSharingUsersArray($sharePath);
+               $accessList = $this->file->getAccessList($sharePath);
                $this->newHeader = $this->encryptionModule->begin($this->fullPath, $this->uid, $this->header, $accessList);
 
                return true;
index a38096cf740b8e2483e6e92c6b708528588dec54..661aaf6786db908eaa7cb59bf4000b15e25dec27 100644 (file)
@@ -87,6 +87,11 @@ class Server extends SimpleContainer implements IServerContainer {
                        return new Encryption\Manager($c->getConfig());
                });
 
+               $this->registerService('EncryptionFileHelper', function (Server $c) {
+                       $util = new \OC\Encryption\Util(new \OC\Files\View(), $c->getUserManager(), $c->getConfig());
+                       return new Encryption\File($util);
+               });
+
                $this->registerService('EncryptionKeyStorageFactory', function ($c) {
                        return new Encryption\Keys\Factory();
                });
@@ -407,6 +412,13 @@ class Server extends SimpleContainer implements IServerContainer {
                return $this->query('EncryptionManager');
        }
 
+       /**
+        * @return \OC\Encryption\File
+        */
+       function getEncryptionFilesHelper() {
+               return $this->query('EncryptionFileHelper');
+       }
+
        /**
         * @param string $encryptionModuleId encryption module ID
         *
diff --git a/lib/public/encryption/ifile.php b/lib/public/encryption/ifile.php
new file mode 100644 (file)
index 0000000..cb4faea
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * ownCloud
+ *
+ * @copyright (C) 2015 ownCloud, Inc.
+ *
+ * @author Bjoern Schiessle <schiessle@owncloud.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace OCP\Encryption;
+
+interface IFile {
+
+       /**
+        * get list of users with access to the file
+        *
+        * @param $path to the file
+        * @return array
+        */
+       public function getAccessList($path);
+
+}
\ No newline at end of file
index 9a12e4015935929007ed432951e7b82482f32993..2691604ac37012ea220f4bb535d86ccfbd08857d 100644 (file)
@@ -22,9 +22,7 @@
  */
 
 namespace OCP\Encryption;
-//
-// TODO: move exceptions to OCP
-//
+
 use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
 use OC\Encryption\Exceptions\ModuleAlreadyExistsException;
 
index 9e36bc31beda9b4ebc20cf161d9f909b83591344..509e5894d47d645b68745e711767617d12d57188 100644 (file)
@@ -183,6 +183,11 @@ interface IServerContainer {
         */
        function getEncryptionManager();
 
+       /**
+        * @return \OC\Encryption\File
+        */
+       function getEncryptionFilesHelper();
+
        /**
         * @param string $encryptionModuleId encryption module ID
         *