diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-01 16:36:08 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:30 +0200 |
commit | 664b2bb7af2c8253aa0bbade42531ad4a3ef6bab (patch) | |
tree | 1f6da0f4a10dbc9345a8dd1716986c16c237f3d9 /apps/encryption | |
parent | c9d6ed3d7d04412b721745f61402ff1400c59aeb (diff) | |
download | nextcloud-server-664b2bb7af2c8253aa0bbade42531ad4a3ef6bab.tar.gz nextcloud-server-664b2bb7af2c8253aa0bbade42531ad4a3ef6bab.zip |
cleaning up exception mess
Diffstat (limited to 'apps/encryption')
-rw-r--r-- | apps/encryption/lib/crypto/crypt.php | 2 | ||||
-rw-r--r-- | apps/encryption/lib/exceptions/multikeydecryptexception.php | 4 | ||||
-rw-r--r-- | apps/encryption/lib/exceptions/multikeyencryptexception.php | 4 | ||||
-rw-r--r-- | apps/encryption/lib/exceptions/privatekeymissingexception.php | 14 | ||||
-rw-r--r-- | apps/encryption/lib/exceptions/publickeymissingexception.php | 20 | ||||
-rw-r--r-- | apps/encryption/lib/keymanager.php | 8 | ||||
-rw-r--r-- | apps/encryption/lib/session.php | 2 |
7 files changed, 44 insertions, 10 deletions
diff --git a/apps/encryption/lib/crypto/crypt.php b/apps/encryption/lib/crypto/crypt.php index 6b79057fe7e..80878b3ddb2 100644 --- a/apps/encryption/lib/crypto/crypt.php +++ b/apps/encryption/lib/crypto/crypt.php @@ -24,9 +24,9 @@ namespace OCA\Encryption\Crypto; use OC\Encryption\Exceptions\DecryptionFailedException; use OC\Encryption\Exceptions\EncryptionFailedException; -use OC\Encryption\Exceptions\GenericEncryptionException; use OCA\Encryption\Exceptions\MultiKeyDecryptException; use OCA\Encryption\Exceptions\MultiKeyEncryptException; +use OCP\Encryption\Exceptions\GenericEncryptionException; use OCP\IConfig; use OCP\ILogger; use OCP\IUser; diff --git a/apps/encryption/lib/exceptions/multikeydecryptexception.php b/apps/encryption/lib/exceptions/multikeydecryptexception.php index 36a95544e61..1466d35eda3 100644 --- a/apps/encryption/lib/exceptions/multikeydecryptexception.php +++ b/apps/encryption/lib/exceptions/multikeydecryptexception.php @@ -2,6 +2,8 @@ namespace OCA\Encryption\Exceptions; -class MultiKeyDecryptException extends \Exception { +use OCP\Encryption\Exceptions\GenericEncryptionException; + +class MultiKeyDecryptException extends GenericEncryptionException { } diff --git a/apps/encryption/lib/exceptions/multikeyencryptexception.php b/apps/encryption/lib/exceptions/multikeyencryptexception.php index e518a09d1cc..daf528e2cf7 100644 --- a/apps/encryption/lib/exceptions/multikeyencryptexception.php +++ b/apps/encryption/lib/exceptions/multikeyencryptexception.php @@ -2,6 +2,8 @@ namespace OCA\Encryption\Exceptions; -class MultiKeyEncryptException extends \Exception { +use OCP\Encryption\Exceptions\GenericEncryptionException; + +class MultiKeyEncryptException extends GenericEncryptionException { } diff --git a/apps/encryption/lib/exceptions/privatekeymissingexception.php b/apps/encryption/lib/exceptions/privatekeymissingexception.php index ddc3d11cdbc..50d75870b20 100644 --- a/apps/encryption/lib/exceptions/privatekeymissingexception.php +++ b/apps/encryption/lib/exceptions/privatekeymissingexception.php @@ -19,10 +19,20 @@ * */ - namespace OCA\Encryption\Exceptions; +use OCP\Encryption\Exceptions\GenericEncryptionException; + +class PrivateKeyMissingException extends GenericEncryptionException { -class PrivateKeyMissingException extends \Exception{ + /** + * @param string $userId + */ + public function __construct($userId) { + if(empty($userId)) { + $userId = "<no-user-id-given>"; + } + parent::__construct("Private Key missing for user: $userId"); + } } diff --git a/apps/encryption/lib/exceptions/publickeymissingexception.php b/apps/encryption/lib/exceptions/publickeymissingexception.php new file mode 100644 index 00000000000..9638c28e427 --- /dev/null +++ b/apps/encryption/lib/exceptions/publickeymissingexception.php @@ -0,0 +1,20 @@ +<?php + + +namespace OCA\Encryption\Exceptions; + +use OCP\Encryption\Exceptions\GenericEncryptionException; + +class PublicKeyMissingException extends GenericEncryptionException { + + /** + * @param string $userId + */ + public function __construct($userId) { + if(empty($userId)) { + $userId = "<no-user-id-given>"; + } + parent::__construct("Public Key missing for user: $userId"); + } + +} diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php index c7e0f2617f5..d2659f55a77 100644 --- a/apps/encryption/lib/keymanager.php +++ b/apps/encryption/lib/keymanager.php @@ -4,7 +4,7 @@ namespace OCA\Encryption; use OC\Encryption\Exceptions\DecryptionFailedException; use OCA\Encryption\Exceptions\PrivateKeyMissingException; -use OC\Encryption\Exceptions\PublicKeyMissingException; +use OCA\Encryption\Exceptions\PublicKeyMissingException; use OCA\Encryption\Crypto\Crypt; use OCP\Encryption\Keys\IStorage; use OCP\IConfig; @@ -301,7 +301,7 @@ class KeyManager { if (strlen($privateKey) !== 0) { return $privateKey; } - throw new PrivateKeyMissingException(); + throw new PrivateKeyMissingException($userId); } /** @@ -393,7 +393,7 @@ class KeyManager { if (strlen($publicKey) !== 0) { return $publicKey; } - throw new PublicKeyMissingException(); + throw new PublicKeyMissingException($userId); } public function getPublicShareKeyId() { @@ -496,7 +496,7 @@ class KeyManager { if (!empty($accessList['public'])) { $publicShareKey = $this->getPublicShareKey(); if (empty($publicShareKey)) { - throw new PublicKeyMissingException(); + throw new PublicKeyMissingException($this->getPublicShareKeyId()); } $publicKeys[$this->getPublicShareKeyId()] = $publicShareKey; } diff --git a/apps/encryption/lib/session.php b/apps/encryption/lib/session.php index 5e973913769..82c7829ecbd 100644 --- a/apps/encryption/lib/session.php +++ b/apps/encryption/lib/session.php @@ -70,7 +70,7 @@ class Session { public function getPrivateKey() { $key = $this->session->get('privateKey'); if (is_null($key)) { - throw new Exceptions\PrivateKeyMissingException('no private key stored in session'); + throw new Exceptions\PrivateKeyMissingException('no private key stored in session', 0); } return $key; } |