MessageViewInfoExtractor.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:q-mail 作者:
@WorkerThread
public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations cryptoAnnotations)
        throws MessagingException {

    ArrayList<Part> extraParts = new ArrayList<>();
    Part cryptoContentPart = MessageCryptoStructureDetector.findPrimaryEncryptedOrSignedPart(message, extraParts);

    if (cryptoContentPart == null) {
        if (cryptoAnnotations != null && !cryptoAnnotations.isEmpty()) {
            Timber.e("Got crypto message cryptoContentAnnotations but no crypto root part!");
        }
        return extractSimpleMessageForView(message, message);
    }

    boolean isOpenPgpEncrypted = (MessageCryptoStructureDetector.isPartMultipartEncrypted(cryptoContentPart) &&
                    MessageCryptoStructureDetector.isMultipartEncryptedOpenPgpProtocol(cryptoContentPart)) ||
                    MessageCryptoStructureDetector.isPartPgpInlineEncrypted(cryptoContentPart);
    boolean isSMimeEncrypted = (MessageCryptoStructureDetector.isPartMultipartEncrypted(cryptoContentPart) &&
            MessageCryptoStructureDetector.isMultipartEncryptedSMimeProtocol(cryptoContentPart));
    if ((!QMail.isOpenPgpProviderConfigured() && isOpenPgpEncrypted) || (!QMail.isSMimeProviderConfigured() && isSMimeEncrypted)) {
        CryptoResultAnnotation noProviderAnnotation = CryptoResultAnnotation.createErrorAnnotation(
                CryptoError.SMIME_ENCRYPTED_NO_PROVIDER, null);
        return MessageViewInfo.createWithErrorState(message, false)
                .withCryptoData(noProviderAnnotation, null, null, null);
    }

    CryptoResultAnnotation cryptoContentPartAnnotation =
            cryptoAnnotations != null ? cryptoAnnotations.get(cryptoContentPart) : null;
    if (cryptoContentPartAnnotation != null) {
        return extractCryptoMessageForView(message, extraParts, cryptoContentPart, cryptoContentPartAnnotation);
    }

    return extractSimpleMessageForView(message, message);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号