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.server.core.api.authn.ppolicy;
022
023
024/**
025 * The 3 possible values for the password check quality : <br>
026 * <ul>
027 * <li>NO_CHECK (0) : No check will be done</li>
028 * <li>CHECK_ACCEPT (1) : Check the password and accept hashed passwords</li>
029 * <li>CHECK_REJECT (2) : Check the password but reject hashed passwords</li>
030 * </ul>
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public enum CheckQualityEnum
034{
035    /** Don't check the password */
036    NO_CHECK(0),
037
038    /** Check the password and accept passwords that can't be checked (hashed passwords) */
039    CHECK_ACCEPT(1),
040
041    /** Check the password but reject passwords that can't be checked (hashed passwords) */
042    CHECK_REJECT(2),
043
044    /** An unknown value */
045    UNKNOW(-1);
046
047    /** The stored value */
048    private int value;
049
050
051    /**
052     * Create a new instance of this enum
053     */
054    CheckQualityEnum( int value )
055    {
056        this.value = value;
057    }
058
059
060    /**
061     * @return The internal value
062     */
063    public int getValue()
064    {
065        return value;
066    }
067
068
069    /**
070     * Get back the CheckQualityEnum instance associated with a given value
071     * 
072     * @param value The value we are looking for
073     * @return The associated CheckQualityEnum
074     */
075    public static CheckQualityEnum getCheckQuality( int value )
076    {
077        switch ( value )
078        {
079            case 0:
080                return NO_CHECK;
081
082            case 1:
083                return CHECK_ACCEPT;
084
085            case 2:
086                return CHECK_REJECT;
087
088            default:
089                return UNKNOW;
090        }
091    }
092}