diff --git a/apps/encryption/appinfo/app.php b/apps/encryption/appinfo/app.php deleted file mode 100644 index 5fd5f628de0c3..0000000000000 --- a/apps/encryption/appinfo/app.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @author Christoph Wurst - * @author Clark Tomlinson - * @author Morris Jobke - * - * @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 - * - */ - -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); -} diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php index ac0f2ededd246..78df1183f9260 100644 --- a/apps/encryption/lib/AppInfo/Application.php +++ b/apps/encryption/lib/AppInfo/Application.php @@ -39,10 +39,14 @@ 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 @@ function () use ($container) { ); }); } + + 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'); + } } diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php index 6b74f7ca8eee3..506a7c6050315 100644 --- a/tests/lib/Traits/EncryptionTrait.php +++ b/tests/lib/Traits/EncryptionTrait.php @@ -12,6 +12,7 @@ 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 @@ protected function setUpEncryptionTrait() { $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 @@ protected function tearDownEncryptionTrait() { $this->config->setAppValue('core', 'default_encryption_module', $this->originalEncryptionModule); $this->config->deleteAppValue('encryption', 'useMasterKey'); } + \OC::$server->getEncryptionManager()->unregisterEncryptionModule(Encryption::ID); } }