Example #1
0
function enableApp($app) {
	try {
		OC_App::enable($app);
	} catch (Exception $e) {
		echo $e;
	}
}
Example #2
0
 function tearDown()
 {
     // reset app files_encryption
     if ($this->stateFilesEncryption) {
         \OC_App::enable('files_encryption');
     } else {
         \OC_App::disable('files_encryption');
     }
 }
Example #3
0
 function tearDown()
 {
     // reset app files_trashbin
     if ($this->stateFilesTrashbin) {
         OC_App::enable('files_trashbin');
     } else {
         OC_App::disable('files_trashbin');
     }
 }
Example #4
0
 protected function tearDown()
 {
     // reset app files_trashbin
     if ($this->stateFilesTrashbin) {
         \OC_App::enable('files_trashbin');
     } else {
         \OC_App::disable('files_trashbin');
     }
     parent::tearDown();
 }
Example #5
0
 public static function tearDownAfterClass()
 {
     \OC_FileProxy::$enabled = true;
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER);
     // reset app files_trashbin
     if (self::$stateFilesTrashbin) {
         OC_App::enable('files_trashbin');
     }
 }
Example #6
0
 function tearDown()
 {
     // reset app files_trashbin
     if ($this->stateFilesTrashbin) {
         OC_App::enable('files_trashbin');
     } else {
         OC_App::disable('files_trashbin');
     }
     $this->assertTrue(\OC_FileProxy::$enabled);
 }
Example #7
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
     if (self::$encryptionStatus === true) {
         \OC_App::enable('files_encryption');
     }
     \OC_Config::setValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
     \OC_Config::setValue('trashbin_auto_expire', self::$rememberAutoExpire);
     \OC_Hook::clear();
 }
Example #8
0
 function tearDown()
 {
     // reset app files_trashbin
     if ($this->stateFilesTrashbin) {
         OC_App::enable('files_trashbin');
     } else {
         OC_App::disable('files_trashbin');
     }
     $this->assertTrue(\OC_FileProxy::$enabled);
     \OCP\Config::deleteSystemValue('cipher');
 }
Example #9
0
 protected function tearDown()
 {
     // reset app files_trashbin
     if ($this->stateFilesTrashbin) {
         \OC_App::enable('files_trashbin');
     } else {
         \OC_App::disable('files_trashbin');
     }
     $this->assertTrue(\OC_FileProxy::$enabled);
     $this->config->deleteSystemValue('cipher');
     parent::tearDown();
 }
 public function setUp()
 {
     parent::setUp();
     \OC_App::enable('files_antivirus');
     $this->db = \OC::$server->getDb();
     $this->application = new Application();
     $this->container = $this->application->getContainer();
     $this->config = $this->getMockBuilder('\\OCA\\Files_Antivirus\\AppConfig')->disableOriginalConstructor()->getMock();
     $this->config->method('__call')->will($this->returnCallback(array($this, 'getAppValue')));
     $this->l10n = $this->getMockBuilder('\\OC_L10N')->disableOriginalConstructor()->getMock();
     $this->l10n->method('t')->will($this->returnArgument(0));
 }
Example #11
0
 public function tearDown()
 {
     if ($this->cache) {
         $this->cache->clear();
     }
     $result = \OC_User::deleteUser(self::$user);
     $this->assertTrue($result);
     Filesystem::tearDown();
     // reset app files_encryption
     if ($this->stateFilesEncryption) {
         \OC_App::enable('files_encryption');
     }
 }
Example #12
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if (\OC_App::isEnabled($appId)) {
         $output->writeln($appId . ' is already enabled');
     } else {
         if (!\OC_App::getAppPath($appId)) {
             $output->writeln($appId . ' not found');
         } else {
             \OC_App::enable($appId);
             $output->writeln($appId . ' enabled');
         }
     }
 }
 protected function tearDown()
 {
     if ($this->cache) {
         $this->cache->clear();
     }
     $result = \OC_User::deleteUser(self::$user);
     $this->assertTrue($result);
     Filesystem::tearDown();
     Filesystem::mount($this->originalStorage, array(), '/');
     // reset app files_encryption
     if ($this->stateFilesEncryption) {
         \OC_App::enable('files_encryption');
     }
     parent::tearDown();
 }
Example #14
0
 public static function tearDownAfterClass()
 {
     \OC_FileProxy::$enabled = true;
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER);
     // reset app files_trashbin
     if (self::$stateFilesTrashbin) {
         OC_App::enable('files_trashbin');
     }
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
Example #15
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if (!\OC_App::getAppPath($appId)) {
         $output->writeln($appId . ' not found');
         return 1;
     }
     $groups = $input->getOption('groups');
     if (empty($groups)) {
         \OC_App::enable($appId);
         $output->writeln($appId . ' enabled');
     } else {
         \OC_App::enable($appId, $groups);
         $output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups));
     }
     return 0;
 }
Example #16
0
 /**
  * test deletion of a folder which contains share mount points. Share mount
  * points should be unshared before the folder gets deleted so
  * that the mount point doesn't end up at the trash bin
  */
 function testDeleteParentFolder()
 {
     $status = \OC_App::isEnabled('files_trashbin');
     \OC_App::enable('files_trashbin');
     \OCA\Files_Trashbin\Trashbin::registerHooks();
     OC_FileProxy::register(new OCA\Files\Share\Proxy());
     $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
     $this->assertTrue($fileinfo instanceof \OC\Files\FileInfo);
     \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     // check if user2 can see the shared folder
     $this->assertTrue($view->file_exists($this->folder));
     $foldersShared = \OCP\Share::getItemsSharedWith('folder');
     $this->assertSame(1, count($foldersShared));
     $view->mkdir("localFolder");
     $view->file_put_contents("localFolder/localFile.txt", "local file");
     $view->rename($this->folder, 'localFolder/' . $this->folder);
     // share mount point should now be moved to the subfolder
     $this->assertFalse($view->file_exists($this->folder));
     $this->assertTrue($view->file_exists('localFolder/' . $this->folder));
     $view->unlink('localFolder');
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // shared folder should be unshared
     $foldersShared = \OCP\Share::getItemsSharedWith('folder');
     $this->assertTrue(empty($foldersShared));
     // trashbin should contain the local file but not the mount point
     $rootView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
     $trashContent = \OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_FILES_SHARING_API_USER2);
     $this->assertSame(1, count($trashContent));
     $firstElement = reset($trashContent);
     $timestamp = $firstElement['mtime'];
     $this->assertTrue($rootView->file_exists('files_trashbin/files/localFolder.d' . $timestamp . '/localFile.txt'));
     $this->assertFalse($rootView->file_exists('files_trashbin/files/localFolder.d' . $timestamp . '/' . $this->folder));
     //cleanup
     $rootView->deleteAll('files_trashin');
     if ($status === false) {
         \OC_App::disable('files_trashbin');
     }
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
 }
Example #17
0
 function testDeleteHooksForSharedFiles()
 {
     self::logoutHelper();
     self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER1);
     \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER1);
     // remember files_trashbin state
     $stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
     // we want to tests with app files_trashbin disabled
     \OC_App::disable('files_trashbin');
     // make sure that the trash bin is disabled
     $this->assertFalse(\OC_APP::isEnabled('files_trashbin'));
     $this->user1View->file_put_contents($this->filename, $this->data);
     // check if all keys are generated
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey'));
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/fileKey'));
     // get the file info from previous created file
     $fileInfo = $this->user1View->getFileInfo($this->filename);
     // check if we have a valid file info
     $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
     // share the file with user2
     \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2, \OCP\Constants::PERMISSION_ALL);
     // check if new share key exists
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
     self::logoutHelper();
     self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER2);
     \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER2);
     // user2 update the shared file
     $this->user2View->file_put_contents($this->filename, $this->data);
     // keys should be stored at user1s dir, not in user2s
     $this->assertFalse($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
     $this->assertFalse($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' . $this->filename . '/fileKey'));
     // delete the Shared file from user1 in data/user2/files/Shared
     $result = $this->user2View->unlink($this->filename);
     $this->assertTrue($result);
     // share key for user2 from user1s home should be gone, all other keys should still exists
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey'));
     $this->assertFalse($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/fileKey'));
     // cleanup
     self::logoutHelper();
     self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER1);
     \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER1);
     if ($stateFilesTrashbin) {
         \OC_App::enable('files_trashbin');
     } else {
         \OC_App::disable('files_trashbin');
     }
 }
Example #18
0
 public static function tearDownAfterClass()
 {
     // cleanup users
     \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER1);
     \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER2);
     \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER3);
     // delete group
     \OC_Group::deleteGroup(self::TEST_FILES_SHARING_API_GROUP1);
     // reset app files_encryption
     if (self::$stateFilesEncryption) {
         \OC_App::enable('files_encryption');
     } else {
         \OC_App::disable('files_encryption');
     }
 }
Example #19
0
 /**
  * @brief Update an application
  * @param $data array with all information
  *
  * This function installs an app. All information needed are passed in the
  * associative array $data.
  * The following keys are required:
  *   - source: string, can be "path" or "http"
  *
  * One of the following keys is required:
  *   - path: path to the file containing the app
  *   - href: link to the downloadable file containing the app
  *
  * The following keys are optional:
  *   - pretend: boolean, if set true the system won't do anything
  *   - noupgrade: boolean, if true appinfo/upgrade.php won't be loaded
  *
  * This function works as follows
  *   -# fetching the file
  *   -# removing the old files
  *   -# unzipping new file
  *   -# including appinfo/upgrade.php
  *   -# setting the installed version
  *
  * upgrade.php can determine the current installed version of the app using
  * "OC_Appconfig::getValue($appid, 'installed_version')"
  */
 public static function updateApp($app)
 {
     $ocsid = OC_Appconfig::getValue($app, 'ocsid');
     OC_App::disable($app);
     OC_App::enable($ocsid);
     return true;
 }
Example #20
0
<?php

OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
$appid = OC_App::enable(OC_App::cleanAppId($_POST['appid']));
if ($appid !== false) {
    OC_JSON::success(array('data' => array('appid' => $appid)));
} else {
    $l = OC_L10N::get('settings');
    OC_JSON::error(array("data" => array("message" => $l->t("Could not enable app. "))));
}
Example #21
0
 public static function enable($parameters)
 {
     $app = $parameters['appid'];
     OC_App::enable($app);
     return 100;
 }
Example #22
0
 * @author Kamil Domanski <*****@*****.**>
 * @author Lukas Reschke <*****@*****.**>
 * @author Morris Jobke <*****@*****.**>
 * @author Robin Appelman <*****@*****.**>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
$groups = isset($_POST['groups']) ? (array) $_POST['groups'] : null;
try {
    OC_App::enable(OC_App::cleanAppId((string) $_POST['appid']), $groups);
    OC_JSON::success();
} catch (Exception $e) {
    OC_Log::write('core', $e->getMessage(), OC_Log::ERROR);
    OC_JSON::error(array("data" => array("message" => $e->getMessage())));
}
Example #23
0
<?php

/**
 * Copyright (c) 2012 Thomas Müller <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
require_once __DIR__ . '/../lib/base.php';
OC_App::enable('calendar');
OC_App::enable('contacts');
OC_App::enable('apptemplate_advanced');
#OC_App::enable('files_archive');
#OC_App::enable('mozilla_sync');
#OC_App::enable('news');
#OC_App::enable('provisioning_api');
#OC_App::enable('user_external');
Example #24
0
 function testEncryptAll()
 {
     $filename = "/encryptAll" . uniqid() . ".txt";
     $util = new Encryption\Util($this->view, $this->userId);
     // disable encryption to upload a unencrypted file
     \OC_App::disable('files_encryption');
     $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort);
     $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
     $this->assertTrue(is_array($fileInfoUnencrypted));
     // enable file encryption again
     \OC_App::enable('files_encryption');
     // encrypt all unencrypted files
     $util->encryptAll('/' . $this->userId . '/' . 'files');
     $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
     $this->assertTrue(is_array($fileInfoEncrypted));
     // check if mtime and etags unchanged
     $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
     $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
     $this->view->unlink($this->userId . '/files/' . $filename);
 }
Example #25
0
 function testDecryptAll()
 {
     $filename = "/decryptAll" . $this->getUniqueID() . ".txt";
     $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
     $userdir = $datadir . '/' . $this->userId . '/files/';
     $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort);
     $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
     $this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo);
     $this->assertEquals($fileInfoEncrypted['encrypted'], 1);
     $encContent = file_get_contents($userdir . $filename);
     \OC_App::disable('files_encryption');
     $user = \OCP\User::getUser();
     $this->logoutHelper();
     $this->loginHelper($user, false, false, false);
     $content = file_get_contents($userdir . $filename);
     //content should be encrypted
     $this->assertSame($encContent, $content);
     // now we load the encryption app again
     \OC_App::loadApp('files_encryption');
     // init encryption app
     $params = array('uid' => \OCP\User::getUser(), 'password' => \OCP\User::getUser());
     $view = new \OC\Files\View('/');
     $util = new \OCA\Files_Encryption\Util($view, \OCP\User::getUser());
     $result = $util->initEncryption($params);
     $this->assertTrue($result instanceof \OCA\Files_Encryption\Session);
     $successful = $util->decryptAll();
     $this->assertTrue($successful);
     $this->logoutHelper();
     $this->loginHelper($user, false, false, false);
     // file should be unencrypted and fileInfo should contain the correct values
     $content = file_get_contents($userdir . $filename);
     // now we should get the plain data
     $this->assertSame($this->dataShort, $content);
     $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
     $this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo);
     // check if mtime and etags unchanged
     $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
     $this->assertSame($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
     // file should no longer be encrypted
     $this->assertEquals(0, $fileInfoUnencrypted['encrypted']);
     $backupPath = $this->getBackupPath('decryptAll');
     // check if the keys where moved to the backup location
     $this->assertTrue($this->view->is_dir($backupPath . '/keys'));
     $this->assertTrue($this->view->file_exists($backupPath . '/keys/' . $filename . '/fileKey'));
     $this->assertTrue($this->view->file_exists($backupPath . '/keys/' . $filename . '/' . $user . '.shareKey'));
     // cleanup
     $this->view->unlink($this->userId . '/files/' . $filename);
     $this->view->deleteAll($backupPath);
     \OC_App::enable('files_encryption');
 }
Example #26
0
<?php

OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
OC_JSON::setContentTypeHeader();
$appid = OC_App::enable($_POST['appid']);
if ($appid !== false) {
    OC_JSON::success(array('data' => array('appid' => $appid)));
} else {
    $l = OC_L10N::get('settings');
    OC_JSON::error(array("data" => array("message" => $l->t("Could not enable app. "))));
}
Example #27
0
 function testDeleteHooksForSharedFiles()
 {
     \Test_Encryption_Util::logoutHelper();
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
     \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
     // remember files_trashbin state
     $stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we want to tests with app files_trashbin disabled
     \OC_App::disable('files_trashbin');
     // make sure that the trash bin is disabled
     $this->assertFalse(\OC_APP::isEnabled('files_trashbin'));
     $this->user1View->file_put_contents($this->filename, $this->data);
     // check if all keys are generated
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey'));
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
     // get the file info from previous created file
     $fileInfo = $this->user1View->getFileInfo($this->filename);
     // check if we have a valid file info
     $this->assertTrue(is_array($fileInfo));
     // share the file with user2
     \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2, OCP\PERMISSION_ALL);
     // check if new share key exists
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
     \Test_Encryption_Util::logoutHelper();
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
     \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
     // user2 has a local file with the same name
     $this->user2View->file_put_contents($this->filename, $this->data);
     // check if all keys are generated
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
     // delete the Shared file from user1 in data/user2/files/Shared
     $this->user2View->unlink('/Shared/' . $this->filename);
     // now keys from user1s home should be gone
     $this->assertFalse($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey'));
     $this->assertFalse($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
     $this->assertFalse($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
     // but user2 keys should still exist
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
     $this->assertTrue($this->rootView->file_exists(self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
     // cleanup
     $this->user2View->unlink($this->filename);
     \Test_Encryption_Util::logoutHelper();
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
     \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
     // unshare the file
     \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2);
     $this->user1View->unlink($this->filename);
     if ($stateFilesTrashbin) {
         OC_App::enable('files_trashbin');
     } else {
         OC_App::disable('files_trashbin');
     }
 }
Example #28
0
 public static function tearDownAfterClass()
 {
     if (self::$trashBinStatus) {
         \OC_App::enable('files_trashbin');
     }
 }
Example #29
0
 /**
  * Encrypt all files in a directory
  * @param string $dirPath the directory whose files will be encrypted
  * @return bool
  * @note Encryption is recursive
  */
 public function encryptAll($dirPath)
 {
     $result = true;
     $found = $this->findEncFiles($dirPath);
     // Disable proxy to prevent file being encrypted twice
     \OC_FileProxy::$enabled = false;
     $versionStatus = \OCP\App::isEnabled('files_versions');
     \OC_App::disable('files_versions');
     $encryptedFiles = array();
     // Encrypt unencrypted files
     foreach ($found['plain'] as $plainFile) {
         //get file info
         $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']);
         //relative to data/<user>/file
         $relPath = $plainFile['path'];
         //relative to /data
         $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
         // keep timestamp
         $timestamp = $fileInfo['mtime'];
         // Open plain file handle for binary reading
         $plainHandle = $this->view->fopen($rawPath, 'rb');
         // Open enc file handle for binary writing, with same filename as original plain file
         $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
         if (is_resource($encHandle) && is_resource($plainHandle)) {
             // Move plain file to a temporary location
             $size = stream_copy_to_stream($plainHandle, $encHandle);
             fclose($encHandle);
             fclose($plainHandle);
             $fakeRoot = $this->view->getRoot();
             $this->view->chroot('/' . $this->userId . '/files');
             $this->view->rename($relPath . '.part', $relPath);
             // set timestamp
             $this->view->touch($relPath, $timestamp);
             $encSize = $this->view->filesize($relPath);
             $this->view->chroot($fakeRoot);
             // Add the file to the cache
             \OC\Files\Filesystem::putFileInfo($relPath, array('encrypted' => true, 'size' => $encSize, 'unencrypted_size' => $size, 'etag' => $fileInfo['etag']));
             $encryptedFiles[] = $relPath;
         } else {
             \OCP\Util::writeLog('files_encryption', 'initial encryption: could not encrypt ' . $rawPath, \OCP\Util::FATAL);
             $result = false;
         }
     }
     \OC_FileProxy::$enabled = true;
     if ($versionStatus) {
         \OC_App::enable('files_versions');
     }
     $result = $result && $this->encryptVersions($encryptedFiles);
     return $result;
 }
Example #30
0
 * @author Lukas Reschke <*****@*****.**>
 * @author Robin Appelman <*****@*****.**>
 * @author Thomas Müller <*****@*****.**>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
$groups = isset($_POST['groups']) ? (array) $_POST['groups'] : null;
try {
    $app = OC_App::cleanAppId((string) $_POST['appid']);
    OC_App::enable($app, $groups);
    OC_JSON::success(['data' => ['update_required' => \OC_App::shouldUpgrade($app)]]);
} catch (Exception $e) {
    \OCP\Util::writeLog('core', $e->getMessage(), \OCP\Util::ERROR);
    OC_JSON::error(array("data" => array("message" => $e->getMessage())));
}