diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2022-01-09 15:37:45 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-09 10:07:45 +0000 |
| commit | ccb33af854132f1b35b71393ff68d24850de6960 (patch) | |
| tree | 52e71e7ca560194d863b7c823385271e42eea7d0 /crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt | |
| parent | 6c6ade85a8696142b5fc13df9034f73b4089c912 (diff) | |
| download | HardenedPass-ccb33af854132f1b35b71393ff68d24850de6960.tar.gz HardenedPass-ccb33af854132f1b35b71393ff68d24850de6960.zip | |
Refactor and simplify KeyManager API (#1650)
Diffstat (limited to 'crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt')
| -rw-r--r-- | crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt index 34e64d5f..431cd90c 100644 --- a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt +++ b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoException.kt @@ -2,18 +2,28 @@ package dev.msfjarvis.aps.crypto public sealed class CryptoException(message: String? = null) : Exception(message) -public sealed class KeyPairException(message: String? = null) : CryptoException(message) { - public object PrivateKeyUnavailableException : - KeyPairException("Key object does not have a private sub-key") -} - +/** Sealed exception types for [KeyManager]. */ public sealed class KeyManagerException(message: String? = null) : CryptoException(message) { + + /** Store contains no keys. */ public object NoKeysAvailableException : KeyManagerException("No keys were found") + + /** Key directory does not exist or cannot be accessed. */ public object KeyDirectoryUnavailableException : KeyManagerException("Key directory does not exist") + + /** Failed to delete given key. */ public object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file") + + /** Failed to parse a [Key] as a known type. */ + public object InvalidKeyException : + KeyManagerException("Given key cannot be parsed as a known key type") + + /** No key matching [keyId] could be found. */ public class KeyNotFoundException(keyId: String) : KeyManagerException("No key found with id: $keyId") + + /** Attempting to add another key for [keyId] without requesting a replace. */ public class KeyAlreadyExistsException(keyId: String) : - KeyManagerException("Pre-existing key was found for $keyId but 'replace' is set to false") + KeyManagerException("Pre-existing key was found for $keyId") } |
