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
024/**
025 *  constants representing PasswordPolicyErrorS as stated in the <a href="http://tools.ietf.org/html/draft-behera-ldap-password-policy-10">draft</a>
026 *
027 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
028 */
029public enum PasswordPolicyErrorEnum
030{
031    PASSWORD_EXPIRED(0), ACCOUNT_LOCKED(1), CHANGE_AFTER_RESET(2), PASSWORD_MOD_NOT_ALLOWED(3), MUST_SUPPLY_OLD_PASSWORD(
032        4), INSUFFICIENT_PASSWORD_QUALITY(5), PASSWORD_TOO_SHORT(6), PASSWORD_TOO_YOUNG(7), PASSWORD_IN_HISTORY(8);
033
034    private int value;
035
036
037    private PasswordPolicyErrorEnum( int value )
038    {
039        this.value = value;
040    }
041
042
043    public static PasswordPolicyErrorEnum get( int val )
044    {
045        switch ( val )
046        {
047            case 0:
048                return PASSWORD_EXPIRED;
049
050            case 1:
051                return ACCOUNT_LOCKED;
052
053            case 2:
054                return CHANGE_AFTER_RESET;
055
056            case 3:
057                return PASSWORD_MOD_NOT_ALLOWED;
058
059            case 4:
060                return MUST_SUPPLY_OLD_PASSWORD;
061
062            case 5:
063                return INSUFFICIENT_PASSWORD_QUALITY;
064
065            case 6:
066                return PASSWORD_TOO_SHORT;
067
068            case 7:
069                return PASSWORD_TOO_YOUNG;
070
071            case 8:
072                return PASSWORD_IN_HISTORY;
073
074            default:
075
076                throw new IllegalArgumentException( "unknown password policy error value " + val );
077        }
078    }
079
080
081    public int getValue()
082    {
083        return value;
084    }
085
086}