summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/keymanager.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-07-08 19:08:41 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-07-08 19:08:41 +0200
commit1e284b15ff07b7a90067c5166ee7f85547095a34 (patch)
treee75b13aba83c0378ebfddd365f801df85ad94e63 /apps/encryption/lib/keymanager.php
parent85c3b9d5cf9fe9c9d884c7a08b0da46e4e585720 (diff)
downloadnextcloud-server-1e284b15ff07b7a90067c5166ee7f85547095a34.tar.gz
nextcloud-server-1e284b15ff07b7a90067c5166ee7f85547095a34.zip
only create new key pair if both keys are missing
Diffstat (limited to 'apps/encryption/lib/keymanager.php')
-rw-r--r--apps/encryption/lib/keymanager.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index 05d23873482..8c8c1f8fd78 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -406,19 +406,36 @@ class KeyManager {
}
/**
- * @param $userId
+ * check if user has a private and a public key
+ *
+ * @param string $userId
* @return bool
+ * @throws PrivateKeyMissingException
+ * @throws PublicKeyMissingException
*/
public function userHasKeys($userId) {
+ $privateKey = $publicKey = true;
+
try {
$this->getPrivateKey($userId);
- $this->getPublicKey($userId);
} catch (PrivateKeyMissingException $e) {
- return false;
+ $privateKey = false;
+ $exception = $e;
+ }
+ try {
+ $this->getPublicKey($userId);
} catch (PublicKeyMissingException $e) {
+ $publicKey = false;
+ $exception = $e;
+ }
+
+ if ($privateKey && $publicKey) {
+ return true;
+ } elseif (!$privateKey && !$publicKey) {
return false;
+ } else {
+ throw $exception;
}
- return true;
}
/**