* @note Where a method requires a view object, it's root must be '/'\r
*/\r
class Keymanager {\r
-\r
- /**\r
- * @brief get uid of the owners of the file and the path to the file\r
- * @param $filename\r
- * @return array\r
- */\r
- public static function getUidAndFilename($filename) {\r
- $uid = \OC\Files\Filesystem::getOwner($filename);\r
-\r
- \OC\Files\Filesystem::initMountPoints($uid);\r
- if ( $uid != \OCP\User::getUser() ) {\r
- $info = \OC\Files\Filesystem::getFileInfo($filename);\r
- $ownerView = new \OC\Files\View('/'.$uid.'/files');\r
- $filename = $ownerView->getPath($info['fileid']);\r
- }\r
- return array($uid, $filename);\r
- }\r
\r
/**\r
* @brief retrieve the ENCRYPTED private key from a user\r
*/\r
public static function setShareKey( \OC_FilesystemView $view, $path, $userId, $shareKey ) {\r
\r
- list($owner, $filename) = self::getUidAndFilename($path);\r
+ $util = new Util( $view, $userId );\r
+\r
+ list($owner, $filename) = $util->getUidAndFilename($path);\r
\r
$basePath = '/' . $owner . '/files_encryption/share-keys';\r
\r
public static function getShareKey( \OC_FilesystemView $view, $userId, $filePath ) {\r
\r
\OC_FileProxy::$enabled = false;\r
- list($owner, $filename) = self::getUidAndFilename($filePath);\r
+\r
+ $util = new Util( $view, $userId );\r
+\r
+ list($owner, $filename) = $util->getUidAndFilename($filePath);\r
\r
$shareKeyPath = '/' . $owner . '/files_encryption/share-keys/' . $filename . '.' . $userId . '.shareKey';\r
if ( $view->file_exists( $shareKeyPath ) ) {\r
return true;
}
+ /**
+ * @brief get uid of the owners of the file and the path to the file
+ * @param $filename
+ * @return array
+ */
+ public function getUidAndFilename($filename) {
+ $uid = \OC\Files\Filesystem::getOwner($filename);
+
+ \OC\Files\Filesystem::initMountPoints($uid);
+ if ( $uid != \OCP\User::getUser() ) {
+ $info = \OC\Files\Filesystem::getFileInfo($filename);
+ $ownerView = new \OC\Files\View('/'.$uid.'/files');
+ $filename = $ownerView->getPath($info['fileid']);
+ }
+ return array($uid, $filename);
+ }
+
}