2015-02-24 21:05:19 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2015-04-07 18:02:49 +03:00
|
|
|
* @author Clark Tomlinson <fallen013@gmail.com>
|
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @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-03-31 12:15:47 +03:00
|
|
|
$session = new \OCA\Encryption\Session(\OC::$server->getSession());
|
2015-04-02 14:12:05 +03:00
|
|
|
$userSession = \OC::$server->getUserSession();
|
2015-03-31 12:15:47 +03:00
|
|
|
|
2015-04-02 14:12:05 +03:00
|
|
|
$template = new OCP\Template('encryption', 'settings-personal');
|
2015-03-27 20:10:32 +03:00
|
|
|
$crypt = new \OCA\Encryption\Crypto\Crypt(
|
|
|
|
\OC::$server->getLogger(),
|
2015-04-02 14:12:05 +03:00
|
|
|
$userSession,
|
2016-01-05 14:51:05 +03:00
|
|
|
\OC::$server->getConfig(),
|
|
|
|
\OC::$server->getL10N('encryption'));
|
2015-03-31 18:13:36 +03:00
|
|
|
|
|
|
|
$util = new \OCA\Encryption\Util(
|
|
|
|
new \OC\Files\View(),
|
|
|
|
$crypt,
|
|
|
|
\OC::$server->getLogger(),
|
2015-04-02 14:12:05 +03:00
|
|
|
$userSession,
|
2015-05-12 19:49:25 +03:00
|
|
|
\OC::$server->getConfig(),
|
|
|
|
\OC::$server->getUserManager());
|
2015-03-31 18:13:36 +03:00
|
|
|
|
2015-04-02 14:12:05 +03:00
|
|
|
$keyManager = new \OCA\Encryption\KeyManager(
|
2015-04-22 12:18:18 +03:00
|
|
|
\OC::$server->getEncryptionKeyStorage(),
|
2015-03-27 20:10:32 +03:00
|
|
|
$crypt,
|
|
|
|
\OC::$server->getConfig(),
|
2015-04-02 14:12:05 +03:00
|
|
|
$userSession,
|
2015-03-31 12:15:47 +03:00
|
|
|
$session,
|
2015-03-31 18:13:36 +03:00
|
|
|
\OC::$server->getLogger(), $util);
|
2015-02-24 21:05:19 +03:00
|
|
|
|
2015-04-02 14:12:05 +03:00
|
|
|
$user = $userSession->getUser()->getUID();
|
2015-03-27 20:10:32 +03:00
|
|
|
|
2015-02-24 21:05:19 +03:00
|
|
|
$view = new \OC\Files\View('/');
|
2015-03-27 20:10:32 +03:00
|
|
|
|
2015-03-31 18:13:36 +03:00
|
|
|
|
2015-03-27 20:10:32 +03:00
|
|
|
|
2015-03-31 12:15:47 +03:00
|
|
|
$privateKeySet = $session->isPrivateKeySet();
|
2015-02-24 21:05:19 +03:00
|
|
|
// did we tried to initialize the keys for this session?
|
2015-03-31 12:15:47 +03:00
|
|
|
$initialized = $session->getStatus();
|
2015-02-24 21:05:19 +03:00
|
|
|
|
2015-03-27 03:35:36 +03:00
|
|
|
$recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled');
|
2015-04-29 18:18:41 +03:00
|
|
|
$recoveryEnabledForUser = $util->isRecoveryEnabledForUser($user);
|
2015-02-24 21:05:19 +03:00
|
|
|
|
|
|
|
$result = false;
|
|
|
|
|
|
|
|
if ($recoveryAdminEnabled || !$privateKeySet) {
|
2015-04-02 14:12:05 +03:00
|
|
|
$template->assign('recoveryEnabled', $recoveryAdminEnabled);
|
|
|
|
$template->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
|
|
|
|
$template->assign('privateKeySet', $privateKeySet);
|
|
|
|
$template->assign('initialized', $initialized);
|
2015-02-24 21:05:19 +03:00
|
|
|
|
2015-04-02 14:12:05 +03:00
|
|
|
$result = $template->fetchPage();
|
2015-02-24 21:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|