directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r191604 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
Date Tue, 21 Jun 2005 00:45:01 GMT
Author: elecharny
Date: Mon Jun 20 17:45:00 2005
New Revision: 191604

URL: http://svn.apache.org/viewcvs?rev=191604&view=rev
Log:
Deleted all the xxx-LENGTH transitions. No needed anymore !
This is really a relief, as this was almost half of the code in this class
(down from 1534 lines of - bad - code to 860 lines of better code !)

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java?rev=191604&r1=191603&r2=191604&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java Mon Jun 20 17:45:00 2005
@@ -82,7 +82,7 @@
         // here, and store it in the container.
         super.transitions[SpnegoStatesEnum.SPNEGO_START_STATE][0xA0] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_START_STATE,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_LENGTH,
+                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_VALUE,
                 new GrammarAction( "Spnego neg token init tag" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -100,29 +100,6 @@
                 } );
 
         // SPNEGO --> CHOICE { ...
-        //      negTokenInit  [0]  NegTokenInit, (Length)
-        // We get the negTokenInit length, and store it in the SpnegoObject
-        super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_LENGTH][0xA0] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_LENGTH,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_VALUE,
-                new GrammarAction( "Spnego neg token init Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        // We have to store the expected Length of the PDU
-                        SpnegoContainer spnegoContainer = ( SpnegoContainer ) container;
-                        Spnego      spnego          = spnegoContainer.getSpnego();
-
-                        spnego.setExpectedLength( spnegoContainer.getCurrentTLV().getLength()
-                            .getLength() );
-                        spnego.setCurrentLength( 0 );
-
-                        return;
-                    }
-                } );
-
-        // SPNEGO --> CHOICE { ...
         //      negTokenInit  [0]  NegTokenInit, (Value)
         // We will have a SEQUENCE. There is no value, so this is just a phantom transition.
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_VALUE][0xA0] =
@@ -140,38 +117,7 @@
         // Nothing to do here, it's just a tag...
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_TAG][0x30] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_TAG,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_LENGTH, null );
-
-        // NegTokenInit ::= SEQUENCE { (Length)
-        //    mechTypes     [0]  MechTypeList  OPTIONAL,
-        //    reqFlags      [1]  ContextFlags  OPTIONAL,
-        //    mechToken     [2]  OCTET STRING  OPTIONAL,
-        //    mechListMIC   [3]  OCTET STRING  OPTIONAL }
-        // We have to check the length, and set the new expected length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_LENGTH][0x30] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_LENGTH,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_VALUE,
-                new GrammarAction( "Spnego neg token init sequence Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        // first, we check that the length is OK
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-                        checkLength( spnego, tlv );
-
-                        // Second, we store the new expected length into the global
-                        // expected length, as it won't be usefull any more (this is
-                        // an optimisation, we could have declared another class
-                        // member to do this.) We also reset the current length to 0.
-                        spnego.setExpectedLength( tlv.getLength().getLength() );
-                        spnego.setCurrentLength( 0 );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_VALUE, null );
 
         // NegTokenInit ::= SEQUENCE { (Value)
         //    mechTypes     [0]  MechTypeList  OPTIONAL,
@@ -194,35 +140,7 @@
         // We have a 0xA0 tag, so this is a mechTypes. We have nothing to do.
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG][0xA0] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TYPES_LENGTH, null );
-
-        // NegTokenInit ::= SEQUENCE {
-        //    mechTypes     [0]  MechTypeList  OPTIONAL, (Length)
-        //    ...
-        // MechTypeList ::= SEQUENCE OF MechType
-        // The Length part. We just have to check the length and store the sequence
-        // expected length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPES_LENGTH][0xA0] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TYPES_LENGTH,
-                SpnegoStatesEnum.SPNEGO_MECH_TYPES_VALUE,
-                new GrammarAction( "Mech Types Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Stores the current length in the associated accumulator.
-                        spnego.setMechTypesExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_MECH_TYPES_VALUE, null );
 
         // NegTokenInit ::= SEQUENCE {
         //    mechTypes     [0]  MechTypeList  OPTIONAL, (Value)
@@ -239,39 +157,7 @@
         // Nothing to do
         super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPES_LIST_TAG][0x30] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TYPES_LIST_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TYPES_LIST_LENGTH, null );
-
-        // MechTypeList ::= SEQUENCE OF MechType (Length)
-        // We have to check the length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPES_LIST_LENGTH][0x30] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TYPES_LIST_LENGTH,
-                SpnegoStatesEnum.SPNEGO_MECH_TYPES_LIST_VALUE,
-                new GrammarAction( "Mech Type list sequence Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        int expectedLength = spnego.getMechTypesExpectedLength();
-
-                        int currentLength  = tlv.getSize();
-
-                        if ( expectedLength < currentLength )
-                        {
-                            throw new DecoderException(
-                                "The current length is longer than the expected length" );
-                        }
-
-                        // Stores the expected length of the mech types.
-                        spnego.setMechTypeListExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_MECH_TYPES_LIST_VALUE, null );
 
         // MechTypeList ::= SEQUENCE OF MechType (Value)
         // Nothing to do.
@@ -286,45 +172,7 @@
         // Nothing to do.
         super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPE_TAG][0x06] = new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_MECH_TYPE_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TYPE_LENGTH, null );
-
-        // MechType ::= OBJECT IDENTIFIER (Length)
-        // We have to check the length. We also have to handle the special case of a zero
-        // length OID, which is an error.
-        super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPE_LENGTH][0x06] = new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_MECH_TYPE_LENGTH, SpnegoStatesEnum.SPNEGO_MECH_TYPE_VALUE,
-                new GrammarAction( "Mech Type Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        int expectedLength = spnego.getMechTypeListExpectedLength();
-
-                        int currentLength  = tlv.getSize();
-
-                        if ( expectedLength < currentLength )
-                        {
-                            throw new DecoderException(
-                                "The current length is longer than the expected length" );
-                        }
-                        
-                        if (currentLength == 0)
-                        {
-                            throw new DecoderException(
-                            "The length of an OID cannot be null" );
-                        }
-
-                        // Updates the current length.
-                        spnego.setMechTypeListExpectedLength( expectedLength - currentLength );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_MECH_TYPE_VALUE, null );
 
         // MechType ::= OBJECT IDENTIFIER (Value)
         // Here we will add a new Mech Type to the MechTypeList
@@ -356,7 +204,7 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG][0x06] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TYPE_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_MECH_TYPE_VALUE, null );
 
         //============================================================================================
         // reqFlags State
@@ -369,7 +217,7 @@
         // We have to switch to the Length transition of a reqFlags state
         super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG][0xA1] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_REQ_FLAGS_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_REQ_FLAGS_VALUE, null );
 
         // NegTokenInit ::= SEQUENCE {
         //    ...
@@ -379,37 +227,7 @@
         // We have to switch to the Length transition of a reqFlags state
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG][0xA1] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_REQ_FLAGS_LENGTH, null );
-
-        // NegTokenInit ::= SEQUENCE {
-        //    ...
-        //    reqFlags      [1]  ContextFlags  OPTIONAL, (Length)
-        //    ...
-        // We have to check the length
-        super.transitions[SpnegoStatesEnum.SPNEGO_REQ_FLAGS_LENGTH][0xA1] = new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_REQ_FLAGS_LENGTH, SpnegoStatesEnum.SPNEGO_REQ_FLAGS_VALUE,
-                new GrammarAction( "Req Flags Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Store the length in the req flags expected length
-                        spnego.setReqFlagsExpectedLength( tlv.getLength().getLength() );
-                        
-                        // As we have a ReqFlags element, set the flag to true
-                        spnego.setHasReqFlags(true);
-                        
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_REQ_FLAGS_VALUE, null );
 
         // NegTokenInit ::= SEQUENCE {
         //    ...
@@ -436,52 +254,7 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_TAG][0x03] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_TAG,
-                SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_LENGTH, null );
-
-        // ContextFlags ::= BIT_STRING { (Length)
-        //     delegFlag     (0),
-        //     mutualFlag    (1),
-        //     replayFlag    (2),
-        //     sequenceFlag  (3),
-        //     anonFlag      (4),
-        //     confFlag      (5),
-        //     integFlag     (6)
-        // }
-        // We have to check the length, and handle the special case of an empty length, which
-        /// is an error.
-        super.transitions[SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_LENGTH][0x03] =
-            new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_LENGTH,
-                SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_VALUE,
-                new GrammarAction( "Req Flags Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        int                    expectedLength  = spnego.getReqFlagsExpectedLength();
-                        int                    currentLength   =
-                            tlv.getLength().getSize() + tlv.getTag().getSize() +
-                            tlv.getLength().getLength();
-
-                        if ( expectedLength != currentLength )
-                        {
-                            throw new DecoderException(
-                                "The ReqFlags length is different than the expected length" );
-                        }
-
-                        if ( tlv.getLength().getLength() == 0 )
-                        {
-                            throw new DecoderException( "The req flags must not be empty" );
-                        }
-
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_VALUE, null );
 
         // ContextFlags ::= BIT_STRING { (value)
         //     delegFlag     (0),
@@ -519,6 +292,8 @@
                         spnego.setMutualFlag( bitString.getBit( 4 ) );
                         spnego.setReplayFlag( bitString.getBit( 5 ) );
                         spnego.setSequenceFlag( bitString.getBit( 6 ) );
+                        
+                        spnego.setHasReqFlags(true);
 
                         return;
                     }
@@ -535,7 +310,7 @@
         // Nothing to do
         super.transitions[SpnegoStatesEnum.SPNEGO_REQ_FLAGS_FOLLOWING_TAG][0xA2] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_REQ_FLAGS_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_VALUE, null );
 
         // NegTokenInit ::= SEQUENCE {
         //    ...
@@ -545,7 +320,7 @@
         // Nothing to do
         super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG][0xA2] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_VALUE, null );
 
         // NegTokenInit ::= SEQUENCE {
         //    ...
@@ -555,33 +330,7 @@
         // Nothing to do
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG][0xA2] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH, null );
-
-        // NegTokenInit ::= SEQUENCE {
-        //    ...
-        //    mechToken     [2]  OCTET STRING  OPTIONAL, (Length)
-        //    ...
-        super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH][0xA2] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH,
-                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_VALUE,
-                new GrammarAction( "Mech Token Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Store the length in the mech token expected length
-                        spnego.setMechTokenExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_VALUE, null );
 
         // mechToken     [2]  OCTET STRING  OPTIONAL, (Value)
         // Nothing to do, the value follows.
@@ -597,15 +346,15 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_TAG][0x04] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_TAG,
-                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_VALUE, null );
 
-        // mechToken     [2]  OCTET STRING  OPTIONAL, (Length)
-        // Checks the length. If the length is 0, we will allocate an empty OctetString.
-        super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_LENGTH][0x04] =
+        // mechToken     [2]  OCTET STRING  OPTIONAL, (Value)
+        // We will allocate a new Octet String.
+        super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_VALUE][0x04] =
             new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_LENGTH,
                 SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_VALUE,
-                new GrammarAction( "Mech Token Length" )
+                SpnegoStatesEnum.SPNEGO_METH_TOKEN_FOLLOWING_TAG,
+                new GrammarAction( "Mech Token Value" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
@@ -615,59 +364,22 @@
                             spnegoContainer.getSpnego();
                         TLV                    tlv             = spnegoContainer.getCurrentTLV();
 
-                        int                    expectedLength  = spnego
-                            .getMechTokenExpectedLength();
-                        int                    currentLength   =
-                            tlv.getLength().getSize() + tlv.getTag().getSize() +
-                            tlv.getLength().getLength();
-
-                        if ( expectedLength != currentLength )
-                        {
-                            throw new DecoderException(
-                                "The MechToken length is different than the expected length" );
-                        }
-
+                        // Stores the mechToken data
+                        // We have to deal with the special case of a null length
                         if ( tlv.getLength().getLength() == 0 )
                         {
                             spnego.setMechToken( OctetString.EMPTY_STRING );
                         }
                         else
                         {
-
                             // Creates a new mechToken
-                            OctetString mechToken = new OctetString();
-
-                            spnego.setMechToken( mechToken );
+                            spnego.setMechToken( new OctetString( tlv.getValue().getData() ) );
                         }
 
                         return;
                     }
                 } );
 
-        // mechToken     [2]  OCTET STRING  OPTIONAL, (Value)
-        // We will allocate a new Octet String.
-        super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_VALUE][0x04] =
-            new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_VALUE,
-                SpnegoStatesEnum.SPNEGO_METH_TOKEN_FOLLOWING_TAG,
-                new GrammarAction( "Mech Token Value" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Stores the mechToken data
-                        OctetString mechToken = spnego.getMechToken();
-
-                        mechToken.setData( tlv.getValue().getData() );
-                        return;
-                    }
-                } );
-
         //============================================================================================
         // mechListMIC State
         //--------------------------------------------------------------------------------------------
@@ -678,54 +390,28 @@
         // Nothing to do.
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_VALUE, null );
 
         //    mechListMIC   [3]  OCTET STRING  OPTIONAL } (Tag)
         // We are coming from the mechType state
         // Nothing to do.
         super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TYPE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_VALUE, null );
 
         //    mechListMIC   [3]  OCTET STRING  OPTIONAL } (Tag)
         // We are coming from the ContextFlags state
         // Nothing to do.
         super.transitions[SpnegoStatesEnum.SPNEGO_REQ_FLAGS_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_REQ_FLAGS_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_VALUE, null );
 
         //    mechListMIC   [3]  OCTET STRING  OPTIONAL } (Tag)
         // We are coming from the mechToken state
         // Nothing to do.
         super.transitions[SpnegoStatesEnum.SPNEGO_METH_TOKEN_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_METH_TOKEN_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_LENGTH, null );
-
-        // NegTokenInit ::= SEQUENCE {
-        //    ...
-        //    mechListMIC   [3]  OCTET STRING  OPTIONAL } (Length)
-        // We have to check the length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_LENGTH][0xA3] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_LENGTH,
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_VALUE,
-                new GrammarAction( "Mech List MIC Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Store the length in the mech token expected length
-                        spnego.setMechListMICExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_VALUE, null );
 
         // NegTokenInit ::= SEQUENCE {
         //    ...
@@ -743,15 +429,14 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_TAG][0x04] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_TAG,
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_VALUE, null );
 
-        // mechListMIC   [3]  OCTET STRING  OPTIONAL } (Length)
-        // Checks the length. If the length is 0, we will allocate an empty OctetString.
-        super.transitions[SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_LENGTH][0x04] =
+        // mechListMIC   [3]  OCTET STRING  OPTIONAL } (Value)
+        // Stores the MechListMIC OctetString. This is the last transition.
+        super.transitions[SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_VALUE][0x04] =
             new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_LENGTH,
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_VALUE,
-                new GrammarAction( "Mech ListMIC Length" )
+                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_VALUE, -1,
+                new GrammarAction( "Mech ListMIC Value" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
@@ -761,58 +446,21 @@
                             spnegoContainer.getSpnego();
                         TLV                    tlv             = spnegoContainer.getCurrentTLV();
 
-                        int                    expectedLength  =
-                            spnego.getMechListMICExpectedLength();
-                        int                    currentLength   =
-                            tlv.getLength().getSize() + tlv.getTag().getSize() +
-                            tlv.getLength().getLength();
-
-                        if ( expectedLength != currentLength )
-                        {
-                            throw new DecoderException(
-                                "The MechListMIC length is different than the expected length" );
-                        }
-
+                        // Stores the mechListMIC data
                         if ( tlv.getLength().getLength() == 0 )
                         {
                             spnego.setMechListMIC( OctetString.EMPTY_STRING );
                         }
                         else
                         {
-
                             // Creates a new mechListMIC
-                            OctetString mechListMIC = new OctetString();
-
-                            spnego.setMechListMIC( mechListMIC );
+                            spnego.setMechListMIC( new OctetString( tlv.getValue().getData() ) );
                         }
 
                         return;
                     }
                 } );
 
-        // mechListMIC   [3]  OCTET STRING  OPTIONAL } (Value)
-        // Stores the MechListMIC OctetString. This is the last transition.
-        super.transitions[SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_VALUE][0x04] =
-            new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_INIT_MECH_LIST_MIC_OCTET_STRING_VALUE, -1,
-                new GrammarAction( "Mech ListMIC Value" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenInit spnego          = ( SpnegoNegTokenInit )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Stores the mechListMIC data
-                        OctetString mechListMIC = spnego.getMechListMIC();
-
-                        mechListMIC.setData( tlv.getValue().getData() );
-                        return;
-                    }
-                } );
-
         //********************************************************************************************
         //============================================================================================
         // NegTokenTarg State
@@ -823,7 +471,7 @@
         // here, and store it in the container.
         super.transitions[SpnegoStatesEnum.SPNEGO_START_STATE][0xA1] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_START_STATE,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_LENGTH,
+                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_VALUE,
                 new GrammarAction( "Spnego neg token targ tag" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -842,29 +490,6 @@
                 } );
 
         // SPNEGO --> CHOICE { ...
-        //      negTokenTarg  [1]  NegTokenTarg, (Length)
-        // We get the negTokenTarg length, and store it in the SpnegoObject
-        super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_LENGTH][0xA1] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_LENGTH,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_VALUE,
-                new GrammarAction( "Spnego neg token targ Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        // We have to store the expected Length of the PDU
-                        SpnegoContainer spnegoContainer = ( SpnegoContainer ) container;
-                        Spnego      spnego          = spnegoContainer.getSpnego();
-
-                        spnego.setExpectedLength( spnegoContainer.getCurrentTLV().getLength()
-                            .getLength() );
-                        spnego.setCurrentLength( 0 );
-
-                        return;
-                    }
-                } );
-
-        // SPNEGO --> CHOICE { ...
         //      negTokenTarg  [1]  NegTokenTarg, (Value)
         // We will have a SEQUENCE. There is no value, so this is just a phantom transition.
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_VALUE][0xA1] =
@@ -886,42 +511,7 @@
         // Nothing to do here, it's just a tag...
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_TAG][0x30] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_TAG,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_LENGTH, null );
-
-        // NegTokenTarg ::= SEQUENCE { (Tag)
-        //    negResult      [0]  ENUMERATED {
-        //            accept_completed (0),
-        //            accept_incomplete (1),
-        //            rejected (2) }           OPTIONAL,
-        //    supportedMech  [1]  MechType     OPTIONAL,
-        //    responseToken  [2]  OCTET STRING OPTIONAL,
-        //    mechListMIC    [3]  OCTET STRING OPTIONAL
-        // }
-        // We have to check the length, and set the new expected length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_LENGTH][0x30] =
-            new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_LENGTH,
-                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_VALUE,
-                new GrammarAction( "Spnego neg token targ sequence Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        // first, we check that the length is OK
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-                        checkLength( spnego, tlv );
-
-                        // Second, we store the new expected length into the global
-                        // expected length, as it won't be usefull any more (this is
-                        // an optimisation, we could have declared another class
-                        // member to do this.) We also reset the current length to 0.
-                        spnego.setExpectedLength( tlv.getLength().getLength() );
-                        spnego.setCurrentLength( 0 );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_VALUE, null );
 
         // NegTokenTarg ::= SEQUENCE { (Tag)
         //    negResult      [0]  ENUMERATED {
@@ -952,35 +542,7 @@
         // We have to switch to the Length transition of a negResult state
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG][0xA0] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_NEG_RESULT_LENGTH, null );
-
-        // negResult      [0]  ENUMERATED {
-        //        accept_completed (0),
-        //        accept_incomplete (1),
-        //        rejected (2) 
-        // } OPTIONAL,
-        // ...
-        // We have to check the length
-        super.transitions[SpnegoStatesEnum.SPNEGO_NEG_RESULT_LENGTH][0xA0] = new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_NEG_RESULT_LENGTH, SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE,
-                new GrammarAction( "neg result Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Store the length in the Neg Result expected length
-                        spnego.setNegResultExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE, null );
 
         // negResult      [0]  ENUMERATED {
         //        accept_completed (0),
@@ -1006,53 +568,7 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE_TAG][0x0A] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE_TAG,
-                SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE_LENGTH, null );
-
-        // negResult      [0]  ENUMERATED { (Tag)
-        //        accept_completed (0),
-        //        accept_incomplete (1),
-        //        rejected (2) 
-        // } 
-        //
-        // We have to check the length, and handle the special case of an empty length, which
-        /// is an error. The length MUST be 1, nothing else.
-        super.transitions[SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE_LENGTH][0x0A] =
-            new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE_LENGTH,
-                SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE_VALUE,
-                new GrammarAction( "neg result value Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-                        int valueLength = tlv.getLength().getLength();
-
-                        int                    expectedLength  = spnego.getNegResultExpectedLength();
-                        
-                        int                    currentLength   =
-                            tlv.getLength().getSize() + tlv.getTag().getSize() +
-                            valueLength;
-
-                        // The length must be 1, as the result is a value in [0..2]
-                        if (valueLength != 1)
-                        {
-                            throw new DecoderException(
-                            "The negResult length must be 1, not " + valueLength );
-                        }
-                        
-                        if ( expectedLength != currentLength )
-                        {
-                            throw new DecoderException(
-                                "The NegResult length is different than the expected length" );
-                        }
-
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_NEG_RESULT_VALUE_VALUE, null );
 
         // negResult      [0]  ENUMERATED { (Tag)
         //        accept_completed (0),
@@ -1103,7 +619,7 @@
         // We have to switch to the Length transition of a supportedMech State
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG][0xA1] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_VALUE, null );
 
         // supportedMech  [1]  MechType OPTIONAL, (Tag)
         // ...
@@ -1111,31 +627,7 @@
         // We have to switch to the Length transition of a supportedMech State
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_RESULT_FOLLOWING_TAG][0xA1] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_RESULT_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_LENGTH, null );
-
-        // supportedMech  [1]  MechType OPTIONAL, (Length)
-        // ...
-        // Just check the length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_LENGTH][0xA1] = new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_LENGTH, SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_VALUE,
-                new GrammarAction( "supported Mech Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Store the length in the supported Mech expected length
-                        spnego.setSupportedMechExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_VALUE, null );
 
         // supportedMech  [1]  MechType OPTIONAL, (Value)
         // ...
@@ -1155,48 +647,7 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_OID_TAG][0x06] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_OID_TAG,
-                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_OID_LENGTH, null );
-
-        // supportedMech  [1]  MechType OPTIONAL,
-        // ...
-        // MechType ::= OBJECT IDENTIFIER (Length)
-        //
-        // We have to check the length, and handle the special case of an empty length,
-        // which is an error.
-        super.transitions[SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_OID_LENGTH][0x06] =
-            new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_OID_LENGTH,
-                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_OID_VALUE,
-                new GrammarAction( "supported mech OID Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        int expectedLength = spnego.getSupportedMechExpectedLength();
-
-                        int currentLength  = tlv.getSize();
-
-                        if ( expectedLength < currentLength )
-                        {
-                            throw new DecoderException(
-                                "The current length is longer than the expected length" );
-                        }
-                        
-                        if (currentLength == 0)
-                        {
-                            throw new DecoderException(
-                            "The length of an OID cannot be null" );
-                        }
-
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_OID_VALUE, null );
 
         // supportedMech  [1]  MechType OPTIONAL,
         // ...
@@ -1236,7 +687,7 @@
         // We have to switch to the Length transition of a responseToken State
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG][0xA2] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_VALUE, null );
 
         // responseToken [2] OCTET STRING OPTIONAL, (Tag)
         // ...
@@ -1244,7 +695,7 @@
         // We have to switch to the Length transition of a responseToken State
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_RESULT_FOLLOWING_TAG][0xA2] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_RESULT_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_VALUE, null );
 
         // responseToken [2] OCTET STRING OPTIONAL, (Tag)
         // ...
@@ -1252,31 +703,7 @@
         // We have to switch to the Length transition of a responseToken State
         super.transitions[SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_FOLLOWING_TAG][0xA2] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_LENGTH, null );
-
-        // responseToken [2] OCTET STRING OPTIONAL, (Length)
-        // ...
-        // Just check the length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_LENGTH][0xA2] = new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_LENGTH, SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_VALUE,
-                new GrammarAction( "response Token Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Store the length in the supported Mech expected length
-                        spnego.setResponseTokenExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_VALUE, null );
 
         // responseToken [2] OCTET STRING OPTIONAL, (Value)
         // ...
@@ -1294,16 +721,16 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_TAG][0x04] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_TAG,
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_VALUE, null );
 
-        // response token OCTET STRING (Length)
+        // response token OCTET STRING (Value)
         //
-        // We have to check the length, and handle the special case of an empty length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_LENGTH][0x04] =
+        // Get the response token and store it into the SpnegoObject
+        super.transitions[SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_VALUE][0x04] =
             new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_LENGTH,
                 SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_VALUE,
-                new GrammarAction( "response token octet string Length" )
+                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_FOLLOWING_TAG,
+                new GrammarAction( "response token octet string value" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
@@ -1313,61 +740,23 @@
                             spnegoContainer.getSpnego();
                         TLV                    tlv             = spnegoContainer.getCurrentTLV();
 
-                        // Checks the length.
-                        int expectedLength = spnego.getResponseTokenExpectedLength();
-
-                        int currentLength  = tlv.getSize();
-
-                        if ( expectedLength < currentLength )
-                        {
-                            throw new DecoderException(
-                                "The current length is longer than the expected length" );
-                        }
-                        
+                        // Stores the response token
                         // Deal with a zero-length octet string
-                        if (currentLength == 0)
+                        if (tlv.getLength().getLength() == 0)
                         {
                             spnego.setResponseToken(OctetString.EMPTY_STRING);
                         }
                         else
                         {
                             // Create a responseToken
-                            // TODO: use the length to allocate the best
-                            // OctetString possible.
-                            OctetString responseToken = new OctetString();
 
-                            spnego.setResponseToken( responseToken );
+                            spnego.setResponseToken( new OctetString( tlv.getValue().getData() ) );
                         }
 
                         return;
                     }
                 } );
 
-        // response token OCTET STRING (Value)
-        //
-        // Get the response token and store it into the SpnegoObject
-        super.transitions[SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_VALUE][0x04] =
-            new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_OCTET_STRING_VALUE,
-                SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_FOLLOWING_TAG,
-                new GrammarAction( "response token octet string value" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Stores the response token
-                        OctetString responseToken = spnego.getResponseToken();
-                        responseToken.setData( tlv.getValue().getData() );
-
-                        return;
-                    }
-                } );
-
         //============================================================================================
         // mechListMIC State
         //--------------------------------------------------------------------------------------------
@@ -1377,7 +766,7 @@
         // We have to switch to the Length transition of a mechListMIC State
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_TARG_SEQUENCE_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_VALUE, null );
 
         // mechListMIC [3] OCTET STRING OPTIONAL (Tag)
         // ...
@@ -1385,7 +774,7 @@
         // We have to switch to the Length transition of a mechListMIC State
         super.transitions[SpnegoStatesEnum.SPNEGO_NEG_RESULT_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_RESULT_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_VALUE, null );
 
         // mechListMIC [3] OCTET STRING OPTIONAL (Tag)
         // ...
@@ -1393,7 +782,7 @@
         // We have to switch to the Length transition of a mechListMIC State
         super.transitions[SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_SUPPORTED_METH_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_VALUE, null );
 
         // mechListMIC [3] OCTET STRING OPTIONAL (Tag)
         // ...
@@ -1401,31 +790,7 @@
         // We have to switch to the Length transition of a mechListMIC State
         super.transitions[SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_FOLLOWING_TAG][0xA3] =
             new GrammarTransition( SpnegoStatesEnum.SPNEGO_RESPONSE_TOKEN_FOLLOWING_TAG,
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_LENGTH, null );
-
-        // mechListMIC [3] OCTET STRING OPTIONAL (Length)
-        // ...
-        // Just check the length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_LENGTH][0xA3] = new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_LENGTH, SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_VALUE,
-                new GrammarAction( "mech List MIC Length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Checks the length.
-                        checkLength( spnego, tlv );
-
-                        // Store the length in the supported Mech expected length
-                        spnego.setMechListMICExpectedLength( tlv.getLength().getLength() );
-                        return;
-                    }
-                } );
+                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_VALUE, null );
 
         // mechListMIC [3] OCTET STRING OPTIONAL (Value)
         // ...
@@ -1443,16 +808,17 @@
         super.transitions[SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_TAG][0x04] =
             new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_TAG,
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_LENGTH, null );
+                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_VALUE, null );
 
-        // mech list MIC OCTET STRING (Length)
+        // mech list MIC OCTET STRING (Value)
         //
-        // We have to check the length, and handle the special case of an empty length.
-        super.transitions[SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_LENGTH][0x04] =
+        // Get the mech list MIC and store it into the SpnegoObject.
+        // This is the last state of this grammar.
+        super.transitions[SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_VALUE][0x04] =
             new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_LENGTH,
                 SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_VALUE,
-                new GrammarAction( "mech list MIC octet string Length" )
+                -1,
+                new GrammarAction( "mech list MIC octet string value" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
@@ -1462,57 +828,17 @@
                             spnegoContainer.getSpnego();
                         TLV                    tlv             = spnegoContainer.getCurrentTLV();
 
-                        // Checks the length.
-                        int expectedLength = spnego.getMechListMICExpectedLength();
-
-                        int currentLength  = tlv.getSize();
-
-                        if ( expectedLength < currentLength )
-                        {
-                            throw new DecoderException(
-                                "The current length is longer than the expected length" );
-                        }
-                        
-                        // Deal with a zero-length octet string
-                        if (currentLength == 0)
+                        // Stores the response token
+                        if (tlv.getLength().getLength() == 0)
                         {
                             spnego.setMechListMIC(OctetString.EMPTY_STRING);
                         }
                         else
                         {
                             // Create a responseToken
-                            // TODO: use the length to allocate the best
-                            // OctetString possible.
-                            OctetString mechListMIC = new OctetString();
 
-                            spnego.setMechListMIC( mechListMIC );
+                            spnego.setMechListMIC( new OctetString( tlv.getValue().getData() ) );
                         }
-
-                        return;
-                    }
-                } );
-
-        // mech list MIC OCTET STRING (Value)
-        //
-        // Get the mech list MIC and store it into the SpnegoObject.
-        // This is the last state of this grammar.
-        super.transitions[SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_VALUE][0x04] =
-            new GrammarTransition(
-                SpnegoStatesEnum.SPNEGO_TARG_MECH_LIST_MIC_OCTET_STRING_VALUE,
-                -1,
-                new GrammarAction( "mech list MIC octet string value" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        SpnegoContainer        spnegoContainer = ( SpnegoContainer ) container;
-                        SpnegoNegTokenTarg spnego          = ( SpnegoNegTokenTarg )
-                            spnegoContainer.getSpnego();
-                        TLV                    tlv             = spnegoContainer.getCurrentTLV();
-
-                        // Stores the response token
-                        OctetString mechListMIC = spnego.getMechListMIC();
-                        mechListMIC.setData( tlv.getValue().getData() );
 
                         return;
                     }



Mime
View raw message