use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageCryptoSplitter method split.
@Nullable
public static CryptoMessageParts split(@NonNull Message message, @Nullable MessageCryptoAnnotations annotations) {
ArrayList<Part> extraParts = new ArrayList<>();
Part primaryPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, extraParts);
if (primaryPart == null) {
return null;
}
if (annotations == null) {
CryptoResultAnnotation rootPartAnnotation = CryptoResultAnnotation.createErrorAnnotation(CryptoError.OPENPGP_ENCRYPTED_NO_PROVIDER, null);
return new CryptoMessageParts(primaryPart, rootPartAnnotation, extraParts);
}
CryptoResultAnnotation rootPartAnnotation = annotations.get(primaryPart);
Part rootPart;
if (rootPartAnnotation != null && rootPartAnnotation.hasReplacementData()) {
rootPart = rootPartAnnotation.getReplacementData();
} else {
rootPart = primaryPart;
}
return new CryptoMessageParts(rootPart, rootPartAnnotation, extraParts);
}
use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageCryptoStructureDetectorTest method findEncrypted__withMultipartMixedSubSignedAndText__shouldReturnSigned.
@Test
public void findEncrypted__withMultipartMixedSubSignedAndText__shouldReturnSigned() throws Exception {
Message message = messageFromBody(multipart("mixed", multipart("signed", "application/pgp-signature", bodypart("text/plain"), bodypart("application/pgp-signature")), bodypart("text/plain")));
List<Part> signedParts = MessageCryptoStructureDetector.findMultipartSignedParts(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 MessageCryptoStructureDetectorTest method findSigned__withComplexMultipartSigned__shouldReturnRoot.
@Test
public void findSigned__withComplexMultipartSigned__shouldReturnRoot() throws Exception {
Message message = messageFromBody(multipart("signed", "protocol=\"application/pgp-signature\"", multipart("mixed", bodypart("text/plain"), bodypart("application/pdf")), bodypart("application/pgp-signature")));
List<Part> signedParts = MessageCryptoStructureDetector.findMultipartSignedParts(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 MessageCryptoStructureDetectorTest method findSigned__withMissingSignature__shouldReturnEmpty.
@Test
public void findSigned__withMissingSignature__shouldReturnEmpty() throws Exception {
Message message = messageFromBody(multipart("signed", "protocol=\"application/pgp-signature\"", bodypart("text/plain")));
List<Part> signedParts = MessageCryptoStructureDetector.findMultipartSignedParts(message, messageCryptoAnnotations);
assertTrue(signedParts.isEmpty());
}
use of com.fsck.k9.mailstore.MessageCryptoAnnotations in project k-9 by k9mail.
the class MessageCryptoStructureDetectorTest method findEncrypted__withMultipartMixedSubSigned__shouldReturnSigned.
@Test
public void findEncrypted__withMultipartMixedSubSigned__shouldReturnSigned() throws Exception {
Message message = messageFromBody(multipart("mixed", multipart("signed", "protocol=\"application/pgp-signature\"", bodypart("text/plain"), bodypart("application/pgp-signature"))));
List<Part> signedParts = MessageCryptoStructureDetector.findMultipartSignedParts(message, messageCryptoAnnotations);
assertEquals(1, signedParts.size());
assertSame(getPart(message, 0), signedParts.get(0));
}
Aggregations