View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.directory.shared.kerberos.codec.authenticator;
21  
22  
23  import org.apache.directory.api.asn1.ber.grammar.Grammar;
24  import org.apache.directory.api.asn1.ber.grammar.States;
25  
26  
27  /**
28   * This class store the Authenticator grammar's constants. It is also used for debugging
29   * purpose
30   *
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public enum AuthenticatorStatesEnum implements States
34  {
35      // Start
36      START_STATE, // 0
37  
38      // ----- AUTHENTICATOR message --------------------------------------
39      AUTHENTICATOR_STATE, // 1
40      AUTHENTICATOR_SEQ_STATE, // 2
41  
42      AUTHENTICATOR_AUTHENTICATOR_VNO_TAG_STATE, // 3
43      AUTHENTICATOR_AUTHENTICATOR_VNO_STATE, // 4
44  
45      AUTHENTICATOR_CREALM_TAG_STATE, // 5
46      AUTHENTICATOR_CREALM_STATE, // 6
47  
48      AUTHENTICATOR_CNAME_STATE, // 7
49  
50      AUTHENTICATOR_CKSUM_STATE, // 8
51  
52      AUTHENTICATOR_CUSEC_TAG_STATE, // 9
53      AUTHENTICATOR_CUSEC_STATE, // 10
54  
55      AUTHENTICATOR_CTIME_TAG_STATE, // 11
56      AUTHENTICATOR_CTIME_STATE, // 12
57  
58      AUTHENTICATOR_SUBKEY_STATE, // 13
59  
60      AUTHENTICATOR_SEQ_NUMBER_TAG_STATE, // 14
61      AUTHENTICATOR_SEQ_NUMBER_STATE, // 15
62  
63      AUTHENTICATOR_AUTHORIZATION_DATA_STATE, // 16
64  
65      // End
66      LAST_AUTHENTICATOR_STATE; // 17
67  
68      /**
69       * Get the grammar name
70       *
71       * @param grammar The grammar code
72       * @return The grammar name
73       */
74      public String getGrammarName( int grammar )
75      {
76          return "AUTHENTICATOR_GRAMMAR";
77      }
78  
79  
80      /**
81       * Get the grammar name
82       *
83       * @param grammar The grammar class
84       * @return The grammar name
85       */
86      public String getGrammarName( Grammar<AuthenticatorContainer> grammar )
87      {
88          if ( grammar instanceof AuthenticatorGrammar )
89          {
90              return "AUTHENTICATOR_GRAMMAR";
91          }
92          else
93          {
94              return "UNKNOWN GRAMMAR";
95          }
96      }
97  
98  
99      /**
100      * Get the string representing the state
101      *
102      * @param state The state number
103      * @return The String representing the state
104      */
105     public String getState( int state )
106     {
107         return ( ( state == LAST_AUTHENTICATOR_STATE.ordinal() ) ? "AUTHENTICATOR_END_STATE" : name() );
108     }
109 
110 
111     /**
112      * {@inheritDoc}
113      */
114     public boolean isEndState()
115     {
116         return this == LAST_AUTHENTICATOR_STATE;
117     }
118 
119 
120     /**
121      * {@inheritDoc}
122      */
123     public AuthenticatorStatesEnum getStartState()
124     {
125         return START_STATE;
126     }
127 }