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 /** The password has expired */
32 PASSWORD_EXPIRED(0),
33
34 /** The account is locked */
35 ACCOUNT_LOCKED(1),
36
37 /** */
38 CHANGE_AFTER_RESET(2),
39
40 /** the password modification is not allowed */
41 PASSWORD_MOD_NOT_ALLOWED(3),
42
43 /** The ld password must be supplied */
44 MUST_SUPPLY_OLD_PASSWORD(4),
45
46 /** The password quality is not sufficient */
47 INSUFFICIENT_PASSWORD_QUALITY(5),
48
49 /** The password is too short */
50 PASSWORD_TOO_SHORT(6),
51
52 /** The password has been changed too recently to be used */
53 PASSWORD_TOO_YOUNG(7),
54
55 /** The password is in history */
56 PASSWORD_IN_HISTORY(8);
57
58 private int value;
59
60
61 PasswordPolicyErrorEnum( int value )
62 {
63 this.value = value;
64 }
65
66
67 /**
68 * Get the PasswordPolicyErrorEnum gien its numeric value
69 *
70 * @param val The numeric value to retrieve
71 * @return The associated PasswordPolicyErrorEnum
72 */
73 public static PasswordPolicyErrorEnum get( int val )
74 {
75 switch ( val )
76 {
77 case 0:
78 return PASSWORD_EXPIRED;
79
80 case 1:
81 return ACCOUNT_LOCKED;
82
83 case 2:
84 return CHANGE_AFTER_RESET;
85
86 case 3:
87 return PASSWORD_MOD_NOT_ALLOWED;
88
89 case 4:
90 return MUST_SUPPLY_OLD_PASSWORD;
91
92 case 5:
93 return INSUFFICIENT_PASSWORD_QUALITY;
94
95 case 6:
96 return PASSWORD_TOO_SHORT;
97
98 case 7:
99 return PASSWORD_TOO_YOUNG;
100
101 case 8:
102 return PASSWORD_IN_HISTORY;
103
104 default:
105
106 throw new IllegalArgumentException( "unknown password policy error value " + val );
107 }
108 }
109
110
111 /**
112 * @return the PasswordPolicyError interned value
113 */
114 public int getValue()
115 {
116 return value;
117 }
118 }