public class

BerInputStream

extends Object
java.lang.Object
   ↳ com.microstrategy.utils.BerInputStream
Known Direct Subclasses

Class Overview

Decodes ASN.1 types encoded with BER (X.690)

Summary

Constants
int INDEFINIT_LENGTH Indicates indefinite length of the current type
Fields
protected byte[] buffer Internal buffer for storing encoded array
public int choiceIndex The last choice index
public Object content Current decoded content
protected int contentOffset Current decoded content offset
protected InputStream in Associated InputStream
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.
public int oidElement
public int tag Current decoded tag
protected int tagOffset Current decoded tag offset
public int[] times Keeps last decoded: year, month, day, hour, minute, second, millisecond
Public Constructors
BerInputStream(InputStream in)
Creates stream for decoding.
BerInputStream(InputStream in, int initialSize)
Creates stream for decoding.
Public Methods
void compactBuffer()
Reallocates the buffer in order to make it exactly the size of data it contains
Object get(Object key)
final byte[] getBuffer()
Returns internal buffer used for decoding
final int getContentOffset()
byte[] getEncoded()
Returns encoded array.
final int getEndOffset()
Returns end offset for the current encoded type
final int getLength()
Returns length of the current content for decoding
static int getLength(byte[] encoding)
Returns the length of the encoding
final int getOffset()
Returns the current offset
final int getTagOffset()
Returns start offset for the current encoded type
int next()
Decodes next encoded type.
void put(Object key, Object entry)
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 readOID()
Decodes ASN.1 ObjectIdentifier type
void readOctetString()
Decodes ASN.1 Octetstring type
final void setVerify()
Sets verify mode.
Protected Methods
int read()
Reads the next encoded byte from the encoded input stream.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

protected static final int INDEFINIT_LENGTH

Indicates indefinite length of the current type

Constant Value: -1 (0xffffffff)

Fields

protected byte[] buffer

Internal buffer for storing encoded array

public int choiceIndex

The last choice index

public Object content

Current decoded content

protected int contentOffset

Current decoded content offset

protected InputStream in

Associated InputStream

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.

protected boolean isVerify

Indicates verify or store mode. In store mode a decoded content is stored in a newly allocated appropriate object. The content variable holds a reference to the last created object. In verify mode a decoded content is not stored.

protected int length

Current decoded length

protected int offset

The position in the buffer. Next read must place data into the buffer from this offset

public int oidElement

public int tag

Current decoded tag

protected int tagOffset

Current decoded tag offset

public int[] times

Keeps last decoded: year, month, day, hour, minute, second, millisecond

Public Constructors

public BerInputStream (InputStream in)

Creates stream for decoding. Allocates initial buffer of default size

Parameters
in is associated InputStream
Throws
IOException

public BerInputStream (InputStream in, int initialSize)

Creates stream for decoding. Allocates initial buffer of initialSize size

Parameters
in is associated InputStream
initialSize the internal buffer initial size
Throws
IOException

Public Methods

public void compactBuffer ()

Reallocates the buffer in order to make it exactly the size of data it contains

public Object get (Object key)

public final byte[] getBuffer ()

Returns internal buffer used for decoding

Returns
  • - buffer

public final int getContentOffset ()

public byte[] getEncoded ()

Returns encoded array. MUST be invoked after decoding corresponding ASN.1 notation

public final int getEndOffset ()

Returns end offset for the current encoded type

Returns
  • - offset

public final int getLength ()

Returns length of the current content for decoding

Returns
  • - length of content

public static int getLength (byte[] encoding)

Returns the length of the encoding

public final int getOffset ()

Returns the current offset

Returns
  • - offset

public final int getTagOffset ()

Returns start offset for the current encoded type

Returns
  • - offset

public int next ()

Decodes next encoded type. Initializes tag, length, tagOffset and contentOffset variables

Returns
  • next decoded tag
Throws
IOException - if error occured

public void put (Object key, Object entry)

public void readBitString ()

Decodes ASN.1 bitstring type

Throws
IOException - if error occured

public void readBoolean ()

Decodes ASN.1 boolean type

Throws
IOException - if error occured

public void readContent ()

Reads the next encoded content from the encoded input stream. The method MUST be used for reading a primitive encoded content.

Throws
IOException - if error occured

public void readEnumerated ()

Decodes ASN.1 Enumerated type

Throws
IOException - if error occured

public void readOID ()

Decodes ASN.1 ObjectIdentifier type

Throws
IOException - if error occured

public void readOctetString ()

Decodes ASN.1 Octetstring type

Throws
IOException - if error occured

public final void setVerify ()

Sets verify mode.

Protected Methods

protected int read ()

Reads the next encoded byte from the encoded input stream.

Returns
  • the next encoded byte
Throws
IOException - if error occured