Ejemplo n.º 1
0
<?php

/**
 * Copyright (c) 2013 Sam Tuke <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
// Add CSS stylesheet
\OC_Util::addStyle('files_encryption', 'settings-personal');
$tmpl = new OCP\Template('files_encryption', 'settings-personal');
$user = \OCP\USER::getUser();
$view = new \OC\Files\View('/');
$util = new \OCA\Files_Encryption\Util($view, $user);
$session = new \OCA\Files_Encryption\Session($view);
$privateKeySet = $session->getPrivateKey() !== false;
// did we tried to initialize the keys for this session?
$initialized = $session->getInitialized();
$recoveryAdminEnabled = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled');
$recoveryEnabledForUser = $util->recoveryEnabledForUser();
$result = false;
if ($recoveryAdminEnabled || !$privateKeySet) {
    \OCP\Util::addscript('files_encryption', 'settings-personal');
    $tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);
    $tmpl->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
    $tmpl->assign('privateKeySet', $privateKeySet);
    $tmpl->assign('initialized', $initialized);
    $result = $tmpl->fetchPage();
}
return $result;
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 *
 * Script to change recovery key password
 *
 */
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
$l = \OC::$server->getL10N('core');
$return = false;
$errorMessage = $l->t('Could not update the private key password.');
$oldPassword = (string) $_POST['oldPassword'];
$newPassword = (string) $_POST['newPassword'];
$view = new \OC\Files\View('/');
$session = new \OCA\Files_Encryption\Session($view);
$user = \OCP\User::getUser();
$loginName = \OC::$server->getUserSession()->getLoginName();
// check new password
$passwordCorrect = \OCP\User::checkPassword($loginName, $newPassword);
if ($passwordCorrect !== false) {
    $proxyStatus = \OC_FileProxy::$enabled;
    \OC_FileProxy::$enabled = false;
    $encryptedKey = \OCA\Files_Encryption\Keymanager::getPrivateKey($view, $user);
    $decryptedKey = $encryptedKey ? \OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedKey, $oldPassword) : false;
    if ($decryptedKey) {
        $cipher = \OCA\Files_Encryption\Helper::getCipher();
        $encryptedKey = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($decryptedKey, $newPassword, $cipher);
        if ($encryptedKey) {
            \OCA\Files_Encryption\Keymanager::setPrivateKey($encryptedKey, $user);
            $session->setPrivateKey($decryptedKey);
Ejemplo n.º 3
0
    $hash = '#?dir=' . \OCP\Util::encodePath($dir);
    if ($view !== 'files') {
        $hash .= '&view=' . urlencode($view);
    }
    header('Location: ' . OCP\Util::linkTo('files', 'index.php') . $hash);
    exit;
}
$user = OC_User::getUser();
$config = \OC::$server->getConfig();
// mostly for the home storage's free space
$dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
$storageInfo = OC_Helper::getStorageInfo('/', $dirInfo);
// if the encryption app is disabled, than everything is fine (INIT_SUCCESSFUL status code)
$encryptionInitStatus = 2;
if (OC_App::isEnabled('files_encryption')) {
    $session = new \OCA\Files_Encryption\Session(new \OC\Files\View('/'));
    $encryptionInitStatus = $session->getInitialized();
}
$nav = new OCP\Template('files', 'appnavigation', '');
function sortNavigationItems($item1, $item2)
{
    return $item1['order'] - $item2['order'];
}
\OCA\Files\App::getNavigationManager()->add(array('id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', 'order' => 5, 'name' => $l->t('Favorites')));
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
usort($navItems, 'sortNavigationItems');
$nav->assign('navigationItems', $navItems);
$contentItems = array();
function renderScript($appName, $scriptName)
{
    $content = '';
Ejemplo n.º 4
0
<?php

/**
 * Copyright (c) 2011 Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
\OC_Util::checkAdminUser();
$tmpl = new OCP\Template('files_encryption', 'settings-admin');
// Check if an adminRecovery account is enabled for recovering files after lost pwd
$recoveryAdminEnabled = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled', '0');
$session = new \OCA\Files_Encryption\Session(new \OC\Files\View('/'));
$initStatus = $session->getInitialized();
$tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);
$tmpl->assign('initStatus', $initStatus);
\OCP\Util::addscript('files_encryption', 'settings-admin');
\OCP\Util::addscript('core', 'multiselect');
return $tmpl->fetchPage();