directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r168019 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
Date Tue, 03 May 2005 23:25:51 GMT
Author: elecharny
Date: Tue May  3 16:25:51 2005
New Revision: 168019

URL: http://svn.apache.org/viewcvs?rev=168019&view=rev
Log:
Added the actions to handle the req flags.

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=168019&r1=168018&r2=168019&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
Tue May  3 16:25:51 2005
@@ -23,6 +23,7 @@
 import org.apache.asn1.ber.grammar.GrammarTransition;
 import org.apache.asn1.ber.grammar.IGrammar;
 import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.primitives.BitString;
 import org.apache.asn1.primitives.OID;
 import org.apache.asn1.primitives.OctetString;
 import org.apache.asn1.spnego.codec.SpnegoContainer;
@@ -356,6 +357,7 @@
         //    ...
         //    reqFlags      [1]  ContextFlags  OPTIONAL, (Tag)
         //    ...
+        // Nothing to do
         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 );
@@ -364,9 +366,25 @@
         //    ...
         //    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,
-                null );
+                new GrammarAction( "Req Flags Length" )
+                {
+	                public void action( IAsn1Container container ) throws DecoderException
+	                {
+	                    SpnegoContainer spnegoContainer = ( SpnegoContainer ) container;
+	                    SpnegoNegTokenInitPOJO spnego   = ( SpnegoNegTokenInitPOJO )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());
+	                    return;
+	                }
+                }  );
 
         // NegTokenInit ::= SEQUENCE {
         //    ...
@@ -403,7 +421,37 @@
         // The next state will be the MechToken following
         super.transitions[SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_LENGTH][0x03] = new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_LENGTH, SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_VALUE,
-                null );
+                new GrammarAction( "Req Flags Length" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        SpnegoContainer spnegoContainer = ( SpnegoContainer ) container;
+                        SpnegoNegTokenInitPOJO spnego   = ( SpnegoNegTokenInitPOJO )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)
+                        {
+                            spnego.setAnonFlag(false);
+                            spnego.setConfFlag(false);
+                            spnego.setDelegFlag(false);
+                            spnego.setIntegFlag(false);
+                            spnego.setMutualFlag(false);
+                            spnego.setReplayFlag(false);
+                            spnego.setSequenceFlag(false);
+                        }
+
+                        // The flags wioll be set in the next state
+                        return;
+                    }
+                } );
 
         // ContextFlags ::= BIT_STRING { (value)
         //     delegFlag     (0),
@@ -417,7 +465,29 @@
         // The next state will be the MechToken following
         super.transitions[SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_VALUE][0x03] = new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_VALUE, SpnegoStatesEnum.SPNEGO_REQ_FLAGS_FOLLOWING_TAG,
-                null );
+                new GrammarAction( "Req Flags Value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        SpnegoContainer spnegoContainer = ( SpnegoContainer ) container;
+                        SpnegoNegTokenInitPOJO spnego   = ( SpnegoNegTokenInitPOJO )spnegoContainer.getSpnego();
+                        TLV				tlv 			= spnegoContainer.getCurrentTLV();
+
+                        // Get the req falgs and set the flag
+                        BitString bitString = new BitString(tlv.getValue().getData());
+                        
+                        spnego.setAnonFlag(bitString.getBit(0));
+                        spnego.setConfFlag(bitString.getBit(1));
+                        spnego.setDelegFlag(bitString.getBit(2));
+                        spnego.setIntegFlag(bitString.getBit(3));
+                        spnego.setMutualFlag(bitString.getBit(4));
+                        spnego.setReplayFlag(bitString.getBit(5));
+                        spnego.setSequenceFlag(bitString.getBit(6));
+
+                        bitString = null;
+                        return;
+                    }
+                } );
 
         //------------------------------------------------------------------------------------------
         // NegTokenInit ::= SEQUENCE { 
@@ -521,7 +591,7 @@
                         }
                         return;
                     }
-                }  );
+                } );
 
         // mechToken     [2]  OCTET STRING  OPTIONAL, (Value)
         // We will allocate a new Octet String.



Mime
View raw message