aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib')
-rwxr-xr-xapps/files_encryption/lib/helper.php20
-rwxr-xr-xapps/files_encryption/lib/keymanager.php12
-rw-r--r--apps/files_encryption/lib/proxy.php2
-rw-r--r--apps/files_encryption/lib/stream.php4
-rw-r--r--apps/files_encryption/lib/util.php2
5 files changed, 18 insertions, 22 deletions
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index 897b5d46620..17bcac5c585 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -225,7 +225,7 @@ class Helper {
* @return bool
*/
public static function isPublicAccess() {
- if (strpos($_SERVER['HTTP_REFERER'], 'public.php') !== false) {
+ if (\OCP\User::getUser() === false) {
return true;
} else {
return false;
@@ -253,21 +253,21 @@ class Helper {
}
/**
- * @brief get user from the path, because we can't assume that \OCP\User::getUser()
- * will always return the right result
- * @param type $path
- * @return boolean
+ * @brief try to get the user from the path if no user is logged in
+ * @param string $path
+ * @return mixed user or false if we couldn't determine a user
*/
public static function getUser($path) {
$user = \OCP\User::getUser();
- // if we are logged in and if we don't come from a public URL, then we return the userid
- if ($user && strpos($_SERVER['HTTP_REFERER'], 'public.php') === false) {
+
+ // if we are logged in, then we return the userid
+ if ($user) {
return $user;
}
- // ...otherwise we try to access a publically shared files.
+ // if no user is logged in we try to access a publicly shared files.
// In this case we need to try to get the user from the path
$trimmed = ltrim($path, '/');
@@ -288,10 +288,10 @@ class Helper {
}
/**
- * @brief get path to the correspondig file in data/user/files if path points
+ * @brief get path to the corresponding file in data/user/files if path points
* to a version or to a file in cache
* @param string $path path to a version or a file in the trash
- * @return string path to correspondig file relative to data/user/files
+ * @return string path to corresponding file relative to data/user/files
*/
public static function getPathToRealFile($path) {
$trimmed = ltrim($path, '/');
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index b1832b667d6..b2c756894b4 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -114,14 +114,12 @@ class Keymanager {
* @param \OC_FilesystemView $view
* @param \OCA\Encryption\Util $util
* @param string $path relative path of the file, including filename
- * @param $userId
- * @param $catfile
- * @internal param string $key
+ * @param string $catfile keyfile content
* @return bool true/false
* @note The keyfile is not encrypted here. Client code must
* asymmetrically encrypt the keyfile before passing it to this method
*/
- public static function setFileKey(\OC_FilesystemView $view, $util, $path, $userId, $catfile) {
+ public static function setFileKey(\OC_FilesystemView $view, $util, $path, $catfile) {
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
@@ -178,7 +176,7 @@ class Keymanager {
* @note The keyfile returned is asymmetrically encrypted. Decryption
* of the keyfile must be performed by client code
*/
- public static function getFileKey(\OC_FilesystemView $view, $util, $filePath) {
+ public static function getFileKey($view, $util, $filePath) {
list($owner, $filename) = $util->getUidAndFilename($filePath);
@@ -215,13 +213,12 @@ class Keymanager {
* @brief Delete a keyfile
*
* @param \OC_FilesystemView $view
- * @param string $userId username
* @param string $path path of the file the key belongs to
* @return bool Outcome of unlink operation
* @note $path must be relative to data/user/files. e.g. mydoc.txt NOT
* /data/admin/files/mydoc.txt
*/
- public static function deleteFileKey(\OC_FilesystemView $view, $userId, $path) {
+ public static function deleteFileKey(\OC_FilesystemView $view, $path) {
$trimmed = ltrim($path, '/');
@@ -364,7 +361,6 @@ class Keymanager {
* @param string $userId
* @param \OCA\Encryption\Util $util
* @param string $filePath
- * @internal param \OCA\Encryption\file $string name
* @return string file key or false
* @note The sharekey returned is encrypted. Decryption
* of the keyfile must be performed by client code
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 426d92f41de..5ba3bfa784f 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -203,7 +203,7 @@ class Proxy extends \OC_FileProxy {
list($owner, $ownerPath) = $util->getUidAndFilename($relativePath);
// Delete keyfile & shareKey so it isn't orphaned
- if (!Keymanager::deleteFileKey($view, $owner, $ownerPath)) {
+ if (!Keymanager::deleteFileKey($view, $ownerPath)) {
\OCP\Util::writeLog('Encryption library',
'Keyfile or shareKey could not be deleted for file "' . $ownerPath . '"', \OCP\Util::ERROR);
}
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index b22bc726234..7a37d2200a4 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -103,7 +103,7 @@ class Stream {
$util = new Util($this->rootView, $this->userId);
- // get the key ID which we want to use, canm be the users key or the
+ // get the key ID which we want to use, can be the users key or the
// public share key
$this->keyId = $util->getKeyId();
@@ -528,7 +528,7 @@ class Stream {
$this->encKeyfiles = Crypt::multiKeyEncrypt($this->plainKey, $publicKeys);
// Save the new encrypted file key
- Keymanager::setFileKey($this->rootView, $util, $this->relPath, $this->keyId, $this->encKeyfiles['data']);
+ Keymanager::setFileKey($this->rootView, $util, $this->relPath, $this->encKeyfiles['data']);
// Save the sharekeys
Keymanager::setShareKeys($this->rootView, $util, $this->relPath, $this->encKeyfiles['keys']);
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index c84033802cf..33ab3f56965 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1093,7 +1093,7 @@ class Util {
// Save the recrypted key to it's owner's keyfiles directory
// Save new sharekeys to all necessary user directory
if (
- !Keymanager::setFileKey($this->view, $this, $filePath, $fileOwner, $multiEncKey['data'])
+ !Keymanager::setFileKey($this->view, $this, $filePath, $multiEncKey['data'])
|| !Keymanager::setShareKeys($this->view, $this, $filePath, $multiEncKey['keys'])
) {