From 49b4ff63122988dc1587844e6b4b2ee5d0855385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 9 Oct 2014 00:58:07 +0200 Subject: Replace PgpGeneralException with NotFoundException where appropriate --- .../keychain/remote/OpenPgpService.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java') 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..80199d00c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -272,23 +272,24 @@ 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(); + final long sigSubKeyId; + try { + CachedPublicKeyRing signingRing = + new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId()); + sigSubKeyId = signingRing.getSecretSignId(); + } catch (NotFoundException 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; if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) { passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); } else { - try { - 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! - return getCreateAccountIntent(data, getAccountName(data)); - } + passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), + accSettings.getKeyId(), sigSubKeyId); } if (passphrase == null) { // get PendingIntent for passphrase input, add it to given params and return to client -- cgit v1.2.3