summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/hooks/hooks.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/hooks/hooks.php')
-rw-r--r--apps/files_encryption/hooks/hooks.php47
1 files changed, 10 insertions, 37 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index b0075a3ada7..c8565964ba9 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -179,7 +179,6 @@ class Hooks {
$view = new \OC_FilesystemView( '/' );
$userId = \OCP\User::getUser();
$util = new Util( $view, $userId );
- $session = new Session();
$shares = \OCP\Share::getUsersSharingFile( $params['fileTarget'], 1 );
@@ -207,55 +206,29 @@ class Hooks {
}
}
-
- $userPubKeys = Keymanager::getPublicKeys( $view, $userIds );
-
- \OC_FileProxy::$enabled = false;
-
- // get the keyfile
- $encKeyfile = Keymanager::getFileKey( $view, $userId, $params['fileTarget'] );
-
- $privateKey = $session->getPrivateKey();
-
- // decrypt the keyfile
- $plainKeyfile = Crypt::keyDecrypt( $encKeyfile, $privateKey );
-
- // re-enc keyfile to sharekeys
- $shareKeys = Crypt::multiKeyEncrypt( $plainKeyfile, $userPubKeys );
-
- // save sharekeys
- if ( ! Keymanager::setShareKeys( $view, $params['fileTarget'], $shareKeys['keys'] ) ) {
-
- trigger_error( "SET Share keys failed" );
-
- }
-
- // Delete existing keyfile
- // Do this last to ensure file is recoverable in case of error
-// Keymanager::deleteFileKey( $view, $userId, $params['fileTarget'] );
-
- \OC_FileProxy::$enabled = true;
-
- return true;
+
+ return Crypt::encKeyfileToMultipleUsers($shares, $params['fileTarget']);
}
/**
* @brief
*/
- public static function preUnshare( $params ) {
-
- // Delete existing catfile
+ public static function postUnshare( $params ) {
+ $shares = \OCP\Share::getUsersSharingFile( $params['fileTarget'], 1 );
- // Generate new catfile and env keys
+ $userIds = array();
+ foreach ( $shares as $share ) {
+ $userIds[] = $share['userId'];
+ }
- // Save env keys to user folders
+ return Crypt::encKeyfileToMultipleUsers($userIDs, $params['fileTarget']);
}
/**
* @brief
*/
- public static function preUnshareAll( $params ) {
+ public static function postUnshareAll( $params ) {
trigger_error( "preUnshareAll" );