From 0963efc78b7d46b2c92a5e13e0fffb8f67255242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 28 Apr 2014 20:13:46 +0200 Subject: Many API fixes for GET_KEY and GET_KEY_IDS --- .../keychain/pgp/PgpDecryptVerify.java | 6 ---- .../keychain/remote/OpenPgpService.java | 32 ++++++++++++++++------ .../keychain/ui/ViewKeyMainFragment.java | 4 +-- 3 files changed, 25 insertions(+), 17 deletions(-) (limited to 'OpenKeychain/src/main/java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index 8d228ec96..0d005a4ef 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -691,12 +691,6 @@ public class PgpDecryptVerify { if (signature != null) { updateProgress(R.string.progress_verifying_signature, 90, 100); - JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = - new JcaPGPContentVerifierBuilderProvider() - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); - - signature.init(contentVerifierBuilderProvider, signatureKey); - InputStream sigIn = new BufferedInputStream(new ByteArrayInputStream(clearText)); lookAhead = readInputLine(lineOut, sigIn); 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 a44c9a586..9f093ada0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -117,7 +117,7 @@ public class OpenPgpService extends RemoteService { } Intent result = new Intent(); - result.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keyIdsArray); + result.putExtra(OpenPgpApi.RESULT_KEY_IDS, keyIdsArray); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); return result; } @@ -223,7 +223,7 @@ public class OpenPgpService extends RemoteService { Intent result = getKeyIdsFromEmails(data, userIds); if (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0) == OpenPgpApi.RESULT_CODE_SUCCESS) { - keyIds = result.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); + keyIds = result.getLongArrayExtra(OpenPgpApi.RESULT_KEY_IDS); } else { // if not success -> result contains a PendingIntent for user interaction return result; @@ -232,7 +232,8 @@ public class OpenPgpService extends RemoteService { Intent result = new Intent(); result.putExtra(OpenPgpApi.RESULT_ERROR, new OpenPgpError(OpenPgpError.GENERIC_ERROR, - "Missing parameter user_ids or key_ids!")); + "Missing parameter user_ids or key_ids!") + ); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); return result; } @@ -334,7 +335,8 @@ public class OpenPgpService extends RemoteService { OpenPgpService.this, masterKeyId); } }, - inputData, os); + inputData, os + ); builder.allowSymmetricDecryption(false) // no support for symmetric encryption .allowedKeyIds(allowedKeyIds) // allow only private keys associated with // accounts of this app @@ -408,7 +410,7 @@ public class OpenPgpService extends RemoteService { try { long keyId = data.getLongExtra(OpenPgpApi.EXTRA_KEY_ID, 0); - if (mProviderHelper.getPGPPublicKeyRing(keyId) == null) { + if (mProviderHelper.getPGPPublicKeyRingWithKeyId(keyId) == null) { Intent result = new Intent(); // If keys are not in db we return an additional PendingIntent @@ -443,10 +445,22 @@ public class OpenPgpService extends RemoteService { } private Intent getKeyIdsImpl(Intent data) { - // get key ids based on given user ids - String[] userIds = data.getStringArrayExtra(OpenPgpApi.EXTRA_USER_IDS); - Intent result = getKeyIdsFromEmails(data, userIds); - return result; + // if data already contains key ids extra GET_KEY_IDS has been executed again + // after user interaction. Then, we just need to return the array again! + if (data.hasExtra(OpenPgpApi.EXTRA_KEY_IDS)) { + long[] keyIdsArray = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); + + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_KEY_IDS, keyIdsArray); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + return result; + } else { + // get key ids based on given user ids + + String[] userIds = data.getStringArrayExtra(OpenPgpApi.EXTRA_USER_IDS); + Intent result = getKeyIdsFromEmails(data, userIds); + return result; + } } /** diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 5b1ed5866..ef4da3010 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -125,7 +125,7 @@ public class ViewKeyMainFragment extends Fragment implements return; } - getActivity().setProgressBarIndeterminateVisibility(Boolean.TRUE); + getActivity().setProgressBarIndeterminateVisibility(true); mContainer.setVisibility(View.GONE); mDataUri = dataUri; @@ -314,7 +314,7 @@ public class ViewKeyMainFragment extends Fragment implements mKeysAdapter.swapCursor(data); break; } - getActivity().setProgressBarIndeterminateVisibility(Boolean.FALSE); + getActivity().setProgressBarIndeterminateVisibility(false); mContainer.setVisibility(View.VISIBLE); } -- cgit v1.2.3