001/* 002 * Copyright 2007-2017 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2017 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025import com.unboundid.util.ThreadSafety; 026import com.unboundid.util.ThreadSafetyLevel; 027 028 029 030/** 031 * This enum defines a set of error types that may be included in the password 032 * policy response control as defined in draft-behera-ldap-password-policy. 033 * <BR> 034 * <BLOCKQUOTE> 035 * <B>NOTE:</B> This class, and other classes within the 036 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 037 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 038 * server products. These classes provide support for proprietary 039 * functionality or for external specifications that are not considered stable 040 * or mature enough to be guaranteed to work in an interoperable way with 041 * other types of LDAP servers. 042 * </BLOCKQUOTE> 043 */ 044@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 045public enum PasswordPolicyErrorType 046{ 047 /** 048 * The error type that indicates the user's password is expired. 049 */ 050 PASSWORD_EXPIRED("password expired", 0), 051 052 053 054 /** 055 * The error type that indicates the user's account is locked or disabled. 056 */ 057 ACCOUNT_LOCKED("account locked", 1), 058 059 060 061 /** 062 * The error type that indicates the user's password must be changed before 063 * any other operation will be allowed. 064 */ 065 CHANGE_AFTER_RESET("change after reset", 2), 066 067 068 069 /** 070 * The error type that indicates that user password changes aren't allowed. 071 */ 072 PASSWORD_MOD_NOT_ALLOWED("password mod not allowed", 3), 073 074 075 076 /** 077 * The error type that indicates the user must provide the current password 078 * when attempting to set a new one. 079 */ 080 MUST_SUPPLY_OLD_PASSWORD("must supply old password", 4), 081 082 083 084 /** 085 * The error type that indicates the proposed password is too weak to be 086 * acceptable. 087 */ 088 INSUFFICIENT_PASSWORD_QUALITY("insufficient password quality", 5), 089 090 091 092 /** 093 * The error type that indicates the proposed password is too short. 094 */ 095 PASSWORD_TOO_SHORT("password too short", 6), 096 097 098 099 /** 100 * The error type that indicates the user's password cannot be changed because 101 * it has not been long enough since it was last changed. 102 */ 103 PASSWORD_TOO_YOUNG("password too young", 7), 104 105 106 107 /** 108 * The error type that indicates the proposed password is already in the 109 * password history. 110 */ 111 PASSWORD_IN_HISTORY("password in history", 8); 112 113 114 115 // The numeric value associated with this password policy error type. 116 private final int value; 117 118 // The human-readable name for this password policy error type. 119 private final String name; 120 121 122 123 /** 124 * Creates a new password policy error type with the provided information. 125 * 126 * @param name The human-readable name for this error type. 127 * @param value The numeric value associated with this error type. 128 */ 129 PasswordPolicyErrorType(final String name, final int value) 130 { 131 this.name = name; 132 this.value = value; 133 } 134 135 136 137 /** 138 * Retrieves the human-readable name for this password policy error type. 139 * 140 * @return The human-readable name for this password policy error type. 141 */ 142 public String getName() 143 { 144 return name; 145 } 146 147 148 149 /** 150 * Retrieves the integer value for this password policy error type. 151 * 152 * @return The integer value for this password policy error type. 153 */ 154 public int intValue() 155 { 156 return value; 157 } 158 159 160 161 /** 162 * Retrieves the password policy error type with the specified int value. 163 * 164 * @param intValue The numeric value associated with the error type. 165 * 166 * @return The associated error type, or {@code null} if there is no 167 * password policy error type with the specified set of values. 168 */ 169 public static PasswordPolicyErrorType valueOf(final int intValue) 170 { 171 switch (intValue) 172 { 173 case 0: 174 return PASSWORD_EXPIRED; 175 176 case 1: 177 return ACCOUNT_LOCKED; 178 179 case 2: 180 return CHANGE_AFTER_RESET; 181 182 case 3: 183 return PASSWORD_MOD_NOT_ALLOWED; 184 185 case 4: 186 return MUST_SUPPLY_OLD_PASSWORD; 187 188 case 5: 189 return INSUFFICIENT_PASSWORD_QUALITY; 190 191 case 6: 192 return PASSWORD_TOO_SHORT; 193 194 case 7: 195 return PASSWORD_TOO_YOUNG; 196 197 case 8: 198 return PASSWORD_IN_HISTORY; 199 200 default: 201 return null; 202 } 203 } 204 205 206 207 /** 208 * Retrieves a string representation for this password policy error type. 209 * 210 * @return A string representation for this password policy error type. 211 */ 212 @Override() 213 public String toString() 214 { 215 return name; 216 } 217}