--- /dev/null
+<?php
+
+/**
+ * Copyright (c) 2013, Bjoern Schiessle <schiessle@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or later.
+ * See the COPYING-README file.
+ *
+ * @brief Script to change recovery key password
+ *
+ */
+
+use OCA\Encryption;
+
+\OCP\JSON::checkLoggedIn();
+\OCP\JSON::checkAppEnabled('files_encryption');
+\OCP\JSON::callCheck();
+
+$l = OC_L10N::get('core');
+
+$return = false;
+
+$oldPassword = $_POST['oldPassword'];
+$newPassword = $_POST['newPassword'];
+
+$view = new \OC\Files\View('/');
+$session = new \OCA\Encryption\Session($view);
+$user = \OCP\User::getUser();
+
+$proxyStatus = \OC_FileProxy::$enabled;
+\OC_FileProxy::$enabled = false;
+
+$keyPath = '/' . $user . '/files_encryption/'.$user.'.private.key';
+
+$encryptedKey = $view->file_get_contents($keyPath);
+$decryptedKey = \OCA\Encryption\Crypt::decryptPrivateKey($encryptedKey, $oldPassword);
+
+if ($decryptedKey) {
+
+ $encryptedKey = \OCA\Encryption\Crypt::symmetricEncryptFileContent($decryptedKey, $newPassword);
+ $view->file_put_contents($keyPath, $encryptedKey);
+
+ $session->getPrivateKey($decryptedKey);
+
+ $return = true;
+}
+
+\OC_FileProxy::$enabled = $proxyStatus;
+
+// success or failure
+if ($return) {
+ \OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.'))));
+} else {
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Could not update the private key password. Maybe the old password was not correct.'))));
+}
\ No newline at end of file
}
);
+
+ // update private key password
+
+ $('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
+ var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
+ var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
+ if (newPrivateKeyPassword != '' && oldPrivateKeyPassword != '' ) {
+ $('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
+ } else {
+ $('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
+ }
+ });
+
+ $('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
+ var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
+ var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
+ OC.msg.startSaving('#encryption .msg');
+ $.post(
+ OC.filePath( 'files_encryption', 'ajax', 'updatePrivateKeyPassword.php' )
+ , { oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword }
+ , function( data ) {
+ if (data.status == "error") {
+ OC.msg.finishedSaving('#encryption .msg', data);
+ } else {
+ OC.msg.finishedSaving('#encryption .msg', data);
+ }
+ }
+ );
+ });
+
});
\ No newline at end of file
$user = \OCP\USER::getUser();\r
$view = new \OC_FilesystemView('/');\r
$util = new \OCA\Encryption\Util($view, $user);\r
+$session = new \OCA\Encryption\Session($view);\r
+\r
+$privateKeySet = ($session->getPrivateKey() !== false) ? true : false;\r
\r
$recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled');\r
$recoveryEnabledForUser = $util->recoveryEnabledForUser();\r
\r
$tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);\r
$tmpl->assign('recoveryEnabledForUser', $recoveryEnabledForUser);\r
+$tmpl->assign("privateKeySet" , $privateKeySet);\r
\r
return $tmpl->fetchPage();\r
\r
<legend>\r
<?php p( $l->t( 'Encryption' ) ); ?>\r
</legend>\r
+\r
+ <?php if ( ! $_["privateKeySet"] ): ?>\r
+ <p>\r
+ <label for="changePrivateKeyPasswd"><?php p( $l->t( "Your private key password no longer match your log-in password:" ) ); ?></label>\r
+ <br />\r
+ <em><?php p( $l->t( "Set your old private key password to your current log-in password." ) ); ?></em>\r
+ <br />\r
+ <input\r
+ type="password"\r
+ name="changePrivateKeyPassword"\r
+ id="oldPrivateKeyPassword" />\r
+ <label for="oldPrivateKeyPassword"><?php p($l->t( "Old log-in password" )); ?></label>\r
+ <br />\r
+ <input\r
+ type="password"\r
+ name="changePrivateKeyPassword"\r
+ id="newPrivateKeyPassword" />\r
+ <label for="newRecoveryPassword"><?php p($l->t( "Current log-in password" )); ?></label>\r
+ <br />\r
+ <button\r
+ type="button"\r
+ name="submitChangePrivateKeyPassword"\r
+ disabled><?php p($l->t( "Update Private Key Password" )); ?>\r
+ </button>\r
+ <span class="msg"></span>\r
+ </p>\r
+ <?php endif; ?>\r
+\r
+ <br />\r
\r
<?php if ( $_["recoveryEnabled"] ): ?>\r
<p>\r
<div id="recoveryEnabledError"><?php p( $l->t( 'Could not update file recovery' ) ); ?></div>\r
</p>\r
<?php endif; ?>\r
+\r
<br />\r
</fieldset>\r
</form>\r