// 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"))
{
SMIMESigned s = new SMIMESigned(
(MimeMultipart)msg.getContent());
//
// extract the content
//
MimeBodyPart content = s.getContent();
System.out.println("Content:");
Object cont = content.getContent();
if (cont instanceof String)
{
System.out.println((String)cont);
}
else if (cont instanceof Multipart)
{
Multipart mp = (Multipart)cont;
int count = mp.getCount();
for (int i = 0; i < count; i++)
{
BodyPart m = mp.getBodyPart(i);
Object part = m.getContent();
System.out.println("Part " + i);
System.out.println("---------------------------");
if (part instanceof String)
{
System.out.println((String)part);
}
else
{
System.out.println("can't print...");
}
}
}
System.out.println("Status:");
verify(s);
}
else if (msg.isMimeType("application/pkcs7-mime")
|| msg.isMimeType("application/x-pkcs7-mime"))
{
//
// in this case the content is wrapped in the signature block.
//
SMIMESigned s = new SMIMESigned(msg);
//
// extract the content
//
MimeBodyPart content = s.getContent();
System.out.println("Content:");
Object cont = content.getContent();