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.authenticator;
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 Authenticator 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 AuthenticatorStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    // ----- AUTHENTICATOR message --------------------------------------
039    AUTHENTICATOR_STATE, // 1
040    AUTHENTICATOR_SEQ_STATE, // 2
041
042    AUTHENTICATOR_AUTHENTICATOR_VNO_TAG_STATE, // 3
043    AUTHENTICATOR_AUTHENTICATOR_VNO_STATE, // 4
044
045    AUTHENTICATOR_CREALM_TAG_STATE, // 5
046    AUTHENTICATOR_CREALM_STATE, // 6
047
048    AUTHENTICATOR_CNAME_STATE, // 7
049
050    AUTHENTICATOR_CKSUM_STATE, // 8
051
052    AUTHENTICATOR_CUSEC_TAG_STATE, // 9
053    AUTHENTICATOR_CUSEC_STATE, // 10
054
055    AUTHENTICATOR_CTIME_TAG_STATE, // 11
056    AUTHENTICATOR_CTIME_STATE, // 12
057
058    AUTHENTICATOR_SUBKEY_STATE, // 13
059
060    AUTHENTICATOR_SEQ_NUMBER_TAG_STATE, // 14
061    AUTHENTICATOR_SEQ_NUMBER_STATE, // 15
062
063    AUTHENTICATOR_AUTHORIZATION_DATA_STATE, // 16
064
065    // End
066    LAST_AUTHENTICATOR_STATE; // 17
067
068    /**
069     * Get the grammar name
070     *
071     * @param grammar The grammar code
072     * @return The grammar name
073     */
074    public String getGrammarName( int grammar )
075    {
076        return "AUTHENTICATOR_GRAMMAR";
077    }
078
079
080    /**
081     * Get the grammar name
082     *
083     * @param grammar The grammar class
084     * @return The grammar name
085     */
086    public String getGrammarName( Grammar<AuthenticatorContainer> grammar )
087    {
088        if ( grammar instanceof AuthenticatorGrammar )
089        {
090            return "AUTHENTICATOR_GRAMMAR";
091        }
092        else
093        {
094            return "UNKNOWN GRAMMAR";
095        }
096    }
097
098
099    /**
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}