use of com.fsck.k9.mailstore.CryptoResultAnnotation 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.mailstore.CryptoResultAnnotation in project k-9 by k9mail.
the class MessageCryptoHelper method addErrorAnnotation.
private void addErrorAnnotation(Part part, CryptoError error, MimeBodyPart replacementPart) {
CryptoResultAnnotation annotation = CryptoResultAnnotation.createErrorAnnotation(error, replacementPart);
messageAnnotations.put(part, annotation);
}
use of com.fsck.k9.mailstore.CryptoResultAnnotation in project k-9 by k9mail.
the class MessageCryptoHelper method handleCryptoOperationSuccess.
private void handleCryptoOperationSuccess(MimeBodyPart outputPart) {
OpenPgpDecryptionResult decryptionResult = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_DECRYPTION);
OpenPgpSignatureResult signatureResult = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
PendingIntent pendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
CryptoResultAnnotation resultAnnotation = CryptoResultAnnotation.createOpenPgpResultAnnotation(decryptionResult, signatureResult, pendingIntent, outputPart);
onCryptoOperationSuccess(resultAnnotation);
}
use of com.fsck.k9.mailstore.CryptoResultAnnotation in project k-9 by k9mail.
the class MessageCryptoHelper method propagateEncapsulatedSignedPart.
private void propagateEncapsulatedSignedPart(CryptoResultAnnotation resultAnnotation, Part part) {
Part encapsulatingPart = messageAnnotations.findKeyForAnnotationWithReplacementPart(part);
CryptoResultAnnotation encapsulatingPartAnnotation = messageAnnotations.get(encapsulatingPart);
if (encapsulatingPart != null && resultAnnotation.hasSignatureResult()) {
CryptoResultAnnotation replacementAnnotation = encapsulatingPartAnnotation.withEncapsulatedResult(resultAnnotation);
messageAnnotations.put(encapsulatingPart, replacementAnnotation);
}
}
Aggregations