You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Application.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Clark Tomlinson <fallen013@gmail.com>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. namespace OCA\Encryption\AppInfo;
  29. use OCA\Encryption\Crypto\Crypt;
  30. use OCA\Encryption\Crypto\DecryptAll;
  31. use OCA\Encryption\Crypto\EncryptAll;
  32. use OCA\Encryption\Crypto\Encryption;
  33. use OCA\Encryption\HookManager;
  34. use OCA\Encryption\Hooks\UserHooks;
  35. use OCA\Encryption\KeyManager;
  36. use OCA\Encryption\Recovery;
  37. use OCA\Encryption\Session;
  38. use OCA\Encryption\Users\Setup;
  39. use OCA\Encryption\Util;
  40. use OCP\Encryption\IManager;
  41. use OCP\IConfig;
  42. class Application extends \OCP\AppFramework\App {
  43. /**
  44. * @param array $urlParams
  45. */
  46. public function __construct($urlParams = []) {
  47. parent::__construct('encryption', $urlParams);
  48. }
  49. public function setUp(IManager $encryptionManager) {
  50. if ($encryptionManager->isEnabled()) {
  51. /** @var Setup $setup */
  52. $setup = $this->getContainer()->query(Setup::class);
  53. $setup->setupSystem();
  54. }
  55. }
  56. /**
  57. * register hooks
  58. */
  59. public function registerHooks(IConfig $config) {
  60. if (!$config->getSystemValueBool('maintenance')) {
  61. $container = $this->getContainer();
  62. $server = $container->getServer();
  63. // Register our hooks and fire them.
  64. $hookManager = new HookManager();
  65. $hookManager->registerHook([
  66. new UserHooks($container->query(KeyManager::class),
  67. $server->getUserManager(),
  68. $server->getLogger(),
  69. $container->query(Setup::class),
  70. $server->getUserSession(),
  71. $container->query(Util::class),
  72. $container->query(Session::class),
  73. $container->query(Crypt::class),
  74. $container->query(Recovery::class))
  75. ]);
  76. $hookManager->fireHooks();
  77. } else {
  78. // Logout user if we are in maintenance to force re-login
  79. $this->getContainer()->getServer()->getUserSession()->logout();
  80. }
  81. }
  82. public function registerEncryptionModule(IManager $encryptionManager) {
  83. $container = $this->getContainer();
  84. $encryptionManager->registerEncryptionModule(
  85. Encryption::ID,
  86. Encryption::DISPLAY_NAME,
  87. function () use ($container) {
  88. return new Encryption(
  89. $container->query(Crypt::class),
  90. $container->query(KeyManager::class),
  91. $container->query(Util::class),
  92. $container->query(Session::class),
  93. $container->query(EncryptAll::class),
  94. $container->query(DecryptAll::class),
  95. $container->getServer()->getLogger(),
  96. $container->getServer()->getL10N($container->getAppName())
  97. );
  98. });
  99. }
  100. }