summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/session.php
diff options
context:
space:
mode:
authorFlorin Peter <github@florin-peter.de>2013-05-28 11:00:49 +0200
committerFlorin Peter <github@florin-peter.de>2013-05-28 11:00:49 +0200
commit09b54ccb2b01c558b1d9ccad1e335492d97b4fe1 (patch)
tree5962c534191376de8457e7d1a345e52210794d26 /apps/files_encryption/lib/session.php
parent3a76c22372654bacb5c33a927779be06baca616e (diff)
parent086c33ef57ddddcad84e9cb21c9e24b5a4c43a5d (diff)
downloadnextcloud-server-09b54ccb2b01c558b1d9ccad1e335492d97b4fe1.tar.gz
nextcloud-server-09b54ccb2b01c558b1d9ccad1e335492d97b4fe1.zip
Merge branch 'master' into remove_unused_vars
Conflicts: apps/files_encryption/lib/session.php apps/files_encryption/lib/util.php
Diffstat (limited to 'apps/files_encryption/lib/session.php')
-rw-r--r--apps/files_encryption/lib/session.php55
1 files changed, 39 insertions, 16 deletions
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index 52dd0b604e9..dbf9a487995 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -83,18 +83,14 @@ class Session {
}
- if (\OCP\USER::getUser() === false
- || (isset($_GET['service']) && $_GET['service'] === 'files'
- && isset($_GET['t']))
- ) {
+ if (\OCA\Encryption\Helper::isPublicAccess()) {
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
- $encryptedKey = $this->view->file_get_contents(
- '/owncloud_private_key/' . $publicShareKeyId . '.private.key');
- $privateKey = Crypt::symmetricDecryptFileContent($encryptedKey, '');
- $this->setPrivateKey($privateKey);
+ $encryptedKey = $this->view->file_get_contents( '/owncloud_private_key/' . $publicShareKeyId . '.private.key' );
+ $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, '' );
+ $this->setPublicSharePrivateKey( $privateKey );
\OC_FileProxy::$enabled = $proxyStatus;
}
@@ -104,6 +100,8 @@ class Session {
* @brief Sets user private key to session
* @param string $privateKey
* @return bool
+ *
+ * @note this should only be set on login
*/
public function setPrivateKey($privateKey) {
@@ -114,27 +112,52 @@ class Session {
}
/**
- * @brief Gets user private key from session
+ * @brief Gets user or public share private key from session
* @returns string $privateKey The user's plaintext private key
*
*/
public function getPrivateKey() {
+ // return the public share private key if this is a public access
+ if (\OCA\Encryption\Helper::isPublicAccess()) {
+ return $this->getPublicSharePrivateKey();
+ } else {
+ if (isset($_SESSION['privateKey']) && !empty($_SESSION['privateKey'])) {
+ return $_SESSION['privateKey'];
+ } else {
+ return false;
+ }
+ }
+ }
- if (
- isset($_SESSION['privateKey'])
- && !empty($_SESSION['privateKey'])
- ) {
+ /**
+ * @brief Sets public user private key to session
+ * @param string $privateKey
+ * @return bool
+ */
+ public function setPublicSharePrivateKey($privateKey) {
- return $_SESSION['privateKey'];
+ $_SESSION['publicSharePrivateKey'] = $privateKey;
- } else {
+ return true;
- return false;
+ }
+ /**
+ * @brief Gets public share private key from session
+ * @returns string $privateKey
+ *
+ */
+ public function getPublicSharePrivateKey() {
+
+ if (isset($_SESSION['publicSharePrivateKey']) && !empty($_SESSION['publicSharePrivateKey'])) {
+ return $_SESSION['publicSharePrivateKey'];
+ } else {
+ return false;
}
}
+
/**
* @brief Sets user legacy key to session
* @param $legacyKey