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

90 lines
2.5 KiB
PHP
Raw Normal View History

2015-02-24 13:05:19 -05:00
<?php
2015-02-24 13:05:19 -05:00
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
2015-02-24 13:05:19 -05:00
*/
namespace OCA\Encryption\AppInfo;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Crypto\DecryptAll;
2015-08-24 09:56:04 -04:00
use OCA\Encryption\Crypto\EncryptAll;
use OCA\Encryption\Crypto\Encryption;
2015-02-24 13:05:19 -05: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 13:05:19 -05:00
use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
2015-02-24 13:05:19 -05:00
use OCP\Encryption\IManager;
use OCP\IConfig;
use Psr\Log\LoggerInterface;
2015-02-24 13:05:19 -05:00
2015-03-30 05:49:03 -04:00
class Application extends \OCP\AppFramework\App {
2015-02-24 13:05:19 -05:00
/**
* @param array $urlParams
*/
public function __construct($urlParams = []) {
2015-03-30 05:49:03 -04: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 13:05:19 -05:00
}
/**
* register hooks
*/
public function registerHooks(IConfig $config) {
if (!$config->getSystemValueBool('maintenance')) {
2015-02-24 13:05:19 -05: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(),
$server->get(LoggerInterface::class),
$container->query(Setup::class),
2015-03-26 20:35:36 -04:00
$server->getUserSession(),
$container->query(Util::class),
$container->query(Session::class),
$container->query(Crypt::class),
$container->query(Recovery::class))
2015-02-24 13:05:19 -05: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 04:32:08 -04: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),
$container->getServer()->get(LoggerInterface::class),
$container->getServer()->getL10N($container->getAppName())
);
});
2015-02-24 13:05:19 -05:00
}
}