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.krbPriv;
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 stores the KRB-PRIV 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 KrbPrivStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    // ----- KRB-SAFE component --------------------------------------
039    KRB_PRIV_TAG_STATE, // 1
040
041    KRB_PRIV_SEQ_STATE, // 2
042
043    KRB_PRIV_PVNO_TAG_STATE, // 3
044    KRB_PRIV_PVNO_STATE, // 4
045
046    KRB_PRIV_MSGTYPE_TAG_STATE, // 5
047    KRB_PRIV_MSGTYPE_STATE, // 6
048
049    KRB_PRIV_EN_PART_TAG_STATE, // 7
050
051    // End
052    LAST_KRB_PRIV_STATE; // 8
053
054    /**
055     * Get the grammar name
056     *
057     * @param grammar The grammar code
058     * @return The grammar name
059     */
060    public String getGrammarName( int grammar )
061    {
062        return "KRB_PRIV_GRAMMAR";
063    }
064
065
066    /**
067     * Get the grammar name
068     *
069     * @param grammar The grammar class
070     * @return The grammar name
071     */
072    public String getGrammarName( Grammar<KrbPrivContainer> grammar )
073    {
074        if ( grammar instanceof KrbPrivGrammar )
075        {
076            return "KRB_PRIV_GRAMMAR";
077        }
078        else
079        {
080            return "UNKNOWN GRAMMAR";
081        }
082    }
083
084
085    /**
086     * Get the string representing the state
087     *
088     * @param state The state number
089     * @return The String representing the state
090     */
091    public String getState( int state )
092    {
093        return ( ( state == LAST_KRB_PRIV_STATE.ordinal() ) ? "LAST_KRB_PRIV_STATE" : name() );
094    }
095
096
097    /**
098     * {@inheritDoc}
099     */
100    public boolean isEndState()
101    {
102        return this == LAST_KRB_PRIV_STATE;
103    }
104
105
106    /**
107     * {@inheritDoc}
108     */
109    public KrbPrivStatesEnum getStartState()
110    {
111        return START_STATE;
112    }
113}