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", "BCFIPS");
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 | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv MimeBodyPart | |
| pack-priv Object |
| Access | Constructor and Description |
|---|---|
| public | SMIMESignedParser(DigestCalculatorProvider
provider for digest calculators. digCalcProvider, MimeMultipart signed message with signature. message)base constructor using a defaultContentTransferEncoding of 7bit. |
| public | SMIMESignedParser(DigestCalculatorProvider
provider for digest calculators. digCalcProvider, MimeMultipart signed message with signature. message, File the temporary file to use to back the signed data. backingFile)base constructor using a defaultContentTransferEncoding of 7bit and a specified backing file. |
| public | SMIMESignedParser(DigestCalculatorProvider
provider for digest calculators. digCalcProvider, MimeMultipart the signed message with signature. message, String new default to use. defaultContentTransferEncoding)base constructor with settable contentTransferEncoding. |
| public | SMIMESignedParser(DigestCalculatorProvider
provider for digest calculators. digCalcProvider, MimeMultipart the signed message with signature. message, String new default to use. defaultContentTransferEncoding, File the temporary file to use to back the signed data. backingFile)base constructor with settable contentTransferEncoding and a specified backing file. |
| public | SMIMESignedParser(DigestCalculatorProvider
provider for digest calculators. digCalcProvider, Part the message containing the encapsulated signed data. message)base constructor for a signed message with encapsulated content. |
| public | SMIMESignedParser(DigestCalculatorProvider
provider for digest calculators. digCalcProvider, Part the Part containing the signed content. message, File the file the encapsulated part is to be written to after it has been decoded. file)Constructor for a signed message with encapsulated content. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public MimeBodyPart | |
| public MimeMessage | Returns: a MimeMessage holding the content.the session to base the MimeMessage around. session)Return the content that was signed as a mime message. |
| public Object | Returns: depending on whether this was unencapsulated or not it will return a MimeMultipart or a MimeBodyPartreturn the content that was signed with its signature attached. |
| private static InputStream | |
| private static CMSTypedStream | |
| private static File |
| content | back to summary |
|---|---|
| pack-priv MimeBodyPart content | |
| message | back to summary |
|---|---|
| pack-priv Object message | |
| SMIMESignedParser | back to summary |
|---|---|
| public SMIMESignedParser(DigestCalculatorProvider digCalcProvider, MimeMultipart message) throws MessagingException, CMSException base constructor using a defaultContentTransferEncoding of 7bit. A temporary backing file will be created for the signed data.
| |
| SMIMESignedParser | back to summary |
|---|---|
| public SMIMESignedParser(DigestCalculatorProvider digCalcProvider, MimeMultipart message, File backingFile) throws MessagingException, CMSException base constructor using a defaultContentTransferEncoding of 7bit and a specified backing file.
| |
| SMIMESignedParser | back to summary |
|---|---|
| public SMIMESignedParser(DigestCalculatorProvider digCalcProvider, MimeMultipart message, String defaultContentTransferEncoding) throws MessagingException, CMSException base constructor with settable contentTransferEncoding. A temporary backing file will be created to contain the signed data.
| |
| SMIMESignedParser | back to summary |
|---|---|
| public SMIMESignedParser(DigestCalculatorProvider digCalcProvider, MimeMultipart message, String defaultContentTransferEncoding, File backingFile) throws MessagingException, CMSException base constructor with settable contentTransferEncoding and a specified backing file.
| |
| SMIMESignedParser | back to summary |
|---|---|
| public SMIMESignedParser(DigestCalculatorProvider digCalcProvider, Part message) throws MessagingException, CMSException, SMIMEException base constructor for a signed message with encapsulated content. Note in this case the encapsulated MimeBody part will only be suitable for a single writeTo - once writeTo has been called the file containing the body part will be deleted. If writeTo is not called the file will be left in the temp directory.
| |
| SMIMESignedParser | back to summary |
|---|---|
| public SMIMESignedParser(DigestCalculatorProvider digCalcProvider, Part message, File file) throws MessagingException, CMSException, SMIMEException Constructor for a signed message with encapsulated content. The encapsulated content, if it exists, is written to the file represented by the File object passed in.
| |
| drainContent | back to summary |
|---|---|
| private void drainContent() throws CMSException | |
| 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 with its signature attached.
| |
| getInputStream | back to summary |
|---|---|
| private static InputStream getInputStream(Part bodyPart) throws MessagingException | |
| getSignedInputStream | back to summary |
|---|---|
| private static CMSTypedStream getSignedInputStream(BodyPart bodyPart, String defaultContentTransferEncoding, File backingFile) throws MessagingException | |
| getTmpFile | back to summary |
|---|---|
| private static File getTmpFile() throws MessagingException | |
| Modifier and Type | Field and Description |
|---|---|
| private final File |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| _file | back to summary |
|---|---|
| private final File _file | |
| TemporaryFileInputStream | back to summary |
|---|---|
| pack-priv TemporaryFileInputStream(File file) throws FileNotFoundException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream. Once the stream has been closed, further read(), available(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.
| |