A simple example of usage - note, in the example below the validity of the certificate isn't verified, just the fact that one of the certs matches the given signer...
CertStore certs = s.getCertificates("Collection", "BC");
SignerInformationStore signers = s.getSignerInfos();
Collection c = signers.getSigners();
Iterator it = c.iterator();
while (it.hasNext())
{
SignerInformation signer = (SignerInformation)it.next();
Collection certCollection = certs.getCertificates(signer.getSID());
Iterator certIt = certCollection.iterator();
X509Certificate cert = (X509Certificate)certIt.next();
if (signer.verify(cert.getPublicKey()))
{
verified++;
}
}
Note
if you are using this class with AS2 or some other protocol that does not use 7bit as the default content transfer encoding you will need to use the constructor that allows you to specify the default content transfer encoding, such as "binary".
| Modifier and Type | Field and Description |
|---|---|
| pack-priv MimeBodyPart | |
| pack-priv Object |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SMIMESigned(MimeMultipart
the signed message message, String new default to use defaultContentTransferEncoding)base constructor with settable contentTransferEncoding |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public MimeBodyPart | |
| public MimeMessage | Returns: a MimeMessage holding the content.Return the content that was signed as a mime message. |
| public Object | getContentWithSignature()
return the content that was signed - depending on whether this was unencapsulated or not it will return a MimeMultipart or a MimeBodyPart |
| private static InputStream |
| content | back to summary |
|---|---|
| pack-priv MimeBodyPart content | |
| message | back to summary |
|---|---|
| pack-priv Object message | |
| SMIMESigned | back to summary |
|---|---|
| public SMIMESigned(MimeMultipart message) throws MessagingException, CMSException base constructor using a defaultContentTransferEncoding of 7bit
| |
| SMIMESigned | back to summary |
|---|---|
| public SMIMESigned(MimeMultipart message, String defaultContentTransferEncoding) throws MessagingException, CMSException base constructor with settable contentTransferEncoding
| |
| SMIMESigned | back to summary |
|---|---|
| public SMIMESigned(Part message) throws MessagingException, CMSException, SMIMEException base constructor for a signed message with encapsulated content.
| |
| getContent | back to summary |
|---|---|
| public MimeBodyPart getContent() return the content that was signed. | |
| getContentAsMimeMessage | back to summary |
|---|---|
| public MimeMessage getContentAsMimeMessage(Session session) throws MessagingException, IOException Return the content that was signed as a mime message.
| |
| getContentWithSignature | back to summary |
|---|---|
| public Object getContentWithSignature() return the content that was signed - depending on whether this was unencapsulated or not it will return a MimeMultipart or a MimeBodyPart | |
| getInputStream | back to summary |
|---|---|
| private static InputStream getInputStream(Part bodyPart) throws MessagingException | |