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;
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),
032    ACCOUNT_LOCKED(1),
033    CHANGE_AFTER_RESET(2),
034    PASSWORD_MOD_NOT_ALLOWED(3),
035    MUST_SUPPLY_OLD_PASSWORD(
036        4),
037    INSUFFICIENT_PASSWORD_QUALITY(5),
038    PASSWORD_TOO_SHORT(6),
039    PASSWORD_TOO_YOUNG(7),
040    PASSWORD_IN_HISTORY(8);
041
042    private int value;
043
044
045    private PasswordPolicyErrorEnum( int value )
046    {
047        this.value = value;
048    }
049
050
051    public static PasswordPolicyErrorEnum get( int val )
052    {
053        switch ( val )
054        {
055            case 0:
056                return PASSWORD_EXPIRED;
057
058            case 1:
059                return ACCOUNT_LOCKED;
060
061            case 2:
062                return CHANGE_AFTER_RESET;
063
064            case 3:
065                return PASSWORD_MOD_NOT_ALLOWED;
066
067            case 4:
068                return MUST_SUPPLY_OLD_PASSWORD;
069
070            case 5:
071                return INSUFFICIENT_PASSWORD_QUALITY;
072
073            case 6:
074                return PASSWORD_TOO_SHORT;
075
076            case 7:
077                return PASSWORD_TOO_YOUNG;
078
079            case 8:
080                return PASSWORD_IN_HISTORY;
081
082            default:
083
084                throw new IllegalArgumentException( "unknown password policy error value " + val );
085        }
086    }
087
088
089    public int getValue()
090    {
091        return value;
092    }
093
094}