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.api.ldap.extras.controls.ppolicy;
22  
23  
24  /**
25   *  constants representing PasswordPolicyErrorS as stated in the <a href="http://tools.ietf.org/html/draft-behera-ldap-password-policy-10">draft</a>
26   *
27   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28   */
29  public enum PasswordPolicyErrorEnum
30  {
31      PASSWORD_EXPIRED(0),
32      ACCOUNT_LOCKED(1),
33      CHANGE_AFTER_RESET(2),
34      PASSWORD_MOD_NOT_ALLOWED(3),
35      MUST_SUPPLY_OLD_PASSWORD(
36          4),
37      INSUFFICIENT_PASSWORD_QUALITY(5),
38      PASSWORD_TOO_SHORT(6),
39      PASSWORD_TOO_YOUNG(7),
40      PASSWORD_IN_HISTORY(8);
41  
42      private int value;
43  
44  
45      private PasswordPolicyErrorEnum( int value )
46      {
47          this.value = value;
48      }
49  
50  
51      public static PasswordPolicyErrorEnum get( int val )
52      {
53          switch ( val )
54          {
55              case 0:
56                  return PASSWORD_EXPIRED;
57  
58              case 1:
59                  return ACCOUNT_LOCKED;
60  
61              case 2:
62                  return CHANGE_AFTER_RESET;
63  
64              case 3:
65                  return PASSWORD_MOD_NOT_ALLOWED;
66  
67              case 4:
68                  return MUST_SUPPLY_OLD_PASSWORD;
69  
70              case 5:
71                  return INSUFFICIENT_PASSWORD_QUALITY;
72  
73              case 6:
74                  return PASSWORD_TOO_SHORT;
75  
76              case 7:
77                  return PASSWORD_TOO_YOUNG;
78  
79              case 8:
80                  return PASSWORD_IN_HISTORY;
81  
82              default:
83  
84                  throw new IllegalArgumentException( "unknown password policy error value " + val );
85          }
86      }
87  
88  
89      public int getValue()
90      {
91          return value;
92      }
93  
94  }