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

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