aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain-API-Demo
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-06-17 19:51:41 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-06-17 19:51:41 +0200
commitd4e054d5f24afeef8859c9294f3ef1b69242b037 (patch)
treeb92709e0e7b32cc768ad8d5c220a0fbb202b4663 /OpenPGP-Keychain-API-Demo
parent0f3e78ebf7d0c71a18fef55e543c5b54a066735b (diff)
downloadopen-keychain-d4e054d5f24afeef8859c9294f3ef1b69242b037.tar.gz
open-keychain-d4e054d5f24afeef8859c9294f3ef1b69242b037.tar.bz2
open-keychain-d4e054d5f24afeef8859c9294f3ef1b69242b037.zip
some fixes all over
Diffstat (limited to 'OpenPGP-Keychain-API-Demo')
-rw-r--r--OpenPGP-Keychain-API-Demo/res/layout/crypto_provider_demo.xml69
-rw-r--r--OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl12
-rw-r--r--OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java54
3 files changed, 96 insertions, 39 deletions
diff --git a/OpenPGP-Keychain-API-Demo/res/layout/crypto_provider_demo.xml b/OpenPGP-Keychain-API-Demo/res/layout/crypto_provider_demo.xml
index ecc2b4ac5..e4c9e1441 100644
--- a/OpenPGP-Keychain-API-Demo/res/layout/crypto_provider_demo.xml
+++ b/OpenPGP-Keychain-API-Demo/res/layout/crypto_provider_demo.xml
@@ -8,12 +8,37 @@
android:layout_height="match_parent"
android:orientation="vertical" >
- <Button
- android:id="@+id/crypto_provider_demo_register"
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Encrypt User Id"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <EditText
+ android:id="@+id/crypto_provider_demo_encrypt_user_id"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="dominik@dominikschuermann.de"
+ android:textAppearance="@android:style/TextAppearance.Small" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Sign User Id"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <EditText
+ android:id="@+id/crypto_provider_demo_sign_user_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:onClick="registerCryptoProvider"
- android:text="Register crypto provider" />
+ android:text="dominik@dominikschuermann.de"
+ android:textAppearance="@android:style/TextAppearance.Small" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Message"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/crypto_provider_demo_message"
@@ -22,25 +47,17 @@
android:text="message"
android:textAppearance="@android:style/TextAppearance.Small" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Ciphertext"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
<EditText
android:id="@+id/crypto_provider_demo_ciphertext"
android:layout_width="match_parent"
android:layout_height="150dip"
- android:text="-----BEGIN PGP MESSAGE-----
-Charset: UTF-8
-Version: GnuPG v1.4.12 (GNU/Linux)
-Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-
-hQEMAwCgOoTtKmfpAQgAlzmyQYCfkalCsAIxwtroHV9Bwz5LWY4GJNVrFBVddSFJ
-VkVxx/UDqtIS+TvL8RBG3Er3xFilTV+iBSDjSGIXHkSv6Z7Od69nKcQpJLNaCpDj
-/Ag7PsINLUzAvUdPto3ZMCwShe/uoD4e4Gr5BG8na/9W77tegufS2gUUlc5BAOZP
-GUlSPySJP2bpI/3U/R86Z2ByzFKeJIEKWBtBvMPmIgA5VPo0+mamTedRhOIrJM/R
-vUMM2HfLjAxcX9lYEw4aQGROOu1xpN9FPojQOO10imibZb+TEcxtSHwpj2vll1BP
-pXvtuR0E9OGVmRI9aBXiRTB2P9SJ6UPpR13m8FaLVtJPAa2xH4wA5Yr6uZ5x7LjO
-BtO8VErKgoUpO57BgU1ZsVFEcrGiobkreXabKIB+qC0qMJ6maoLlnOPi1IAvhU42
-z/7HBqqhcNiHc5JMs9+wmw==
-=00nh
------END PGP MESSAGE-----"
+ android:text="ciphertext"
android:textAppearance="@android:style/TextAppearance.Small" />
<Button
@@ -51,6 +68,20 @@ z/7HBqqhcNiHc5JMs9+wmw==
android:text="Encrypt" />
<Button
+ android:id="@+id/crypto_provider_demo_sign"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="signOnClick"
+ android:text="Sign" />
+
+ <Button
+ android:id="@+id/crypto_provider_demo_encrypt_and_sign"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="encryptAndSignOnClick"
+ android:text="Encrypt and Sign" />
+
+ <Button
android:id="@+id/crypto_provider_demo_decrypt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl b/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl
index 04c8eb30e..53f39dffc 100644
--- a/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl
+++ b/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl
@@ -37,30 +37,30 @@ interface ICryptoService {
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in ICryptoCallback callback);
/**
- * Encrypt and sign
+ * Sign
*
* @param inputBytes
* Byte array you want to encrypt
- * @param encryptionUserIds
- * User Ids (emails) of recipients
* @param signatureUserId
* User Ids (email) of sender
* @param callback
* Callback where to return results
*/
- oneway void encryptAndSign(in byte[] inputBytes, in String[] encryptionUserIds, String signatureUserId, in ICryptoCallback callback);
+ oneway void sign(in byte[] inputBytes, String signatureUserId, in ICryptoCallback callback);
/**
- * Sign
+ * Encrypt and sign
*
* @param inputBytes
* Byte array you want to encrypt
+ * @param encryptionUserIds
+ * User Ids (emails) of recipients
* @param signatureUserId
* User Ids (email) of sender
* @param callback
* Callback where to return results
*/
- oneway void sign(in byte[] inputBytes, String signatureUserId, in ICryptoCallback callback);
+ oneway void encryptAndSign(in byte[] inputBytes, in String[] encryptionUserIds, String signatureUserId, in ICryptoCallback callback);
/**
* Decrypts and verifies given input bytes. If no signature is present this method
diff --git a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java
index 4522110f0..831c269e1 100644
--- a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java
+++ b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java
@@ -39,15 +39,17 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
+import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.TextView;
public class CryptoProviderDemoActivity extends Activity {
Activity mActivity;
- TextView mMessageTextView;
- TextView mCiphertextTextView;
- TextView mDataTextView;
+ EditText mMessage;
+ EditText mCiphertext;
+ EditText mEncryptUserId;
+ EditText mSignUserId;
private CryptoServiceConnection mCryptoServiceConnection;
@@ -58,9 +60,10 @@ public class CryptoProviderDemoActivity extends Activity {
mActivity = this;
- mMessageTextView = (TextView) findViewById(R.id.crypto_provider_demo_message);
- mCiphertextTextView = (TextView) findViewById(R.id.crypto_provider_demo_ciphertext);
- mDataTextView = (TextView) findViewById(R.id.aidl_demo_data);
+ mMessage = (EditText) findViewById(R.id.crypto_provider_demo_message);
+ mCiphertext = (EditText) findViewById(R.id.crypto_provider_demo_ciphertext);
+ mEncryptUserId = (EditText) findViewById(R.id.crypto_provider_demo_encrypt_user_id);
+ mSignUserId = (EditText) findViewById(R.id.crypto_provider_demo_sign_user_id);
selectCryptoProvider();
}
@@ -72,7 +75,9 @@ public class CryptoProviderDemoActivity extends Activity {
@Override
public void onEncryptSignSuccess(byte[] outputBytes) throws RemoteException {
- // not needed here
+ Log.d(Constants.TAG, "onEncryptSignSuccess");
+
+ // TODO
}
@Override
@@ -80,32 +85,53 @@ public class CryptoProviderDemoActivity extends Activity {
throws RemoteException {
Log.d(Constants.TAG, "onDecryptVerifySuccess");
- // PgpData data = new PgpData();
- // data.setDecryptedData(new String(outputBytes));
- // mFragment.setMessageWithPgpData(data);
+ mMessage.setText(new String(outputBytes));
}
@Override
public void onError(CryptoError error) throws RemoteException {
Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId());
- Log.e(Constants.TAG, "onError getErrorId:" + error.getMessage());
+ Log.e(Constants.TAG, "onError getMessage:" + error.getMessage());
}
};
public void encryptOnClick(View view) {
- byte[] inputBytes = mMessageTextView.getText().toString().getBytes();
+ byte[] inputBytes = mMessage.getText().toString().getBytes();
try {
mCryptoServiceConnection.getService().encrypt(inputBytes,
- new String[] { "dominik@dominikschuermann.de" }, callback);
+ new String[] { mEncryptUserId.getText().toString() }, callback);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "CryptoProviderDemo", e);
+ }
+ }
+
+ public void signOnClick(View view) {
+ byte[] inputBytes = mMessage.getText().toString().getBytes();
+
+ try {
+ mCryptoServiceConnection.getService().sign(inputBytes,
+ mSignUserId.getText().toString(), callback);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "CryptoProviderDemo", e);
+ }
+ }
+
+ public void encryptAndSignOnClick(View view) {
+ byte[] inputBytes = mMessage.getText().toString().getBytes();
+
+ try {
+ mCryptoServiceConnection.getService().encryptAndSign(inputBytes,
+ new String[] { mEncryptUserId.getText().toString() },
+ mSignUserId.getText().toString(), callback);
} catch (RemoteException e) {
Log.e(Constants.TAG, "CryptoProviderDemo", e);
}
}
public void decryptOnClick(View view) {
- byte[] inputBytes = mCiphertextTextView.getText().toString().getBytes();
+ byte[] inputBytes = mCiphertext.getText().toString().getBytes();
try {
mCryptoServiceConnection.getService().decryptAndVerify(inputBytes, callback);