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.api.ldap.extras.controls.ppolicy_impl;
022
023
024import org.apache.directory.api.asn1.ber.grammar.Grammar;
025import org.apache.directory.api.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    /**
065     * {@inheritDoc}
066     */
067    public String getGrammarName( int grammar )
068    {
069        return "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR";
070    }
071
072
073    /**
074     * {@inheritDoc}
075     */
076    public String getState( int state )
077    {
078        return ( ( state == END_STATE.ordinal() ) ? "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR" : name() );
079    }
080
081
082    /**
083     * {@inheritDoc}
084     */
085    public boolean isEndState()
086    {
087        return this == END_STATE;
088    }
089
090
091    /**
092     * {@inheritDoc}
093     */
094    public PasswordPolicyStates getStartState()
095    {
096        return START_STATE;
097    }
098}