use of com.fsck.k9.mail.Body in project k-9 by k9mail.
the class SmtpTransportTest method sendMessage_with8BitEncoding.
@Test
public void sendMessage_with8BitEncoding() throws Exception {
Message message = getDefaultMessage();
MockSmtpServer server = createServerAndSetupForPlainAuthentication("8BITMIME");
server.expect("MAIL FROM:<user@localhost> BODY=8BITMIME");
server.output("250 OK");
server.expect("RCPT TO:<user2@localhost>");
server.output("250 OK");
server.expect("DATA");
server.output("354 End data with <CR><LF>.<CR><LF>");
server.expect("[message data]");
server.expect(".");
server.output("250 OK: queued as 12345");
server.expect("QUIT");
server.output("221 BYE");
server.closeConnection();
SmtpTransport transport = startServerAndCreateSmtpTransport(server);
transport.sendMessage(message);
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.Body in project k-9 by k9mail.
the class SmtpTransportTest method sendMessage_with8BitEncodingExtensionNotCaseSensitive.
@Test
public void sendMessage_with8BitEncodingExtensionNotCaseSensitive() throws Exception {
Message message = getDefaultMessage();
MockSmtpServer server = createServerAndSetupForPlainAuthentication("8bitmime");
server.expect("MAIL FROM:<user@localhost> BODY=8BITMIME");
server.output("250 OK");
server.expect("RCPT TO:<user2@localhost>");
server.output("250 OK");
server.expect("DATA");
server.output("354 End data with <CR><LF>.<CR><LF>");
server.expect("[message data]");
server.expect(".");
server.output("250 OK: queued as 12345");
server.expect("QUIT");
server.output("221 BYE");
server.closeConnection();
SmtpTransport transport = startServerAndCreateSmtpTransport(server);
transport.sendMessage(message);
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.Body in project k-9 by k9mail.
the class MessageDecryptVerifier method findPrimaryPartInMixed.
@Nullable
private static Part findPrimaryPartInMixed(Part part, List<Part> outputExtraParts) {
Body body = part.getBody();
boolean isMultipartMixed = part.isMimeType("multipart/mixed") && body instanceof Multipart;
if (!isMultipartMixed) {
return null;
}
Multipart multipart = (Multipart) body;
if (multipart.getCount() == 0) {
return null;
}
BodyPart firstBodyPart = multipart.getBodyPart(0);
Part foundPart;
if (isPartEncryptedOrSigned(firstBodyPart)) {
foundPart = firstBodyPart;
} else {
foundPart = findPrimaryPartInAlternative(firstBodyPart);
}
if (foundPart != null && outputExtraParts != null) {
for (int i = 1; i < multipart.getCount(); i++) {
outputExtraParts.add(multipart.getBodyPart(i));
}
}
return foundPart;
}
use of com.fsck.k9.mail.Body in project k-9 by k9mail.
the class MessageDecryptVerifier method findSignedParts.
public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) {
List<Part> signedParts = new ArrayList<>();
Stack<Part> partsToCheck = new Stack<>();
partsToCheck.push(startPart);
while (!partsToCheck.isEmpty()) {
Part part = partsToCheck.pop();
if (messageCryptoAnnotations.has(part)) {
CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part);
MimeBodyPart replacementData = resultAnnotation.getReplacementData();
if (replacementData != null) {
part = replacementData;
}
}
Body body = part.getBody();
if (isPartMultipartSigned(part)) {
signedParts.add(part);
continue;
}
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
for (int i = multipart.getCount() - 1; i >= 0; i--) {
BodyPart bodyPart = multipart.getBodyPart(i);
partsToCheck.push(bodyPart);
}
}
}
return signedParts;
}
use of com.fsck.k9.mail.Body in project k-9 by k9mail.
the class MessageDecryptVerifier method findEncryptedParts.
public static List<Part> findEncryptedParts(Part startPart) {
List<Part> encryptedParts = new ArrayList<>();
Stack<Part> partsToCheck = new Stack<>();
partsToCheck.push(startPart);
while (!partsToCheck.isEmpty()) {
Part part = partsToCheck.pop();
Body body = part.getBody();
if (isPartMultipartEncrypted(part)) {
encryptedParts.add(part);
continue;
}
if (body instanceof Multipart) {
Multipart multipart = (Multipart) body;
for (int i = multipart.getCount() - 1; i >= 0; i--) {
BodyPart bodyPart = multipart.getBodyPart(i);
partsToCheck.push(bodyPart);
}
}
}
return encryptedParts;
}
Aggregations