1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00
This commit is contained in:
cketti 2015-02-06 23:12:26 +01:00
parent ee1180e34c
commit b515e947cf

View File

@ -55,7 +55,7 @@ public class MessageCryptoHelper {
private Deque<Part> partsToDecryptOrVerify; private Deque<Part> partsToDecryptOrVerify;
private OpenPgpApi openPgpApi; private OpenPgpApi openPgpApi;
private Part currentlyDecrypringOrVerifyingPart; private Part currentlyDecryptingOrVerifyingPart;
private Intent currentCryptoResult; private Intent currentCryptoResult;
private MessageCryptoAnnotations messageAnnotations; private MessageCryptoAnnotations messageAnnotations;
@ -143,7 +143,7 @@ public class MessageCryptoHelper {
} }
private void decryptOrVerifyPart(Part part) { private void decryptOrVerifyPart(Part part) {
currentlyDecrypringOrVerifyingPart = part; currentlyDecryptingOrVerifyingPart = part;
decryptVerify(new Intent()); decryptVerify(new Intent());
} }
@ -155,9 +155,9 @@ public class MessageCryptoHelper {
intent.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, accountName); intent.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, accountName);
try { try {
if (MessageDecryptVerifier.isPgpMimeSignedPart(currentlyDecrypringOrVerifyingPart)) { if (MessageDecryptVerifier.isPgpMimeSignedPart(currentlyDecryptingOrVerifyingPart)) {
callAsyncDetachedVerify(intent); callAsyncDetachedVerify(intent);
} else if (MessageDecryptVerifier.isPgpInlinePart(currentlyDecrypringOrVerifyingPart)) { } else if (MessageDecryptVerifier.isPgpInlinePart(currentlyDecryptingOrVerifyingPart)) {
callAsyncInlineOperation(intent); callAsyncInlineOperation(intent);
} else { } else {
callAsyncDecrypt(intent); callAsyncDecrypt(intent);
@ -209,7 +209,7 @@ public class MessageCryptoHelper {
private void callAsyncDetachedVerify(Intent intent) throws IOException, MessagingException { private void callAsyncDetachedVerify(Intent intent) throws IOException, MessagingException {
PipedInputStream pipedInputStream = getPipedInputStreamForSignedData(); PipedInputStream pipedInputStream = getPipedInputStreamForSignedData();
byte[] signatureData = MessageDecryptVerifier.getSignatureData(currentlyDecrypringOrVerifyingPart); byte[] signatureData = MessageDecryptVerifier.getSignatureData(currentlyDecryptingOrVerifyingPart);
intent.putExtra(OpenPgpApi.EXTRA_DETACHED_SIGNATURE, signatureData); intent.putExtra(OpenPgpApi.EXTRA_DETACHED_SIGNATURE, signatureData);
openPgpApi.executeApiAsync(intent, pipedInputStream, null, new IOpenPgpCallback() { openPgpApi.executeApiAsync(intent, pipedInputStream, null, new IOpenPgpCallback() {
@ -229,7 +229,7 @@ public class MessageCryptoHelper {
@Override @Override
public void run() { public void run() {
try { try {
Multipart multipartSignedMultipart = (Multipart) currentlyDecrypringOrVerifyingPart.getBody(); Multipart multipartSignedMultipart = (Multipart) currentlyDecryptingOrVerifyingPart.getBody();
BodyPart signatureBodyPart = multipartSignedMultipart.getBodyPart(0); BodyPart signatureBodyPart = multipartSignedMultipart.getBodyPart(0);
Log.d(K9.LOG_TAG, "signed data type: " + signatureBodyPart.getMimeType()); Log.d(K9.LOG_TAG, "signed data type: " + signatureBodyPart.getMimeType());
signatureBodyPart.writeTo(out); signatureBodyPart.writeTo(out);
@ -256,14 +256,14 @@ public class MessageCryptoHelper {
@Override @Override
public void run() { public void run() {
try { try {
if (MessageDecryptVerifier.isPgpMimePart(currentlyDecrypringOrVerifyingPart)) { if (MessageDecryptVerifier.isPgpMimePart(currentlyDecryptingOrVerifyingPart)) {
Multipart multipartEncryptedMultipart = Multipart multipartEncryptedMultipart =
(Multipart) currentlyDecrypringOrVerifyingPart.getBody(); (Multipart) currentlyDecryptingOrVerifyingPart.getBody();
BodyPart encryptionPayloadPart = multipartEncryptedMultipart.getBodyPart(1); BodyPart encryptionPayloadPart = multipartEncryptedMultipart.getBodyPart(1);
Body encryptionPayloadBody = encryptionPayloadPart.getBody(); Body encryptionPayloadBody = encryptionPayloadPart.getBody();
encryptionPayloadBody.writeTo(out); encryptionPayloadBody.writeTo(out);
} else if (MessageDecryptVerifier.isPgpInlinePart(currentlyDecrypringOrVerifyingPart)) { } else if (MessageDecryptVerifier.isPgpInlinePart(currentlyDecryptingOrVerifyingPart)) {
String text = MessageExtractor.getTextFromPart(currentlyDecrypringOrVerifyingPart); String text = MessageExtractor.getTextFromPart(currentlyDecryptingOrVerifyingPart);
out.write(text.getBytes()); out.write(text.getBytes());
} else { } else {
Log.wtf(K9.LOG_TAG, "No suitable data to stream found!"); Log.wtf(K9.LOG_TAG, "No suitable data to stream found!");
@ -393,7 +393,7 @@ public class MessageCryptoHelper {
} }
private void addOpenPgpResultPartToMessage(OpenPgpResultAnnotation resultAnnotation) { private void addOpenPgpResultPartToMessage(OpenPgpResultAnnotation resultAnnotation) {
messageAnnotations.put(currentlyDecrypringOrVerifyingPart, resultAnnotation); messageAnnotations.put(currentlyDecryptingOrVerifyingPart, resultAnnotation);
} }
private void onCryptoFailed(OpenPgpError error) { private void onCryptoFailed(OpenPgpError error) {