//
// Get a Session object with the default properties.
//
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage msg = new MimeMessage(session, new SharedFileInputStream("signed.message"));
//
// make sure this was a multipart/signed message - there should be
// two parts as we have one part for the content that was signed and
// one part for the actual signature.
//
if (msg.isMimeType("multipart/signed"))
{
SMIMESignedParser s = new SMIMESignedParser(
(MimeMultipart)msg.getContent());
System.out.println("Status:");
verify(s);
}
else if (msg.isMimeType("application/pkcs7-mime"))
{
//
// in this case the content is wrapped in the signature block.
//
SMIMESignedParser s = new SMIMESignedParser(msg);
System.out.println("Status:");
verify(s);
}
else
{
System.err.println("Not a signed message!");
}