directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r164673 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoStatesEnum.java
Date Mon, 25 Apr 2005 22:30:18 GMT
Author: elecharny
Date: Mon Apr 25 15:30:17 2005
New Revision: 164673

URL: http://svn.apache.org/viewcvs?rev=164673&view=rev
Log:
Added the getState method.

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoStatesEnum.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoStatesEnum.java?rev=164673&r1=164672&r2=164673&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoStatesEnum.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoStatesEnum.java
Mon Apr 25 15:30:17 2005
@@ -16,33 +16,123 @@
  */
 package org.apache.asn1.spnego.codec.grammars;
 
+import org.apache.asn1.ber.grammar.IStates;
+
 /**
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SpnegoStatesEnum {
+public class SpnegoStatesEnum implements IStates {
     // LdapMessage ------------------------------------------------------------
     /** Initiate the counter to 0 */
-    private static int SPNEGO_START_STATE = 0;
+    private static final int SPNEGO_START_STATE = 0;
 
     /** SPNEGO neg token init Tag */
-    public static int SPNEGO_NEG_TOKEN_INIT_TAG = 0;
+    public static final int SPNEGO_NEG_TOKEN_INIT_TAG = 0;
 
     /** SPNEGO neg token init Length */
-    public static int SPNEGO_NEG_TOKEN_INIT_LENGTH = 1;
+    public static final int SPNEGO_NEG_TOKEN_INIT_LENGTH = 1;
 
     /** SPNEGO neg token init Value */
-    public static int SPNEGO_NEG_TOKEN_INIT_VALUE = 2;
+    public static final int SPNEGO_NEG_TOKEN_INIT_VALUE = 2;
+    
+    /** SPNEGO neg token init SEQUENCE Tag */
+    public static final int SPNEGO_NEG_TOKEN_INIT_SEQUENCE_TAG = 3;
+
+    /** SPNEGO neg token init SEQUENCE Length */
+    public static final int SPNEGO_NEG_TOKEN_INIT_SEQUENCE_LENGTH = 4;
+
+    /** SPNEGO neg token init SEQUENCE Value */
+    public static final int SPNEGO_NEG_TOKEN_INIT_SEQUENCE_VALUE = 5;
     
     /** SPNEGO neg token targ Tag */
-    public static int SPNEGO_NEG_TOKEN_TARG_TAG = 3;
+    public static final int SPNEGO_NEG_TOKEN_TARG_TAG = 6;
 
     /** SPNEGO neg token targ Length */
-    public static int SPNEGO_NEG_TOKEN_TARG_LENGTH = 4;
+    public static final int SPNEGO_NEG_TOKEN_TARG_LENGTH = 7;
 
     /** SPNEGO neg token targ Value */
-    public static int SPNEGO_NEG_TOKEN_TARG_VALUE = 5;
+    public static final int SPNEGO_NEG_TOKEN_TARG_VALUE = 8;
     
+    /** SPNEGO last state */
     public static final int LAST_SPNEGO_STATE = 10;
 
+    /** SPNEGO Grammar */
     public static final int SPNEGO_GRAMMAR = 0;
+
+    /** A string representation of all the states */
+    private static String[] SpnegoMessageString =
+        new String[]
+        {
+            "LDAP_MESSAGE_TAG", 
+            "LDAP_MESSAGE_LENGTH", 
+            "LDAP_MESSAGE_VALUE", 
+            "LDAP_MESSAGE_ID_TAG",
+            "LDAP_MESSAGE_ID_LENGTH", 
+            "LDAP_MESSAGE_ID_VALUE", 
+            "PROTOCOL_OP_TAG",
+            "PROTOCOL_OP_LENGTH", 
+            "PROTOCOL_OP_VALUE"
+        };
+
+    /** The instance */
+    private static SpnegoStatesEnum instance = new SpnegoStatesEnum();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * This is a private constructor. This class is a singleton
+     *
+     */
+    private SpnegoStatesEnum()
+    {
+    }
+
+    /**
+     * Get an instance of this class
+     * @return An instance on this class
+     */
+    public static IStates getInstance()
+    {
+        return instance;
+    }
+
+    /**
+     * Get the string representing the state
+     * 
+     * @param grammar The current grammar being used
+     * @param state The state number
+     * @return The String representing the state
+     */
+    public String getState( int grammar, int state )
+    {
+
+        if (grammar == SPNEGO_GRAMMAR)
+        {
+            if  ( state == -1 ) 
+            {
+                return "END_STATE";
+            }
+            else
+            {
+                switch (state)
+                {
+                    case SPNEGO_NEG_TOKEN_INIT_TAG : return "SPNEGO_NEG_TOKEN_INIT_TAG";
+                    case SPNEGO_NEG_TOKEN_INIT_LENGTH : return "SPNEGO_NEG_TOKEN_INIT_LENGTH";

+                    case SPNEGO_NEG_TOKEN_INIT_VALUE : return "SPNEGO_NEG_TOKEN_INIT_VALUE";
+                    case SPNEGO_NEG_TOKEN_INIT_SEQUENCE_TAG : return "SPNEGO_NEG_TOKEN_INIT_SEQUENCE_TAG";
+                    case SPNEGO_NEG_TOKEN_INIT_SEQUENCE_LENGTH : return "SPNEGO_NEG_TOKEN_INIT_SEQUENCE_LENGTH";
+                    case SPNEGO_NEG_TOKEN_INIT_SEQUENCE_VALUE : return "SPNEGO_NEG_TOKEN_INIT_SEQUENCE_VALUE";
+                    case SPNEGO_NEG_TOKEN_TARG_TAG : return "SPNEGO_NEG_TOKEN_TARG_TAG";
+                    case SPNEGO_NEG_TOKEN_TARG_LENGTH : return "SPNEGO_NEG_TOKEN_TARG_LENGTH";
+                    case SPNEGO_NEG_TOKEN_TARG_VALUE : return "SPNEGO_NEG_TOKEN_TARG_VALUE";
+                	default : return "UNKNOWN";
+                }
+            }
+            
+        }
+        else 
+        {
+            return "UNKNOWN";
+        }
+    }
 }



Mime
View raw message