diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-02-14 17:01:17 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-02-14 17:01:17 +0100 |
commit | d6953745810bd4c6dee3bfefb538236b2b7bdbb9 (patch) | |
tree | 9469b7280846e9b164a6c64cf6e3a7f9da83ed9e /OpenPGP-Keychain-API | |
parent | acad2ba95723a940467e89a07e91498188a88745 (diff) | |
download | open-keychain-d6953745810bd4c6dee3bfefb538236b2b7bdbb9.tar.gz open-keychain-d6953745810bd4c6dee3bfefb538236b2b7bdbb9.tar.bz2 open-keychain-d6953745810bd4c6dee3bfefb538236b2b7bdbb9.zip |
conversion of other methods
Diffstat (limited to 'OpenPGP-Keychain-API')
10 files changed, 195 insertions, 417 deletions
diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java index 39843eb82..a7060abb2 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java +++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java @@ -25,11 +25,11 @@ import android.content.IntentSender; import android.content.pm.ResolveInfo; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.v4.app.TaskStackBuilder; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.Button; import android.widget.EditText; import android.widget.ListAdapter; import android.widget.TextView; @@ -54,13 +54,17 @@ public class OpenPgpProviderActivity extends Activity { EditText mMessage; EditText mCiphertext; EditText mEncryptUserIds; + Button mSign; + Button mEncrypt; + Button mSignAndEncrypt; + Button mDecryptAndVerify; private OpenPgpServiceConnection mCryptoServiceConnection; public static final int REQUEST_CODE_SIGN = 9910; public static final int REQUEST_CODE_ENCRYPT = 9911; - public static final int REQUEST_CODE_SIGN_AND_ENC = 9912; - public static final int REQUEST_CODE_DECRYPT = 9913; + public static final int REQUEST_CODE_SIGN_AND_ENCRYPT = 9912; + public static final int REQUEST_CODE_DECRYPT_AND_VERIFY = 9913; @Override public void onCreate(Bundle icicle) { @@ -73,127 +77,38 @@ public class OpenPgpProviderActivity extends Activity { mCiphertext = (EditText) findViewById(R.id.crypto_provider_demo_ciphertext); mEncryptUserIds = (EditText) findViewById(R.id.crypto_provider_demo_encrypt_user_id); + mSign = (Button) findViewById(R.id.crypto_provider_demo_sign); + mEncrypt = (Button) findViewById(R.id.crypto_provider_demo_encrypt); + mSignAndEncrypt = (Button) findViewById(R.id.crypto_provider_demo_sign_and_encrypt); + mDecryptAndVerify = (Button) findViewById(R.id.crypto_provider_demo_decrypt_and_verify); + mSign.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sign(new Bundle()); + } + }); + mEncrypt.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encrypt(new Bundle()); + } + }); + mSignAndEncrypt.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + signAndEncrypt(new Bundle()); + } + }); + mDecryptAndVerify.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + decryptAndVerify(new Bundle()); + } + }); + selectCryptoProvider(); } -// /** -// * Callback from remote openpgp service -// */ -// final IOpenPgpKeyIdsCallback.Stub getKeysEncryptCallback = new IOpenPgpKeyIdsCallback.Stub() { -// -// @Override -// public void onSuccess(final long[] keyIds) throws RemoteException { -// Log.d(Constants.TAG, "getKeysEncryptCallback keyId " + keyIds[0]); -// mActivity.runOnUiThread(new Runnable() { -// -// @Override -// public void run() { -// // encrypt after getting key ids -// String inputStr = mMessage.getText().toString(); -// OpenPgpData input = new OpenPgpData(inputStr); -// -// Log.d(Constants.TAG, "getKeysEncryptCallback inputStr " + inputStr); -// -// try { -// mCryptoServiceConnection.getService().encrypt(input, -// new OpenPgpData(OpenPgpData.TYPE_STRING), keyIds, encryptCallback); -// } catch (RemoteException e) { -// Log.e(Constants.TAG, "CryptoProviderDemo", e); -// } -// } -// }); -// } -// -// @Override -// public void onError(OpenPgpError error) throws RemoteException { -// handleError(error); -// } -// -// }; -// -// final IOpenPgpKeyIdsCallback.Stub getKeysSignAndEncryptCallback = new IOpenPgpKeyIdsCallback.Stub() { -// -// @Override -// public void onSuccess(final long[] keyIds) throws RemoteException { -// Log.d(Constants.TAG, "getKeysSignAndEncryptCallback keyId " + keyIds[0]); -// -// mActivity.runOnUiThread(new Runnable() { -// -// @Override -// public void run() { -// // encrypt after getting key ids -// String inputStr = mMessage.getText().toString(); -// OpenPgpData input = new OpenPgpData(inputStr); -// -// try { -// mCryptoServiceConnection.getService().signAndEncrypt(input, -// new OpenPgpData(OpenPgpData.TYPE_STRING), keyIds, encryptCallback); -// } catch (RemoteException e) { -// Log.e(Constants.TAG, "CryptoProviderDemo", e); -// } -// } -// }); -// } -// -// @Override -// public void onError(OpenPgpError error) throws RemoteException { -// handleError(error); -// } -// -// }; -// -// final IOpenPgpCallback.Stub encryptCallback = new IOpenPgpCallback.Stub() { -// -// @Override -// public void onSuccess(final OpenPgpData output, OpenPgpSignatureResult signatureResult) -// throws RemoteException { -// Log.d(Constants.TAG, "encryptCallback"); -// -// runOnUiThread(new Runnable() { -// -// @Override -// public void run() { -// mCiphertext.setText(output.getString()); -// } -// }); -// } -// -// @Override -// public void onError(OpenPgpError error) throws RemoteException { -// handleError(error); -// } -// -// }; -// -// final IOpenPgpCallback.Stub decryptAndVerifyCallback = new IOpenPgpCallback.Stub() { -// -// @Override -// public void onSuccess(final OpenPgpData output, final OpenPgpSignatureResult signatureResult) -// throws RemoteException { -// Log.d(Constants.TAG, "decryptAndVerifyCallback"); -// -// runOnUiThread(new Runnable() { -// -// @Override -// public void run() { -// mMessage.setText(output.getString()); -// if (signatureResult != null) { -// Toast.makeText(OpenPgpProviderActivity.this, -// "signature result:\n" + signatureResult.toString(), -// Toast.LENGTH_LONG).show(); -// } -// } -// }); -// -// } -// -// @Override -// public void onError(OpenPgpError error) throws RemoteException { -// handleError(error); -// } -// -// }; - private void handleError(final OpenPgpError error) { mActivity.runOnUiThread(new Runnable() { @@ -208,28 +123,30 @@ public class OpenPgpProviderActivity extends Activity { }); } - public void encryptOnClick(View view) { -// try { -// mCryptoServiceConnection.getService().getKeyIds( -// mEncryptUserIds.getText().toString().split(","), true, getKeysEncryptCallback); -// } catch (RemoteException e) { -// Log.e(Constants.TAG, "CryptoProviderDemo", e); -// } - } - - public void signOnClick(View view) { + private InputStream getInputstream(boolean ciphertext) { InputStream is = null; try { - String inputStr = mMessage.getText().toString(); + String inputStr = null; + if (ciphertext) { + inputStr = mCiphertext.getText().toString(); + } else { + inputStr = mMessage.getText().toString(); + } is = new ByteArrayInputStream(inputStr.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { e.printStackTrace(); } + + return is; + } + + + public void sign(Bundle params) { + InputStream is = getInputstream(false); final ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(mCryptoServiceConnection.getService()); - api.sign(new Bundle(), is, os, new OpenPgpApi.IOpenPgpCallback() { + api.sign(params, is, os, new OpenPgpApi.IOpenPgpCallback() { @Override public void onReturn(Bundle result) { switch (result.getInt(OpenPgpConstants.RESULT_CODE)) { @@ -248,52 +165,128 @@ public class OpenPgpProviderActivity extends Activity { PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT); try { OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(), - REQUEST_CODE_SIGN, null, // or new Intent() (in billing) + REQUEST_CODE_SIGN, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } -// try { -// pi.send(OpenPgpProviderActivity.this, 42, null, new PendingIntent.OnFinished() { -// -// @Override -// public void onSendFinished(PendingIntent pendingIntent, Intent intent, int resultCode, String resultData, Bundle resultExtras) { -// Log.d(Constants.TAG, "onSendFinished"); -// Log.d(Constants.TAG, "resultCode: " + resultCode); -// -// } -// }, null); -// } catch (PendingIntent.CanceledException e) { -// e.printStackTrace(); -// } break; } } } }); + } + + public void encrypt(Bundle params) { + params.putStringArray(OpenPgpConstants.PARAMS_USER_IDS, mEncryptUserIds.getText().toString().split(",")); + + InputStream is = getInputstream(false); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + OpenPgpApi api = new OpenPgpApi(mCryptoServiceConnection.getService()); + api.encrypt(params, is, os, new OpenPgpApi.IOpenPgpCallback() { + @Override + public void onReturn(Bundle result) { + switch (result.getInt(OpenPgpConstants.RESULT_CODE)) { + case OpenPgpConstants.RESULT_CODE_SUCCESS: { + try { + Log.d(OpenPgpConstants.TAG, "result: " + os.toByteArray().length + + " str=" + os.toString("UTF-8")); + + mCiphertext.setText(os.toString("UTF-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + break; + } + case OpenPgpConstants.RESULT_CODE_USER_INTERACTION_REQUIRED: { + PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT); + try { + OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(), + REQUEST_CODE_ENCRYPT, null, + 0, 0, 0); + } catch (IntentSender.SendIntentException e) { + e.printStackTrace(); + } + break; + } + } + } + }); } - public void signAndEncryptOnClick(View view) { -// try { -// mCryptoServiceConnection.getService().getKeyIds( -// mEncryptUserIds.getText().toString().split(","), true, -// getKeysSignAndEncryptCallback); -// } catch (RemoteException e) { -// Log.e(Constants.TAG, "CryptoProviderDemo", e); -// } + public void signAndEncrypt(Bundle params) { + params.putStringArray(OpenPgpConstants.PARAMS_USER_IDS, mEncryptUserIds.getText().toString().split(",")); + + InputStream is = getInputstream(false); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + + OpenPgpApi api = new OpenPgpApi(mCryptoServiceConnection.getService()); + api.signAndEncrypt(params, is, os, new OpenPgpApi.IOpenPgpCallback() { + @Override + public void onReturn(Bundle result) { + switch (result.getInt(OpenPgpConstants.RESULT_CODE)) { + case OpenPgpConstants.RESULT_CODE_SUCCESS: { + try { + Log.d(OpenPgpConstants.TAG, "result: " + os.toByteArray().length + + " str=" + os.toString("UTF-8")); + + mCiphertext.setText(os.toString("UTF-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + break; + } + case OpenPgpConstants.RESULT_CODE_USER_INTERACTION_REQUIRED: { + PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT); + try { + OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(), + REQUEST_CODE_SIGN_AND_ENCRYPT, null, + 0, 0, 0); + } catch (IntentSender.SendIntentException e) { + e.printStackTrace(); + } + break; + } + } + } + }); } - public void decryptAndVerifyOnClick(View view) { -// String inputStr = mCiphertext.getText().toString(); -// OpenPgpData input = new OpenPgpData(inputStr); -// -// try { -// mCryptoServiceConnection.getService().decryptAndVerify(input, -// new OpenPgpData(OpenPgpData.TYPE_STRING), decryptAndVerifyCallback); -// } catch (RemoteException e) { -// Log.e(Constants.TAG, "CryptoProviderDemo", e); -// } + public void decryptAndVerify(Bundle params) { + InputStream is = getInputstream(true); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + + OpenPgpApi api = new OpenPgpApi(mCryptoServiceConnection.getService()); + api.decryptAndVerify(params, is, os, new OpenPgpApi.IOpenPgpCallback() { + @Override + public void onReturn(Bundle result) { + switch (result.getInt(OpenPgpConstants.RESULT_CODE)) { + case OpenPgpConstants.RESULT_CODE_SUCCESS: { + try { + Log.d(OpenPgpConstants.TAG, "result: " + os.toByteArray().length + + " str=" + os.toString("UTF-8")); + + mCiphertext.setText(os.toString("UTF-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + break; + } + case OpenPgpConstants.RESULT_CODE_USER_INTERACTION_REQUIRED: { + PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT); + try { + OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(), + REQUEST_CODE_DECRYPT_AND_VERIFY, null, + 0, 0, 0); + } catch (IntentSender.SendIntentException e) { + e.printStackTrace(); + } + break; + } + } + } + }); } @Override @@ -304,8 +297,34 @@ public class OpenPgpProviderActivity extends Activity { case REQUEST_CODE_SIGN: { Log.d(Constants.TAG, "resultCode: " + resultCode); + // try to sign again after password caching + if (resultCode == RESULT_OK) { + sign(new Bundle()); + } + } + case REQUEST_CODE_ENCRYPT: { + Log.d(Constants.TAG, "resultCode: " + resultCode); + + // try to sign again after password caching + if (resultCode == RESULT_OK) { + // use data extras now as params for call (they now include key ids! + encrypt(data.getExtras()); + } + } + case REQUEST_CODE_SIGN_AND_ENCRYPT: { + Log.d(Constants.TAG, "resultCode: " + resultCode); + + // try to sign again after password caching + if (resultCode == RESULT_OK) { + signAndEncrypt(data.getExtras()); + } + } + case REQUEST_CODE_DECRYPT_AND_VERIFY: { + Log.d(Constants.TAG, "resultCode: " + resultCode); + + // try to sign again after password caching if (resultCode == RESULT_OK) { - signOnClick(null); + decryptAndVerify(new Bundle()); } } } diff --git a/OpenPGP-Keychain-API/example-app/src/main/res/layout/crypto_provider_demo.xml b/OpenPGP-Keychain-API/example-app/src/main/res/layout/crypto_provider_demo.xml index 9f2a0e6ee..6647a417b 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/res/layout/crypto_provider_demo.xml +++ b/OpenPGP-Keychain-API/example-app/src/main/res/layout/crypto_provider_demo.xml @@ -54,7 +54,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" - android:onClick="encryptOnClick" android:text="Encrypt" /> <Button @@ -62,14 +61,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" - android:onClick="signOnClick" android:text="Sign" /> <Button - android:id="@+id/crypto_provider_demo_encrypt_and_sign" + android:id="@+id/crypto_provider_demo_sign_and_encrypt" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:onClick="signAndEncryptOnClick" android:text="Sign and Encrypt" /> </LinearLayout> @@ -77,7 +74,6 @@ android:id="@+id/crypto_provider_demo_decrypt_and_verify" android:layout_width="match_parent" android:layout_height="wrap_content" - android:onClick="decryptAndVerifyOnClick" android:text="Decrypt and Verify" /> </LinearLayout>
\ No newline at end of file diff --git a/OpenPGP-Keychain-API/example-app/src/main/res/layout/intent_demo.xml b/OpenPGP-Keychain-API/example-app/src/main/res/layout/intent_demo.xml index a765343f9..ed416a05f 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/res/layout/intent_demo.xml +++ b/OpenPGP-Keychain-API/example-app/src/main/res/layout/intent_demo.xml @@ -12,7 +12,7 @@ android:id="@+id/Button02" android:layout_width="match_parent" android:layout_height="wrap_content" - android:onClick="encryptOnClick" + android:onClick="encrypt" android:text="Encrypt" /> <Button @@ -54,7 +54,7 @@ android:id="@+id/intent_demo_encrypt" android:layout_width="match_parent" android:layout_height="wrap_content" - android:onClick="encryptOnClick" + android:onClick="encrypt" android:text="Encrypt" /> <Button diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpCallback.aidl b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpCallback.aidl deleted file mode 100644 index ba41de1ba..000000000 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpCallback.aidl +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openintents.openpgp; - -import org.openintents.openpgp.OpenPgpData; -import org.openintents.openpgp.OpenPgpSignatureResult; -import org.openintents.openpgp.OpenPgpError; - -interface IOpenPgpCallback { - - /** - * onSuccess returns on successful OpenPGP operations. - * - * @param output - * contains resulting output (decrypted content (when input was encrypted) - * or content without signature (when input was signed-only)) - * @param signatureResult - * signatureResult is only non-null if decryptAndVerify() was called and the content - * was encrypted or signed-and-encrypted. - */ - oneway void onSuccess(in OpenPgpData output, in OpenPgpSignatureResult signatureResult); - - /** - * onError returns on errors or when allowUserInteraction was set to false, but user interaction - * was required execute an OpenPGP operation. - * - * @param error - * See OpenPgpError class for more information. - */ - oneway void onError(in OpenPgpError error); -}
\ No newline at end of file diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpKeyIdsCallback.aidl b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpKeyIdsCallback.aidl deleted file mode 100644 index f9b5fc453..000000000 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpKeyIdsCallback.aidl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openintents.openpgp; - -import org.openintents.openpgp.OpenPgpError; - -interface IOpenPgpKeyIdsCallback { - - /** - * onSuccess returns on successful getKeyIds operations. - * - * @param keyIds - * returned key ids - */ - oneway void onSuccess(in long[] keyIds); - - /** - * onError returns on errors or when allowUserInteraction was set to false, but user interaction - * was required execute an OpenPGP operation. - * - * @param error - * See OpenPgpError class for more information. - */ - oneway void onError(in OpenPgpError error); -}
\ No newline at end of file diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl index 714ca040e..ced1df026 100644 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl +++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl @@ -16,10 +16,6 @@ package org.openintents.openpgp; -import org.openintents.openpgp.OpenPgpData; -import org.openintents.openpgp.IOpenPgpCallback; -import org.openintents.openpgp.IOpenPgpKeyIdsCallback; - interface IOpenPgpService { /** @@ -29,7 +25,7 @@ interface IOpenPgpService { * params: * int api_version (current: 1) * boolean ascii_armor true/false (for output) - * + * String passphrase (for key, optional) * * Bundle return: * int result_code 0,1, or 2 (see OpenPgpConstants) @@ -41,9 +37,6 @@ interface IOpenPgpService { /** * sign only - * - * params: - * String passphrase (optional) */ Bundle sign(in Bundle params, in ParcelFileDescriptor input, in ParcelFileDescriptor output); diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/OpenPgpData.aidl b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/OpenPgpData.aidl deleted file mode 100644 index 3711e4fb4..000000000 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/aidl/org/openintents/openpgp/OpenPgpData.aidl +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openintents.openpgp; - -// Declare OpenPgpData so AIDL can find it and knows that it implements the parcelable protocol. -parcelable OpenPgpData;
\ No newline at end of file diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/OpenPgpData.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/OpenPgpData.java deleted file mode 100644 index 6615c2146..000000000 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/OpenPgpData.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openintents.openpgp; - -import android.net.Uri; -import android.os.Parcel; -import android.os.ParcelFileDescriptor; -import android.os.Parcelable; - -public class OpenPgpData implements Parcelable { - public static final int TYPE_STRING = 0; - public static final int TYPE_BYTE_ARRAY = 1; - public static final int TYPE_FILE_DESCRIPTOR = 2; - public static final int TYPE_URI = 3; - - int type; - - String string; - byte[] bytes = new byte[0]; - ParcelFileDescriptor fileDescriptor; - Uri uri; - - public int getType() { - return type; - } - - public String getString() { - return string; - } - - public byte[] getBytes() { - return bytes; - } - - public ParcelFileDescriptor getFileDescriptor() { - return fileDescriptor; - } - - public Uri getUri() { - return uri; - } - - public OpenPgpData() { - - } - - /** - * Not a real constructor. This can be used to define requested output type. - * - * @param type - */ - public OpenPgpData(int type) { - this.type = type; - } - - public OpenPgpData(String string) { - this.string = string; - this.type = TYPE_STRING; - } - - public OpenPgpData(byte[] bytes) { - this.bytes = bytes; - this.type = TYPE_BYTE_ARRAY; - } - - public OpenPgpData(ParcelFileDescriptor fileDescriptor) { - this.fileDescriptor = fileDescriptor; - this.type = TYPE_FILE_DESCRIPTOR; - } - - public OpenPgpData(Uri uri) { - this.uri = uri; - this.type = TYPE_URI; - } - - public OpenPgpData(OpenPgpData b) { - this.string = b.string; - this.bytes = b.bytes; - this.fileDescriptor = b.fileDescriptor; - this.uri = b.uri; - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(type); - dest.writeString(string); - dest.writeInt(bytes.length); - dest.writeByteArray(bytes); - dest.writeParcelable(fileDescriptor, 0); - dest.writeParcelable(uri, 0); - } - - public static final Creator<OpenPgpData> CREATOR = new Creator<OpenPgpData>() { - public OpenPgpData createFromParcel(final Parcel source) { - OpenPgpData vr = new OpenPgpData(); - vr.type = source.readInt(); - vr.string = source.readString(); - vr.bytes = new byte[source.readInt()]; - source.readByteArray(vr.bytes); - vr.fileDescriptor = source.readParcelable(ParcelFileDescriptor.class.getClassLoader()); - vr.fileDescriptor = source.readParcelable(Uri.class.getClassLoader()); - return vr; - } - - public OpenPgpData[] newArray(final int size) { - return new OpenPgpData[size]; - } - }; - -} diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java index 226eeacc2..16c79ca27 100644 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java +++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java @@ -22,14 +22,14 @@ import android.os.Parcelable; public class OpenPgpSignatureResult implements Parcelable { // generic error on signature verification public static final int SIGNATURE_ERROR = 0; - // successfully verified signature, with trusted public key - public static final int SIGNATURE_SUCCESS_TRUSTED = 1; + // successfully verified signature, with certified public key + public static final int SIGNATURE_SUCCESS_CERTIFIED = 1; // no public key was found for this signature verification // you can retrieve the key with // getKeys(new String[] {String.valueOf(signatureResult.getKeyId)}, true, callback) public static final int SIGNATURE_UNKNOWN_PUB_KEY = 2; - // successfully verified signature, but with untrusted public key - public static final int SIGNATURE_SUCCESS_UNTRUSTED = 3; + // successfully verified signature, but with certified public key + public static final int SIGNATURE_SUCCESS_UNCERTIFIED = 3; int status; boolean signatureOnly; diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java index 1bf3d76a3..64bc92fdd 100644 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java +++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java @@ -30,6 +30,7 @@ public class OpenPgpConstants { // OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53) public static final String PARAMS_REQUEST_ASCII_ARMOR = "ascii_armor"; // (for encrypt method) + public static final String PARAMS_USER_IDS = "user_ids"; public static final String PARAMS_KEY_IDS = "key_ids"; /* Bundle return */ |