A simple example of usage.
X509Certificate signCert = ...
certList.add(signCert);
Store certs = new JcaCertStore(certList);
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(signKP.getPrivate());
CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();
gen.addSignerInfoGenerator(
new JcaSignerInfoGeneratorBuilder(
new JcaDigestCalculatorProviderBuilder().setProvider("BC").build())
.build(sha1Signer, signCert));
gen.addCertificates(certs);
OutputStream sigOut = gen.open(bOut);
sigOut.write("Hello World!".getBytes());
sigOut.close();
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CMSSignedDataStreamGenerator(DigestAlgorithmIdentifierFinder digestAlgIdFinder)
base constructor with a custom DigestAlgorithmIdentifierFinder |
| Modifier and Type | Method and Description |
|---|---|
| private ASN1Integer | |
| private boolean | |
| public List | Returns: a list of the Digest AlgorithmIdentifiersReturn a list of the current Digest AlgorithmIdentifiers applying to the next signature. |
| public OutputStream | open(OutputStream out)
generate a signed object that for a CMS Signed Data object using the given provider. |
| public OutputStream | open(OutputStream out, boolean encapsulate)
generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data". |
| public OutputStream | open(OutputStream
stream the CMS object is to be written to. out, boolean true if data should be encapsulated. encapsulate, OutputStream output stream to copy the data being signed to. dataOutputStream)generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data". |
| public OutputStream | open(ASN1ObjectIdentifier eContentType, OutputStream out, boolean encapsulate)
generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature. |
| public OutputStream | open(ASN1ObjectIdentifier
OID for data to be signed. eContentType, OutputStream stream the CMS object is to be written to. out, boolean true if data should be encapsulated. encapsulate, OutputStream output stream to copy the data being signed to. dataOutputStream)generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature. |
| public void | setBufferSize(int
length of octet strings to buffer the data. bufferSize)Set the underlying string size for encapsulated data |
| _bufferSize | back to summary |
|---|---|
| private int _bufferSize | |
| CMSSignedDataStreamGenerator | back to summary |
|---|---|
| public CMSSignedDataStreamGenerator() base constructor | |
| CMSSignedDataStreamGenerator | back to summary |
|---|---|
| public CMSSignedDataStreamGenerator(DigestAlgorithmIdentifierFinder digestAlgIdFinder) base constructor with a custom DigestAlgorithmIdentifierFinder | |
| calculateVersion | back to summary |
|---|---|
| private ASN1Integer calculateVersion(ASN1ObjectIdentifier contentOid) | |
| checkForVersion3 | back to summary |
|---|---|
| private boolean checkForVersion3(List<E> signerInfos, List<E> signerInfoGens) | |
| getDigestAlgorithms | back to summary |
|---|---|
| public List Return a list of the current Digest AlgorithmIdentifiers applying to the next signature.
| |
| open | back to summary |
|---|---|
| public OutputStream open(OutputStream out) throws IOException generate a signed object that for a CMS Signed Data object using the given provider. | |
| open | back to summary |
|---|---|
| public OutputStream open(OutputStream out, boolean encapsulate) throws IOException generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data". | |
| open | back to summary |
|---|---|
| public OutputStream open(OutputStream out, boolean encapsulate, OutputStream dataOutputStream) throws IOException generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data". If dataOutputStream is non null the data being signed will be written to the stream as it is processed.
| |
| open | back to summary |
|---|---|
| public OutputStream open(ASN1ObjectIdentifier eContentType, OutputStream out, boolean encapsulate) throws IOException generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature. The content type is set according to the OID represented by the string signedContentType. | |
| open | back to summary |
|---|---|
| public OutputStream open(ASN1ObjectIdentifier eContentType, OutputStream out, boolean encapsulate, OutputStream dataOutputStream) throws IOException generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature. The content type is set according to the OID represented by the string signedContentType.
| |
| setBufferSize | back to summary |
|---|---|
| public void setBufferSize(int bufferSize) Set the underlying string size for encapsulated data
| |
| Modifier and Type | Field and Description |
|---|---|
| private ASN1ObjectIdentifier | |
| private BERSequenceGenerator | |
| private OutputStream | |
| private BERSequenceGenerator | |
| private BERSequenceGenerator |
| Access | Constructor and Description |
|---|---|
| public | CmsSignedDataOutputStream(OutputStream out, ASN1ObjectIdentifier contentOID, BERSequenceGenerator sGen, BERSequenceGenerator sigGen, BERSequenceGenerator eiGen)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| public void | write(int
the b)byte.Implements abstract java. |
| public void | write(byte[]
the data. bytes, int the start offset in the data. off, int the number of bytes to write. len)Overrides java. len bytes from the specified byte array
starting at offset off to this output stream.
|
| public void | write(byte[]
the data. bytes)Overrides java. b.length bytes from the specified byte array
to this output stream.
|
| _contentOID | back to summary |
|---|---|
| private ASN1ObjectIdentifier _contentOID | |
| _eiGen | back to summary |
|---|---|
| private BERSequenceGenerator _eiGen | |
| _out | back to summary |
|---|---|
| private OutputStream _out | |
| _sGen | back to summary |
|---|---|
| private BERSequenceGenerator _sGen | |
| _sigGen | back to summary |
|---|---|
| private BERSequenceGenerator _sigGen | |
| CmsSignedDataOutputStream | back to summary |
|---|---|
| public CmsSignedDataOutputStream(OutputStream out, ASN1ObjectIdentifier contentOID, BERSequenceGenerator sGen, BERSequenceGenerator sigGen, BERSequenceGenerator eiGen) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this output stream and releases any system resources
associated with this stream. The general contract of
| |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Implements abstract java. Doc from java. Writes the specified byte to this output stream. The general
contract for
| |
| write | back to summary |
|---|---|
| public void write(byte[] bytes, int off, int len) throws IOException Overrides java. Doc from java. Writes
If
If
| |
| write | back to summary |
|---|---|
| public void write(byte[] bytes) throws IOException Overrides java. Doc from java. Writes
| |