public final class BerEncoder extends Ber
ASN_APPLICATION, ASN_BIT_STRING, ASN_BOOLEAN, ASN_CONSTRUCTOR, ASN_CONTEXT, ASN_ENUMERATED, ASN_INTEGER, ASN_NULL, ASN_OBJECT_ID, ASN_OCTET_STR, ASN_PRIMITIVE, ASN_PRIVATE, ASN_SEQUENCE, ASN_SET, ASN_SIMPLE_STRING, ASN_UNIVERSAL, buf, bufsize, offset
Constructor and Description |
---|
BerEncoder()
Creates a BER buffer for encoding.
|
BerEncoder(int bufsize)
Creates a BER buffer of a specified size for encoding.
|
Modifier and Type | Method and Description |
---|---|
void |
beginSeq(int tag)
Begin encoding a sequence with a tag.
|
void |
encodeBoolean(boolean b)
Encodes a boolean.
|
void |
encodeBoolean(boolean b,
int tag)
Encodes a boolean and a tag
|
void |
encodeByte(int b)
Encode a single byte.
|
void |
encodeInt(int i) |
void |
encodeInt(int i,
int tag)
Encodes an int and a tag.
|
void |
encodeOctetString(byte[] tb,
int tag)
Encodes an octet string and a tag.
|
void |
encodeOctetString(byte[] tb,
int tag,
int tboffset,
int length)
Encodes a portion of an octet string and a tag.
|
void |
encodeString(String str,
boolean encodeUTF8)
Encodes a string.
|
void |
encodeString(String str,
int tag,
boolean encodeUTF8)
Encodes a string and a tag.
|
void |
encodeStringArray(String[] strs,
boolean encodeUTF8)
Encodes an array of strings.
|
void |
endSeq()
Terminate a BER sequence.
|
byte[] |
getBuf()
Gets the buffer that contains the BER encoding.
|
int |
getDataLen()
Gets the number of encoded bytes in this BER buffer.
|
byte[] |
getTrimmedBuf()
Gets the buffer that contains the BER encoding, trimming unused bytes.
|
void |
reset()
Resets encoder to state when newly constructed.
|
public BerEncoder()
public BerEncoder(int bufsize)
bufsize
- The number of bytes for the buffer.public void reset()
public int getDataLen()
public byte[] getBuf()
IllegalStateException
- If buffer contains unbalanced sequence.public byte[] getTrimmedBuf()
IllegalStateException
- If buffer contains unbalanced sequence.public void beginSeq(int tag)
public void endSeq() throws davmail.ldap.Ber.EncodeException
davmail.ldap.Ber.EncodeException
public void encodeByte(int b)
public void encodeInt(int i)
public void encodeInt(int i, int tag)
BER integer w tag ::= tag berlength byte {byte}*
public void encodeBoolean(boolean b)
BER boolean ::= 0x01 0x01 {0xff|0x00}
public void encodeBoolean(boolean b, int tag)
BER boolean w TAG ::= tag 0x01 {0xff|0x00}
public void encodeString(String str, boolean encodeUTF8) throws davmail.ldap.Ber.EncodeException
The string is converted into bytes using UTF-8 or ISO-Latin-1.BER string ::= 0x04 strlen byte1 byte2...
davmail.ldap.Ber.EncodeException
public void encodeString(String str, int tag, boolean encodeUTF8) throws davmail.ldap.Ber.EncodeException
BER string w TAG ::= tag strlen byte1 byte2...
davmail.ldap.Ber.EncodeException
public void encodeOctetString(byte[] tb, int tag, int tboffset, int length) throws davmail.ldap.Ber.EncodeException
davmail.ldap.Ber.EncodeException
public void encodeOctetString(byte[] tb, int tag) throws davmail.ldap.Ber.EncodeException
davmail.ldap.Ber.EncodeException
public void encodeStringArray(String[] strs, boolean encodeUTF8) throws davmail.ldap.Ber.EncodeException
davmail.ldap.Ber.EncodeException
Copyright © 2001–2024 MickaĆ«l Guessant. All rights reserved.