001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/ds/resource/legal-notices/cddl.txt 011 * or http://www.opensource.org/licenses/cddl1.php. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/ds/resource/legal-notices/cddl.txt. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Portions Copyright 2007-2016 UnboundID Corp. 026 * Portions Copyright 2006-2008 Sun Microsystems, Inc. 027 */ 028package com.unboundid.directory.sdk.ds.types; 029 030 031 032import com.unboundid.util.ThreadSafety; 033import com.unboundid.util.ThreadSafetyLevel; 034import com.unboundid.util.StaticUtils; 035 036 037 038/** 039 * This class implements an enumeration that holds the possible event types that 040 * can trigger an account status notification. 041 */ 042@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 043public enum AccountStatusNotificationType 044{ 045 /** 046 * Indicates that an account status message should be generated whenever a 047 * user account has been temporarily locked after too many failed attempts. 048 */ 049 ACCOUNT_TEMPORARILY_LOCKED("account-temporarily-locked"), 050 051 052 053 /** 054 * Indicates that an account status message should be generated whenever a 055 * user account has been permanently locked (requiring an administrative 056 * password reset) after too many failed attempts. 057 */ 058 ACCOUNT_PERMANENTLY_LOCKED("account-permanently-locked"), 059 060 061 062 /** 063 * Indicates that an account status message should be generated whenever a 064 * user account has been unlocked by an administrator. 065 */ 066 ACCOUNT_UNLOCKED("account-unlocked"), 067 068 069 070 /** 071 * Indicates that an account status message should be generated whenever a 072 * user account has been locked because it was idle for too long. 073 */ 074 ACCOUNT_IDLE_LOCKED("account-idle-locked"), 075 076 077 078 /** 079 * Indicates that an account status message should be generated whenever a 080 * user account has been locked because it the password had been reset by an 081 * administrator but not changed by the user within the required interval. 082 */ 083 ACCOUNT_RESET_LOCKED("account-reset-locked"), 084 085 086 087 /** 088 * Indicates that an account status message should be generated whenever a 089 * user account has been disabled by an administrator. 090 */ 091 ACCOUNT_DISABLED("account-disabled"), 092 093 094 095 /** 096 * Indicates that an account status message should be generated whenever a 097 * user account has been enabled by an administrator. 098 */ 099 ACCOUNT_ENABLED("account-enabled"), 100 101 102 103 /** 104 * Indicates that an account status message should be generated whenever a 105 * user authentication has failed because the account activation time is still 106 * in the future. 107 */ 108 ACCOUNT_NOT_YET_ACTIVE("account-not-yet-active"), 109 110 111 112 /** 113 * Indicates that an account status message should be generated whenever a 114 * user authentication has failed because the account has expired. 115 */ 116 ACCOUNT_EXPIRED("account-expired"), 117 118 119 120 /** 121 * Indicates that an account status notification message should be generated 122 * whenever a user authentication has failed because the password has expired. 123 */ 124 PASSWORD_EXPIRED("password-expired"), 125 126 127 128 129 /** 130 * Indicates that an account status notification message should be generated 131 * the first time that a password expiration warning is encountered for a user 132 * password. 133 */ 134 PASSWORD_EXPIRING("password-expiring"), 135 136 137 138 /** 139 * Indicates that an account status notification message should be generated 140 * whenever a user's password is reset by an administrator. 141 */ 142 PASSWORD_RESET("password-reset"), 143 144 145 146 /** 147 * Indicates whether an account status notification message should be 148 * generated whenever a user changes his/her own password. 149 */ 150 PASSWORD_CHANGED("password-changed"); 151 152 153 154 // The notification type name. 155 private final String name; 156 157 158 159 /** 160 * Creates a new account status notification type with the provided 161 * name. 162 * 163 * @param name The name for this account status notification type. 164 */ 165 private AccountStatusNotificationType(final String name) 166 { 167 this.name = name; 168 } 169 170 171 172 /** 173 * Retrieves the account status notification type with the specified 174 * name. 175 * 176 * @param name The name for the account status notification type 177 * to retrieve. 178 * 179 * @return The requested account status notification type, or 180 * <CODE>null</CODE> if there is no type with the given 181 * name. 182 */ 183 public static AccountStatusNotificationType typeForName(final String name) 184 { 185 final String lowerName = StaticUtils.toLowerCase(name); 186 if (lowerName.equals("account-temporarily-locked")) 187 { 188 return ACCOUNT_TEMPORARILY_LOCKED; 189 } 190 else if (lowerName.equals("account-permanently-locked")) 191 { 192 return ACCOUNT_PERMANENTLY_LOCKED; 193 } 194 else if (lowerName.equals("account-unlocked")) 195 { 196 return ACCOUNT_UNLOCKED; 197 } 198 else if (lowerName.equals("account-idle-locked")) 199 { 200 return ACCOUNT_IDLE_LOCKED; 201 } 202 else if (lowerName.equals("account-reset-locked")) 203 { 204 return ACCOUNT_RESET_LOCKED; 205 } 206 else if (lowerName.equals("account-disabled")) 207 { 208 return ACCOUNT_DISABLED; 209 } 210 else if (lowerName.equals("account-enabled")) 211 { 212 return ACCOUNT_ENABLED; 213 } 214 else if (lowerName.equals("account-not-yet-active")) 215 { 216 return ACCOUNT_NOT_YET_ACTIVE; 217 } 218 else if (lowerName.equals("account-expired")) 219 { 220 return ACCOUNT_EXPIRED; 221 } 222 else if (lowerName.equals("password-expired")) 223 { 224 return PASSWORD_EXPIRED; 225 } 226 else if (lowerName.equals("password-expiring")) 227 { 228 return PASSWORD_EXPIRING; 229 } 230 else if (lowerName.equals("password-reset")) 231 { 232 return PASSWORD_RESET; 233 } 234 else if (lowerName.equals("password-changed")) 235 { 236 return PASSWORD_CHANGED; 237 } 238 else 239 { 240 return null; 241 } 242 } 243 244 245 246 /** 247 * Retrieves the name for this account status notification type. 248 * 249 * @return The name for this account status notification type. 250 */ 251 public String getName() 252 { 253 return name; 254 } 255 256 257 258 /** 259 * Retrieves a string representation of this account status 260 * notification type. 261 * 262 * @return A string representation of this account status 263 * notification type. 264 */ 265 public String toString() 266 { 267 return name; 268 } 269} 270