aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/crypto/encryption.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-05-04 09:57:19 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-05-04 09:57:19 +0200
commit7376ea9b269af6cd6355ed9bf386097121c10c77 (patch)
tree39bd6ab083e6221c4affb5d2d423e66c24a82cc8 /apps/encryption/lib/crypto/encryption.php
parent870ac88c85ffe20db9708b5a4c69fbe18102f0d6 (diff)
parent4a6808a0f4ea1a441599627fca6679513c93af95 (diff)
downloadnextcloud-server-7376ea9b269af6cd6355ed9bf386097121c10c77.tar.gz
nextcloud-server-7376ea9b269af6cd6355ed9bf386097121c10c77.zip
Merge pull request #15584 from owncloud/enc_fix_upload_shared_folder
skip user if we don't have a public key
Diffstat (limited to 'apps/encryption/lib/crypto/encryption.php')
-rw-r--r--apps/encryption/lib/crypto/encryption.php18
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);