001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.directory.shared.kerberos.codec.krbError;
021
022
023import org.apache.directory.api.asn1.ber.grammar.Grammar;
024import org.apache.directory.api.asn1.ber.grammar.States;
025
026
027/**
028 * This class store the KRB-ERROR grammar's constants. It is also used for debugging
029 * purpose
030 *
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public enum KrbErrorStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    // ----- KRB-ERROR component --------------------------------------
039    KRB_ERR_TAG, // 1
040
041    KRB_ERR_SEQ_STATE, // 2
042
043    KRB_ERR_PVNO_TAG_STATE, // 3
044    KRB_ERR_PVNO_STATE, // 4
045
046    KRB_ERR_MSG_TYPE_TAG_STATE, // 5
047    KRB_ERR_MSG_TYPE_STATE, // 6
048
049    KRB_ERR_CTIME_TAG_STATE, // 7
050    KRB_ERR_CTIME_STATE, // 8
051
052    KRB_ERR_CUSEC_TAG_STATE, // 9
053    KRB_ERR_CUSEC_STATE, // 10
054
055    KRB_ERR_STIME_TAG_STATE, // 11
056    KRB_ERR_STIME_STATE, // 12
057
058    KRB_ERR_SUSEC_TAG_STATE, // 13
059    KRB_ERR_SUSEC_STATE, // 14
060
061    KRB_ERR_ERROR_CODE_TAG_STATE, // 15
062    KRB_ERR_ERROR_CODE_STATE, // 16
063
064    KRB_ERR_CREALM_TAG_STATE, // 17
065    KRB_ERR_CREALM_STATE, // 18
066
067    KRB_ERR_CNAME_STATE, // 19
068
069    KRB_ERR_REALM_TAG_STATE, // 20
070    KRB_ERR_REALM_STATE, // 21
071
072    KRB_ERR_SNAME_STATE, // 22
073
074    KRB_ERR_ETEXT_TAG_STATE, // 23
075    KRB_ERR_ETEXT_STATE, // 24
076
077    KRB_ERR_EDATA_TAG_STATE, // 25
078    KRB_ERR_EDATA_STATE, // 26
079
080    // End
081    LAST_KRB_ERR_STATE; // 27
082
083    /**
084     * Get the grammar name
085     *
086     * @param grammar The grammar code
087     * @return The grammar name
088     */
089    public String getGrammarName( int grammar )
090    {
091        return "KRB_ERR_GRAMMAR";
092    }
093
094
095    /**
096     * Get the grammar name
097     *
098     * @param grammar The grammar class
099     * @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}