Identifying Signed Mail which have different content-type like "Application/MS-TNEF" rather than "multipart/signed".

Identifying Signed Mail which have different content-type like "Application/MS-TNEF" rather than "multipart/signed".

Reference :  Ticket 1 , Ticket 2

Cause : 
            Signed mails are processed through JavaMail instead of EWS APIs. To identify signed mails, we search for "multipart/signed" in "content-type" header. In this environment, the header value is different ("application/ms-tnef") and the processing through javamail didn't happen. 

Solution : 
            In Signed Mail, an attachment with the following trace is present.
  1. <t:Attachments>
  2. <t:FileAttachment>
  3. <t:AttachmentId Id="AAMkADY0NTU1YTg3LWRiNmEtNGEzMi1hZWJjLWY4MzI5M2JmNTZjNABGAAAAAABHT8y0coDITYAIEWjYJEv8BwBVfPi3CUySQoJijpvVwXjnAAAAAAEMAABVfPi3CUySQoJijpvVwXjnAAJfZL4LAAABEgAQADWeqRERH8JCgwrm07JybDw="/>
  4. <t:Name>smime.p7m</t:Name>
  5. <t:ContentType>multipart/signed</t:ContentType>
  6. <t:Size>44765</t:Size>
  7. <t:LastModifiedTime>2022-08-08T10:29:46</t:LastModifiedTime>
  8. <t:IsInline>false</t:IsInline>
  9. <t:IsContactPhoto>false</t:IsContactPhoto>
  10. </t:FileAttachment>
  11. </t:Attachments>
An additonal check of whether the attachment has content-type "multipart/signed" is checked. 
Also "smime.p7s" file got skipped.

Before Modification :
  1. "multipart/signed".equalsIgnoreCase(incomingMail.getAllHeaders().get("content-type"))

After Modification :
  1. String signed="multipart/signed";
  2. if(signed.equalsIgnoreCase(incomingMail.getAllHeaders().get("content-type"))){
  3.          flag=true;
  4. }else if (emailMessage.getHasAttachments() || emailMessage.getAttachments().getItems().size() > 0) {
  5.          AttachmentCollection attachments = emailMessage.getAttachments();
  6.          for (Attachment attachment : attachments) {
  7.                if(attachment.getContentType().equalsIgnoreCase(signed)){
  8.                       flag=true;
  9.                }
  10.          }
  11. }
 JAR Compatibility : 13008 ,13001



                  New to ADSelfService Plus?