diff options
Diffstat (limited to 'apps/files_encryption/ajax')
-rw-r--r-- | apps/files_encryption/ajax/adminrecovery.php | 91 | ||||
-rw-r--r-- | apps/files_encryption/ajax/changeRecoveryPassword.php | 92 | ||||
-rw-r--r-- | apps/files_encryption/ajax/getMigrationStatus.php | 44 | ||||
-rw-r--r-- | apps/files_encryption/ajax/updatePrivateKeyPassword.php | 81 | ||||
-rw-r--r-- | apps/files_encryption/ajax/userrecovery.php | 63 |
5 files changed, 0 insertions, 371 deletions
diff --git a/apps/files_encryption/ajax/adminrecovery.php b/apps/files_encryption/ajax/adminrecovery.php deleted file mode 100644 index 1c13df8b885..00000000000 --- a/apps/files_encryption/ajax/adminrecovery.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/** - * @author Björn Schießle <schiessle@owncloud.com> - * @author Florin Peter <github@florin-peter.de> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <icewind@owncloud.com> - * @author Sam Tuke <mail@samtuke.com> - * - * @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/> - * - */ - -use OCA\Files_Encryption\Helper; - -\OCP\JSON::checkAdminUser(); -\OCP\JSON::checkAppEnabled('files_encryption'); -\OCP\JSON::callCheck(); - -$l = \OC::$server->getL10N('files_encryption'); - -$return = false; -$errorMessage = $l->t("Unknown error"); - -//check if both passwords are the same -if (empty($_POST['recoveryPassword'])) { - $errorMessage = $l->t('Missing recovery key password'); - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); - exit(); -} - -if (empty($_POST['confirmPassword'])) { - $errorMessage = $l->t('Please repeat the recovery key password'); - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); - exit(); -} - -if ($_POST['recoveryPassword'] !== $_POST['confirmPassword']) { - $errorMessage = $l->t('Repeated recovery key password does not match the provided recovery key password'); - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); - exit(); -} - -// Enable recoveryAdmin -$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId'); - -if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') { - - $return = Helper::adminEnableRecovery($recoveryKeyId, (string)$_POST['recoveryPassword']); - - // Return success or failure - if ($return) { - $successMessage = $l->t('Recovery key successfully enabled'); - } else { - $errorMessage = $l->t('Could not disable recovery key. Please check your recovery key password!'); - } - -// Disable recoveryAdmin -} elseif ( - isset($_POST['adminEnableRecovery']) - && '0' === $_POST['adminEnableRecovery'] -) { - $return = Helper::adminDisableRecovery((string)$_POST['recoveryPassword']); - - if ($return) { - $successMessage = $l->t('Recovery key successfully disabled'); - } else { - $errorMessage = $l->t('Could not disable recovery key. Please check your recovery key password!'); - } -} - -// Return success or failure -if ($return) { - \OCP\JSON::success(array('data' => array('message' => $successMessage))); -} else { - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); -} diff --git a/apps/files_encryption/ajax/changeRecoveryPassword.php b/apps/files_encryption/ajax/changeRecoveryPassword.php deleted file mode 100644 index 146c0c5c5dc..00000000000 --- a/apps/files_encryption/ajax/changeRecoveryPassword.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php -/** - * @author Björn Schießle <schiessle@owncloud.com> - * @author Christopher Schäpers <kondou@ts.unde.re> - * @author Florin Peter <github@florin-peter.de> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <icewind@owncloud.com> - * - * @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/> - * - */ - -\OCP\JSON::checkAdminUser(); -\OCP\JSON::checkAppEnabled('files_encryption'); -\OCP\JSON::callCheck(); - -$l = \OC::$server->getL10N('core'); - -$return = false; - -$oldPassword = (string)$_POST['oldPassword']; -$newPassword = (string)$_POST['newPassword']; -$confirmPassword = (string)$_POST['confirmPassword']; - -//check if both passwords are the same -if (empty($_POST['oldPassword'])) { - $errorMessage = $l->t('Please provide the old recovery password'); - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); - exit(); -} - -if (empty($_POST['newPassword'])) { - $errorMessage = $l->t('Please provide a new recovery password'); - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); - exit(); -} - -if (empty($_POST['confirmPassword'])) { - $errorMessage = $l->t('Please repeat the new recovery password'); - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); - exit(); -} - -if ($_POST['newPassword'] !== $_POST['confirmPassword']) { - $errorMessage = $l->t('Repeated recovery key password does not match the provided recovery key password'); - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); - exit(); -} - -$view = new \OC\Files\View('/'); -$util = new \OCA\Files_Encryption\Util(new \OC\Files\View('/'), \OCP\User::getUser()); - -$proxyStatus = \OC_FileProxy::$enabled; -\OC_FileProxy::$enabled = false; - -$keyId = $util->getRecoveryKeyId(); - -$encryptedRecoveryKey = \OCA\Files_Encryption\Keymanager::getPrivateSystemKey($keyId); -$decryptedRecoveryKey = $encryptedRecoveryKey ? \OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedRecoveryKey, $oldPassword) : false; - -if ($decryptedRecoveryKey) { - $cipher = \OCA\Files_Encryption\Helper::getCipher(); - $encryptedKey = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($decryptedRecoveryKey, $newPassword, $cipher); - if ($encryptedKey) { - \OCA\Files_Encryption\Keymanager::setPrivateSystemKey($encryptedKey, $keyId); - $return = true; - } -} - -\OC_FileProxy::$enabled = $proxyStatus; - -// success or failure -if ($return) { - \OCP\JSON::success(array('data' => array('message' => $l->t('Password successfully changed.')))); -} else { - \OCP\JSON::error(array('data' => array('message' => $l->t('Could not change the password. Maybe the old password was not correct.')))); -} diff --git a/apps/files_encryption/ajax/getMigrationStatus.php b/apps/files_encryption/ajax/getMigrationStatus.php deleted file mode 100644 index e140a296f32..00000000000 --- a/apps/files_encryption/ajax/getMigrationStatus.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * @author Arthur Schiwon <blizzz@owncloud.com> - * @author Björn Schießle <schiessle@owncloud.com> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @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/> - * - */ - -use OCA\Files_Encryption\Util; - -\OCP\JSON::checkAppEnabled('files_encryption'); - -$loginname = isset($_POST['user']) ? (string)$_POST['user'] : ''; -$password = isset($_POST['password']) ? (string)$_POST['password'] : ''; - -$migrationStatus = Util::MIGRATION_COMPLETED; - -if ($loginname !== '' && $password !== '') { - $username = \OCP\User::checkPassword($loginname, $password); - if ($username) { - $util = new Util(new \OC\Files\View('/'), $username); - $migrationStatus = $util->getMigrationStatus(); - } -} - -\OCP\JSON::success(array('data' => array('migrationStatus' => $migrationStatus))); diff --git a/apps/files_encryption/ajax/updatePrivateKeyPassword.php b/apps/files_encryption/ajax/updatePrivateKeyPassword.php deleted file mode 100644 index e5f2d654348..00000000000 --- a/apps/files_encryption/ajax/updatePrivateKeyPassword.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php -/** - * @author Björn Schießle <schiessle@owncloud.com> - * @author Christopher Schäpers <kondou@ts.unde.re> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <icewind@owncloud.com> - * - * @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/> - * - */ - -\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); - $return = true; - } -} else { - $result = false; - $errorMessage = $l->t('The old password was not correct, please try again.'); -} - -\OC_FileProxy::$enabled = $proxyStatus; - -} else { - $result = false; - $errorMessage = $l->t('The current log-in password was not correct, please try again.'); -} - -// success or failure -if ($return) { - $session->setInitialized(\OCA\Files_Encryption\Session::INIT_SUCCESSFUL); - \OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.')))); -} else { - \OCP\JSON::error(array('data' => array('message' => $errorMessage))); -} diff --git a/apps/files_encryption/ajax/userrecovery.php b/apps/files_encryption/ajax/userrecovery.php deleted file mode 100644 index a1145172f71..00000000000 --- a/apps/files_encryption/ajax/userrecovery.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * @author Björn Schießle <schiessle@owncloud.com> - * @author Florin Peter <github@florin-peter.de> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Sam Tuke <mail@samtuke.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/> - * - */ - -\OCP\JSON::checkLoggedIn(); -\OCP\JSON::checkAppEnabled('files_encryption'); -\OCP\JSON::callCheck(); - -$l = \OC::$server->getL10N('files_encryption'); - -if ( - isset($_POST['userEnableRecovery']) - && (0 == $_POST['userEnableRecovery'] || '1' === $_POST['userEnableRecovery']) -) { - - $userId = \OCP\USER::getUser(); - $view = new \OC\Files\View('/'); - $util = new \OCA\Files_Encryption\Util($view, $userId); - - // Save recovery preference to DB - $return = $util->setRecoveryForUser((string)$_POST['userEnableRecovery']); - - if ($_POST['userEnableRecovery'] === '1') { - $util->addRecoveryKeys(); - } else { - $util->removeRecoveryKeys(); - } - -} else { - - $return = false; - -} - -// Return success or failure -if ($return) { - \OCP\JSON::success(array('data' => array('message' => $l->t('File recovery settings updated')))); -} else { - \OCP\JSON::error(array('data' => array('message' => $l->t('Could not update file recovery')))); -} |