directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r168084 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
Date Wed, 04 May 2005 05:57:14 GMT
Author: elecharny
Date: Tue May  3 22:57:13 2005
New Revision: 168084

URL: http://svn.apache.org/viewcvs?rev=168084&view=rev
Log:
- Fixed some javadoc
- when the req flags bitstring is empty, does now throw an exception
- the BitString is now pooled

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=168084&r1=168083&r2=168084&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 22:57:13 2005
@@ -390,7 +390,7 @@
         //    ...
         //    reqFlags      [1]  ContextFlags  OPTIONAL, (Value)
         //    ...
-        // The next state will be the MechToken following
+        // Nothing to do. 
         super.transitions[SpnegoStatesEnum.SPNEGO_REQ_FLAGS_VALUE][0xA1] = new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_REQ_FLAGS_VALUE, SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_TAG,
                 null );
@@ -404,7 +404,7 @@
         //     confFlag      (5),
         //     integFlag     (6)
         // }
-        // The next state will be the MechToken following
+        // Nothing to do. We have a BitString
         super.transitions[SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_TAG][0x03] = new GrammarTransition(
                 SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_TAG, SpnegoStatesEnum.SPNEGO_CONTEXT_FLAGS_LENGTH,
                 null );
@@ -418,7 +418,8 @@
         //     confFlag      (5),
         //     integFlag     (6)
         // }
-        // The next state will be the MechToken following
+        // 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" )
@@ -439,16 +440,9 @@
                         
                         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);
+                            throw new DecoderException("The req flags must not be empty");
                         }
 
-                        // The flags wioll be set in the next state
                         return;
                     }
                 } );
@@ -473,18 +467,27 @@
                         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));
+                        // Get the req flags and set the flag
+                        try 
+                        {
+                            BitString bitString = (BitString)(spnegoContainer.getPoolManager().allocate(PoolEnum.BIT_STRING_POOL));
+                            bitString.setData(tlv.getValue().getData());
 
-                        bitString = null;
+                            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.free();
+                        }
+                        catch (PoolException pe)
+                        {
+                            throw new DecoderException("Cannot allocate a BitString : " +
pe.getMessage());
+                        }
+                        
                         return;
                     }
                 } );



Mime
View raw message