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.krbError;
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 KRB-ERROR 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 KrbErrorStatesEnum implements States
34  {
35      // Start
36      START_STATE, // 0
37  
38      // ----- KRB-ERROR component --------------------------------------
39      KRB_ERR_TAG, // 1
40  
41      KRB_ERR_SEQ_STATE, // 2
42  
43      KRB_ERR_PVNO_TAG_STATE, // 3
44      KRB_ERR_PVNO_STATE, // 4
45  
46      KRB_ERR_MSG_TYPE_TAG_STATE, // 5
47      KRB_ERR_MSG_TYPE_STATE, // 6
48  
49      KRB_ERR_CTIME_TAG_STATE, // 7
50      KRB_ERR_CTIME_STATE, // 8
51  
52      KRB_ERR_CUSEC_TAG_STATE, // 9
53      KRB_ERR_CUSEC_STATE, // 10
54  
55      KRB_ERR_STIME_TAG_STATE, // 11
56      KRB_ERR_STIME_STATE, // 12
57  
58      KRB_ERR_SUSEC_TAG_STATE, // 13
59      KRB_ERR_SUSEC_STATE, // 14
60  
61      KRB_ERR_ERROR_CODE_TAG_STATE, // 15
62      KRB_ERR_ERROR_CODE_STATE, // 16
63  
64      KRB_ERR_CREALM_TAG_STATE, // 17
65      KRB_ERR_CREALM_STATE, // 18
66  
67      KRB_ERR_CNAME_STATE, // 19
68  
69      KRB_ERR_REALM_TAG_STATE, // 20
70      KRB_ERR_REALM_STATE, // 21
71  
72      KRB_ERR_SNAME_STATE, // 22
73  
74      KRB_ERR_ETEXT_TAG_STATE, // 23
75      KRB_ERR_ETEXT_STATE, // 24
76  
77      KRB_ERR_EDATA_TAG_STATE, // 25
78      KRB_ERR_EDATA_STATE, // 26
79  
80      // End
81      LAST_KRB_ERR_STATE; // 27
82  
83      /**
84       * Get the grammar name
85       *
86       * @param grammar The grammar code
87       * @return The grammar name
88       */
89      public String getGrammarName( int grammar )
90      {
91          return "KRB_ERR_GRAMMAR";
92      }
93  
94  
95      /**
96       * Get the grammar name
97       *
98       * @param grammar The grammar class
99       * @return The grammar name
100      */
101     public String getGrammarName( Grammar<KrbErrorContainer> grammar )
102     {
103         if ( grammar instanceof KrbErrorGrammar )
104         {
105             return "KRB_ERR_GRAMMAR";
106         }
107         else
108         {
109             return "UNKNOWN GRAMMAR";
110         }
111     }
112 
113 
114     /**
115      * Get the string representing the state
116      *
117      * @param state The state number
118      * @return The String representing the state
119      */
120     public String getState( int state )
121     {
122         return ( ( state == LAST_KRB_ERR_STATE.ordinal() ) ? "LAST_KRB_ERR_STATE" : name() );
123     }
124 
125 
126     /**
127      * {@inheritDoc}
128      */
129     public boolean isEndState()
130     {
131         return this == LAST_KRB_ERR_STATE;
132     }
133 
134 
135     /**
136      * {@inheritDoc}
137      */
138     public KrbErrorStatesEnum getStartState()
139     {
140         return START_STATE;
141     }
142 }