aboutsummaryrefslogtreecommitdiffstats
path: root/libraries
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-02-15 01:06:03 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-02-15 01:06:03 +0100
commit494a5fa414fe5962bdee0d50e761da9dc0cc1cc7 (patch)
treeb15206c948f9a3ce20f67deb2e13b5c2aa9b8a18 /libraries
parent21ba41edaec7eb942e0ebe004874a763b9afa638 (diff)
downloadopen-keychain-494a5fa414fe5962bdee0d50e761da9dc0cc1cc7.tar.gz
open-keychain-494a5fa414fe5962bdee0d50e761da9dc0cc1cc7.tar.bz2
open-keychain-494a5fa414fe5962bdee0d50e761da9dc0cc1cc7.zip
private request codes, pass params through methods and pending intents, getKeyIds method
Diffstat (limited to 'libraries')
-rw-r--r--libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl11
-rw-r--r--libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java83
-rw-r--r--libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java4
3 files changed, 60 insertions, 38 deletions
diff --git a/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl b/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl
index ced1df026..2d22f8f2d 100644
--- a/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl
+++ b/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl
@@ -64,4 +64,15 @@ interface IOpenPgpService {
*/
Bundle decryptAndVerify(in Bundle params, in ParcelFileDescriptor input, in ParcelFileDescriptor output);
+ /**
+ * Retrieves key ids based on given user ids (=emails)
+ *
+ * params:
+ * String[] user_ids
+ *
+ * result:
+ * long[] key_ids
+ */
+ Bundle getKeyIds(in Bundle params);
+
} \ No newline at end of file
diff --git a/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java b/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
index adb187c04..5f67ddf88 100644
--- a/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
+++ b/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
@@ -35,6 +35,7 @@ public class OpenPgpApi {
private static final int OPERATION_ENCRYPT = 1;
private static final int OPERATION_SIGN_ENCRYPT = 2;
private static final int OPERATION_DECRYPT_VERIFY = 3;
+ private static final int OPERATION_GET_KEY_IDS = 4;
public OpenPgpApi(IOpenPgpService service) {
this.mService = service;
@@ -88,6 +89,10 @@ public class OpenPgpApi {
executeApiAsync(OPERATION_DECRYPT_VERIFY, params, is, os, callback);
}
+ public Bundle getKeyIds(Bundle params) {
+ return executeApi(OPERATION_GET_KEY_IDS, params, null, null);
+ }
+
public interface IOpenPgpCallback {
void onReturn(final Bundle result);
}
@@ -124,24 +129,6 @@ public class OpenPgpApi {
private Bundle executeApi(int operationId, Bundle params, InputStream is, OutputStream os) {
try {
- // send the input and output pfds
- ParcelFileDescriptor input = ParcelFileDescriptorUtil.pipeFrom(is,
- new ParcelFileDescriptorUtil.IThreadListener() {
-
- @Override
- public void onThreadFinished(Thread thread) {
- Log.d(OpenPgpConstants.TAG, "Copy to service finished");
- }
- });
- ParcelFileDescriptor output = ParcelFileDescriptorUtil.pipeTo(os,
- new ParcelFileDescriptorUtil.IThreadListener() {
-
- @Override
- public void onThreadFinished(Thread thread) {
- Log.d(OpenPgpConstants.TAG, "Service finished writing!");
- }
- });
-
params.putInt(OpenPgpConstants.PARAMS_API_VERSION, OpenPgpConstants.API_VERSION);
// default result is error
@@ -150,25 +137,49 @@ public class OpenPgpApi {
result.putParcelable(OpenPgpConstants.RESULT_ERRORS,
new OpenPgpError(OpenPgpError.GENERIC_ERROR, "This should never happen!"));
- // blocks until result is ready
- switch (operationId) {
- case OPERATION_SIGN:
- result = mService.sign(params, input, output);
- break;
- case OPERATION_ENCRYPT:
- result = mService.encrypt(params, input, output);
- break;
- case OPERATION_SIGN_ENCRYPT:
- result = mService.signAndEncrypt(params, input, output);
- break;
- case OPERATION_DECRYPT_VERIFY:
- result = mService.decryptAndVerify(params, input, output);
- break;
+ if (operationId == OPERATION_GET_KEY_IDS) {
+ result = mService.getKeyIds(params);
+ return result;
+ } else {
+ // send the input and output pfds
+ ParcelFileDescriptor input = ParcelFileDescriptorUtil.pipeFrom(is,
+ new ParcelFileDescriptorUtil.IThreadListener() {
+
+ @Override
+ public void onThreadFinished(Thread thread) {
+ Log.d(OpenPgpConstants.TAG, "Copy to service finished");
+ }
+ });
+ ParcelFileDescriptor output = ParcelFileDescriptorUtil.pipeTo(os,
+ new ParcelFileDescriptorUtil.IThreadListener() {
+
+ @Override
+ public void onThreadFinished(Thread thread) {
+ Log.d(OpenPgpConstants.TAG, "Service finished writing!");
+ }
+ });
+
+
+ // blocks until result is ready
+ switch (operationId) {
+ case OPERATION_SIGN:
+ result = mService.sign(params, input, output);
+ break;
+ case OPERATION_ENCRYPT:
+ result = mService.encrypt(params, input, output);
+ break;
+ case OPERATION_SIGN_ENCRYPT:
+ result = mService.signAndEncrypt(params, input, output);
+ break;
+ case OPERATION_DECRYPT_VERIFY:
+ result = mService.decryptAndVerify(params, input, output);
+ break;
+ }
+ // close() is required to halt the TransferThread
+ output.close();
+
+ return result;
}
- // close() is required to halt the TransferThread
- output.close();
-
- return result;
} catch (Exception e) {
Log.e(OpenPgpConstants.TAG, "Exception", e);
Bundle result = new Bundle();
diff --git a/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java b/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java
index 20f8c36f3..75d4b8c18 100644
--- a/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java
+++ b/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java
@@ -87,12 +87,12 @@ public class ParcelFileDescriptorUtil {
try {
mIn.close();
} catch (IOException e) {
- e.printStackTrace();
+ Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
}
try {
mOut.close();
} catch (IOException e) {
- e.printStackTrace();
+ Log.e(OpenPgpConstants.TAG, "TransferThread" + getId(), e);
}
}
if (mListener != null) {