diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-09-13 21:32:17 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-09-13 21:32:17 +0200 |
commit | f8677a5f166308e34c0652d9890f4120a6e712aa (patch) | |
tree | d49a860bfbb99ffb27e77ab2842bd8cc4832c183 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java | |
parent | a1323a1a1456ce2b50599d66304178ebddb02efd (diff) | |
parent | 7b08b18d251d4d3df681ea3be2235338c6a07c65 (diff) | |
download | open-keychain-f8677a5f166308e34c0652d9890f4120a6e712aa.tar.gz open-keychain-f8677a5f166308e34c0652d9890f4120a6e712aa.tar.bz2 open-keychain-f8677a5f166308e34c0652d9890f4120a6e712aa.zip |
Merge branch 'result-parcels'
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.java | 45 |
1 files changed, 18 insertions, 27 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 fc8f1c7e4..3dc6f8a6e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -34,7 +34,7 @@ import org.sufficientlysecure.keychain.nfc.NfcActivity; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; +import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpSignEncrypt; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; @@ -462,32 +462,23 @@ public class OpenPgpService extends RemoteService { .setDecryptMetadataOnly(decryptMetadataOnly) .setNfcState(nfcDecryptedSessionKey); - PgpDecryptVerifyResult 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 (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { - // get PendingIntent for passphrase input, add it to given params and return to client - return getPassphraseIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded()); - } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == 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(); |