summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-11-27 11:46:24 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2013-11-27 11:46:24 +0100
commit7f3b178d7340708ae6593e733552062a60de68d4 (patch)
tree7952196a1001b7a1a32959c0a274d7162614096d
parent49038545f8d658b75865413444aebddedf178dec (diff)
downloadnextcloud-server-7f3b178d7340708ae6593e733552062a60de68d4.tar.gz
nextcloud-server-7f3b178d7340708ae6593e733552062a60de68d4.zip
some small changes according to the review comments
-rwxr-xr-xapps/files_encryption/lib/helper.php11
-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
-rwxr-xr-xapps/files_encryption/tests/crypt.php4
-rw-r--r--apps/files_encryption/tests/keymanager.php2
7 files changed, 19 insertions, 18 deletions
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index a844fc6a398..998c78ec8be 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 (\OCP\USER::getUser() === false) {
+ if (\OCP\User::getUser() === false) {
return true;
} else {
return false;
@@ -252,6 +252,11 @@ class Helper {
return $relPath;
}
+ /**
+ * @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();
@@ -261,7 +266,7 @@ class Helper {
return $user;
}
- // if no user is logged in 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, '/');
@@ -282,7 +287,7 @@ 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
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 4695673a48b..599d718c069 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -113,14 +113,12 @@ class Keymanager {
*
* @param \OC_FilesystemView $view
* @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, $path, $userId, $catfile) {
+ public static function setFileKey(\OC_FilesystemView $view, $path, $catfile) {
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
@@ -179,7 +177,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);
@@ -216,13 +214,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, '/');
@@ -368,7 +365,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 b0b2b62aa1b..7a2fcf7233d 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -201,7 +201,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 4b0156e661e..40b9837b950 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -102,7 +102,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();
@@ -527,7 +527,7 @@ class Stream {
$this->encKeyfiles = Crypt::multiKeyEncrypt($this->plainKey, $publicKeys);
// Save the new encrypted file key
- Keymanager::setFileKey($this->rootView, $this->relPath, $this->keyId, $this->encKeyfiles['data']);
+ Keymanager::setFileKey($this->rootView, $this->relPath, $this->encKeyfiles['data']);
// Save the sharekeys
Keymanager::setShareKeys($this->rootView, $this->relPath, $this->encKeyfiles['keys']);
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index ca9651742f8..4ffc72d1531 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, $filePath, $fileOwner, $multiEncKey['data'])
+ !Keymanager::setFileKey($this->view, $filePath, $multiEncKey['data'])
|| !Keymanager::setShareKeys($this->view, $filePath, $multiEncKey['keys'])
) {
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index 0086371d223..ca14e3e2ccb 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -201,7 +201,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
// Teardown
$this->view->unlink($this->userId . '/files/' . $filename);
- Encryption\Keymanager::deleteFileKey($this->view, $this->userId, $filename);
+ Encryption\Keymanager::deleteFileKey($this->view, $filename);
}
/**
@@ -287,7 +287,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->view->unlink($this->userId . '/files/' . $filename);
- Encryption\Keymanager::deleteFileKey($this->view, $this->userId, $filename);
+ Encryption\Keymanager::deleteFileKey($this->view, $filename);
}
diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php
index ad6bbd3a7e9..a63db7d9074 100644
--- a/apps/files_encryption/tests/keymanager.php
+++ b/apps/files_encryption/tests/keymanager.php
@@ -151,7 +151,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
$this->view->file_put_contents($this->userId . '/files/' . $file, $this->dataShort);
- Encryption\Keymanager::setFileKey($this->view, $file, $this->userId, $key);
+ Encryption\Keymanager::setFileKey($this->view, $file, $key);
$this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/keyfiles/' . $file . '.key'));