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.ldap.extras.extended.ads_impl.certGeneration;
021
022
023import org.apache.directory.shared.asn1.ber.grammar.Grammar;
024import org.apache.directory.shared.asn1.ber.grammar.States;
025
026/**
027 * This class store the CertGeneration's grammar constants. It is also used
028 * for debugging purposes.
029 * 
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 */
032public enum CertGenerationStatesEnum implements States
033{
034
035    /** The END_STATE */
036    END_STATE,
037
038    /** start state*/
039    START_STATE,
040
041    /** sequence*/
042    CERT_GENERATION_REQUEST_SEQUENCE_STATE,
043
044    /** the target Dn*/
045    TARGETDN_STATE,
046
047    /** the issuer Dn*/
048    ISSUER_STATE,
049
050    /** the subject Dn*/
051    SUBJECT_STATE,
052
053    /** the key algorithm*/
054    KEY_ALGORITHM_STATE,
055
056    /** terminal state */
057    LAST_CERT_GENERATION_STATE;
058
059    /**
060     * Get the grammar name
061     * 
062     * @param grammar The grammar class
063     * @return The grammar name
064     */
065    public String getGrammarName( Grammar<CertGenerationContainer> grammar )
066    {
067        return "CERT_GENERATION_GRAMMER";
068    }
069
070    
071    /**
072     * Get the grammar name
073     * 
074     * @param grammar The grammar code
075     * @return The grammar name
076     */
077    public String getGrammarName( int grammar )
078    {
079        return "CERT_GENERATION_GRAMMER";
080    }
081
082    
083    /**
084     * Get the string representing the state
085     * 
086     * @param state The state number
087     * @return The String representing the state
088     */
089    public String getState( int state )
090    {
091        return ( ( state == END_STATE.ordinal() ) ? "CERT_GENERATION_END_STATE" : this.name() );
092    }
093
094    
095    /**
096     * {@inheritDoc}
097     */
098    public boolean isEndState()
099    {
100        return this == END_STATE;
101    }
102    
103    
104    /**
105     * {@inheritDoc}
106     */
107    public CertGenerationStatesEnum getStartState()
108    {
109        return START_STATE;
110    }
111}