private void findPartsForMultipartEncryptionPass() { List<Part> encryptedParts = MessageCryptoStructureDetector.findMultipartEncryptedParts(currentMessage); for (Part part : encryptedParts) { if (!MessageHelper.isCompletePartAvailable(part)) { addErrorAnnotation(part, CryptoError.OPENPGP_ENCRYPTED_BUT_INCOMPLETE, MessageHelper.createEmptyPart()); continue; } if (MessageCryptoStructureDetector.isMultipartEncryptedOpenPgpProtocol(part)) { CryptoPart cryptoPart = new CryptoPart(CryptoPartType.PGP_ENCRYPTED, part); partsToProcess.add(cryptoPart); continue; } addErrorAnnotation(part, CryptoError.ENCRYPTED_BUT_UNSUPPORTED, MessageHelper.createEmptyPart()); } }
@WorkerThread public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations cryptoAnnotations, boolean openPgpProviderConfigured) 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!"); } MessageViewInfo messageViewInfo = extractSimpleMessageForView(message, message); return messageViewInfo.withSubject(message.getSubject(), false); } boolean isOpenPgpEncrypted = (MessageCryptoStructureDetector.isPartMultipartEncrypted(cryptoContentPart) && MessageCryptoStructureDetector.isMultipartEncryptedOpenPgpProtocol(cryptoContentPart)) || MessageCryptoStructureDetector.isPartPgpInlineEncrypted(cryptoContentPart); if (!openPgpProviderConfigured && isOpenPgpEncrypted) { CryptoResultAnnotation noProviderAnnotation = CryptoResultAnnotation.createErrorAnnotation( CryptoError.OPENPGP_ENCRYPTED_NO_PROVIDER, null); return MessageViewInfo.createWithErrorState(message, false) .withCryptoData(noProviderAnnotation, null, null); } MessageViewInfo messageViewInfo = getMessageContent(message, cryptoAnnotations, extraParts, cryptoContentPart); messageViewInfo = extractSubject(messageViewInfo); return messageViewInfo; }