diff options
author | Thialfihar <thialfihar@gmail.com> | 2010-04-15 16:37:32 +0000 |
---|---|---|
committer | Thialfihar <thialfihar@gmail.com> | 2010-04-15 16:37:32 +0000 |
commit | c212f28c446044acb5fc7ef7487b95b777b39c44 (patch) | |
tree | d6e2c7eaa5a32a728de4d92463f041cedb08489a /src/org/thialfihar/android/apg/DecryptMessageActivity.java | |
parent | acd71a45c09ad6668a03ec74399d8f526ab647e2 (diff) | |
download | open-keychain-c212f28c446044acb5fc7ef7487b95b777b39c44.tar.gz open-keychain-c212f28c446044acb5fc7ef7487b95b777b39c44.tar.bz2 open-keychain-c212f28c446044acb5fc7ef7487b95b777b39c44.zip |
rewrote sign-only code, also finally recognize sign-only emails in the list and allow opening them for verification
Diffstat (limited to 'src/org/thialfihar/android/apg/DecryptMessageActivity.java')
-rw-r--r-- | src/org/thialfihar/android/apg/DecryptMessageActivity.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/org/thialfihar/android/apg/DecryptMessageActivity.java b/src/org/thialfihar/android/apg/DecryptMessageActivity.java index 055c8256c..8b7985c77 100644 --- a/src/org/thialfihar/android/apg/DecryptMessageActivity.java +++ b/src/org/thialfihar/android/apg/DecryptMessageActivity.java @@ -63,6 +63,7 @@ public class DecryptMessageActivity extends Activity private String mReplyTo = null; private String mSubject = null; + private boolean mSignedOnly = false; private ProgressDialog mProgressDialog = null; private Thread mRunningThread = null; @@ -193,6 +194,15 @@ public class DecryptMessageActivity extends Activity // replace non breakable spaces data = data.replaceAll("\\xa0", " "); mMessage.setText(data); + } else { + matcher = Apg.PGP_SIGNED_MESSAGE.matcher(data); + if (matcher.matches()) { + data = matcher.group(1); + // replace non breakable spaces + data = data.replaceAll("\\xa0", " "); + mMessage.setText(data); + mDecryptButton.setText(R.string.btn_verify); + } } } mReplyTo = intent.getExtras().getString("replyTo"); @@ -266,8 +276,18 @@ public class DecryptMessageActivity extends Activity private void decryptClicked() { String error = null; + String messageData = mMessage.getText().toString(); + Matcher matcher = Apg.PGP_SIGNED_MESSAGE.matcher(messageData); + if (matcher.matches()) { + mSignedOnly = true; + decryptStart(); + return; + } + + // else treat it as an encrypted message + mSignedOnly = false; ByteArrayInputStream in = - new ByteArrayInputStream(mMessage.getText().toString().getBytes()); + new ByteArrayInputStream(messageData.getBytes()); try { mDecryptionKeyId = Apg.getDecryptionKeyId(in); showDialog(AskForSecretKeyPassPhrase.DIALOG_PASS_PHRASE); @@ -320,7 +340,11 @@ public class DecryptMessageActivity extends Activity ByteArrayOutputStream out = new ByteArrayOutputStream(); try { - data = Apg.decrypt(in, out, Apg.getPassPhrase(), this); + if (mSignedOnly) { + data = Apg.verifyText(in, out, this); + } else { + data = Apg.decrypt(in, out, Apg.getPassPhrase(), this); + } } catch (PGPException e) { error = e.getMessage(); } catch (IOException e) { |