nextcloud/apps/encryption/lib/AppInfo/Application.php

110 lines
3.3 KiB
PHP
Raw Normal View History

2015-02-24 21:05:19 +03:00
<?php
/**
2016-07-21 17:49:16 +03:00
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
2016-05-26 20:56:05 +03:00
* @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>
* @author Roeland Jago Douma <roeland@famdouma.nl>
2015-06-25 12:43:55 +03:00
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
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,
* along with this program. If not, see <http://www.gnu.org/licenses/>
2015-02-24 21:05:19 +03:00
*
*/
2015-02-24 21:05:19 +03:00
namespace OCA\Encryption\AppInfo;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Crypto\DecryptAll;
2015-08-24 16:56:04 +03:00
use OCA\Encryption\Crypto\EncryptAll;
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;
use OCA\Encryption\Session;
2015-02-24 21:05:19 +03:00
use OCA\Encryption\Users\Setup;
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
*/
public function __construct($urlParams = []) {
2015-03-30 12:49:03 +03:00
parent::__construct('encryption', $urlParams);
}
public function setUp(IManager $encryptionManager) {
if ($encryptionManager->isEnabled()) {
/** @var Setup $setup */
$setup = $this->getContainer()->query(Setup::class);
$setup->setupSystem();
}
2015-02-24 21:05:19 +03:00
}
/**
* register hooks
*/
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([
new UserHooks($container->query(KeyManager::class),
$server->getUserManager(),
2015-03-27 03:35:36 +03:00
$server->getLogger(),
$container->query(Setup::class),
2015-03-27 03:35:36 +03:00
$server->getUserSession(),
$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();
}
}
public function registerEncryptionModule(IManager $encryptionManager) {
2015-03-26 11:32:08 +03:00
$container = $this->getContainer();
$encryptionManager->registerEncryptionModule(
Encryption::ID,
Encryption::DISPLAY_NAME,
function () use ($container) {
return new Encryption(
$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-02-24 21:05:19 +03:00
}
}