A simple example of usage.
X509Certificate signCert = ...
KeyPair signKP = ...
List certList = new ArrayList();
certList.add(signCert);
Store certs = new JcaCertStore(certList);
SMIMESignedGenerator gen = new SMIMESignedGenerator();
gen.addSignerInfoGenerator(new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC").build("SHA1withRSA", signKP.getPrivate(), signCert));
gen.addCertificates(certs);
MimeMultipart smime = fact.generate(content);
Note 1: 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".
Note 2: between RFC 3851 and RFC 5751 the values used in the micalg parameter for signed messages changed. We will accept both, but the default is now to use RFC 5751. In the event you are dealing with an older style system you will also need to use a constructor that sets the micalgs table and call it with RFC3851_MICALGS.
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private List | |
| private List | |
| private Map | |
| private List | |
| private List | |
| private List | |
| private static final String | |
| private List | |
| private List | |
| private final String | |
| private static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| private static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| private final Map | |
| public static final Map | |
| public static final Map | |
| private List | |
| public static final Map |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SMIMESignedGenerator(String
new default to use. defaultContentTransferEncoding)base constructor - default content transfer encoding explicitly set |
| public | SMIMESignedGenerator(Map<K, V>
a map of ANS1ObjectIdentifiers to strings hash algorithm names. micAlgs)base constructor - default content transfer encoding explicitly set |
| public | SMIMESignedGenerator(String
new default to use. defaultContentTransferEncoding, Map<K, V> a map of ANS1ObjectIdentifiers to strings hash algorithm names. micAlgs)base constructor - default content transfer encoding explicitly set |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| private void | |
| public void | |
| public void | addSigners(SignerInformationStore
store of signers signerStore)Add a store of precalculated signers to the generator. |
| public MimeMultipart | |
| public MimeMultipart | |
| public MimeBodyPart | Returns: a MimeBodyPart containing the certs and CRLs.Creates a certificate management message which is like a signed message with no content or signers but that still carries certificates and CRLs. |
| public MimeBodyPart | generateEncapsulated(MimeBodyPart content)
generate a signed message with encapsulated content Note doing this is strongly not recommended as it means a recipient of the message will have to be able to read the signature to read the message. |
| public MimeBodyPart | |
| public Map | Returns: a map of oids (as String objects) and byte[] representing digests.Return a map of oids and byte arrays representing the digests calculated on the content during the last generate. |
| private MimeMultipart | |
| private MimeBodyPart |
| _attributeCerts | back to summary |
|---|---|
| private List<E> _attributeCerts | |
| _certStores | back to summary |
|---|---|
| private List<E> _certStores | |
| _digests | back to summary |
|---|---|
| private Map<K, V> _digests | |
| _oldSigners | back to summary |
|---|---|
| private List<E> _oldSigners | |
| _signers | back to summary |
|---|---|
| private List<E> _signers | |
| attrCertStores | back to summary |
|---|---|
| private List<E> attrCertStores | |
| CERTIFICATE_MANAGEMENT_CONTENT | back to summary |
|---|---|
| private static final String CERTIFICATE_MANAGEMENT_CONTENT | |
| certStores | back to summary |
|---|---|
| private List<E> certStores | |
| crlStores | back to summary |
|---|---|
| private List<E> crlStores | |
| defaultContentTransferEncoding | back to summary |
|---|---|
| private final String defaultContentTransferEncoding | |
| DETACHED_SIGNATURE_TYPE | back to summary |
|---|---|
| private static final String DETACHED_SIGNATURE_TYPE | |
| DIGEST_GOST3411 | back to summary |
|---|---|
| public static final String DIGEST_GOST3411 | |
| DIGEST_MD5 | back to summary |
|---|---|
| public static final String DIGEST_MD5 | |
| DIGEST_RIPEMD128 | back to summary |
|---|---|
| public static final String DIGEST_RIPEMD128 | |
| DIGEST_RIPEMD160 | back to summary |
|---|---|
| public static final String DIGEST_RIPEMD160 | |
| DIGEST_RIPEMD256 | back to summary |
|---|---|
| public static final String DIGEST_RIPEMD256 | |
| DIGEST_SHA1 | back to summary |
|---|---|
| public static final String DIGEST_SHA1 | |
| DIGEST_SHA224 | back to summary |
|---|---|
| public static final String DIGEST_SHA224 | |
| DIGEST_SHA256 | back to summary |
|---|---|
| public static final String DIGEST_SHA256 | |
| DIGEST_SHA384 | back to summary |
|---|---|
| public static final String DIGEST_SHA384 | |
| DIGEST_SHA512 | back to summary |
|---|---|
| public static final String DIGEST_SHA512 | |
| ENCAPSULATED_SIGNED_CONTENT_TYPE | back to summary |
|---|---|
| private static final String ENCAPSULATED_SIGNED_CONTENT_TYPE | |
| ENCRYPTION_DSA | back to summary |
|---|---|
| public static final String ENCRYPTION_DSA | |
| ENCRYPTION_ECDSA | back to summary |
|---|---|
| public static final String ENCRYPTION_ECDSA | |
| ENCRYPTION_ECGOST3410 | back to summary |
|---|---|
| public static final String ENCRYPTION_ECGOST3410 | |
| ENCRYPTION_GOST3410 | back to summary |
|---|---|
| public static final String ENCRYPTION_GOST3410 | |
| ENCRYPTION_RSA | back to summary |
|---|---|
| public static final String ENCRYPTION_RSA | |
| ENCRYPTION_RSA_PSS | back to summary |
|---|---|
| public static final String ENCRYPTION_RSA_PSS | |
| micAlgs | back to summary |
|---|---|
| private final Map<K, V> micAlgs | |
| RFC3851_MICALGS | back to summary |
|---|---|
| public static final Map<K, V> RFC3851_MICALGS | |
| RFC5751_MICALGS | back to summary |
|---|---|
| public static final Map<K, V> RFC5751_MICALGS | |
| signerInfoGens | back to summary |
|---|---|
| private List<E> signerInfoGens | |
| STANDARD_MICALGS | back to summary |
|---|---|
| public static final Map<K, V> STANDARD_MICALGS | |
| SMIMESignedGenerator | back to summary |
|---|---|
| public SMIMESignedGenerator() base constructor - default content transfer encoding 7bit | |
| SMIMESignedGenerator | back to summary |
|---|---|
| public SMIMESignedGenerator(String defaultContentTransferEncoding) base constructor - default content transfer encoding explicitly set
| |
| SMIMESignedGenerator | back to summary |
|---|---|
| public SMIMESignedGenerator(Map<K, V> micAlgs) base constructor - default content transfer encoding explicitly set
| |
| SMIMESignedGenerator | back to summary |
|---|---|
| public SMIMESignedGenerator(String defaultContentTransferEncoding, Map<K, V> micAlgs) base constructor - default content transfer encoding explicitly set | |
| addAttributeCertificates | back to summary |
|---|---|
| public void addAttributeCertificates(Store<T> certStore) | |
| addCertificates | back to summary |
|---|---|
| public void addCertificates(Store<T> certStore) | |
| addCRLs | back to summary |
|---|---|
| public void addCRLs(Store<T> crlStore) | |
| addHashHeader | back to summary |
|---|---|
| private void addHashHeader(StringBuffer header, List<E> signers) | |
| addSignerInfoGenerator | back to summary |
|---|---|
| public void addSignerInfoGenerator(SignerInfoGenerator sigInfoGen) | |
| addSigners | back to summary |
|---|---|
| public void addSigners(SignerInformationStore signerStore) Add a store of precalculated signers to the generator.
| |
| generate | back to summary |
|---|---|
| public MimeMultipart generate(MimeBodyPart content) throws SMIMEException | |
| generate | back to summary |
|---|---|
| public MimeMultipart generate(MimeMessage message) throws SMIMEException | |
| generateCertificateManagement | back to summary |
|---|---|
| public MimeBodyPart generateCertificateManagement() throws SMIMEException Creates a certificate management message which is like a signed message with no content or signers but that still carries certificates and CRLs.
| |
| generateEncapsulated | back to summary |
|---|---|
| public MimeBodyPart generateEncapsulated(MimeBodyPart content) throws SMIMEException generate a signed message with encapsulated content Note doing this is strongly not recommended as it means a recipient of the message will have to be able to read the signature to read the message. | |
| generateEncapsulated | back to summary |
|---|---|
| public MimeBodyPart generateEncapsulated(MimeMessage message) throws SMIMEException | |
| getGeneratedDigests | back to summary |
|---|---|
| public Map Return a map of oids and byte arrays representing the digests calculated on the content during the last generate.
| |
| make | back to summary |
|---|---|
| private MimeMultipart make(MimeBodyPart content) throws SMIMEException | |
| makeEncapsulated | back to summary |
|---|---|
| private MimeBodyPart makeEncapsulated(MimeBodyPart content) throws SMIMEException | |
| Modifier and Type | Field and Description |
|---|---|
| private final MimeBodyPart | |
| private final boolean | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected CMSSignedDataStreamGenerator | |
| public void | |
| private void |
| content | back to summary |
|---|---|
| private final MimeBodyPart content | |
| encapsulate | back to summary |
|---|---|
| private final boolean encapsulate | |
| noProvider | back to summary |
|---|---|
| private final boolean noProvider | |
| ContentSigner | back to summary |
|---|---|
| pack-priv ContentSigner(MimeBodyPart content, boolean encapsulate) | |
| getGenerator | back to summary |
|---|---|
| protected CMSSignedDataStreamGenerator getGenerator() throws CMSException | |
| write | back to summary |
|---|---|
| public void write(OutputStream out) throws IOException Implements org. | |
| writeBodyPart | back to summary |
|---|---|
| private void writeBodyPart(OutputStream out, MimeBodyPart bodyPart) throws IOException, MessagingException | |