This commit is contained in:
Morris Jobke 2021-06-02 11:31:08 -04:00 committed by GitHub
commit 6825f1b7f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 44 deletions

View File

@ -1,39 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Clark Tomlinson <fallen013@gmail.com>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @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/>
*
*/
namespace OCA\Encryption\AppInfo;
\OCP\Util::addscript('encryption', 'encryption');
$encryptionManager = \OC::$server->getEncryptionManager();
$encryptionSystemReady = $encryptionManager->isReady();
/** @var Application $app */
$app = \OC::$server->query(Application::class);
if ($encryptionSystemReady) {
$app->registerEncryptionModule($encryptionManager);
$app->registerHooks(\OC::$server->getConfig());
$app->setUp($encryptionManager);
}

View File

@ -39,10 +39,14 @@ use OCA\Encryption\Recovery;
use OCA\Encryption\Session;
use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Encryption\IManager;
use OCP\IConfig;
class Application extends \OCP\AppFramework\App {
class Application extends \OCP\AppFramework\App implements IBootstrap {
/**
* @param array $urlParams
*/
@ -106,4 +110,19 @@ class Application extends \OCP\AppFramework\App {
);
});
}
public function register(IRegistrationContext $context): void {
}
public function boot(IBootContext $context): void {
$encryptionManager = $context->getServerContainer()->getEncryptionManager();
$encryptionSystemReady = $encryptionManager->isReady();
if ($encryptionSystemReady) {
$this->registerEncryptionModule($encryptionManager);
$this->registerHooks(\OC::$server->getConfig());
$this->setUp($encryptionManager);
}
\OCP\Util::addScript('encryption', 'encryption');
}
}

View File

@ -12,6 +12,7 @@ use OC\Encryption\EncryptionWrapper;
use OC\Files\Filesystem;
use OC\Memcache\ArrayCache;
use OCA\Encryption\AppInfo\Application;
use OCA\Encryption\Crypto\Encryption;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCP\Encryption\IManager;
@ -86,15 +87,16 @@ trait EncryptionTrait {
$this->markTestSkipped('Encryption not ready');
}
\OC_App::loadApp('encryption');
$this->encryptionApp = new Application([], $isReady);
$this->config = \OC::$server->getConfig();
$this->encryptionWasEnabled = $this->config->getAppValue('core', 'encryption_enabled', 'no');
$this->originalEncryptionModule = $this->config->getAppValue('core', 'default_encryption_module');
$this->config->setAppValue('core', 'default_encryption_module', \OCA\Encryption\Crypto\Encryption::ID);
$this->config->setAppValue('core', 'encryption_enabled', 'yes');
\OC_App::loadApp('encryption');
$this->encryptionApp = new Application();
$this->assertTrue(\OC::$server->getEncryptionManager()->isEnabled());
}
@ -104,5 +106,6 @@ trait EncryptionTrait {
$this->config->setAppValue('core', 'default_encryption_module', $this->originalEncryptionModule);
$this->config->deleteAppValue('encryption', 'useMasterKey');
}
\OC::$server->getEncryptionManager()->unregisterEncryptionModule(Encryption::ID);
}
}