001/* 002 * Copyright 2007-2017 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2007-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.experimental; 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-10. 033 */ 034@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 035public enum DraftBeheraLDAPPasswordPolicy10ErrorType 036{ 037 /** 038 * The error type that indicates the user's password is expired. 039 */ 040 PASSWORD_EXPIRED("password expired", 0), 041 042 043 044 /** 045 * The error type that indicates the user's account is locked or disabled. 046 */ 047 ACCOUNT_LOCKED("account locked", 1), 048 049 050 051 /** 052 * The error type that indicates the user's password must be changed before 053 * any other operation will be allowed. 054 */ 055 CHANGE_AFTER_RESET("change after reset", 2), 056 057 058 059 /** 060 * The error type that indicates that user password changes aren't allowed. 061 */ 062 PASSWORD_MOD_NOT_ALLOWED("password mod not allowed", 3), 063 064 065 066 /** 067 * The error type that indicates the user must provide the current password 068 * when attempting to set a new one. 069 */ 070 MUST_SUPPLY_OLD_PASSWORD("must supply old password", 4), 071 072 073 074 /** 075 * The error type that indicates the proposed password is too weak to be 076 * acceptable. 077 */ 078 INSUFFICIENT_PASSWORD_QUALITY("insufficient password quality", 5), 079 080 081 082 /** 083 * The error type that indicates the proposed password is too short. 084 */ 085 PASSWORD_TOO_SHORT("password too short", 6), 086 087 088 089 /** 090 * The error type that indicates the user's password cannot be changed because 091 * it has not been long enough since it was last changed. 092 */ 093 PASSWORD_TOO_YOUNG("password too young", 7), 094 095 096 097 /** 098 * The error type that indicates the proposed password is already in the 099 * password history. 100 */ 101 PASSWORD_IN_HISTORY("password in history", 8); 102 103 104 105 // The numeric value associated with this password policy error type. 106 private final int value; 107 108 // The human-readable name for this password policy error type. 109 private final String name; 110 111 112 113 /** 114 * Creates a new password policy error type with the provided information. 115 * 116 * @param name The human-readable name for this error type. 117 * @param value The numeric value associated with this error type. 118 */ 119 DraftBeheraLDAPPasswordPolicy10ErrorType(final String name, final int value) 120 { 121 this.name = name; 122 this.value = value; 123 } 124 125 126 127 /** 128 * Retrieves the human-readable name for this password policy error type. 129 * 130 * @return The human-readable name for this password policy error type. 131 */ 132 public String getName() 133 { 134 return name; 135 } 136 137 138 139 /** 140 * Retrieves the integer value for this password policy error type. 141 * 142 * @return The integer value for this password policy error type. 143 */ 144 public int intValue() 145 { 146 return value; 147 } 148 149 150 151 /** 152 * Retrieves the password policy error type with the specified int value. 153 * 154 * @param intValue The numeric value associated with the error type. 155 * 156 * @return The associated error type, or {@code null} if there is no 157 * password policy error type with the specified set of values. 158 */ 159 public static DraftBeheraLDAPPasswordPolicy10ErrorType 160 valueOf(final int intValue) 161 { 162 switch (intValue) 163 { 164 case 0: 165 return PASSWORD_EXPIRED; 166 167 case 1: 168 return ACCOUNT_LOCKED; 169 170 case 2: 171 return CHANGE_AFTER_RESET; 172 173 case 3: 174 return PASSWORD_MOD_NOT_ALLOWED; 175 176 case 4: 177 return MUST_SUPPLY_OLD_PASSWORD; 178 179 case 5: 180 return INSUFFICIENT_PASSWORD_QUALITY; 181 182 case 6: 183 return PASSWORD_TOO_SHORT; 184 185 case 7: 186 return PASSWORD_TOO_YOUNG; 187 188 case 8: 189 return PASSWORD_IN_HISTORY; 190 191 default: 192 return null; 193 } 194 } 195 196 197 198 /** 199 * Retrieves a string representation for this password policy error type. 200 * 201 * @return A string representation for this password policy error type. 202 */ 203 @Override() 204 public String toString() 205 { 206 return name; 207 } 208}