diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-09 01:37:44 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-09 01:37:44 +0200 |
commit | 45b02008fba52eaba833009c517afa697d2443f4 (patch) | |
tree | dc204f76d6dbd1162e92c3335f322db65249d692 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java | |
parent | b3f56c927b47565bdaa7e3b4ea2a8a214aa56652 (diff) | |
download | open-keychain-45b02008fba52eaba833009c517afa697d2443f4.tar.gz open-keychain-45b02008fba52eaba833009c517afa697d2443f4.tar.bz2 open-keychain-45b02008fba52eaba833009c517afa697d2443f4.zip |
Replace many PgpGeneralExceptions with PgpKeyNotFoundException
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java index 08b7316aa..db0a9b137 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java @@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.pgp; import org.spongycastle.openpgp.PGPKeyRing; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.util.IterableIterator; import java.io.IOException; @@ -56,11 +57,11 @@ public abstract class CanonicalizedKeyRing extends KeyRing { return getRing().getPublicKey().getFingerprint(); } - public String getPrimaryUserId() throws PgpGeneralException { + public String getPrimaryUserId() throws PgpKeyNotFoundException { return getPublicKey().getPrimaryUserId(); } - public String getPrimaryUserIdWithFallback() throws PgpGeneralException { + public String getPrimaryUserIdWithFallback() throws PgpKeyNotFoundException { return getPublicKey().getPrimaryUserIdWithFallback(); } @@ -87,24 +88,24 @@ public abstract class CanonicalizedKeyRing extends KeyRing { return creationDate.after(now) || (expiryDate != null && expiryDate.before(now)); } - public boolean canCertify() throws PgpGeneralException { + public boolean canCertify() throws PgpKeyNotFoundException { return getRing().getPublicKey().isEncryptionKey(); } - public long getEncryptId() throws PgpGeneralException { + public long getEncryptId() throws PgpKeyNotFoundException { for(CanonicalizedPublicKey key : publicKeyIterator()) { if (key.canEncrypt() && key.isValid()) { return key.getKeyId(); } } - throw new PgpGeneralException("No valid encryption key found!"); + throw new PgpKeyNotFoundException("No valid encryption key found!"); } - public boolean hasEncrypt() throws PgpGeneralException { + public boolean hasEncrypt() throws PgpKeyNotFoundException { try { getEncryptId(); return true; - } catch(PgpGeneralException e) { + } catch(PgpKeyNotFoundException e) { return false; } } |