APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.jndi.ldap

public final Class BerDecoder

extends Ber
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.ISO_8859_1, .StandardCharsets.UTF_8

A BER decoder. Contains methods to parse a BER buffer.
Authors
Jagane Sundar, Vincent Ryan

Field Summary

Modifier and TypeField and Description
private int
Inherited from com.sun.jndi.ldap.Ber:
ASN_APPLICATIONASN_BIT_STRINGASN_BOOLEANASN_CONSTRUCTORASN_CONTEXTASN_ENUMERATEDASN_INTEGERASN_NULLASN_OBJECT_IDASN_OCTET_STRASN_PRIMITIVEASN_PRIVATEASN_SEQUENCEASN_SETASN_SIMPLE_STRINGASN_UNIVERSALbufbufsizeoffset

Constructor Summary

AccessConstructor and Description
public
BerDecoder(byte[] buf, int offset, int bufsize)

Creates a BER decoder that reads bytes from the specified buffer.

Method Summary

Modifier and TypeMethod and Description
public int
bytesLeft()

Returns the number of unparsed bytes in this BER buffer.

public int
getParsePosition()

Returns the current parse position.

public boolean

Returns:

true if the tagged integer is 0; false otherwise.
parseBoolean
()

Parses an ASN_BOOLEAN tagged integer from this BER buffer.

public int

Returns:

The byte parsed.
parseByte
()

Parses the next byte in this BER buffer.

public int

Returns:

The tag of enumeration.
parseEnumeration
()

Parses an ASN_ENUMERATED tagged integer from this BER buffer.

public int

Returns:

The value of the integer.
parseInt
()

Parses an ASN_INTEGER tagged integer from this BER buffer.

private int
parseIntWithTag(int tag)

Parses an integer that's preceded by a tag.

public int
parseLength()

Parses a possibly variable length field.

public byte[]

Returns:

A non-null array containing the octet string.
parseOctetString
(int
The tag to look for.
tag
,
int[]
An array for returning the relative parsed position. If null, the relative parsed position is not returned.
rlen
)

Parses an octet string of a given type(tag) from this BER buffer.

public int

Returns:

The sequence's tag.
parseSeq
(int[]
An array for returning size of the sequence in bytes. If null, the size is not returned.
rlen
)

Parses the next sequence in this BER buffer.

public String
parseString(boolean decodeUTF8)

Parses a string.

public String

Returns:

The non-null parsed string.
parseStringWithTag
(int
The tag that precedes the string.
tag
,
boolean
If true, use UTF-8 when decoding the string; otherwise use ISO-Latin-1 (8859_1). Use true for LDAPv3; false for LDAPv2.
decodeUTF8
,
int[]
An array for holding the relative parsed offset; if null offset not set.
rlen
)

Parses a string of a given tag from this BER buffer.

public int

Returns:

The next byte.
peekByte
()

Returns the next byte in this BER buffer without consuming it.

public void
reset()

Resets this decode to start parsing from the initial offset (ie., same state as after calling the constructor).

pack-priv void
seek(int
The number of bytes to skip
i
)

Used to skip bytes.

Inherited from com.sun.jndi.ldap.Ber:
dumpBER

Field Detail

origOffsetback to summary
private int origOffset

Constructor Detail

BerDecoderback to summary
public BerDecoder(byte[] buf, int offset, int bufsize)

Creates a BER decoder that reads bytes from the specified buffer.

Method Detail

bytesLeftback to summary
public int bytesLeft()

Returns the number of unparsed bytes in this BER buffer.

getParsePositionback to summary
public int getParsePosition()

Returns the current parse position. It points to the byte that will be parsed next. Useful for parsing sequences.

parseBooleanback to summary
public boolean parseBoolean() throws DecodeException

Parses an ASN_BOOLEAN tagged integer from this BER buffer.

Returns:boolean

true if the tagged integer is 0; false otherwise.

parseByteback to summary
public int parseByte() throws DecodeException

Parses the next byte in this BER buffer.

Returns:int

The byte parsed.

parseEnumerationback to summary
public int parseEnumeration() throws DecodeException

Parses an ASN_ENUMERATED tagged integer from this BER buffer.

Returns:int

The tag of enumeration.

parseIntback to summary
public int parseInt() throws DecodeException

Parses an ASN_INTEGER tagged integer from this BER buffer.

Returns:int

The value of the integer.

parseIntWithTagback to summary
private int parseIntWithTag(int tag) throws DecodeException

Parses an integer that's preceded by a tag.

 BER integer ::= tag length byte {byte}*
parseLengthback to summary
public int parseLength() throws DecodeException

Parses a possibly variable length field.

parseOctetStringback to summary
public byte[] parseOctetString(int tag, int[] rlen) throws DecodeException

Parses an octet string of a given type(tag) from this BER buffer.

 BER Binary Data of type "tag" ::= tag length {byte}*
Parameters
tag:int

The tag to look for.

rlen:int[]

An array for returning the relative parsed position. If null, the relative parsed position is not returned.

Returns:byte[]

A non-null array containing the octet string.

Exceptions
DecodeException:
If the next byte in the BER buffer is not tag, or if length specified in the BER buffer exceeds the number of bytes left in the buffer.
parseSeqback to summary
public int parseSeq(int[] rlen) throws DecodeException

Parses the next sequence in this BER buffer.

Parameters
rlen:int[]

An array for returning size of the sequence in bytes. If null, the size is not returned.

Returns:int

The sequence's tag.

parseStringback to summary
public String parseString(boolean decodeUTF8) throws DecodeException

Parses a string.

parseStringWithTagback to summary
public String parseStringWithTag(int tag, boolean decodeUTF8, int[] rlen) throws DecodeException

Parses a string of a given tag from this BER buffer.

BER simple string ::= tag length {byte}*
Parameters
tag:int

The tag that precedes the string.

decodeUTF8:boolean

If true, use UTF-8 when decoding the string; otherwise use ISO-Latin-1 (8859_1). Use true for LDAPv3; false for LDAPv2.

rlen:int[]

An array for holding the relative parsed offset; if null offset not set.

Returns:String

The non-null parsed string.

peekByteback to summary
public int peekByte() throws DecodeException

Returns the next byte in this BER buffer without consuming it.

Returns:int

The next byte.

resetback to summary
public void reset()

Resets this decode to start parsing from the initial offset (ie., same state as after calling the constructor).

seekback to summary
pack-priv void seek(int i) throws DecodeException

Used to skip bytes. Usually used when trying to recover from parse error. Don't need to be public right now?

Parameters
i:int

The number of bytes to skip