public class BerInputStream extends Object
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buffer |
int |
choiceIndex
The last choice index
|
Object |
content
Current decoded content
|
protected int |
contentOffset
Current decoded content offset
|
protected static int |
INDEFINIT_LENGTH
Indicates indefinite length of the current type
|
protected boolean |
isIndefinedLength
Indicates defined or indefined reading mode for associated InputStream.
|
protected boolean |
isVerify
Indicates verify or store mode.
|
protected int |
length
Current decoded length
|
protected int |
offset
The position in the buffer.
|
int |
oidElement |
int |
tag
Current decoded tag
|
protected int |
tagOffset
Current decoded tag offset
|
int[] |
times
Keeps last decoded: year, month, day, hour, minute, second, millisecond
|
Constructor and Description |
---|
BerInputStream(byte[] encoded)
Creates stream for decoding.
|
BerInputStream(byte[] encoded,
int offset,
int expectedLength)
Creates stream for decoding.
|
BerInputStream(InputStream in)
Creates stream for decoding.
|
BerInputStream(InputStream in,
int initialSize)
Creates stream for decoding.
|
Modifier and Type | Method and Description |
---|---|
void |
compactBuffer()
Reallocates the buffer in order to make it
exactly the size of data it contains
|
Object |
get(Object key) |
byte[] |
getBuffer()
Returns internal buffer used for decoding
|
byte[] |
getEncoded()
Returns encoded array.
|
int |
getEndOffset()
Returns end offset for the current encoded type
|
int |
getLength()
Returns length of the current content for decoding
|
static int |
getLength(byte[] encoding)
Returns the length of the encoding
|
int |
getOffset()
Returns the current offset
|
int |
getTagOffset()
Returns start offset for the current encoded type
|
int |
next()
Decodes next encoded type.
|
void |
put(Object key,
Object entry) |
protected int |
read()
Reads the next encoded byte from the encoded input stream.
|
void |
readBitString()
Decodes ASN.1 bitstring type
|
void |
readBoolean()
Decodes ASN.1 boolean type
|
void |
readContent()
Reads the next encoded content from the encoded input stream.
|
void |
readEnumerated()
Decodes ASN.1 Enumerated type
|
void |
readGeneralizedTime()
Decodes ASN.1 GeneralizedTime type
|
void |
readInteger()
Decodes ASN.1 Integer type
|
void |
readOctetString()
Decodes ASN.1 Octetstring type
|
void |
readOID()
Decodes ASN.1 ObjectIdentifier type
|
void |
readSequence(ASN1Sequence sequence)
Decodes ASN.1 Sequence type
|
void |
readSequenceOf(ASN1SequenceOf sequenceOf)
Decodes ASN.1 SequenceOf type
|
void |
readSet(ASN1Set set)
Decodes ASN.1 Set type
|
void |
readSetOf(ASN1SetOf setOf)
Decodes ASN.1 SetOf type
|
void |
readString(ASN1StringType type)
Decodes ASN.1 String type
|
void |
readUTCTime()
Decodes ASN.1 UTCTime type
|
void |
reset(byte[] encoded)
Resets this stream to initial state.
|
void |
setVerify()
Sets verify mode.
|
protected byte[] buffer
protected int offset
protected static final int INDEFINIT_LENGTH
public int tag
protected int length
public Object content
protected int tagOffset
protected int contentOffset
public int choiceIndex
public int[] times
public int oidElement
protected boolean isVerify
content
variable holds
a reference to the last created object.
In verify mode a decoded content is not stored.protected boolean isIndefinedLength
public BerInputStream(byte[] encoded) throws IOException
IOException
public BerInputStream(byte[] encoded, int offset, int expectedLength) throws IOException
encoded
- bytes array to be decodedoffset
- the encoding offsetexpectedLength
- expected length of full encoding, this includes
identifier, length an content octetsIOException
public BerInputStream(InputStream in) throws IOException
IOException
public BerInputStream(InputStream in, int initialSize) throws IOException
initialSize
- the internal buffer initial sizeIOException
public final void reset(byte[] encoded) throws IOException
encoded
- a new bytes array to be decodedIOException
- if an error occurspublic int next() throws IOException
IOException
- if error occuredpublic static int getLength(byte[] encoding)
public void readBitString() throws IOException
IOException
public void readEnumerated() throws IOException
IOException
public void readBoolean() throws IOException
IOException
public void readGeneralizedTime() throws IOException
IOException
- if error occuredpublic void readUTCTime() throws IOException
IOException
- if an I/O error occurs or the end of the stream is reachedpublic void readInteger() throws IOException
IOException
public void readOctetString() throws IOException
IOException
public void readOID() throws IOException
IOException
public void readSequence(ASN1Sequence sequence) throws IOException
IOException
public void readSequenceOf(ASN1SequenceOf sequenceOf) throws IOException
IOException
public void readSet(ASN1Set set) throws IOException
IOException
public void readSetOf(ASN1SetOf setOf) throws IOException
IOException
public void readString(ASN1StringType type) throws IOException
IOException
- if an I/O error occurs or the end of the stream is reachedpublic byte[] getEncoded()
public final byte[] getBuffer()
public final int getLength()
public final int getOffset()
public final int getEndOffset()
public final int getTagOffset()
public final void setVerify()
protected int read() throws IOException
IOException
public void readContent() throws IOException
IOException
public void compactBuffer()