aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-10-09 01:37:44 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-10-09 01:37:44 +0200
commit45b02008fba52eaba833009c517afa697d2443f4 (patch)
treedc204f76d6dbd1162e92c3335f322db65249d692 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
parentb3f56c927b47565bdaa7e3b4ea2a8a214aa56652 (diff)
downloadopen-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/remote/OpenPgpService.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
index b650147cf..eb016529d 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -31,6 +31,7 @@ import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
import org.spongycastle.util.encoders.Hex;
+import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.ui.NfcActivity;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
@@ -272,9 +273,16 @@ public class OpenPgpService extends RemoteService {
InputData inputData = new InputData(is, inputLength);
// Find the appropriate subkey to sign with
- CachedPublicKeyRing signingRing =
- new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
- final long sigSubKeyId = signingRing.getSecretSignId();
+ long sigSubKeyId;
+ try {
+ CachedPublicKeyRing signingRing =
+ new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
+ sigSubKeyId = signingRing.getSecretSignId();
+ } catch (PgpKeyNotFoundException e) {
+ // secret key that is set for this account is deleted?
+ // show account config again!
+ return getCreateAccountIntent(data, getAccountName(data));
+ }
// get passphrase from cache, if key has "no" passphrase, this returns an empty String
String passphrase;
@@ -285,8 +293,7 @@ public class OpenPgpService extends RemoteService {
passphrase = PassphraseCacheService.getCachedPassphrase(getContext(),
accSettings.getKeyId(), sigSubKeyId);
} catch (PassphraseCacheService.KeyNotFoundException e) {
- // secret key that is set for this account is deleted?
- // show account config again!
+ // should happen earlier, but return again here if it happens
return getCreateAccountIntent(data, getAccountName(data));
}
}