|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--iaik.pkcs.pkcs7.DataStream
This class represents the stream-implementation of the PKCS#7 content
type Data.
Each PKCS#7 content type is associated with a specific object identifier, derived from:
pkcs-7 OBJECT IDENTIFIER ::=
{ iso(1) member-body(2) US(840) rsadsi(113549)
pkcs(1) 7 }
The object identifier for the Data content type is defined as:
data OBJECT IDENTIFIER ::= { pkcs-7 1 }
which corresponds to the OID string "1.2.840.1.113549.1.7.1".
PKCS#7 specifies
the Data content type as base type without any cryptographic enhancements:
Data ::= OCTET STRING
Use the DataStream(InputStream is, int blockSize)
constructor to create a new DataStream object for the given raw data supplying
input stream:
InputStream input_stream = ...; int blockSize = ...; DataStream data_stream = new DataStream(InputStream, blockSize);If
blockSize is set to a positive value, the data is BER encoded as
indefinite constructed octet string being composed of a series of definite primitive
encoded octet strings of blockSize length:
0x24 0x80
0x04 <blocksize> <data>
0x04 <blocksize> <data>
0x04 <blocksize> <data>
...
0x00 0x00
However, if blockSize
is not positive, whole the data is encoded as one single primitive definite octet string,
which may cause a memory overflow when dealing with large data volumes (consult the
documentation of the ContentStream
class for more information about the difference between the two encoding schemes).
In contrast to the non-stream variant of the PKCS#7 Data type (implemented by the
Data class), where the raw data is
supplied as byte array and therefore can be accessed arbitrarily often, it is important
to keep in mind that now for the DataStream class, the raw data carrying
input stream only can be read once, which shall not be done before actually performing
the encoding (again, see ContentStream)!
After writing a DataStream object BER encoded to an output stream by calling
the writeTo method, it may be read back, decoded
and re-parsed again by means of the DataStream(InputStream is)
constructor. In this case, the
getInputStream method may be used for
reading the raw data included in the received DataStream object.
ContentStream,
ContentInfoStream,
OCTET_STRING| Constructor Summary | |
protected |
DataStream()
Default constructor for dynamic object creation in ContentInfo. |
|
DataStream(InputStream is)
Creates a new PKCS#7 data from a BER encoded InputStream. |
|
DataStream(InputStream is,
int blockSize)
Creates a new PKCS#7 Data from an InputStream supplying the raw content data. |
| Method Summary | |
void |
decode(InputStream is)
Reads and decodes the Data from a DerInputStream. |
int |
getBlockSize()
Gets the block size defining the length of each definite primitive encoded octet string component. |
ObjectID |
getContentType()
Returns the object identifier of this PKCS#7 Data. |
InputStream |
getInputStream()
Returns an InputStream where the contents of this object can be read. |
void |
setBlockSize(int blockSize)
Sets the block size for defining the length of each definite primitive encoded octet string component. |
ASN1Object |
toASN1Object()
Returns this PKCS#7 Data as ASN1Object.
|
String |
toString()
Returns a string giving some information about this DataStream
object. |
String |
toString(boolean detailed)
Returns a string giving some - if requested - detailed information about this DataStream object. |
void |
writeTo(OutputStream os)
Writes this PKCS#7 DataStream object BER encoded to the given output stream.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected DataStream()
public DataStream(InputStream is,
int blockSize)
blockSize is smaller or equal to zero, the data
will be DER encoded as primitive definite OCTET STRING when writing it to
a stream by means of the writeTo method.
However, if blockSize is set to a positive value, the data will
be BER encoded as indefinite constructed octet string being composed of a series
of definite primitive encoded octet strings of blockSize length:
0x24 0x80
0x04 <blocksize> <data>
0x04 <blocksize> <data>
0x04 <blocksize> <data>
...
0x00 0x00
is - the stream containing the contentblockSize - the block size defining the length of each primitive definite
encoded octet string component; or initiating an entire primitive
definite encoding, when being not positiveOCTET_STRING
public DataStream(InputStream is)
throws IOException,
PKCSParsingException
DataStream object, supplied as BER encoded input stream that
may have been created by calling writeTo.
Use the DataStream(InputStream is, int blockSize)
constructor for supplying the content data when creating a
DataStream object.
IOException - if an I/O error occurs during reading from the InputStreamPKCSParsingException - if an error occurs while parsing the object| Method Detail |
public void decode(InputStream is)
throws IOException,
PKCSParsingException
DerInputStream,
internally a DerInputStream is created before parsing the data.decode in interface ContentStreamis - the InputStream holding a DER encoded PKCS#7 Data objectIOException - if an I/O error occurs during reading from the InputStreamPKCSParsingException - if an error occurs while parsing the objectDerInputStreampublic 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 positiveOCTET_STRINGpublic int getBlockSize()
blockSize is smaller or equal to zero the
whole data is encoded as definite primitive octet string.
This method may be used for enforcing block encoding when wrapping the
EncryptedData into a ContentInfo.getBlockSize in interface ContentStreamOCTET_STRINGpublic ObjectID getContentType()
Data.getContentType in interface ContentStreamObjectID.pkcs7_dataObjectIDpublic InputStream getInputStream()
When having created a new DataStream object to be encoded
to a stream, this method should not be utilized at all, since the stream
automatically will be read during performing the encoding (which is done
when calling the writeTo method).
When having decoded and parsed a DataStream object coming
from some stream, this method may be used for reading the raw data.
public ASN1Object toASN1Object()
throws PKCSException
Data as ASN1Object.
From the internal value an ASN.1 OCTET STRING object is created. If block size
has a value > 0 a constructed OCTET STRING is created.toASN1Object in interface ContentStreamData as ASN1ObjectOCTET_STRING
public void writeTo(OutputStream os)
throws PKCSException,
IOException
DataStream object BER encoded to the given output stream.
From the internal value an ASN.1 OCTET STRING object is created, BER
encoded and written to the stream.
If block size has a value > 0 a constructed OCTET STRING is created. In
this case the encoding is splitted according to the defined block size:
0x24 0x80
0x04 <blocksize> <data>
0x04 <blocksize> <data>
0x04 <blocksize> <data>
...
0x00 0x00
If the block size is not positive, whole the data is encoded as one
single primitive definite octet string:
0x04 <length> <data>
the - output stream to which to encode the dataIOException - if an error occurs during writing to the streamPKCSException - if an encoding error occursOCTET_STRINGpublic String toString()
DataStream
object.toString in class Objectpublic String toString(boolean detailed)
DataStream object.toString in interface ContentStreamdetailed - - whether or not to give detailed information
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK