Package com.microstrategy.utils
Class BerInputStream
- java.lang.Object
-
- com.microstrategy.utils.BerInputStream
-
- Direct Known Subclasses:
DerInputStream
public class BerInputStream extends java.lang.Object
Decodes ASN.1 types encoded with BER (X.690)- Since:
- MicroStrategy Web 9.0.1
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
buffer
Internal buffer for storing encoded arrayint
choiceIndex
The last choice indexjava.lang.Object
content
Current decoded contentprotected int
contentOffset
Current decoded content offsetprotected java.io.InputStream
in
AssociatedInputStream
protected static int
INDEFINIT_LENGTH
Indicates indefinite length of the current typeprotected boolean
isIndefinedLength
Indicates defined or indefined reading mode for associated InputStream.protected boolean
isVerify
Indicates verify or store mode.protected int
length
Current decoded lengthprotected int
offset
The position in the buffer.int
oidElement
int
tag
Current decoded tagprotected int
tagOffset
Current decoded tag offsetint[]
times
Keeps last decoded: year, month, day, hour, minute, second, millisecond
-
Constructor Summary
Constructors Constructor Description BerInputStream(java.io.InputStream in)
Creates stream for decoding.BerInputStream(java.io.InputStream in, int initialSize)
Creates stream for decoding.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
compactBuffer()
Reallocates the buffer in order to make it exactly the size of data it containsjava.lang.Object
get(java.lang.Object key)
byte[]
getBuffer()
Returns internal buffer used for decodingint
getContentOffset()
byte[]
getEncoded()
Returns encoded array.int
getEndOffset()
Returns end offset for the current encoded typeint
getLength()
Returns length of the current content for decodingstatic int
getLength(byte[] encoding)
Returns the length of the encodingint
getOffset()
Returns the current offsetint
getTagOffset()
Returns start offset for the current encoded typeint
next()
Decodes next encoded type.void
put(java.lang.Object key, java.lang.Object entry)
protected int
read()
Reads the next encoded byte from the encoded input stream.void
readBitString()
Decodes ASN.1 bitstring typevoid
readBoolean()
Decodes ASN.1 boolean typevoid
readContent()
Reads the next encoded content from the encoded input stream.void
readEnumerated()
Decodes ASN.1 Enumerated typevoid
readOctetString()
Decodes ASN.1 Octetstring typevoid
readOID()
Decodes ASN.1 ObjectIdentifier typevoid
setVerify()
Sets verify mode.
-
-
-
Field Detail
-
in
protected java.io.InputStream in
AssociatedInputStream
-
buffer
protected byte[] buffer
Internal buffer for storing encoded array
-
offset
protected int offset
The position in the buffer. Next read must place data into the buffer from this offset
-
INDEFINIT_LENGTH
protected static final int INDEFINIT_LENGTH
Indicates indefinite length of the current type- See Also:
- Constant Field Values
-
tag
public int tag
Current decoded tag
-
length
protected int length
Current decoded length
-
content
public java.lang.Object content
Current decoded content
-
tagOffset
protected int tagOffset
Current decoded tag offset
-
contentOffset
protected int contentOffset
Current decoded content offset
-
choiceIndex
public int choiceIndex
The last choice index
-
times
public int[] times
Keeps last decoded: year, month, day, hour, minute, second, millisecond
-
oidElement
public int oidElement
-
isVerify
protected boolean isVerify
Indicates verify or store mode. In store mode a decoded content is stored in a newly allocated appropriate object. Thecontent
variable holds a reference to the last created object. In verify mode a decoded content is not stored.
-
isIndefinedLength
protected boolean isIndefinedLength
Indicates defined or indefined reading mode for associated InputStream. This mode is defined by reading a length for a first ASN.1 type from InputStream.
-
-
Constructor Detail
-
BerInputStream
public BerInputStream(java.io.InputStream in) throws java.io.IOException
Creates stream for decoding. Allocates initial buffer of default size- Parameters:
in
- is associatedInputStream
- Throws:
java.io.IOException
-
BerInputStream
public BerInputStream(java.io.InputStream in, int initialSize) throws java.io.IOException
Creates stream for decoding. Allocates initial buffer ofinitialSize
size- Parameters:
in
- is associatedInputStream
initialSize
- the internal buffer initial size- Throws:
java.io.IOException
-
-
Method Detail
-
next
public int next() throws java.io.IOException
Decodes next encoded type. Initializes tag, length, tagOffset and contentOffset variables- Returns:
- next decoded tag
- Throws:
java.io.IOException
- - if error occured
-
getLength
public static int getLength(byte[] encoding)
Returns the length of the encoding
-
readBitString
public void readBitString() throws java.io.IOException
Decodes ASN.1 bitstring type- Throws:
java.io.IOException
- - if error occured
-
readEnumerated
public void readEnumerated() throws java.io.IOException
Decodes ASN.1 Enumerated type- Throws:
java.io.IOException
- - if error occured
-
readBoolean
public void readBoolean() throws java.io.IOException
Decodes ASN.1 boolean type- Throws:
java.io.IOException
- - if error occured
-
readOctetString
public void readOctetString() throws java.io.IOException
Decodes ASN.1 Octetstring type- Throws:
java.io.IOException
- - if error occured
-
readOID
public void readOID() throws java.io.IOException
Decodes ASN.1 ObjectIdentifier type- Throws:
java.io.IOException
- - if error occured
-
getEncoded
public byte[] getEncoded()
Returns encoded array. MUST be invoked after decoding corresponding ASN.1 notation
-
getBuffer
public final byte[] getBuffer()
Returns internal buffer used for decoding- Returns:
- - buffer
-
getLength
public final int getLength()
Returns length of the current content for decoding- Returns:
- - length of content
-
getOffset
public final int getOffset()
Returns the current offset- Returns:
- - offset
-
getEndOffset
public final int getEndOffset()
Returns end offset for the current encoded type- Returns:
- - offset
-
getTagOffset
public final int getTagOffset()
Returns start offset for the current encoded type- Returns:
- - offset
-
getContentOffset
public final int getContentOffset()
-
setVerify
public final void setVerify()
Sets verify mode.
-
read
protected int read() throws java.io.IOException
Reads the next encoded byte from the encoded input stream.- Returns:
- the next encoded byte
- Throws:
java.io.IOException
- - if error occured
-
readContent
public void readContent() throws java.io.IOException
Reads the next encoded content from the encoded input stream. The method MUST be used for reading a primitive encoded content.- Throws:
java.io.IOException
- - if error occured
-
compactBuffer
public void compactBuffer()
Reallocates the buffer in order to make it exactly the size of data it contains
-
put
public void put(java.lang.Object key, java.lang.Object entry)
-
get
public java.lang.Object get(java.lang.Object key)
-
-