When using the outlookMsgToEmailBuilder function
|
public static EmailFromOutlookMessage outlookMsgToEmailBuilder(@NotNull final InputStream msgInputStream) { |
I sometimes get this error message:
org.simplejavamail.internal.smimesupport.SmimeException: Error unwrapping S/MIME enveloped attachment:
AttachmentResource{
name='smime.p7s',
dataSource.name=smime.p7s,
dataSource.getContentType=multipart/signed
}
This is caused by a Nullpointer in this function when the contentType in the calling function does not contain the parameter protocol:
|
private static boolean isSmimeSignatureProtocoll(String protocol) { |
|
return protocol.equalsIgnoreCase("application/pkcs7-signature") |
|
|| protocol.equalsIgnoreCase("application/x-pkcs7-signature"); |
|
} |
|
private static boolean isSmimeSignatureContentType(ContentType contentType) { |
|
String baseContentType = contentType.getBaseType(); |
|
return baseContentType.equalsIgnoreCase("multipart/signed") |
|
&& isSmimeSignatureProtocoll(contentType.getParameter("protocol")); |
|
} |
I haven't been able to create an email with this problem myself (if necessary I can obtain one) but here is the way we handle these emails:
- Drag & Drop from Outlook to a Browser
- Transfer the file to a server
- Convert the file to a ByteArrayInputStream
- Call
outlookMsgToEmailBuilder with that InputStream
I don't know why these mails don't contain a protocol, but the easiest way to prevent the NullPointer would be to make the isSmimeSignatureProtocoll function nullsave by using protocol as input parameter for equalsIgnoreCase:
"application/pkcs7-signature".equalsIgnoreCase(protocol) || "application/x-pkcs7-signature".equalsIgnoreCase(protocol)
This would change the NullPointer to a false.
When using the
outlookMsgToEmailBuilderfunctionsimple-java-mail/modules/simple-java-mail/src/main/java/org/simplejavamail/converter/EmailConverter.java
Line 201 in cd197aa
I sometimes get this error message:
This is caused by a Nullpointer in this function when the
contentTypein the calling function does not contain the parameterprotocol:simple-java-mail/modules/smime-module/src/main/java/org/simplejavamail/internal/smimesupport/SmimeUtilFixed.java
Lines 59 to 62 in cd197aa
simple-java-mail/modules/smime-module/src/main/java/org/simplejavamail/internal/smimesupport/SmimeUtilFixed.java
Lines 53 to 57 in cd197aa
I haven't been able to create an email with this problem myself (if necessary I can obtain one) but here is the way we handle these emails:
outlookMsgToEmailBuilderwith that InputStreamI don't know why these mails don't contain a protocol, but the easiest way to prevent the NullPointer would be to make the
isSmimeSignatureProtocollfunction nullsave by usingprotocolas input parameter forequalsIgnoreCase:This would change the NullPointer to a
false.