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.kdcReqBody;
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-REQ-BODY 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 KdcReqBodyStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    // ----- KDC-REQ-BODY message --------------------------------------
039    KDC_REQ_BODY_SEQ_STATE, // 1
040
041    KDC_REQ_BODY_KDC_OPTIONS_TAG_STATE, // 2
042    KDC_REQ_BODY_KDC_OPTIONS_STATE, // 3
043
044    KDC_REQ_BODY_CNAME_OR_REALM_TAG_STATE, // 4
045    KDC_REQ_BODY_CNAME_STATE, // 5
046
047    KDC_REQ_BODY_REALM_TAG_STATE, // 6
048
049    KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE, // 7
050    KDC_REQ_BODY_SNAME_STATE, // 8
051
052    KDC_REQ_BODY_FROM_STATE, // 9
053
054    KDC_REQ_BODY_TILL_TAG_STATE, // 10
055    KDC_REQ_BODY_TILL_STATE, // 11
056
057    KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, // 12
058    KDC_REQ_BODY_RTIME_STATE, // 13
059
060    KDC_REQ_BODY_NONCE_TAG_STATE, // 14
061    KDC_REQ_BODY_NONCE_STATE, // 15
062
063    KDC_REQ_BODY_ETYPE_TAG_STATE, // 16
064    KDC_REQ_BODY_ETYPE_SEQ_STATE, // 17
065    KDC_REQ_BODY_ETYPE_STATE, // 18
066
067    KDC_REQ_BODY_ADDRESSES_STATE, // 19
068
069    KDC_REQ_BODY_ENC_AUTH_DATA_STATE, // 20
070
071    KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE, // 21
072    KDC_REQ_BODY_ADDITIONAL_TICKETS_SEQ_STATE, // 22
073    KDC_REQ_BODY_ADDITIONAL_TICKETS_STATE, // 23
074
075    // End
076    LAST_KDC_REQ_BODY_STATE; // 24
077
078    /**
079     * Get the grammar name
080     *
081     * @param grammar The grammar code
082     * @return The grammar name
083     */
084    public String getGrammarName( int grammar )
085    {
086        return "KDC_REQ_BODY_GRAMMAR";
087    }
088
089
090    /**
091     * Get the grammar name
092     *
093     * @param grammar The grammar class
094     * @return The grammar name
095     */
096    public String getGrammarName( Grammar<KdcReqBodyContainer> grammar )
097    {
098        if ( grammar instanceof KdcReqBodyGrammar )
099        {
100            return "KDC_REQ_BODY_GRAMMAR";
101        }
102        else
103        {
104            return "UNKNOWN GRAMMAR";
105        }
106    }
107
108
109    /**
110     * Get the string representing the state
111     *
112     * @param state The state number
113     * @return The String representing the state
114     */
115    public String getState( int state )
116    {
117        return ( ( state == LAST_KDC_REQ_BODY_STATE.ordinal() ) ? "KDC_REQ_BODY_END_STATE" : name() );
118    }
119
120
121    /**
122     * {@inheritDoc}
123     */
124    public boolean isEndState()
125    {
126        return this == LAST_KDC_REQ_BODY_STATE;
127    }
128
129
130    /**
131     * {@inheritDoc}
132     */
133    public KdcReqBodyStatesEnum getStartState()
134    {
135        return START_STATE;
136    }
137}