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