public class CMSEnvelopedDataOutputStream extends CMSOutputStream
CMSEnvelopedDataOutputStream writes its output in the form of a CMS
enveloped-data structure, enveloping the data in the process.
Specifically, the effect of using this class is as if the following process took place:
enveloped-data.
except that the actual process is done in one pass, eliminating the necessity to accumulate all of the input data before writing any output.
In the case where a CMSConnector is provided instead of a CMSOutputStream, only the
exposed content i.e. the Content field of the ContentInfo structure minus the
explicit [0] tag is written to the underlying output stream.
IMPORTANT: This class generates large CMS enveloped-data Objects more efficiently (Java VM memory usage) than the
CMSEnvelopedDataContentInfo class.
| Constructor and Description |
|---|
CMSEnvelopedDataOutputStream(CMSOutputConnector conn,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients,
boolean writeContent)
Creates a
CMSEnvelopedDataOutputStream. |
CMSEnvelopedDataOutputStream(CMSOutputConnector conn,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients,
boolean writeContent,
OriginatorInfo origInfo,
AttributeSet unprotectedAttribs)
Creates a
CMSEnvelopedDataOutputStream. |
CMSEnvelopedDataOutputStream(java.io.OutputStream out,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients)
Creates a
CMSEnvelopedDataOutputStream. |
CMSEnvelopedDataOutputStream(java.io.OutputStream out,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients)
Creates a
CMSEnvelopedDataOutputStream. |
CMSEnvelopedDataOutputStream(java.io.OutputStream out,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients,
boolean writeContent)
Creates a
CMSEnvelopedDataOutputStream. |
CMSEnvelopedDataOutputStream(java.io.OutputStream out,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients,
boolean writeContent,
OriginatorInfo origInfo,
AttributeSet unprotectedAttribs)
Creates a
CMSEnvelopedDataOutputStream. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
ASN1ObjectID |
getExposedContentType()
Returns the content type of the data output to the underlying output stream.
|
void |
terminate()
Finish writing the
enveloped-data structure. |
void |
write(byte[] b,
int offset,
int len) |
void |
write(int ch) |
public CMSEnvelopedDataOutputStream(java.io.OutputStream out,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients)
throws java.security.NoSuchAlgorithmException
CMSEnvelopedDataOutputStream.
The enclosed content type will be set to Data.
Note the changes in exceptions Exceptions not thrown -- AlgorithmIdentifierException Exceptions introduced -- NoSuchAlgorithmException
out - The output stream.contentEncryptionAlgID - The content encryption algorithm.recipients - The recipients (each element must be an instance of
CMSRecipientInfoSpec).java.security.NoSuchAlgorithmException - Unrecognized encryption algorithm.public CMSEnvelopedDataOutputStream(java.io.OutputStream out,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients)
throws java.security.NoSuchAlgorithmException
CMSEnvelopedDataOutputStream.
Note the changes in exceptions Exceptions not thrown -- AlgorithmIdentifierException Exceptions introduced -- NoSuchAlgorithmException
out - The output stream.enclosedContentType - The content type of content being encrypted.contentEncryptionAlgID - The content encryption algorithm.recipients - The recipients (each element must be an instance of
CMSRecipientInfoSpec).java.security.NoSuchAlgorithmException - Unrecognized encryption algorithm.public CMSEnvelopedDataOutputStream(java.io.OutputStream out,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients,
boolean writeContent)
throws java.security.NoSuchAlgorithmException
CMSEnvelopedDataOutputStream.
Note the changes in exceptions Exceptions not thrown -- AlgorithmIdentifierException Exceptions introduced -- NoSuchAlgorithmException
out - The output stream.enclosedContentType - The content type of content being encrypted.contentEncryptionAlgID - The content encryption algorithm.recipients - The recipients (each element must be an instance of
CMSRecipientInfoSpec).writeContent - Indicates if enclosed content is to be written to the output stream.java.security.NoSuchAlgorithmException - Unrecognized encryption algorithm.public CMSEnvelopedDataOutputStream(java.io.OutputStream out,
ASN1ObjectID enclosedContentType,
AlgorithmIdentifier contentEncryptionAlgID,
java.util.Vector recipients,
boolean writeContent,
OriginatorInfo origInfo,
AttributeSet unprotectedAttribs)
throws java.security.NoSuchAlgorithmException
CMSEnvelopedDataOutputStream.
Note the changes in exceptions Exceptions not thrown -- AlgorithmIdentifierException Exceptions introduced -- NoSuchAlgorithmException
out - The output stream.enclosedContentType - The content type of content being encrypted.contentEncryptionAlgID - The content encryption algorithm.recipients - The recipients (each element must be an instance of
CMSRecipientInfoSpec).writeContent - Indicates if enclosed content is to be written to the output stream.origInfo - The OriginatorInfo.unprotectedAttribs - The unprotected attributes.java.security.NoSuchAlgorithmException - Unrecognized encryption algorithm.public CMSEnvelopedDataOutputStream(CMSOutputConnector conn, ASN1ObjectID enclosedContentType, AlgorithmIdentifier contentEncryptionAlgID, java.util.Vector recipients, boolean writeContent) throws java.security.NoSuchAlgorithmException
CMSEnvelopedDataOutputStream.
Note the changes in exceptions Exceptions not thrown -- AlgorithmIdentifierException Exceptions introduced -- NoSuchAlgorithmException
conn - The output connector.contentEncryptionAlgID - The content encryption algorithm.recipients - The recipient certificates (each element must be an instance of
CMSRecipientInfoSpec).recipients - The recipients (each element must be an instance of
CMSRecipientInfoSpec).writeContent - Indicates if enclosed content is to be written to the output stream.java.security.NoSuchAlgorithmException - Unrecognized encryption algorithm.public CMSEnvelopedDataOutputStream(CMSOutputConnector conn, ASN1ObjectID enclosedContentType, AlgorithmIdentifier contentEncryptionAlgID, java.util.Vector recipients, boolean writeContent, OriginatorInfo origInfo, AttributeSet unprotectedAttribs) throws java.security.NoSuchAlgorithmException
CMSEnvelopedDataOutputStream.
Note the changes in exceptions Exceptions not thrown -- AlgorithmIdentifierException Exceptions introduced -- NoSuchAlgorithmException
conn - The output connector.enclosedContentType - The content type of content being encrypted.contentEncryptionAlgID - The content encryption algorithm.recipients - The recipients (each element must be an instance of
CMSRecipientInfoSpec).writeContent - Indicates if enclosed content is to be written to the output stream.origInfo - The OriginatorInfo.unprotectedAttribs - The set of unprotected attributes.java.security.NoSuchAlgorithmException - Unrecognized encryption algorithm.public void terminate()
throws java.io.IOException
enveloped-data structure.
This must be called only after all the enclosed data has been written to the output stream.
terminate in class CMSOutputStreamjava.io.IOException - An I/O error occurs.public void write(int ch)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void write(byte[] b,
int offset,
int len)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterOutputStreamjava.io.IOExceptionpublic ASN1ObjectID getExposedContentType()
getExposedContentType in class CMSOutputStream