diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java | 43 |
1 files changed, 17 insertions, 26 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 1092fe7b4..3dc6f8a6e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -462,32 +462,23 @@ public class OpenPgpService extends RemoteService { .setDecryptMetadataOnly(decryptMetadataOnly) .setNfcState(nfcDecryptedSessionKey); - DecryptVerifyResult decryptVerifyResult; - try { - // TODO: currently does not support binary signed-only content - decryptVerifyResult = builder.build().execute(); - - // throw exceptions upwards to client with meaningful messages - } catch (PgpDecryptVerify.InvalidDataException e) { - throw new Exception(getString(R.string.error_invalid_data)); - } catch (PgpDecryptVerify.KeyExtractionException e) { - throw new Exception(getString(R.string.error_could_not_extract_private_key)); - } catch (PgpDecryptVerify.WrongPassphraseException e) { - throw new Exception(getString(R.string.error_wrong_passphrase)); - } catch (PgpDecryptVerify.NoSecretKeyException e) { - throw new Exception(getString(R.string.error_no_secret_key_found)); - } catch (PgpDecryptVerify.IntegrityCheckFailedException e) { - throw new Exception(getString(R.string.error_integrity_check_failed)); - } catch (PgpDecryptVerify.NeedNfcDataException e) { - // return PendingIntent to execute NFC activity - return getNfcDecryptIntent(data, e.mPassphrase, e.mEncryptedSessionKey); - } - - if (DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE == decryptVerifyResult.getStatus()) { - // get PendingIntent for passphrase input, add it to given params and return to client - return getPassphraseIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded()); - } else if (DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE == decryptVerifyResult.getStatus()) { - throw new PgpGeneralException("Decryption of symmetric content not supported by API!"); + // TODO: currently does not support binary signed-only content + DecryptVerifyResult decryptVerifyResult = builder.build().execute(); + + if (decryptVerifyResult.isPending()) { + switch (decryptVerifyResult.getResult()) { + case DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE: + return getPassphraseIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded()); + case DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE: + throw new PgpGeneralException( + "Decryption of symmetric content not supported by API!"); + case DecryptVerifyResult.RESULT_PENDING_NFC: + // TODO get passphrase here? currently not in DecryptVerifyResult + return getNfcDecryptIntent( + data, null, decryptVerifyResult.getNfcEncryptedSessionKey()); + } + throw new PgpGeneralException( + "Encountered unhandled type of pending action not supported by API!"); } OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); |