* @brief Sets user private key to session
* @param string $privateKey
* @return bool
+ *
+ * @note this should only be set on login
*/
- public function setPrivateKey( $privateKey ) {
+ public function setPrivateKey($privateKey) {
$_SESSION['privateKey'] = $privateKey;
*
*/
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;
}
}