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 */
020
021package org.apache.directory.shared.ldap.extras.controls.ppolicy;
022
023
024import org.apache.directory.shared.asn1.ber.grammar.Grammar;
025import org.apache.directory.shared.asn1.ber.grammar.States;
026
027
028/**
029 * various states used in {@link PasswordPolicyGrammar}.
030 *
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public enum PasswordPolicyStates implements States
034{
035
036    START_STATE,                            // 0
037
038    PPOLICY_SEQ_STATE,                      // 1
039    
040    PPOLICY_WARNING_TAG_STATE,              // 2
041
042    PPOLICY_TIME_BEFORE_EXPIRATION_STATE,   // 3
043
044    PPOLICY_GRACE_AUTHNS_REMAINING_STATE,   // 4
045
046    PPOLICY_ERROR_TAG_STATE,                // 5
047
048    END_STATE;                              // 6
049
050    /**
051     * {@inheritDoc}
052     */
053    public String getGrammarName( Grammar<?> grammar )
054    {
055        if( grammar instanceof PasswordPolicyGrammar )
056        {
057            return "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR";
058        }
059        
060        return "UNKNOWN_GRAMMAR";
061    }
062
063    /**
064     * {@inheritDoc}
065     */
066    public String getGrammarName( int grammar )
067    {
068        return "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR";
069    }
070
071
072    /**
073     * {@inheritDoc}
074     */
075    public String getState( int state )
076    {
077        return ( ( state == END_STATE.ordinal() ) ? "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR" : name() );
078    }
079
080
081    /**
082     * {@inheritDoc}
083     */
084    public boolean isEndState()
085    {
086        return this == END_STATE;
087    }
088    
089    
090    /**
091     * {@inheritDoc}
092     */
093    public PasswordPolicyStates getStartState()
094    {
095        return START_STATE;
096    }
097}