View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  
21  package org.apache.directory.server.core.api.authn.ppolicy;
22  
23  
24  /**
25   * The 3 possible values for the password check quality : <br>
26   * <ul>
27   * <li>NO_CHECK (0) : No check will be done</li>
28   * <li>CHECK_ACCEPT (1) : Check the password and accept hashed passwords</li>
29   * <li>CHECK_REJECT (2) : Check the password but reject hashed passwords</li>
30   * </ul>
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public enum CheckQualityEnum
34  {
35      /** Don't check the password */
36      NO_CHECK(0),
37  
38      /** Check the password and accept passwords that can't be checked (hashed passwords) */
39      CHECK_ACCEPT(1),
40  
41      /** Check the password but reject passwords that can't be checked (hashed passwords) */
42      CHECK_REJECT(2),
43  
44      /** An unknown value */
45      UNKNOW(-1);
46  
47      /** The stored value */
48      private int value;
49  
50  
51      /**
52       * Create a new instance of this enum
53       */
54      CheckQualityEnum( int value )
55      {
56          this.value = value;
57      }
58  
59  
60      /**
61       * @return The internal value
62       */
63      public int getValue()
64      {
65          return value;
66      }
67  
68  
69      /**
70       * Get back the CheckQualityEnum instance associated with a given value
71       * 
72       * @param value The value we are looking for
73       * @return The associated CheckQualityEnum
74       */
75      public static CheckQualityEnum getCheckQuality( int value )
76      {
77          switch ( value )
78          {
79              case 0:
80                  return NO_CHECK;
81  
82              case 1:
83                  return CHECK_ACCEPT;
84  
85              case 2:
86                  return CHECK_REJECT;
87  
88              default:
89                  return UNKNOW;
90          }
91      }
92  }