use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageViewInfoExtractor method extractMessageForView.
@WorkerThread
public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations annotations) throws MessagingException {
Part rootPart;
CryptoResultAnnotation cryptoResultAnnotation;
List<Part> extraParts;
CryptoMessageParts cryptoMessageParts = MessageCryptoSplitter.split(message, annotations);
if (cryptoMessageParts != null) {
rootPart = cryptoMessageParts.contentPart;
cryptoResultAnnotation = cryptoMessageParts.contentCryptoAnnotation;
extraParts = cryptoMessageParts.extraParts;
} else {
if (annotations != null && !annotations.isEmpty()) {
Timber.e("Got message annotations but no crypto root part!");
}
rootPart = message;
cryptoResultAnnotation = null;
extraParts = null;
}
List<AttachmentViewInfo> attachmentInfos = new ArrayList<>();
ViewableExtractedText viewable = extractViewableAndAttachments(Collections.singletonList(rootPart), attachmentInfos);
List<AttachmentViewInfo> extraAttachmentInfos = new ArrayList<>();
String extraViewableText = null;
if (extraParts != null) {
ViewableExtractedText extraViewable = extractViewableAndAttachments(extraParts, extraAttachmentInfos);
extraViewableText = extraViewable.text;
}
AttachmentResolver attachmentResolver = AttachmentResolver.createFromPart(rootPart);
boolean isMessageIncomplete = !message.isSet(Flag.X_DOWNLOADED_FULL) || MessageExtractor.hasMissingParts(message);
return MessageViewInfo.createWithExtractedContent(message, isMessageIncomplete, rootPart, viewable.html, attachmentInfos, cryptoResultAnnotation, attachmentResolver, extraViewableText, extraAttachmentInfos);
}
use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubTextAndSigned__shouldReturnSigned.
@Test
public void findEncrypted__withMultipartMixedSubTextAndSigned__shouldReturnSigned() throws Exception {
Message message = messageFromBody(multipart("mixed", bodypart("text/plain"), multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature"))));
List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, messageCryptoAnnotations);
assertEquals(1, signedParts.size());
assertSame(getPart(message, 1), signedParts.get(0));
}
use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubSigned__shouldReturnSigned.
@Test
public void findEncrypted__withMultipartMixedSubSigned__shouldReturnSigned() throws Exception {
Message message = messageFromBody(multipart("mixed", multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature"))));
List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, messageCryptoAnnotations);
assertEquals(1, signedParts.size());
assertSame(getPart(message, 0), signedParts.get(0));
}
use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findSigned__withSimpleMultipartSigned__shouldReturnRoot.
@Test
public void findSigned__withSimpleMultipartSigned__shouldReturnRoot() throws Exception {
Message message = messageFromBody(multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature")));
List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, messageCryptoAnnotations);
assertEquals(1, signedParts.size());
assertSame(message, signedParts.get(0));
}
use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findSigned__withComplexMultipartSigned__shouldReturnRoot.
@Test
public void findSigned__withComplexMultipartSigned__shouldReturnRoot() throws Exception {
Message message = messageFromBody(multipart("signed", multipart("mixed", bodypart("text/plain"), bodypart("application/pdf")), bodypart("application/pgp-signature")));
List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, messageCryptoAnnotations);
assertEquals(1, signedParts.size());
assertSame(message, signedParts.get(0));
}
Aggregations