Search in sources :

Example 6 with CryptoResultAnnotation

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;
}
Also used : BodyPart(com.fsck.k9.mail.BodyPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Multipart(com.fsck.k9.mail.Multipart) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation) ArrayList(java.util.ArrayList) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Body(com.fsck.k9.mail.Body) Stack(java.util.Stack)

Example 7 with CryptoResultAnnotation

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);
}
Also used : CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation)

Example 8 with CryptoResultAnnotation

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);
}
Also used : OpenPgpDecryptionResult(org.openintents.openpgp.OpenPgpDecryptionResult) CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation) PendingIntent(android.app.PendingIntent) OpenPgpSignatureResult(org.openintents.openpgp.OpenPgpSignatureResult)

Example 9 with CryptoResultAnnotation

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);
    }
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation)

Aggregations

CryptoResultAnnotation (com.fsck.k9.mailstore.CryptoResultAnnotation)7 Part (com.fsck.k9.mail.Part)5 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)4 BodyPart (com.fsck.k9.mail.BodyPart)3 ArrayList (java.util.ArrayList)3 PendingIntent (android.app.PendingIntent)1 Nullable (android.support.annotation.Nullable)1 WorkerThread (android.support.annotation.WorkerThread)1 Body (com.fsck.k9.mail.Body)1 Multipart (com.fsck.k9.mail.Multipart)1 CryptoMessageParts (com.fsck.k9.ui.crypto.MessageCryptoSplitter.CryptoMessageParts)1 Stack (java.util.Stack)1 OpenPgpDecryptionResult (org.openintents.openpgp.OpenPgpDecryptionResult)1 OpenPgpSignatureResult (org.openintents.openpgp.OpenPgpSignatureResult)1