Interface Asn1Container
- All Known Implementing Classes:
AbstractContainer
public interface Asn1Container
Every ASN1 container must implement this interface.
- Author:
- Apache Directory Project
-
Method Summary
Modifier and TypeMethodDescriptionGets the currentTLVintGet the size of the decoded messageGets the grammarintGet the maximum PDU size allowedintGets a new TLV idGet the parent's TLVgetState()Gets the current grammar stateGets the current stream containing the bytes to decodeintgetTlvId()Gets the current TLV idEnum<?> Gets the transitionvoidincrementDecodedBytes(int nb) Increment the decodedBytes by the latest received buffer's size.booleanTells if the decoding should be done immediately or if the container should gather the data beforebooleanChecks that we can have a end state after this transitionvoidrewind()Move backward in the stream to the first byte for a given TLV.voidsetCurrentTLV(TLV tlv) Sets the current TLVvoidsetDecodedBytes(int decodedBytes) Set the size of the decoded messagzvoidsetGathering(boolean isGathering) Set the isGathering flagvoidsetGrammar(Grammar<? extends Asn1Container> grammar) Sets the grammarvoidsetGrammarEndAllowed(boolean grammarEndAllowed) Sets the flag to allow a end transitionvoidsetMaxPDUSize(int maxPDUSize) Set the maximum PDU size.voidsetParentTLV(TLV parentTLV) Sets the parent TLVvoidsetState(TLVStateEnum state) Sets the new current statevoidsetStream(ByteBuffer stream) Stores the Stream being decodedvoidsetTransition(Enum<?> transition) Updates the transition from a state to anothervoidUpdate the parent's length
-
Method Details
-
getStream
ByteBuffer getStream()Gets the current stream containing the bytes to decode- Returns:
- The current stream
-
setStream
Stores the Stream being decoded- Parameters:
stream- The stream being decoded
-
getState
-
setState
-
getCurrentTLV
-
setCurrentTLV
-
getGrammar
-
setGrammar
Sets the grammar- Parameters:
grammar- The grammar to set
-
getTransition
Enum<?> getTransition()Gets the transition- Returns:
- Returns the transition from the previous state to the new state
-
setTransition
Updates the transition from a state to another- Parameters:
transition- The transition to set
-
getParentTLV
-
setParentTLV
-
isGrammarEndAllowed
boolean isGrammarEndAllowed()Checks that we can have a end state after this transition- Returns:
- true if this can be the last transition
-
setGrammarEndAllowed
void setGrammarEndAllowed(boolean grammarEndAllowed) Sets the flag to allow a end transition- Parameters:
grammarEndAllowed- true or false, depending on the next transition being an end or not.
-
getNewTlvId
int getNewTlvId()Gets a new TLV id- Returns:
- a unique value representing the current TLV id
-
getTlvId
int getTlvId()Gets the current TLV id- Returns:
- a unique value representing the current TLV id
-
getDecodedBytes
int getDecodedBytes()Get the size of the decoded message- Returns:
- The number of decoded bytes for this message. This is used to control the PDU size and avoid PDU exceeding the maximum allowed size to break the server.
-
setDecodedBytes
void setDecodedBytes(int decodedBytes) Set the size of the decoded messagz- Parameters:
decodedBytes- The number of decoded bytes for this message.
-
incrementDecodedBytes
void incrementDecodedBytes(int nb) Increment the decodedBytes by the latest received buffer's size.- Parameters:
nb- The buffer size.
-
getMaxPDUSize
int getMaxPDUSize()Get the maximum PDU size allowed- Returns:
- The maximum PDU size.
-
setMaxPDUSize
void setMaxPDUSize(int maxPDUSize) Set the maximum PDU size.- Parameters:
maxPDUSize- The maximum PDU size (if negative or null, will be replaced by the max integer value)
-
rewind
void rewind()Move backward in the stream to the first byte for a given TLV. This is useful when we have read some Tag and Length in order to define the next transition, and if this transition do a grammar switch. -
updateParent
void updateParent()Update the parent's length -
isGathering
boolean isGathering()Tells if the decoding should be done immediately or if the container should gather the data before- Returns:
- true if the container should gather the value into itself, false if the decoding of the Value part should be done immediately for constructed types.
-
setGathering
void setGathering(boolean isGathering) Set the isGathering flag- Parameters:
isGathering- true to ask the Asn1Decoder to gather the data into the container. If not set, the default value is 'false'
-