diff options
Diffstat (limited to 'apps/encryption/lib/crypto/encryption.php')
-rw-r--r-- | apps/encryption/lib/crypto/encryption.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index 4e181b0712a..29fda09e87f 100644 --- a/apps/encryption/lib/crypto/encryption.php +++ b/apps/encryption/lib/crypto/encryption.php @@ -25,6 +25,7 @@ namespace OCA\Encryption\Crypto; +use OCA\Encryption\Exceptions\PublicKeyMissingException; use OCA\Encryption\Util; use OCP\Encryption\IEncryptionModule; use OCA\Encryption\KeyManager; @@ -67,6 +68,7 @@ class Encryption implements IEncryptionModule { /** @var Util */ private $util; + /** @var ILogger */ private $logger; @@ -161,6 +163,9 @@ class Encryption implements IEncryptionModule { * @param string $path to the file * @return string remained data which should be written to the file in case * of a write operation + * @throws PublicKeyMissingException + * @throws \Exception + * @throws \OCA\Encryption\Exceptions\MultiKeyEncryptException */ public function end($path) { $result = ''; @@ -171,7 +176,18 @@ class Encryption implements IEncryptionModule { } $publicKeys = array(); foreach ($this->accessList['users'] as $uid) { - $publicKeys[$uid] = $this->keyManager->getPublicKey($uid); + try { + $publicKeys[$uid] = $this->keyManager->getPublicKey($uid); + } catch (PublicKeyMissingException $e) { + $this->logger->warning( + 'no public key found for user "{uid}", user will not be able to read the file', + ['app' => 'encryption', 'uid' => $uid] + ); + // if the public key of the owner is missing we should fail + if ($uid === $this->user) { + throw $e; + } + } } $publicKeys = $this->keyManager->addSystemKeys($this->accessList, $publicKeys); |