public class Asn1Decoder extends Object implements TLVBerDecoderMBean
| Modifier and Type | Field and Description |
|---|---|
private static boolean |
END
This flag is used to indicate that there are no more bytes in the stream
|
private boolean |
indefiniteLengthAllowed
Flag that is used to allow/disallow the indefinite form of Length
|
private static boolean |
IS_DEBUG
A speedup for logger
|
private static org.slf4j.Logger |
LOG
The logger
|
private int |
maxLengthLength
The maximum number of bytes that could be used to encode the Length
|
private int |
maxTagLength
The maximum number of bytes that could be used to encode the Tag
|
private static boolean |
MORE
This flag is used to indicate that there are more bytes in the stream
|
| Constructor and Description |
|---|
Asn1Decoder()
A public constructor of an Asn1 Decoder.
|
| Modifier and Type | Method and Description |
|---|---|
void |
allowIndefiniteLength()
Allow indefinite length.
|
void |
decode(ByteBuffer stream,
Asn1Container container)
The decoder main function.
|
void |
disallowIndefiniteLength()
Disallow indefinite length.
|
private void |
dumpTLVTree(Asn1Container container)
Dump the current TLV tree
|
int |
getMaxLengthLength()
Get the actual maximum number of bytes that can be used to encode the
Length
|
int |
getMaxTagLength()
Get the actual maximum number of bytes that can be used to encode the Tag
|
private String |
getParentLength(TLV tlv)
A debug function used to dump the expected length stack.
|
boolean |
isIndefiniteLengthAllowed()
Tell if indefinite length form could be used for Length
|
private boolean |
isTLVDecoded(Asn1Container container)
Check if the TLV tree is fully decoded
|
void |
setMaxLengthLength(int maxLengthLength)
Set the number of bytes that can be used to encode the Value length,
including the first byte.
|
void |
setMaxTagLength(int maxTagLength)
Set the maximum number of bytes that should be used to encode a Tag
label, including the first byte.
|
private void |
treatLengthEndState(Asn1Container container)
The Length is fully decoded.
|
private boolean |
treatLengthPendingState(ByteBuffer stream,
Asn1Container container)
This function is called when a Length is in the process of being decoded,
but the lack of bytes in the buffer stopped the process.
|
private boolean |
treatLengthStartState(ByteBuffer stream,
Asn1Container container)
Treat the Length start.
|
private boolean |
treatTagStartState(ByteBuffer stream,
Asn1Container container)
Treat the start of a TLV.
|
private boolean |
treatTLVDoneState(ByteBuffer stream,
Asn1Container container)
When the TLV has been fully decoded, we have to execute the associated
action and switch to the next TLV, which will start with a Tag.
|
private boolean |
treatValuePendingState(ByteBuffer stream,
Asn1Container container)
Treat a pending Value when we get more bytes in the buffer.
|
private boolean |
treatValueStartState(ByteBuffer stream,
Asn1Container container)
Treat the Value part.
|
private static final org.slf4j.Logger LOG
private static final boolean IS_DEBUG
private static final boolean MORE
private static final boolean END
private boolean indefiniteLengthAllowed
private int maxLengthLength
private int maxTagLength
private boolean treatTagStartState(ByteBuffer stream, Asn1Container container)
stream - The ByteBuffer containing the PDU to decodecontainer - The container that stores the current state,
the result and other informations.true if there are more bytes to read, false
otherwiseprivate void dumpTLVTree(Asn1Container container)
container - The containerprivate boolean isTLVDecoded(Asn1Container container)
container - The containertrue if the TLV has been decodedprivate boolean treatLengthStartState(ByteBuffer stream, Asn1Container container) throws org.apache.directory.api.asn1.DecoderException
stream - The ByteBuffer containing the PDU to decodecontainer - The container that stores the current state,
the result and other informations.true if there are more bytes to read, false
otherwiseorg.apache.directory.api.asn1.DecoderException - Thrown if anything went wrongprivate boolean treatLengthPendingState(ByteBuffer stream, Asn1Container container)
stream - The ByteBuffer containing the PDU to decodecontainer - The container that stores the current state,
the result and other informations.true if there are more bytes to read, false
otherwiseprivate String getParentLength(TLV tlv)
tlv - The current TLV.private void treatLengthEndState(Asn1Container container) throws org.apache.directory.api.asn1.DecoderException
container - The container that stores the current state,
the result and other informations.org.apache.directory.api.asn1.DecoderException - Thrown if anything went wrongprivate boolean treatValueStartState(ByteBuffer stream, Asn1Container container)
stream - The ByteBuffer containing the PDU to decodecontainer - The container that stores the current state,
the result and other informations.true if there are more bytes to read, false
otherwiseprivate boolean treatValuePendingState(ByteBuffer stream, Asn1Container container)
stream - The ByteBuffer containing the PDU to decodecontainer - The container that stores the current state,
the result and other informations.MORE if some bytes remain in the buffer when the
value has been decoded, END if whe still need to get some
more bytes.private boolean treatTLVDoneState(ByteBuffer stream, Asn1Container container) throws org.apache.directory.api.asn1.DecoderException
stream - The ByteBuffer containing the PDU to decodecontainer - The container that stores the current state,
the result and other informations.true if there are more bytes to read, false
otherwiseorg.apache.directory.api.asn1.DecoderException - Thrown if anything went wrongpublic void decode(ByteBuffer stream, Asn1Container container) throws org.apache.directory.api.asn1.DecoderException
stream - The ByteBuffer containing the PDU to decodecontainer - The container that store the state, the result
and other elements.org.apache.directory.api.asn1.DecoderException - Thrown if anything went wrong!public int getMaxLengthLength()
getMaxLengthLength in interface TLVBerDecoderMBeanpublic int getMaxTagLength()
getMaxTagLength in interface TLVBerDecoderMBeanpublic void disallowIndefiniteLength()
disallowIndefiniteLength in interface TLVBerDecoderMBeanpublic void allowIndefiniteLength()
allowIndefiniteLength in interface TLVBerDecoderMBeanpublic boolean isIndefiniteLengthAllowed()
isIndefiniteLengthAllowed in interface TLVBerDecoderMBeantrue if the Indefinite form is allowedpublic void setMaxLengthLength(int maxLengthLength)
throws org.apache.directory.api.asn1.DecoderException
setMaxLengthLength in interface TLVBerDecoderMBeanmaxLengthLength - the number of byte to useorg.apache.directory.api.asn1.DecoderException - Thrown if the indefinite length is
allowed or if the length's Length is above 126 bytespublic void setMaxTagLength(int maxTagLength)
setMaxTagLength in interface TLVBerDecoderMBeanmaxTagLength - The length to useCopyright © 2003–2017 The Apache Software Foundation. All rights reserved.