directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r159160 - in directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber: ./ Asn1Decoder.java
Date Sun, 27 Mar 2005 18:37:41 GMT
Author: elecharny
Date: Sun Mar 27 10:37:40 2005
New Revision: 159160

URL: http://svn.apache.org/viewcvs?view=rev&rev=159160
Log:
A first working version of the new ASN.1 LDAP decoder.

Added:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java?view=auto&rev=159160
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java Sun
Mar 27 10:37:40 2005
@@ -0,0 +1,833 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1.ber;
+
+
+import org.apache.asn1.ber.containers.IAsn1Container;
+import org.apache.asn1.ber.tlv.Length;
+import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.ber.tlv.ITLVBerDecoderMBean;
+import org.apache.asn1.ber.tlv.TLVStateEnum;
+import org.apache.asn1.ber.tlv.Tag;
+import org.apache.asn1.ldap.codec.DecoderException;
+import org.apache.asn1.util.StringUtils;
+import org.apache.asn1.util.pools.LocalPoolManager;
+import org.apache.asn1.util.pools.PoolEnum;
+import org.apache.asn1.util.pools.PoolException;
+import org.apache.asn1.util.pools.PoolObject;
+
+import org.apache.log4j.Logger;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * 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.
+ *
+ * @author   <a href="mailto:dev@directory.apache.org">Apache
+ *           Directory Project</a>
+ */
+public class Asn1Decoder implements ITLVBerDecoderMBean
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = Logger.getLogger( Asn1Decoder.class );
+
+    /** Speeding up the logging */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** This flag is used to indicate that there are more bytes in the stream */
+    private static final boolean MORE = true;
+
+    /** This flag is used to indicate that there are no more bytes in the stream */
+    private static final boolean END = false;
+
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** Flag that is used to allow/disallow the indefinite form of Length */
+    private boolean indefiniteLengthAllowed;
+
+    /** The maximum number of bytes that could be used to encode the Length */
+    private int maxLengthLength;
+
+    /** The maximum number of bytes that could be used to encode the Tag */
+    private int maxTagLength;
+
+    /** The local pool Manager */
+    private LocalPoolManager poolMgr;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * A private constructor to avoid a new instanciation of this class. A
+     * public constructor
+     */
+    public Asn1Decoder()
+    {
+        this.indefiniteLengthAllowed = false;
+        this.maxLengthLength         = 1;
+        this.maxTagLength            = 1;
+        poolMgr                      = new LocalPoolManager();
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Treat the start of a TLV. It reads the tag and get its value.
+     *
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException If something went wrong.
+     */
+    private boolean treatTagStartState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        if ( stream.hasRemaining() )
+        {
+
+            byte octet = stream.get();
+
+            if ( DEBUG )
+            {
+                log.debug( "  current byte : " + StringUtils.dumpByte( octet ) );
+            }
+
+            try
+            {
+
+                TLV tlv = ( TLV ) poolMgr.allocate( PoolEnum.TLV_POOL );
+                Tag tag = tlv.getTag();
+
+                tag.setSize( 1 );
+                tag.setPrimitive( ( octet & Tag.CONSTRUCTED_FLAG ) == 0 );
+                tag.setTypeClass( Tag.TYPE_CLASS[( octet & Tag.TYPE_CLASS_MASK ) >>>
6] );
+
+                int value = octet & Tag.SHORT_MASK;
+
+                if ( value == Tag.SHORT_MASK )
+                {
+
+                    // we have to check the typeClass. UNIVERSAL class is not
+                    // allowed with this value.
+                    if ( tag.isUniversal() )
+                    {
+                        throw new DecoderException( "Universal tag 31 is reserved" );
+                    }
+
+                    // we will have more than one byte to encode the value
+                    // The tag is encoded on [2 - 6 bytes], its value
+                    // is container in the 7 lower bits of the bytes following
+                    // the first byte.
+                    container.setState( TLVStateEnum.TAG_STATE_PENDING );
+                    tag.setId( 0 );
+                    tag.addByte( octet );
+                }
+                else
+                {
+                    // It's a tag wich value is below 30 (31 is not allowed
+                    // as it signals a multi-bytes value. Everything is done.
+
+                    // We have to check for reserved tags if typeClass is UNIVERSAL
+                    if ( tag.isUniversal() )
+                    {
+
+                        if ( ( value == 14 ) || ( value == 15 ) )
+                        {
+                            throw new DecoderException( "Universal tag " + value + " is reserved"
);
+                        }
+                    }
+
+                    tag.setId( value );
+                    tag.addByte( octet );
+
+                    // The tag has been completed, we have to decode the Length
+                    container.setState( TLVStateEnum.TAG_STATE_END );
+                }
+
+                // Store the current TLV in the container.
+                container.setCurrentTLV( tlv );
+
+                return MORE;
+            }
+            catch ( PoolException pe )
+            {
+                throw new DecoderException( "Cannot allocate a TLV : " + pe.getMessage()
);
+            }
+        }
+        else
+        {
+
+            // The stream has been exhausted
+            return END;
+        }
+    }
+
+    /**
+     * Treat a tag that is more than one byte long if the stream was cut in pieces. This
+     * function is called when some new bytes where got from the stream.
+     * 
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatTagPendingState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        if ( stream.hasRemaining() )
+        {
+
+            Tag  tag    = container.getCurrentTLV().getTag();
+            byte octect = stream.get();
+
+            if ( DEBUG )
+            {
+                log.debug( "  current byte : " + StringUtils.dumpByte( octect ) );
+            }
+
+            if ( tag.getSize() >= Tag.MAX_TAG_BYTES )
+            {
+                container.setState( TLVStateEnum.TAG_STATE_OVERFLOW );
+                log.error( "Tag label Overflow" );
+                throw new DecoderException( "Tag label overflow" );
+            }
+
+            byte val = ( byte ) ( octect & Tag.LONG_MASK );
+
+            tag.setId( ( tag.getId() << 7 ) | val );
+            tag.incTagSize();
+
+            if ( val == octect )
+            {
+
+                // The Tag is completed, so let's decode the Length
+                container.setState( TLVStateEnum.LENGTH_STATE_START );
+            }
+
+            return MORE;
+        }
+        else
+        {
+
+            return END;
+        }
+
+    }
+
+    /**
+     * Action to be executed when the Tag has been decoded. Basically, this
+     * is a debug action. We will log the information that the Tag has been
+     * decoded.
+     *  
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatTagEndState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        if ( DEBUG )
+        {
+
+            Tag tag = container.getCurrentTLV().getTag();
+            log.debug( tag.toString() + " has been decoded" );
+        }
+
+        // After having decoded a tag, we have to execute the action
+        // which controls if this tag is allowed and well formed.
+        container.getGrammar().executeAction( container );
+
+        // Switch to the next state, which is the Length decoding
+        container.setState( TLVStateEnum.LENGTH_STATE_START );
+
+        return MORE;
+    }
+
+    /**
+     * Treat the Length start. The tag has been decoded, so we have to deal
+     * with the LENGTH, which can be multi-bytes.
+     *
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatLengthStartState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        if ( stream.hasRemaining() )
+        {
+
+            byte octet = stream.get();
+
+            if ( DEBUG )
+            {
+                log.debug( "  current byte : " + StringUtils.dumpByte( octet ) );
+            }
+
+            Length length = container.getCurrentTLV().getLength();
+
+            if ( ( octet & Length.LENGTH_LONG_FORM ) == 0 )
+            {
+
+                // We don't have a long form. The Length of the Value part is
+                // given by this byte.
+                length.setLength( octet );
+                length.setExpectedLength( 0 );
+                length.setCurrentLength( 0 );
+                length.setSize( 1 );
+
+                if ( octet == 0 )
+                {
+                    container.setState( TLVStateEnum.TLV_STATE_DONE );
+                }
+                else
+                {
+                    container.setState( TLVStateEnum.LENGTH_STATE_END );
+                }
+            }
+            else if ( ( octet & Length.LENGTH_EXTENSION_RESERVED ) !=
+                    Length.LENGTH_EXTENSION_RESERVED )
+            {
+
+                int expectedLength = octet & Length.SHORT_MASK;
+
+                if ( expectedLength > 4 )
+                {
+                    log.error( "Overflow : can't have more than 4 bytes long length" );
+                    throw new DecoderException(
+                        "Overflow : can't have more than 4 bytes long length" );
+                }
+
+                length.setExpectedLength( expectedLength );
+                length.setCurrentLength( 0 );
+                length.setLength( 0 );
+                length.setSize( 1 );
+                container.setState( TLVStateEnum.LENGTH_STATE_PENDING );
+            }
+            else
+            {
+                log.error( "Length reserved extension used" );
+                throw new DecoderException( "Length reserved extension used" );
+            }
+
+            return MORE;
+        }
+        else
+        {
+
+            return END;
+        }
+    }
+
+    /**
+     * 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. 
+     *
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatLengthPendingState( ByteBuffer stream, IAsn1Container container
)
+        throws DecoderException
+    {
+
+        if ( stream.hasRemaining() )
+        {
+
+            Length length = container.getCurrentTLV().getLength();
+
+            while ( length.getCurrentLength() < length.getExpectedLength() )
+            {
+
+                byte octect = stream.get();
+
+                if ( DEBUG )
+                {
+                    log.debug( "  current byte : " + StringUtils.dumpByte( octect ) );
+                }
+
+                length.incCurrentLength();
+                length.incSize();
+                length.setLength( ( length.getLength() << 8 ) | octect );
+            }
+
+            container.setState( TLVStateEnum.VALUE_STATE_START );
+
+            return MORE;
+        }
+        else
+        {
+
+            return END;
+        }
+    }
+
+    /**
+     * The Length is fully decoded. We have to call an action to check the
+     * size.
+     *
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatLengthEndState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        Length length = container.getCurrentTLV().getLength();
+
+        if ( DEBUG )
+        {
+            log.debug( length.toString() + " has been decoded" );
+        }
+
+        if ( length.getLength() == 0 )
+        {
+
+            // The length is 0, so we can't expect a value.
+            container.setState( TLVStateEnum.TLV_STATE_DONE );
+        }
+        else
+        {
+
+            // Go ahead and decode the value part
+            container.setState( TLVStateEnum.VALUE_STATE_START );
+        }
+
+        // Execute the action to check if the length is OK
+        container.getGrammar().executeAction( container );
+
+        return MORE;
+    }
+
+    /**
+     * Treat the Value part. We will distinguish two cases : 
+     *  - if the Tag is a Primitive one, we will get the value.
+     *  - if the Tag is a Constructed one, nothing will be done.
+     * 
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatValueStartState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        TLV currentTlv = container.getCurrentTLV();
+
+        if ( currentTlv.getTag().isConstructed() )
+        {
+            container.setState( TLVStateEnum.TLV_STATE_DONE );
+
+            return MORE;
+        }
+        else
+        {
+
+            int length  = currentTlv.getLength().getLength();
+            int nbBytes = stream.remaining();
+
+            if ( nbBytes < length )
+            {
+                currentTlv.getValue().init( length );
+                currentTlv.getValue().setData( stream.array() );
+                container.setState( TLVStateEnum.VALUE_STATE_PENDING );
+
+                return END;
+            }
+            else
+            {
+                currentTlv.getValue().init( length );
+                stream.get( currentTlv.getValue().getData(), 0, length );
+                container.setState( TLVStateEnum.TLV_STATE_DONE );
+
+                return MORE;
+            }
+        }
+    }
+
+    /**
+     * Treat a pending Value when we get more bytes in the buffer.
+     *
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>MORE</code> if some bytes remain in the buffer when 
+     * the value has been decoded, <code>END</code> if whe still need to get

+     * some more bytes.
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatValuePendingState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        TLV currentTlv    = container.getCurrentTLV();
+
+        int length        = currentTlv.getLength().getLength();
+        int currentLength = currentTlv.getValue().getCurrentLength();
+        int nbBytes       = stream.remaining();
+
+        if ( ( currentLength + nbBytes ) < length )
+        {
+            currentTlv.getValue().addData( stream.array() );
+            container.setState( TLVStateEnum.VALUE_STATE_PENDING );
+
+            return END;
+        }
+        else
+        {
+
+            int    remaining = length - currentLength;
+            byte[] data      = new byte[remaining];
+            stream.get( data, 0, remaining );
+            currentTlv.getValue().addData( data );
+            container.setState( TLVStateEnum.TLV_STATE_DONE );
+
+            return MORE;
+        }
+    }
+
+    /**
+     * 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.
+     * 
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that stores the current state,
+     * the result and other informations.
+     * 
+     * @return <code>true</code> if there are more bytes to read, <code>false

+     * </code> otherwise
+     * 
+     * @throws DecoderException Thrown if anything went wrong
+     */
+    private boolean treatTLVDoneState( ByteBuffer stream, IAsn1Container container )
+        throws DecoderException
+    {
+
+        // First, we have to execute the associated action
+        container.getGrammar().executeAction( container );
+
+        // Then we switch to the Start tag state and free the current TLV
+        container.setState( TLVStateEnum.TAG_STATE_START );
+        container.getCurrentTLV().free();
+
+        return stream.hasRemaining();
+    }
+
+    /**
+     * An helper function that return a string representing the current state
+     * for debuging purpose.
+     * 
+     * @param state The state
+     * 
+     * @return A string representation of the state
+    */
+    private String stateToString( int state )
+    {
+
+        switch ( state )
+        {
+
+            case TLVStateEnum.TAG_STATE_START :
+                return "TAG_STATE_START";
+
+            case TLVStateEnum.TAG_STATE_PENDING :
+                return "TAG_STATE_PENDING";
+
+            case TLVStateEnum.TAG_STATE_END :
+                return "TAG_STATE_END";
+
+            case TLVStateEnum.TAG_STATE_OVERFLOW :
+                return "TAG_STATE_OVERFLOW";
+
+            case TLVStateEnum.LENGTH_STATE_START :
+                return "LENGTH_STATE_START";
+
+            case TLVStateEnum.LENGTH_STATE_PENDING :
+                return "LENGTH_STATE_PENDING";
+
+            case TLVStateEnum.LENGTH_STATE_END :
+                return "LENGTH_STATE_END";
+
+            case TLVStateEnum.VALUE_STATE_START :
+                return "VALUE_STATE_START";
+
+            case TLVStateEnum.VALUE_STATE_PENDING :
+                return "VALUE_STATE_PENDING";
+
+            case TLVStateEnum.TLV_STATE_DONE :
+                return "TLV_STATE_DONE";
+
+            default :
+                return "UNKNOWN_STATE";
+        }
+    }
+
+    /**
+     * The decoder main function. This is where we read bytes from the stream
+     * and go through the automaton. It's an inifnite loop which stop when no
+     * more bytes are to be read. It can occurs if the ByteBuffer is exhausted 
+     * or if the PDU has been fully decoded. 
+     *
+     * @param stream The ByteBuffer containing the PDU to decode
+     * @param container The container that storethe state, the result and
+     * other elements.
+     *
+     * @throws DecoderException Thrown if enything went wrong!
+     */
+    public void decode( ByteBuffer stream, IAsn1Container container ) throws DecoderException
+    {
+
+        /* We have to deal with the current state. This is an
+         * infinite loop, which will stop for any of these reasons :
+         * - STATE_END has been reached (hopefully, the most frequent case)
+         * - buffer is empty (it could happen)
+         * - STATE_OVERFLOW : bad situation ! The PDU may be a malevolous hand
+         * crafted ones, that try to "kill" our decoder. Whe must log it with
+         * all information to track back this case, and punish the guilty !
+         */
+
+        boolean hasRemaining = stream.hasRemaining();
+
+        if ( DEBUG )
+        {
+            log.debug( "Decoding a PDU" );
+        }
+
+        while ( hasRemaining )
+        {
+
+            if ( DEBUG )
+            {
+                log.debug( "--- State = " + stateToString( container.getState() ) + " ---"
);
+            }
+
+            switch ( container.getState() )
+            {
+
+                case TLVStateEnum.TAG_STATE_START :
+                    hasRemaining = treatTagStartState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.TAG_STATE_PENDING :
+                    hasRemaining = treatTagPendingState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.TAG_STATE_END :
+                    hasRemaining = treatTagEndState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.TAG_STATE_OVERFLOW :
+                    log.error( "Incompatible state : OVERFLOW" );
+                    throw new DecoderException( "Incompatible state occured" );
+
+                case TLVStateEnum.LENGTH_STATE_START :
+                    hasRemaining = treatLengthStartState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.LENGTH_STATE_PENDING :
+                    hasRemaining = treatLengthPendingState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.LENGTH_STATE_END :
+                    hasRemaining = treatLengthEndState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.VALUE_STATE_START :
+                    hasRemaining = treatValueStartState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.VALUE_STATE_PENDING :
+                    hasRemaining = treatValuePendingState( stream, container );
+
+                    break;
+
+                case TLVStateEnum.VALUE_STATE_END :
+
+                    // Nothing to do. We will never reach this state
+                    break;
+
+                case TLVStateEnum.TLV_STATE_DONE :
+                    hasRemaining = treatTLVDoneState( stream, container );
+
+                    break;
+            }
+        }
+
+        if ( DEBUG )
+        {
+            log.debug( "<--- End decoding : " + container.getCurrentTLV().toString() );
+        }
+
+        return;
+    } // end method decode
+
+    /**
+     * Get the length's Length.
+     *
+     * @return  Returns the length's Length.
+     */
+    public int getMaxLengthLength()
+    {
+
+        return maxLengthLength;
+    }
+
+    /**
+     * Get the maximum Tag's length
+     *
+     * @return  Returns the maximum tag Length.
+     */
+    public int getMaxTagLength()
+    {
+
+        return maxTagLength;
+    }
+
+    /**
+     * Disallow indefinite length.
+     */
+    public void disallowIndefiniteLength()
+    {
+        this.indefiniteLengthAllowed = false;
+    }
+
+    /**
+     * Allow indefinite length.
+     */
+    public void allowIndefiniteLength()
+    {
+        this.indefiniteLengthAllowed = true;
+    }
+
+    /**
+     * Tells if indefinite length form could be used for Length
+     *
+     * @return  Returns <code>true</code> if the current decoder support
+     *          indefinite length
+     */
+    public boolean isIndefiniteLengthAllowed()
+    {
+
+        return indefiniteLengthAllowed;
+    }
+
+    /**
+     * Set the maximul length for a Length
+     *
+     * @param maxLengthLength  The lengthLength to set.
+     *
+     * @throws  DecoderException Thrown if the indefinite length is allowed
+     * or if the length's Length is above 126 bytes
+     */
+    public void setMaxLengthLength( int maxLengthLength ) throws DecoderException
+    {
+
+        if ( ( this.indefiniteLengthAllowed ) && ( maxLengthLength > 126 ) )
+        {
+            throw new DecoderException(
+                "Length above 126 bytes are not allowed for a definite form Length" );
+        }
+
+        this.maxLengthLength = maxLengthLength;
+    }
+
+    /**
+     * Set the maximum Tag length
+     *
+     * @param maxTagLength  The tagLength to set.
+     */
+    public void setMaxTagLength( int maxTagLength )
+    {
+        this.maxTagLength = maxTagLength;
+    }
+
+    /**
+     * Ask the local pool manager to allocate an object.
+     *
+     * @param pool The pool in which the object will be taken from
+     *
+     * @return The allocated object
+     *
+     * @throws PoolException Thrown if the object could not be allocated
+     */
+    public PoolObject allocate( int pool ) throws PoolException
+    {
+
+        return poolMgr.allocate( pool );
+    }
+
+    /**
+     * @return Returns the pool manager to the caller.
+     */
+    public LocalPoolManager getPoolManager()
+    {
+
+        return poolMgr;
+    }
+
+} // end class TLVTagDecoder



Mime
View raw message