public class CompressedDataStream extends java.lang.Object implements ContentStream
id-ct-compressedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) ct(1) 9 }
which refers to the OID "1.2.840.113549.1.9.16.1.9".
The CompressedData type provides a means for compressing or decompressing the content of a CMS message. The algorithm identifier identifies the compression algorithm to be used. The ZLIB compression algorithm is used as the default algorithm for compressing the EncapsulatedContent(as defined by RFC 3274). ZLIB compression is defined in RFC1950 and RFC 1951.
CompressedData ::= SEQUENCE {
version CMSVersion,
compressionAlgorithm CompressionAlgorithmIdentifier,
encapContentInfo EncapsulatedContentInfo
}
| Modifier and Type | Field and Description |
|---|---|
static ObjectID |
contentType
The object identifier which specifies the CMS compressed data, see RFC
3274
|
static int |
DEFAULT_BLOCKSIZE
The Default blocksize set to 2048 bytes
|
static int |
EXPLICIT
Used to determine if data is explicitly compressed
|
static int |
IMPLICIT
Used to determine if data is implicitly compressed
|
protected int |
m_blockSize
The user defined blocksize
|
protected AlgorithmID |
m_compressionAlgorithm
The compression algorithm ID
|
protected ObjectID |
m_encapContentType
The encapulsted content type
|
protected java.io.InputStream |
m_inputStream
The input stream used to compress data
|
protected int |
m_version
The SMIME version, should be 0
|
| Modifier | Constructor and Description |
|---|---|
protected |
CompressedDataStream()
Default constructor for dynamic object creation in ContentInfoStream.
|
|
CompressedDataStream(java.io.InputStream inputstream)
Creates a new CompressedDataStream where the BER encoded data is read
from the given InputStream.
|
|
CompressedDataStream(java.io.InputStream inputstream,
AlgorithmID algorithmid,
int mode)
Creates a new CMS CompressedDataStream object where the content to be
compressed is read from the supplied InputStream.
|
|
CompressedDataStream(ObjectID objectid,
java.io.InputStream inputstream,
AlgorithmID algorithmid,
int mode)
Creates a new CompressedDataStream object for the given content data.
|
| Modifier and Type | Method and Description |
|---|---|
void |
decode(java.io.InputStream inputstream)
Reads and decodes an encoded CompressedDataStream from an input stream.
|
int |
getBlockSize()
Gets the block size defining the length of each definite primitive
encoded octet string component.
|
AlgorithmID |
getCompressionAlgorithm()
Returns the compression algorithm
|
CompressionProvider |
getCompressionProvider()
Returns the CompressionProvider
|
ObjectID |
getContentType()
Returns the content type this class implements.
|
EncapsulatedContentInfoStream |
getEncapsulatedContentInfoStream()
Returns the EncapsulatedContentInfoStream.
|
ObjectID |
getEncapsulatedContentType()
Returns the content type the EncapsulatetContentInfo represents.
|
java.io.InputStream |
getInputStream()
Returns an InputStream from where the compressed data can be read.
|
int |
getMode()
Returns the mode of this CompressedData.
|
int |
getVersion()
Returns the version of SMime compresssion being used (0)
|
void |
setBlockSize(int blocksize)
Sets the block size for defining the length of each definite primitive
encoded octet string component.
|
void |
setCompressionProvider(CompressionProvider compressionprovider)
Sets the CompressionProvider for this CompressedDataStream.
|
void |
setInputStream(java.io.InputStream inputstream)
Sets the content supplying input stream.
|
ASN1Object |
toASN1Object()
Returns this CMS CompressedDataStream as an ASN1Object.
|
protected ASN1Object |
toASN1Object(int blocksize)
Returns this CMS
CompressedData as ASN1Object. |
java.lang.String |
toString()
Returns a string giving some information about this
CompressedDataStream object. |
java.lang.String |
toString(boolean detailed)
Returns a string giving some - if requested - detailed information about
this
CompressedDataStream object. |
void |
writeTo(java.io.OutputStream outputstream)
BER encodes and writes this CompressedData to the supplied output stream.
|
void |
writeTo(java.io.OutputStream outputstream,
int blocksize)
Writes this CompressedData encoded to the supplied output stream.
|
protected java.io.InputStream m_inputStream
protected int m_blockSize
protected ObjectID m_encapContentType
protected AlgorithmID m_compressionAlgorithm
protected int m_version
public static final int DEFAULT_BLOCKSIZE
public static final int EXPLICIT
public static final int IMPLICIT
public static final ObjectID contentType
public CompressedDataStream(java.io.InputStream inputstream,
AlgorithmID algorithmid,
int mode)
inputstream - the InputStream containing the data to encryptalgorithmid - algorithm used to compress the datamode - either CompressedDataStream.IMPLICIT for including the
compressed data, or CompressedDataStream.EXPLICIT for not
including itpublic CompressedDataStream(java.io.InputStream inputstream)
throws CMSParsingException,
java.io.IOException
inputstream - the InputStream holding a BER encoded EncryptedDataStream
objectjava.io.IOException - if an I/O error occurs during reading from the InputStreamCMSParsingException - if an error occurs while parsing the objectpublic CompressedDataStream(ObjectID objectid, java.io.InputStream inputstream, AlgorithmID algorithmid, int mode)
objectid - the content type (e.g. ObjectID.cms_data) of the data to be
compressedinputstream - the data to be compressed, supplied from an input streamalgorithmid - the compression algorithm to be used for content compressionmode - either CompressedDataStream.IMPLICIT for including the
compressed data, or CompressedDataStream.EXPLICIT for not
including itprotected CompressedDataStream()
public void writeTo(java.io.OutputStream outputstream,
int blocksize)
throws java.io.IOException
* 0x24 0x80
0x04 <blocksize> <data>
0x04 <blocksize> <data>
0x04 <blocksize> <data>
...
0x00 0x00
If the block size is not positive, the whole data is encoded as one
single primitive definie octet string:
0x04 <length> <data>
outputstream - the output stream to which this SignedData shall be writtenblocksize - the block size defining the encoding scheme - and specifying
the length of each primitive encoded octet string component,
if positivejava.io.IOException - if an error occurs during writing the objectpublic void writeTo(java.io.OutputStream outputstream)
throws java.io.IOException
outputstream - the output stream to which this EnvelopedData shall be writtenjava.io.IOExceptionpublic java.lang.String toString(boolean detailed)
CompressedDataStream object.toString in interface ContentStreamdetailed - -
whether or not to give detailed informationpublic java.lang.String toString()
CompressedDataStream object.toString in class java.lang.Objectprotected ASN1Object toASN1Object(int blocksize) throws CMSException
CompressedData as ASN1Object.
Note: If AlgorithmID parameters are not set, this method will encode the AlgorithmIdentifier with only the algorithm ObjectID (as per RFC 3274 section 2.1 recommendations).
For Example:
Without Algorithm Parameters, AlgorithmIdentifier will be encoded as follows:
AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER }
With Algorithm Parameters, AlgorithmIdentifier will be encoded as
follows:
AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm }
blocksize - the block size defining the encoding scheme - and specifying
the length of each primitive encoded octet string component,
if positiveCompressedData as ASN1ObjectCMSException - if the ASN1Object could not be createdpublic ASN1Object toASN1Object() throws CMSException
toASN1Object in interface ContentStreamCompressedData as ASN1Object.CMSException - if the ASN1Object could not be createdpublic void setCompressionProvider(CompressionProvider compressionprovider)
This class may use the following method of the CompressionProvider, which may be overriden by an application, if required:
getInputStreamCompressEngine() to get an InputStreamCompressEngine through which the data is to be piped for data compression/decompression
compressionprovider - the CompressionProviderpublic CompressionProvider getCompressionProvider()
public void setInputStream(java.io.InputStream inputstream)
throws java.io.IOException,
java.security.NoSuchAlgorithmException
inputstream - an input stream supplying the content to be
compressed/decompressedjava.io.IOException - -
if an I/O error occursjava.security.NoSuchAlgorithmException - -
if the compression algorithm is not supportedpublic void setBlockSize(int blocksize)
blockSize
is smaller or equal to zero the whole data is encoded as definite
primitive octet string.setBlockSize in interface ContentStreamblocksize - for defining the encoding scheme and setting the octet string
component length, if positivepublic int getVersion()
public int getMode()
public java.io.InputStream getInputStream()
throws java.io.IOException,
java.security.NoSuchAlgorithmException
When having created a new CompressedDataStream object to be encoded to a stream, this method should only be called in EXPLICT mode to get and read away the compressed content to be transmitted by other means. In IMPLICT mode this method shall not be called at all since the compressed content has to be included in the CompressedData message (and therefore should not be read "away"). When having decoded and parsed a received CompressedDataStream object coming from some stream, this method may be used for obtaining the raw (decompressed) content.
java.io.IOExceptionjava.security.NoSuchAlgorithmExceptionpublic ObjectID getEncapsulatedContentType()
public EncapsulatedContentInfoStream getEncapsulatedContentInfoStream()
public ObjectID getContentType()
getContentType in interface ContentStreamObjectID.cms_compressedData ("1.2..840.113549.1.9.16.1.9") public AlgorithmID getCompressionAlgorithm()
public int getBlockSize()
blockSize
is smaller or equal to zero the whole data is encoded as definite
primitive octet string.getBlockSize in interface ContentStreampublic void decode(java.io.InputStream inputstream)
throws CMSParsingException,
java.io.IOException
decode in interface ContentStreaminputstream - the InputStream supplying an encoded CompressedData objectjava.io.IOException - if an I/O error occurs during reading from the InputStreamCMSParsingException - if an error occurs while parsing the object