*/
public function getPrivateKey() {
- if ( !is_null( \OC::$session->get('privateKey') ) ) {
+ // 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'];
++ if (!is_null( \OC::$session->get('privateKey') )) {
++ return \OC::$session->get('privateKey');
+ } else {
+ return false;
+ }
+ }
+ }
- return \OC::$session->get('privateKey');
+ /**
+ * @brief Sets public user private key to session
+ * @param string $privateKey
+ * @return bool
+ */
+ public function setPublicSharePrivateKey($privateKey) {
- } else {
- $_SESSION['publicSharePrivateKey'] = $privateKey;
++ \OC::$session->set('publicSharePrivateKey', $privateKey);
- return false;
+ return true;
+
+ }
+ /**
+ * @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;
}
}