| java.lang.Object sun.security.util.DerInputStream
DerInputStream | public class DerInputStream (Code) | | A DER input stream, used for parsing ASN.1 DER-encoded data such as
that found in X.509 certificates. DER is a subset of BER/1, which has
the advantage that it allows only a single encoding of primitive data.
(High level data such as dates still support many encodings.) That is,
it uses the "Definite" Encoding Rules (DER) not the "Basic" ones (BER).
Note that, like BER/1, DER streams are streams of explicitly
tagged data values. Accordingly, this programming interface does
not expose any variant of the java.io.InputStream interface, since
that kind of input stream holds untagged data values and using that
I/O model could prevent correct parsing of the DER data.
At this time, this class supports only a subset of the types of DER
data encodings which are defined. That subset is sufficient for parsing
most X.509 certificates.
version: 1.47 author: David Brownell author: Amit Kapoor author: Hemma Prafullchandra |
Constructor Summary | |
public | DerInputStream(byte[] data) Create a DER input stream from a data buffer. | public | DerInputStream(byte[] data, int offset, int len) Create a DER input stream from part of a data buffer.
The buffer is not copied, it is shared. | | DerInputStream(DerInputBuffer buf) |
Method Summary | |
public int | available() Returns the number of bytes available for reading. | public String | getBMPString() Read a string that was encoded as a BMPString DER value. | public BigInteger | getBigInteger() Get a integer from the input stream as a BigInteger object. | public byte[] | getBitString() Get a bit string from the input stream. | int | getByte() | public void | getBytes(byte[] val) Returns the asked number of bytes from the input stream. | public DerValue | getDerValue() Get a single DER-encoded value from the input stream.
It can often be useful to pull a value from the stream
and defer parsing it. | public int | getEnumerated() Get an enumerated from the input stream. | public String | getGeneralString() Read a string that was encoded as a GeneralString DER value. | public Date | getGeneralizedTime() Get a Generalized encoded time value from the input stream. | public String | getIA5String() Read a string that was encoded as a IA5tring DER value. | public int | getInteger() Get an integer from the input stream as an integer. | int | getLength() | static int | getLength(InputStream in) | static int | getLength(int lenByte, InputStream in) | public void | getNull() Reads an encoded null value from the input stream. | public ObjectIdentifier | getOID() Reads an X.200 style Object Identifier from the stream. | public byte[] | getOctetString() Returns an ASN.1 OCTET STRING from the input stream. | public String | getPrintableString() Read a string that was encoded as a PrintableString DER value. | public DerValue[] | getSequence(int startLen) Return a sequence of encoded entities. | public DerValue[] | getSet(int startLen) Return a set of encoded entities. | public DerValue[] | getSet(int startLen, boolean implicit) Return a set of encoded entities. | public String | getT61String() Read a string that was encoded as a T61String DER value. | public Date | getUTCTime() Get a UTC encoded time value from the input stream. | public String | getUTF8String() Read a string that was encoded as a UTF8String DER value. | public BitArray | getUnalignedBitString() Get a bit string from the input stream. | public void | mark(int value) Mark the current position in the buffer, so that
a later call to reset will return here. | public int | peekByte() | protected DerValue[] | readVector(int startLen) | public void | reset() Return to the position of the last mark
call. | public DerInputStream | subStream(int len, boolean do_skip) Creates a new DER input stream from part of this input stream.
Parameters: len - how long a chunk of the current input stream to use,starting at the current position. Parameters: do_skip - true if the existing data in the input stream shouldbe skipped. | public byte[] | toByteArray() Return what has been written to this DerInputStream
as a byte array. |
tag | public byte tag(Code) | | The DER tag of the value; one of the tag_ constants.
|
DerInputStream | public DerInputStream(byte[] data) throws IOException(Code) | | Create a DER input stream from a data buffer. The buffer is not
copied, it is shared. Accordingly, the buffer should be treated
as read-only.
Parameters: data - the buffer from which to create the string (CONSUMED) |
DerInputStream | public DerInputStream(byte[] data, int offset, int len) throws IOException(Code) | | Create a DER input stream from part of a data buffer.
The buffer is not copied, it is shared. Accordingly, the
buffer should be treated as read-only.
Parameters: data - the buffer from which to create the string (CONSUMED) Parameters: offset - the first index of data which willbe read as DER input in the new stream Parameters: len - how long a chunk of the buffer to use,starting at "offset" |
available | public int available()(Code) | | Returns the number of bytes available for reading.
This is most useful for testing whether the stream is
empty.
|
getBMPString | public String getBMPString() throws IOException(Code) | | Read a string that was encoded as a BMPString DER value.
|
getBigInteger | public BigInteger getBigInteger() throws IOException(Code) | | Get a integer from the input stream as a BigInteger object.
the integer held in this DER input stream. |
getBitString | public byte[] getBitString() throws IOException(Code) | | Get a bit string from the input stream. Padded bits (if any)
will be stripped off before the bit string is returned.
|
getBytes | public void getBytes(byte[] val) throws IOException(Code) | | Returns the asked number of bytes from the input stream.
|
getDerValue | public DerValue getDerValue() throws IOException(Code) | | Get a single DER-encoded value from the input stream.
It can often be useful to pull a value from the stream
and defer parsing it. For example, you can pull a nested
sequence out with one call, and only examine its elements
later when you really need to.
|
getEnumerated | public int getEnumerated() throws IOException(Code) | | Get an enumerated from the input stream.
the integer held in this DER input stream. |
getGeneralString | public String getGeneralString() throws IOException(Code) | | Read a string that was encoded as a GeneralString DER value.
|
getGeneralizedTime | public Date getGeneralizedTime() throws IOException(Code) | | Get a Generalized encoded time value from the input stream.
|
getIA5String | public String getIA5String() throws IOException(Code) | | Read a string that was encoded as a IA5tring DER value.
|
getInteger | public int getInteger() throws IOException(Code) | | Get an integer from the input stream as an integer.
the integer held in this DER input stream. |
getNull | public void getNull() throws IOException(Code) | | Reads an encoded null value from the input stream.
|
getOctetString | public byte[] getOctetString() throws IOException(Code) | | Returns an ASN.1 OCTET STRING from the input stream.
|
getPrintableString | public String getPrintableString() throws IOException(Code) | | Read a string that was encoded as a PrintableString DER value.
|
getSequence | public DerValue[] getSequence(int startLen) throws IOException(Code) | | Return a sequence of encoded entities. ASN.1 sequences are
ordered, and they are often used, like a "struct" in C or C++,
to group data values. They may have optional or context
specific values.
Parameters: startLen - guess about how long the sequence will be(used to initialize an auto-growing data structure) array of the values in the sequence |
getSet | public DerValue[] getSet(int startLen) throws IOException(Code) | | Return a set of encoded entities. ASN.1 sets are unordered,
though DER may specify an order for some kinds of sets (such
as the attributes in an X.500 relative distinguished name)
to facilitate binary comparisons of encoded values.
Parameters: startLen - guess about how large the set will be(used to initialize an auto-growing data structure) array of the values in the sequence |
getSet | public DerValue[] getSet(int startLen, boolean implicit) throws IOException(Code) | | Return a set of encoded entities. ASN.1 sets are unordered,
though DER may specify an order for some kinds of sets (such
as the attributes in an X.500 relative distinguished name)
to facilitate binary comparisons of encoded values.
Parameters: startLen - guess about how large the set will be(used to initialize an auto-growing data structure) Parameters: implicit - if true tag is assumed implicit. array of the values in the sequence |
getT61String | public String getT61String() throws IOException(Code) | | Read a string that was encoded as a T61String DER value.
|
getUTCTime | public Date getUTCTime() throws IOException(Code) | | Get a UTC encoded time value from the input stream.
|
getUTF8String | public String getUTF8String() throws IOException(Code) | | Read a string that was encoded as a UTF8String DER value.
|
getUnalignedBitString | public BitArray getUnalignedBitString() throws IOException(Code) | | Get a bit string from the input stream. The bit string need
not be byte-aligned.
|
mark | public void mark(int value)(Code) | | Mark the current position in the buffer, so that
a later call to reset will return here.
|
reset | public void reset()(Code) | | Return to the position of the last mark
call. A mark is implicitly set at the beginning of
the stream when it is created.
|
subStream | public DerInputStream subStream(int len, boolean do_skip) throws IOException(Code) | | Creates a new DER input stream from part of this input stream.
Parameters: len - how long a chunk of the current input stream to use,starting at the current position. Parameters: do_skip - true if the existing data in the input stream shouldbe skipped. If this value is false, the next data readon this stream and the newly created stream will be thesame. |
toByteArray | public byte[] toByteArray()(Code) | | Return what has been written to this DerInputStream
as a byte array. Useful for debugging.
|
|
|