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.kdcRep;
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 KDC-REP 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 KdcRepStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    // ----- KDC-REP component --------------------------------------
039    KDC_REP_SEQ_STATE, // 1
040
041    KDC_REP_PVNO_TAG_STATE, // 2
042    KDC_REP_PVNO_STATE, // 3
043
044    KDC_REP_MSG_TYPE_TAG_STATE, // 4
045    KDC_REP_MSG_TYPE_STATE, // 5
046
047    KDC_REP_PA_DATA_TAG_STATE, // 6
048    KDC_REP_PA_DATA_STATE, // 7
049
050    KDC_REP_CREALM_TAG_STATE, // 8
051    KDC_REP_CREALM_STATE, // 9
052
053    KDC_REP_CNAME_STATE, // 10
054
055    KDC_REP_TICKET_STATE, // 11
056
057    KDC_REP_ENC_PART_STATE, // 12
058
059    // End
060    LAST_KDC_REP_STATE; // 13
061
062    /**
063     * Get the grammar name
064     *
065     * @param grammar The grammar code
066     * @return The grammar name
067     */
068    public String getGrammarName( int grammar )
069    {
070        return "KDC_REP_GRAMMAR";
071    }
072
073
074    /**
075     * Get the grammar name
076     *
077     * @param grammar The grammar class
078     * @return The grammar name
079     */
080    public String getGrammarName( Grammar<KdcRepContainer> grammar )
081    {
082        if ( grammar instanceof KdcRepGrammar )
083        {
084            return "KDC_REP_GRAMMAR";
085        }
086        else
087        {
088            return "UNKNOWN GRAMMAR";
089        }
090    }
091
092
093    /**
094     * Get the string representing the state
095     *
096     * @param state The state number
097     * @return The String representing the state
098     */
099    public String getState( int state )
100    {
101        return ( ( state == LAST_KDC_REP_STATE.ordinal() ) ? "KDC_REP_END_STATE" : name() );
102    }
103
104
105    /**
106     * {@inheritDoc}
107     */
108    public boolean isEndState()
109    {
110        return this == LAST_KDC_REP_STATE;
111    }
112
113
114    /**
115     * {@inheritDoc}
116     */
117    public KdcRepStatesEnum getStartState()
118    {
119        return START_STATE;
120    }
121}