Move encryption from app.php to IBootstrap

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2020-11-10 20:58:24 +01:00
parent 2445b9491e
commit d8d53d39a4
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
3 changed files with 22 additions and 40 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;
@ -104,5 +105,6 @@ trait EncryptionTrait {
$this->config->setAppValue('core', 'default_encryption_module', $this->originalEncryptionModule);
$this->config->deleteAppValue('encryption', 'useMasterKey');
}
\OC::$server->getEncryptionManager()->unregisterEncryptionModule(Encryption::ID);
}
}