From bf809ac85aa6739010463235fe8f7878993c39ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 31 Mar 2015 11:50:53 +0200 Subject: [PATCH] Removing left overs from old encryption app --- apps/files/index.php | 1 - apps/files/js/files.js | 6 --- apps/files/templates/index.php | 1 - lib/private/connector/sabre/file.php | 22 +++----- lib/private/util.php | 45 ----------------- lib/public/util.php | 4 +- settings/ajax/decryptall.php | 62 ----------------------- settings/ajax/deletekeys.php | 35 ------------- settings/ajax/restorekeys.php | 35 ------------- settings/js/personal.js | 75 ---------------------------- settings/personal.php | 11 ---- settings/routes.php | 6 --- settings/templates/personal.php | 52 ------------------- 13 files changed, 9 insertions(+), 346 deletions(-) delete mode 100644 settings/ajax/decryptall.php delete mode 100644 settings/ajax/deletekeys.php delete mode 100644 settings/ajax/restorekeys.php diff --git a/apps/files/index.php b/apps/files/index.php index 3f93285902..23830da695 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -142,7 +142,6 @@ OCP\Util::addscript('files', 'keyboardshortcuts'); $tmpl = new OCP\Template('files', 'index', 'user'); $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']); $tmpl->assign('isPublic', false); -$tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles()); $tmpl->assign("mailNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_mail_notification', 'no')); $tmpl->assign("mailPublicNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_public_notification', 'no')); $tmpl->assign("allowShareWithLink", $config->getAppValue('core', 'shareapi_allow_links', 'yes')); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index e63c3cad52..9d2d563984 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -126,7 +126,6 @@ return; } - var encryptedFiles = $('#encryptedFiles').val(); var initStatus = $('#encryptionInitStatus').val(); if (initStatus === '0') { // enc not initialized, but should be OC.Notification.show(t('files', 'Encryption App is enabled but your keys are not initialized, please log-out and log-in again')); @@ -134,11 +133,6 @@ } if (initStatus === '1') { // encryption tried to init but failed OC.Notification.show(t('files', 'Invalid private key for Encryption App. Please update your private key password in your personal settings to recover access to your encrypted files.')); - return; - } - if (encryptedFiles === '1') { - OC.Notification.show(t('files', 'Encryption was disabled but your files are still encrypted. Please go to your personal settings to decrypt your files.')); - return; } }, diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 222a996aae..84f3033ba9 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -12,7 +12,6 @@ - diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 58579f42df..a436973ba9 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -76,11 +76,6 @@ class File extends \OC\Connector\Sabre\Node implements \Sabre\DAV\IFile { throw new \Sabre\DAV\Exception\ServiceUnavailable("File is not updatable: ".$e->getMessage()); } - // throw an exception if encryption was disabled but the files are still encrypted - if (\OC_Util::encryptedFiles()) { - throw new \Sabre\DAV\Exception\ServiceUnavailable("Encryption is disabled"); - } - // verify path of the target $this->verifyPath(); @@ -187,18 +182,13 @@ class File extends \OC\Connector\Sabre\Node implements \Sabre\DAV\IFile { public function get() { //throw exception if encryption is disabled but files are still encrypted - if (\OC_Util::encryptedFiles()) { - throw new \Sabre\DAV\Exception\ServiceUnavailable("Encryption is disabled"); - } else { - try { - return $this->fileView->fopen(ltrim($this->path, '/'), 'rb'); - } catch (\OCP\Encryption\Exception\EncryptionException $e) { - throw new \Sabre\DAV\Exception\Forbidden($e->getMessage()); - } catch (\OCP\Files\StorageNotAvailableException $e) { - throw new \Sabre\DAV\Exception\ServiceUnavailable("Failed to open file: ".$e->getMessage()); - } + try { + return $this->fileView->fopen(ltrim($this->path, '/'), 'rb'); + } catch (\OCP\Encryption\Exception\EncryptionException $e) { + throw new \Sabre\DAV\Exception\Forbidden($e->getMessage()); + } catch (\OCP\Files\StorageNotAvailableException $e) { + throw new \Sabre\DAV\Exception\ServiceUnavailable("Failed to open file: ".$e->getMessage()); } - } /** diff --git a/lib/private/util.php b/lib/private/util.php index e6dd307fae..3fd0f84468 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -812,51 +812,6 @@ class OC_Util { return $errors; } - - /** - * check if there are still some encrypted files stored - * - * @return boolean - */ - public static function encryptedFiles() { - //check if encryption was enabled in the past - $encryptedFiles = false; - if (OC_App::isEnabled('files_encryption') === false) { - $view = new OC\Files\View('/' . OCP\User::getUser()); - $keysPath = '/files_encryption/keys'; - if ($view->is_dir($keysPath)) { - $dircontent = $view->getDirectoryContent($keysPath); - if (!empty($dircontent)) { - $encryptedFiles = true; - } - } - } - - return $encryptedFiles; - } - - /** - * check if a backup from the encryption keys exists - * - * @return boolean - */ - public static function backupKeysExists() { - //check if encryption was enabled in the past - $backupExists = false; - if (OC_App::isEnabled('files_encryption') === false) { - $view = new OC\Files\View('/' . OCP\User::getUser()); - $backupPath = '/files_encryption/backup.decryptAll'; - if ($view->is_dir($backupPath)) { - $dircontent = $view->getDirectoryContent($backupPath); - if (!empty($dircontent)) { - $backupExists = true; - } - } - } - - return $backupExists; - } - /** * Check for correct file permissions of data directory * diff --git a/lib/public/util.php b/lib/public/util.php index b50ce54839..37cb1b5448 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -219,9 +219,11 @@ class Util { /** * check if some encrypted files are stored * @return bool + * + * @deprecated No longer required */ public static function encryptedFiles() { - return \OC_Util::encryptedFiles(); + return false; } /** diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php deleted file mode 100644 index 5925cee9df..0000000000 --- a/settings/ajax/decryptall.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @author Joas Schilling - * @author Lukas Reschke - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * @author Volkan Gezer - * - * @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 - * - */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); - -//encryption app needs to be loaded -OC_App::loadApp('files_encryption'); - -// init encryption app -$params = array('uid' => \OCP\User::getUser(), - 'password' => (string)$_POST['password']); - -$view = new OC\Files\View('/'); -$util = new \OCA\Files_Encryption\Util($view, \OCP\User::getUser()); -$l = \OC::$server->getL10N('settings'); - -$result = $util->initEncryption($params); - -if ($result !== false) { - - try { - $successful = $util->decryptAll(); - } catch (\Exception $ex) { - \OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR); - $successful = false; - } - - $util->closeEncryptionSession(); - - if ($successful === true) { - \OCP\JSON::success(array('data' => array('message' => $l->t('Files decrypted successfully')))); - } else { - \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator')))); - } -} else { - \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, check your password and try again')))); -} - diff --git a/settings/ajax/deletekeys.php b/settings/ajax/deletekeys.php deleted file mode 100644 index 2192eb8c72..0000000000 --- a/settings/ajax/deletekeys.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @author Morris Jobke - * @author Robin Appelman - * - * @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 - * - */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); - -$l = \OC::$server->getL10N('settings'); - -$util = new \OCA\Files_Encryption\Util(new \OC\Files\View(), \OC_User::getUser()); -$result = $util->deleteBackup('decryptAll'); - -if ($result) { - \OCP\JSON::success(array('data' => array('message' => $l->t('Encryption keys deleted permanently')))); -} else { - \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t permanently delete your encryption keys, please check your owncloud.log or ask your administrator')))); -} diff --git a/settings/ajax/restorekeys.php b/settings/ajax/restorekeys.php deleted file mode 100644 index 52c02b3aba..0000000000 --- a/settings/ajax/restorekeys.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @author Morris Jobke - * @author Robin Appelman - * - * @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 - * - */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); - -$l = \OC::$server->getL10N('settings'); - -$util = new \OCA\Files_Encryption\Util(new \OC\Files\View(), \OC_User::getUser()); -$result = $util->restoreBackup('decryptAll'); - -if ($result) { - \OCP\JSON::success(array('data' => array('message' => $l->t('Backups restored successfully')))); -} else { - \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t restore your encryption keys, please check your owncloud.log or ask your administrator')))); -} diff --git a/settings/js/personal.js b/settings/js/personal.js index 30d7f5e938..a847a1ee3a 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -230,40 +230,6 @@ $(document).ready(function () { return false; }); - $('button:button[name="submitDecryptAll"]').click(function () { - var privateKeyPassword = $('#decryptAll input:password[id="privateKeyPassword"]').val(); - $('#decryptAll button:button[name="submitDecryptAll"]').prop("disabled", true); - $('#decryptAll input:password[name="privateKeyPassword"]').prop("disabled", true); - OC.Encryption.decryptAll(privateKeyPassword); - }); - - - $('button:button[name="submitRestoreKeys"]').click(function () { - $('#restoreBackupKeys button:button[name="submitDeleteKeys"]').prop("disabled", true); - $('#restoreBackupKeys button:button[name="submitRestoreKeys"]').prop("disabled", true); - OC.Encryption.restoreKeys(); - }); - - $('button:button[name="submitDeleteKeys"]').click(function () { - $('#restoreBackupKeys button:button[name="submitDeleteKeys"]').prop("disabled", true); - $('#restoreBackupKeys button:button[name="submitRestoreKeys"]').prop("disabled", true); - OC.Encryption.deleteKeys(); - }); - - $('#decryptAll input:password[name="privateKeyPassword"]').keyup(function (event) { - var privateKeyPassword = $('#decryptAll input:password[id="privateKeyPassword"]').val(); - if (privateKeyPassword !== '') { - $('#decryptAll button:button[name="submitDecryptAll"]').prop("disabled", false); - if (event.which === 13) { - $('#decryptAll button:button[name="submitDecryptAll"]').prop("disabled", true); - $('#decryptAll input:password[name="privateKeyPassword"]').prop("disabled", true); - OC.Encryption.decryptAll(privateKeyPassword); - } - } else { - $('#decryptAll button:button[name="submitDecryptAll"]').prop("disabled", true); - } - }); - var uploadparms = { done: function (e, data) { avatarResponseHandler(data.result); @@ -380,47 +346,6 @@ $(document).ready(function () { }); OC.Encryption = { - decryptAll: function (password) { - var message = t('settings', 'Decrypting files... Please wait, this can take some time.'); - OC.Encryption.msg.start('#decryptAll .msg', message); - $.post('ajax/decryptall.php', {password: password}, function (data) { - if (data.status === "error") { - OC.Encryption.msg.finished('#decryptAll .msg', data); - $('#decryptAll input:password[name="privateKeyPassword"]').prop("disabled", false); - } else { - OC.Encryption.msg.finished('#decryptAll .msg', data); - } - $('#restoreBackupKeys').removeClass('hidden'); - }); - }, - - deleteKeys: function () { - var message = t('settings', 'Delete encryption keys permanently.'); - OC.Encryption.msg.start('#restoreBackupKeys .msg', message); - $.post('ajax/deletekeys.php', null, function (data) { - if (data.status === "error") { - OC.Encryption.msg.finished('#restoreBackupKeys .msg', data); - $('#restoreBackupKeys button:button[name="submitDeleteKeys"]').prop("disabled", false); - $('#restoreBackupKeys button:button[name="submitRestoreKeys"]').prop("disabled", false); - } else { - OC.Encryption.msg.finished('#restoreBackupKeys .msg', data); - } - }); - }, - - restoreKeys: function () { - var message = t('settings', 'Restore encryption keys.'); - OC.Encryption.msg.start('#restoreBackupKeys .msg', message); - $.post('ajax/restorekeys.php', {}, function (data) { - if (data.status === "error") { - OC.Encryption.msg.finished('#restoreBackupKeys .msg', data); - $('#restoreBackupKeys button:button[name="submitDeleteKeys"]').prop("disabled", false); - $('#restoreBackupKeys button:button[name="submitRestoreKeys"]').prop("disabled", false); - } else { - OC.Encryption.msg.finished('#restoreBackupKeys .msg', data); - } - }); - } }; OC.Encryption.msg = { diff --git a/settings/personal.php b/settings/personal.php index e4d278d4f2..12b320ac00 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -59,11 +59,6 @@ $email=$config->getUserValue(OC_User::getUser(), 'settings', 'email', ''); $userLang=$config->getUserValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() ); $languageCodes=OC_L10N::findAvailableLanguages(); -//check if encryption was enabled in the past -$filesStillEncrypted = OC_Util::encryptedFiles(); -$backupKeysExists = OC_Util::backupKeysExists(); -$enableDecryptAll = $filesStillEncrypted || $backupKeysExists; - // array of common languages $commonlangcodes = array( 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko' @@ -120,9 +115,6 @@ $tmpl->assign('activelanguage', $userLang); $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser())); $tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser())); $tmpl->assign('displayName', OC_User::getDisplayName()); -$tmpl->assign('enableDecryptAll' , $enableDecryptAll); -$tmpl->assign('backupKeysExists' , $backupKeysExists); -$tmpl->assign('filesStillEncrypted' , $filesStillEncrypted); $tmpl->assign('enableAvatars', $config->getSystemValue('enable_avatars', true)); $tmpl->assign('avatarChangeSupported', OC_User::canUserChangeAvatar(OC_User::getUser())); $tmpl->assign('certs', $certificateManager->listCertificates()); @@ -163,9 +155,6 @@ $formsAndMore = array_merge($formsAndMore, $formsMap); // add bottom hardcoded forms from the template $formsAndMore[]= array( 'anchor' => 'ssl-root-certificates', 'section-name' => $l->t('SSL root certificates') ); -if($enableDecryptAll) { - $formsAndMore[]= array( 'anchor' => 'encryption', 'section-name' => $l->t('Encryption') ); -} $tmpl->assign('forms', $formsAndMore); $tmpl->printPage(); diff --git a/settings/routes.php b/settings/routes.php index 5a069e5a1c..af9ac1d8ee 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -89,12 +89,6 @@ $this->create('settings_personal_changepassword', '/settings/personal/changepass ->action('OC\Settings\ChangePassword\Controller', 'changePersonalPassword'); $this->create('settings_ajax_setlanguage', '/settings/ajax/setlanguage.php') ->actionInclude('settings/ajax/setlanguage.php'); -$this->create('settings_ajax_decryptall', '/settings/ajax/decryptall.php') - ->actionInclude('settings/ajax/decryptall.php'); -$this->create('settings_ajax_restorekeys', '/settings/ajax/restorekeys.php') - ->actionInclude('settings/ajax/restorekeys.php'); -$this->create('settings_ajax_deletekeys', '/settings/ajax/deletekeys.php') - ->actionInclude('settings/ajax/deletekeys.php'); $this->create('settings_cert_post', '/settings/ajax/addRootCertificate') ->actionInclude('settings/ajax/addRootCertificate.php'); $this->create('settings_cert_remove', '/settings/ajax/removeRootCertificate') diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 2a0b4bb0dc..dfdc619180 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -242,58 +242,6 @@ if($_['passwordChangeSupported']) { - -
- -

- t( 'Encryption' ) ); ?> -

- - - -
- t( "The encryption app is no longer enabled, please decrypt all your files" )); ?> -

- - -
- - -

-
-
- - -
> - - t( "Your encryption keys are moved to a backup location. If something went wrong you can restore the keys. Only delete them permanently if you are sure that all files are decrypted correctly." )); ?> -

- - - - -

-
- -
- - -
- -

t('Version'));?>

getTitle()); ?>