1
0

Admin.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Julius Härtl <jus@bitgrid.net>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\Encryption\Settings;
  27. use OC\Files\View;
  28. use OCA\Encryption\Crypto\Crypt;
  29. use OCA\Encryption\Session;
  30. use OCA\Encryption\Util;
  31. use OCP\AppFramework\Http\TemplateResponse;
  32. use OCP\IConfig;
  33. use OCP\IL10N;
  34. use OCP\ISession;
  35. use OCP\IUserManager;
  36. use OCP\IUserSession;
  37. use OCP\Settings\ISettings;
  38. use Psr\Log\LoggerInterface;
  39. class Admin implements ISettings {
  40. public function __construct(
  41. private IL10N $l,
  42. private LoggerInterface $logger,
  43. private IUserSession $userSession,
  44. private IConfig $config,
  45. private IUserManager $userManager,
  46. private ISession $session
  47. ) {
  48. }
  49. /**
  50. * @return TemplateResponse
  51. */
  52. public function getForm() {
  53. $crypt = new Crypt(
  54. $this->logger,
  55. $this->userSession,
  56. $this->config,
  57. $this->l);
  58. $util = new Util(
  59. new View(),
  60. $crypt,
  61. $this->userSession,
  62. $this->config,
  63. $this->userManager);
  64. // Check if an adminRecovery account is enabled for recovering files after lost pwd
  65. $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0');
  66. $session = new Session($this->session);
  67. $encryptHomeStorage = $util->shouldEncryptHomeStorage();
  68. $parameters = [
  69. 'recoveryEnabled' => $recoveryAdminEnabled,
  70. 'initStatus' => $session->getStatus(),
  71. 'encryptHomeStorage' => $encryptHomeStorage,
  72. 'masterKeyEnabled' => $util->isMasterKeyEnabled(),
  73. ];
  74. return new TemplateResponse('encryption', 'settings-admin', $parameters, '');
  75. }
  76. /**
  77. * @return string the section ID, e.g. 'sharing'
  78. */
  79. public function getSection() {
  80. return 'security';
  81. }
  82. /**
  83. * @return int whether the form should be rather on the top or bottom of
  84. * the admin section. The forms are arranged in ascending order of the
  85. * priority values. It is required to return a value between 0 and 100.
  86. *
  87. * E.g.: 70
  88. */
  89. public function getPriority() {
  90. return 11;
  91. }
  92. }