use of com.fsck.k9.mail.internet.Viewable.Alternative in project k-9 by k9mail.
the class MessageDecryptVerifier method findPrimaryPartInAlternative.
private static Part findPrimaryPartInAlternative(Part part) {
Body body = part.getBody();
if (part.isMimeType("multipart/alternative") && body instanceof Multipart) {
Multipart multipart = (Multipart) body;
if (multipart.getCount() == 0) {
return null;
}
BodyPart firstBodyPart = multipart.getBodyPart(0);
if (isPartPgpInlineEncryptedOrSigned(firstBodyPart)) {
return firstBodyPart;
}
}
return null;
}
use of com.fsck.k9.mail.internet.Viewable.Alternative in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findPrimaryCryptoPart_withMultipartMixedContainingMultipartAlternativeContainingPgpInline.
@Test
public void findPrimaryCryptoPart_withMultipartMixedContainingMultipartAlternativeContainingPgpInline() throws Exception {
List<Part> outputExtraParts = new ArrayList<>();
BodyPart pgpInlinePart = bodypart("text/plain", PGP_INLINE_DATA);
Message message = messageFromBody(multipart("mixed", multipart("alternative", pgpInlinePart, bodypart("text/html")), bodypart("application/octet-stream")));
Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts);
assertSame(pgpInlinePart, cryptoPart);
}
use of com.fsck.k9.mail.internet.Viewable.Alternative in project k-9 by k9mail.
the class MigrationTest method migrateTextHtml.
@Test
public void migrateTextHtml() throws Exception {
SQLiteDatabase db = createV50Database();
insertMultipartAlternativeMessage(db);
db.close();
LocalStore localStore = LocalStore.getInstance(account, RuntimeEnvironment.application);
LocalMessage msg = localStore.getFolder("dev").getMessage("9");
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.BODY);
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
Assert.assertEquals(8, msg.getId());
Assert.assertEquals(9, msg.getHeaderNames().size());
Assert.assertEquals("multipart/alternative", msg.getMimeType());
Assert.assertEquals(0, msg.getAttachmentCount());
Multipart msgBody = (Multipart) msg.getBody();
Assert.assertEquals("------------060200010509000000040004", msgBody.getBoundary());
}
use of com.fsck.k9.mail.internet.Viewable.Alternative in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findPrimaryCryptoPart_withEmptyMultipartAlternative_shouldReturnNull.
@Test
public void findPrimaryCryptoPart_withEmptyMultipartAlternative_shouldReturnNull() throws Exception {
List<Part> outputExtraParts = new ArrayList<>();
Message message = messageFromBody(multipart("alternative"));
Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts);
assertNull(cryptoPart);
}
use of com.fsck.k9.mail.internet.Viewable.Alternative in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findPrimaryCryptoPart_withEmptyMultipartAlternativeInsideMultipartMixed_shouldReturnNull.
@Test
public void findPrimaryCryptoPart_withEmptyMultipartAlternativeInsideMultipartMixed_shouldReturnNull() throws Exception {
List<Part> outputExtraParts = new ArrayList<>();
Message message = messageFromBody(multipart("mixed", multipart("alternative")));
Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts);
assertNull(cryptoPart);
}
Aggregations