2015-02-24 21:05:19 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2015-04-07 18:02:49 +03:00
|
|
|
* @author Clark Tomlinson <fallen013@gmail.com>
|
2020-12-16 16:54:15 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-06-25 12:43:55 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-04-07 18:02:49 +03:00
|
|
|
*
|
2015-02-24 21:05:19 +03:00
|
|
|
* @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,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-02-24 21:05:19 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2015-02-24 21:05:19 +03:00
|
|
|
namespace OCA\Encryption\AppInfo;
|
|
|
|
|
|
|
|
use OCA\Encryption\Crypto\Crypt;
|
2015-08-24 13:03:53 +03:00
|
|
|
use OCA\Encryption\Crypto\DecryptAll;
|
2015-08-24 16:56:04 +03:00
|
|
|
use OCA\Encryption\Crypto\EncryptAll;
|
2015-04-14 17:48:39 +03:00
|
|
|
use OCA\Encryption\Crypto\Encryption;
|
2015-02-24 21:05:19 +03:00
|
|
|
use OCA\Encryption\HookManager;
|
|
|
|
use OCA\Encryption\Hooks\UserHooks;
|
|
|
|
use OCA\Encryption\KeyManager;
|
|
|
|
use OCA\Encryption\Recovery;
|
2015-04-16 14:47:27 +03:00
|
|
|
use OCA\Encryption\Session;
|
2015-02-24 21:05:19 +03:00
|
|
|
use OCA\Encryption\Users\Setup;
|
2015-03-25 00:29:10 +03:00
|
|
|
use OCA\Encryption\Util;
|
2015-02-24 21:05:19 +03:00
|
|
|
use OCP\Encryption\IManager;
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
2015-03-30 12:49:03 +03:00
|
|
|
class Application extends \OCP\AppFramework\App {
|
2015-02-24 21:05:19 +03:00
|
|
|
/**
|
|
|
|
* @param array $urlParams
|
|
|
|
*/
|
2020-03-26 11:30:18 +03:00
|
|
|
public function __construct($urlParams = []) {
|
2015-03-30 12:49:03 +03:00
|
|
|
parent::__construct('encryption', $urlParams);
|
2017-05-30 13:54:58 +03:00
|
|
|
}
|
|
|
|
|
2020-11-23 00:09:09 +03:00
|
|
|
public function setUp(IManager $encryptionManager) {
|
|
|
|
if ($encryptionManager->isEnabled()) {
|
2016-03-02 15:58:06 +03:00
|
|
|
/** @var Setup $setup */
|
2020-11-11 22:46:22 +03:00
|
|
|
$setup = $this->getContainer()->query(Setup::class);
|
2016-03-02 15:58:06 +03:00
|
|
|
$setup->setupSystem();
|
|
|
|
}
|
2015-02-24 21:05:19 +03:00
|
|
|
}
|
|
|
|
|
2015-04-07 19:05:54 +03:00
|
|
|
/**
|
|
|
|
* register hooks
|
|
|
|
*/
|
2020-11-23 00:09:09 +03:00
|
|
|
public function registerHooks(IConfig $config) {
|
|
|
|
if (!$config->getSystemValueBool('maintenance')) {
|
2015-02-24 21:05:19 +03:00
|
|
|
$container = $this->getContainer();
|
|
|
|
$server = $container->getServer();
|
|
|
|
// Register our hooks and fire them.
|
|
|
|
$hookManager = new HookManager();
|
|
|
|
|
|
|
|
$hookManager->registerHook([
|
2020-11-11 22:46:22 +03:00
|
|
|
new UserHooks($container->query(KeyManager::class),
|
2015-09-11 22:18:13 +03:00
|
|
|
$server->getUserManager(),
|
2015-03-27 03:35:36 +03:00
|
|
|
$server->getLogger(),
|
2020-11-11 22:46:22 +03:00
|
|
|
$container->query(Setup::class),
|
2015-03-27 03:35:36 +03:00
|
|
|
$server->getUserSession(),
|
2020-11-11 22:46:22 +03:00
|
|
|
$container->query(Util::class),
|
|
|
|
$container->query(Session::class),
|
|
|
|
$container->query(Crypt::class),
|
|
|
|
$container->query(Recovery::class))
|
2015-02-24 21:05:19 +03:00
|
|
|
]);
|
|
|
|
|
|
|
|
$hookManager->fireHooks();
|
|
|
|
} else {
|
|
|
|
// Logout user if we are in maintenance to force re-login
|
|
|
|
$this->getContainer()->getServer()->getUserSession()->logout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-23 00:09:09 +03:00
|
|
|
public function registerEncryptionModule(IManager $encryptionManager) {
|
2015-03-26 11:32:08 +03:00
|
|
|
$container = $this->getContainer();
|
2015-04-14 17:48:39 +03:00
|
|
|
|
2020-11-23 00:09:09 +03:00
|
|
|
$encryptionManager->registerEncryptionModule(
|
2015-04-14 17:48:39 +03:00
|
|
|
Encryption::ID,
|
|
|
|
Encryption::DISPLAY_NAME,
|
2020-04-09 14:53:40 +03:00
|
|
|
function () use ($container) {
|
2020-04-10 15:19:56 +03:00
|
|
|
return new Encryption(
|
2020-11-11 22:46:22 +03:00
|
|
|
$container->query(Crypt::class),
|
|
|
|
$container->query(KeyManager::class),
|
|
|
|
$container->query(Util::class),
|
|
|
|
$container->query(Session::class),
|
|
|
|
$container->query(EncryptAll::class),
|
|
|
|
$container->query(DecryptAll::class),
|
2015-05-18 14:09:36 +03:00
|
|
|
$container->getServer()->getLogger(),
|
|
|
|
$container->getServer()->getL10N($container->getAppName())
|
2015-04-14 17:48:39 +03:00
|
|
|
);
|
2020-04-10 15:19:56 +03:00
|
|
|
});
|
2015-02-24 21:05:19 +03:00
|
|
|
}
|
|
|
|
}
|