Package com.microstrategy.utils
Class BerInputStream
- java.lang.Object
 - 
- com.microstrategy.utils.BerInputStream
 
 
- 
- Direct Known Subclasses:
 DerInputStream
public class BerInputStream extends java.lang.ObjectDecodes ASN.1 types encoded with BER (X.690)- Since:
 - MicroStrategy Web 9.0.1
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected byte[]bufferInternal buffer for storing encoded arrayintchoiceIndexThe last choice indexjava.lang.ObjectcontentCurrent decoded contentprotected intcontentOffsetCurrent decoded content offsetprotected java.io.InputStreaminAssociatedInputStreamprotected static intINDEFINIT_LENGTHIndicates indefinite length of the current typeprotected booleanisIndefinedLengthIndicates defined or indefined reading mode for associated InputStream.protected booleanisVerifyIndicates verify or store mode.protected intlengthCurrent decoded lengthprotected intoffsetThe position in the buffer.intoidElementinttagCurrent decoded tagprotected inttagOffsetCurrent decoded tag offsetint[]timesKeeps 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 voidcompactBuffer()Reallocates the buffer in order to make it exactly the size of data it containsjava.lang.Objectget(java.lang.Object key)byte[]getBuffer()Returns internal buffer used for decodingintgetContentOffset()byte[]getEncoded()Returns encoded array.intgetEndOffset()Returns end offset for the current encoded typeintgetLength()Returns length of the current content for decodingstatic intgetLength(byte[] encoding)Returns the length of the encodingintgetOffset()Returns the current offsetintgetTagOffset()Returns start offset for the current encoded typeintnext()Decodes next encoded type.voidput(java.lang.Object key, java.lang.Object entry)protected intread()Reads the next encoded byte from the encoded input stream.voidreadBitString()Decodes ASN.1 bitstring typevoidreadBoolean()Decodes ASN.1 boolean typevoidreadContent()Reads the next encoded content from the encoded input stream.voidreadEnumerated()Decodes ASN.1 Enumerated typevoidreadOctetString()Decodes ASN.1 Octetstring typevoidreadOID()Decodes ASN.1 ObjectIdentifier typevoidsetVerify()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. Thecontentvariable 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.IOExceptionCreates 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.IOExceptionCreates stream for decoding. Allocates initial buffer ofinitialSizesize- Parameters:
 in- is associatedInputStreaminitialSize- the internal buffer initial size- Throws:
 java.io.IOException
 
 - 
 
- 
Method Detail
- 
next
public int next() throws java.io.IOExceptionDecodes 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.IOExceptionDecodes ASN.1 bitstring type- Throws:
 java.io.IOException- - if error occured
 
- 
readEnumerated
public void readEnumerated() throws java.io.IOExceptionDecodes ASN.1 Enumerated type- Throws:
 java.io.IOException- - if error occured
 
- 
readBoolean
public void readBoolean() throws java.io.IOExceptionDecodes ASN.1 boolean type- Throws:
 java.io.IOException- - if error occured
 
- 
readOctetString
public void readOctetString() throws java.io.IOExceptionDecodes ASN.1 Octetstring type- Throws:
 java.io.IOException- - if error occured
 
- 
readOID
public void readOID() throws java.io.IOExceptionDecodes 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.IOExceptionReads 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.IOExceptionReads 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)
 
 - 
 
 -