|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.asn1new.ber.Asn1Decoder
public class Asn1Decoder
A BER TLV Tag component decoder. This decoder instanciate a Tag. The tag won't be implementations should not copy the handle to the Tag object delivered but should copy the data if they need it over the long term.
Field Summary | |
---|---|
private static boolean |
DEBUG
A speedup for logs |
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 org.apache.log4j.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 Summary | |
---|---|
Asn1Decoder()
A public constructor of an Asn1 Decoder. |
Method Summary | |
---|---|
void |
allowIndefiniteLength()
Allow indefinite length. |
void |
decode(java.nio.ByteBuffer stream,
IAsn1Container container)
The decoder main function. |
void |
disallowIndefiniteLength()
Disallow indefinite length. |
private void |
dumpTLVTree(IAsn1Container container)
Dump the current TLV tree |
int |
getMaxLengthLength()
Get the length's Length. |
int |
getMaxTagLength()
Get the maximum Tag's length |
private java.lang.String |
getParentLength(TLV tlv)
A debug function used to dump the expected length stack. |
boolean |
isIndefiniteLengthAllowed()
Tells if indefinite length form could be used for Length |
private boolean |
isTLVDecoded(IAsn1Container container)
Check if the TLV tree is fully decoded |
void |
setMaxLengthLength(int maxLengthLength)
Set the maximul length for a Length |
void |
setMaxTagLength(int maxTagLength)
Set the maximum Tag length |
private java.lang.String |
stateToString(int state)
An helper function that return a string representing the current state for debuging purpose. |
private void |
treatLengthEndState(IAsn1Container container)
The Length is fully decoded. |
private boolean |
treatLengthPendingState(java.nio.ByteBuffer stream,
IAsn1Container 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(java.nio.ByteBuffer stream,
IAsn1Container container)
Treat the Length start. |
private void |
treatTagEndState(IAsn1Container container)
Action to be executed when the Tag has been decoded. |
private boolean |
treatTagPendingState(java.nio.ByteBuffer stream,
IAsn1Container container)
Treat a tag that is more than one byte long if the stream was cut in pieces. |
private boolean |
treatTagStartState(java.nio.ByteBuffer stream,
IAsn1Container container)
Treat the start of a TLV. |
private boolean |
treatTLVDoneState(java.nio.ByteBuffer stream,
IAsn1Container 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(java.nio.ByteBuffer stream,
IAsn1Container container)
Treat a pending Value when we get more bytes in the buffer. |
private boolean |
treatValueStartState(java.nio.ByteBuffer stream,
IAsn1Container container)
Treat the Value part. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.log4j.Logger log
private static boolean DEBUG
private static final boolean MORE
private static final boolean END
private boolean indefiniteLengthAllowed
private int maxLengthLength
private int maxTagLength
Constructor Detail |
---|
public Asn1Decoder()
Method Detail |
---|
private boolean treatTagStartState(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.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
otherwise
org.apache.asn1.codec.DecoderException
- If something went wrong.private boolean treatTagPendingState(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.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
otherwise
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate void dumpTLVTree(IAsn1Container container)
container
- The containerprivate boolean isTLVDecoded(IAsn1Container container)
container
- The containerprivate void treatTagEndState(IAsn1Container container) throws org.apache.asn1.codec.DecoderException
container
- The container that stores the current state,
the result and other informations.
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate boolean treatLengthStartState(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.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
otherwise
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate boolean treatLengthPendingState(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.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
otherwise
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate java.lang.String getParentLength(TLV tlv)
tlv
- The current TLV.
private void treatLengthEndState(IAsn1Container container) throws org.apache.asn1.codec.DecoderException
container
- The container that stores the current state,
the result and other informations.
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate boolean treatValueStartState(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.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
otherwise
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate boolean treatValuePendingState(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.DecoderException
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.
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate boolean treatTLVDoneState(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.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
otherwise
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrongprivate java.lang.String stateToString(int state)
state
- The state
public void decode(java.nio.ByteBuffer stream, IAsn1Container container) throws org.apache.asn1.codec.DecoderException
stream
- The ByteBuffer containing the PDU to decodecontainer
- The container that store the state, the result and
other elements.
org.apache.asn1.codec.DecoderException
- Thrown if anything went wrong!public int getMaxLengthLength()
getMaxLengthLength
in interface ITLVBerDecoderMBean
public int getMaxTagLength()
getMaxTagLength
in interface ITLVBerDecoderMBean
public void disallowIndefiniteLength()
disallowIndefiniteLength
in interface ITLVBerDecoderMBean
public void allowIndefiniteLength()
allowIndefiniteLength
in interface ITLVBerDecoderMBean
public boolean isIndefiniteLengthAllowed()
isIndefiniteLengthAllowed
in interface ITLVBerDecoderMBean
true
if the current decoder support
indefinite lengthpublic void setMaxLengthLength(int maxLengthLength) throws org.apache.asn1.codec.DecoderException
setMaxLengthLength
in interface ITLVBerDecoderMBean
maxLengthLength
- The lengthLength to set.
org.apache.asn1.codec.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 ITLVBerDecoderMBean
maxTagLength
- The tagLength to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |