summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-05-28 14:55:42 +0200
committerRobin Appelman <icewind@owncloud.com>2013-05-28 14:55:42 +0200
commitcc0cf931365d0c515038015bc7792f8500fafcc3 (patch)
treeda17b2d05344140b040fd4c55a3851cdd08154c0 /apps
parent9c99048429ff4bf0db742e58931c245d03efb060 (diff)
parent1d720099c328fe3084e05fe3d2bdd9e49acb8dfe (diff)
downloadnextcloud-server-cc0cf931365d0c515038015bc7792f8500fafcc3.tar.gz
nextcloud-server-cc0cf931365d0c515038015bc7792f8500fafcc3.zip
merge master into sessionclass
Diffstat (limited to 'apps')
-rw-r--r--apps/files/l10n/zh_TW.php1
-rw-r--r--apps/files_encryption/l10n/zh_TW.php14
-rwxr-xr-xapps/files_encryption/lib/helper.php16
-rw-r--r--apps/files_encryption/lib/session.php48
-rw-r--r--apps/files_encryption/lib/util.php6
5 files changed, 70 insertions, 15 deletions
diff --git a/apps/files/l10n/zh_TW.php b/apps/files/l10n/zh_TW.php
index 600048a321c..0bd207888dc 100644
--- a/apps/files/l10n/zh_TW.php
+++ b/apps/files/l10n/zh_TW.php
@@ -46,6 +46,7 @@
"{count} folders" => "{count} 個資料夾",
"1 file" => "1 個檔案",
"{count} files" => "{count} 個檔案",
+"Invalid folder name. Usage of 'Shared' is reserved by ownCloud" => "無效的資料夾名稱,'Shared' 的使用被 ownCloud 保留",
"Unable to rename file" => "無法重新命名檔案",
"Upload" => "上傳",
"File handling" => "檔案處理",
diff --git a/apps/files_encryption/l10n/zh_TW.php b/apps/files_encryption/l10n/zh_TW.php
index 2bfadce8553..a0b69bd9fc4 100644
--- a/apps/files_encryption/l10n/zh_TW.php
+++ b/apps/files_encryption/l10n/zh_TW.php
@@ -1,4 +1,16 @@
<?php $TRANSLATIONS = array(
+"Recovery key successfully " => "成功還原金鑰",
+"Could not " => "無法",
+"Password successfully changed." => "成功變更密碼。",
+"Could not change the password. Maybe the old password was not correct." => "無法變更密碼,或許是輸入的舊密碼不正確。",
"Saving..." => "儲存中...",
-"Encryption" => "加密"
+"Encryption" => "加密",
+"Enabled" => "已啓用",
+"Disabled" => "已停用",
+"Change encryption passwords recovery key:" => "變更加密密碼還原金鑰:",
+"Change Password" => "變更密碼",
+"Enable password recovery by sharing all files with your administrator:" => "與管理員分享所有檔案以啓用密碼還原功能:",
+"Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" => "啓用此選項允許您未來遺失密碼時重新取得已加密的檔案",
+"File recovery settings updated" => "檔案還原設定已更新",
+"Could not update file recovery" => "無法更新檔案還原設定"
);
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index 7a2d19eed57..3867a368a9a 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -173,4 +173,20 @@ class Helper
return $return;
}
+
+
+ /**
+ * @brief checks if access is public/anonymous user
+ * @return bool
+ */
+ public static function isPublicAccess() {
+ if (\OCP\USER::getUser() === false
+ || (isset($_GET['service']) && $_GET['service'] == 'files'
+ && isset($_GET['t']))
+ ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
} \ No newline at end of file
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index 30cb7b0e1b3..34913039b0c 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -83,17 +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 );
+ $this->setPublicSharePrivateKey( $privateKey );
\OC_FileProxy::$enabled = $proxyStatus;
}
@@ -103,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 ) {
@@ -113,24 +112,53 @@ 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() {
- 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 (!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 {
+ \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;
}
}
+
/**
* @brief Sets user legacy key to session
* @param $legacyKey
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 4171b7cae50..48485cf2e86 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -127,13 +127,11 @@ class Util {
$this->recoveryKeyId = \OC_Appconfig::getValue('files_encryption', 'recoveryKeyId');
// if we are anonymous/public
- if ($this->userId === false
- || (isset($_GET['service']) && $_GET['service'] == 'files' && isset($_GET['t']))
- ) {
+ if (\OCA\Encryption\Helper::isPublicAccess()) {
$this->userId = $this->publicShareKeyId;
// only handle for files_sharing app
- if ($GLOBALS['app'] === 'files_sharing') {
+ if (isset($GLOBALS['app']) && $GLOBALS['app'] === 'files_sharing') {
$this->userDir = '/' . $GLOBALS['fileOwner'];
$this->fileFolderName = 'files';
$this->userFilesDir = '/' . $GLOBALS['fileOwner'] . '/'