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 * http://www.opensource.org/licenses/cddl1.php.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file. If applicable, add the following below this CDDL HEADER,
016 * with the fields enclosed by brackets "[]" replaced with your own
017 * identifying information:
018 *      Portions Copyright [yyyy] [name of copyright owner]
019 *
020 * CDDL HEADER END
021 *
022 *
023 *      Portions Copyright 2007-2020 Ping Identity Corporation
024 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
025 */
026package com.unboundid.directory.sdk.ds.types;
027
028
029
030import com.unboundid.util.ThreadSafety;
031import com.unboundid.util.ThreadSafetyLevel;
032import com.unboundid.util.StaticUtils;
033
034
035
036/**
037 * This class implements an enumeration that holds the possible event types that
038 * can trigger an account status notification.
039 */
040@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
041public enum AccountStatusNotificationType
042{
043  /**
044   * Indicates that an account has been temporarily locked as a result of too
045   * many failed authentication attempts.  The account will remain locked until
046   * the lockout period expires or until it is manually unlocked by an
047   * administrator (e.g., by a password reset).
048   */
049  ACCOUNT_TEMPORARILY_LOCKED("account-temporarily-locked"),
050
051
052
053  /**
054   * Indicates that an account has been permanently locked as a result of too
055   * many failed authentication attempts.  The account will remain locked until
056   * it is manually unlocked by an administrator (e.g., by a password reset).
057   */
058  ACCOUNT_PERMANENTLY_LOCKED("account-permanently-locked"),
059
060
061
062  /**
063   * Indicates that a failure-locked, idle-locked, or reset-locked account has
064   * been unlocked by an administrator (e.g., by a password reset).
065   */
066  ACCOUNT_UNLOCKED("account-unlocked"),
067
068
069
070  /**
071   * Indicates than an authentication attempt failed because too much time had
072   * elapsed since the account last successfully authenticated.
073   */
074  ACCOUNT_IDLE_LOCKED("account-idle-locked"),
075
076
077
078  /**
079   * Indicates than an authentication attempt failed because the user was
080   * required to change their password after an administrative password reset,
081   * but that they did not do so within the required interval.
082   */
083  ACCOUNT_RESET_LOCKED("account-reset-locked"),
084
085
086
087  /**
088   * Indicates that an account has been disabled by an administrator.
089   */
090  ACCOUNT_DISABLED("account-disabled"),
091
092
093
094  /**
095   * Indicates that an account has been enabled by an administrator.
096   */
097  ACCOUNT_ENABLED("account-enabled"),
098
099
100
101  /**
102   * Indicates than an authentication attempt failed because the account has an
103   * activation time that is in the future.
104   */
105  ACCOUNT_NOT_YET_ACTIVE("account-not-yet-active"),
106
107
108
109  /**
110   * Indicates than an authentication attempt failed because the account has an
111   * expiration time that is in the past.
112   */
113  ACCOUNT_EXPIRED("account-expired"),
114
115
116
117  /**
118   * Indicates than an authentication attempt failed because the account has an
119   * expired password.
120   */
121  PASSWORD_EXPIRED("password-expired"),
122
123
124
125  /**
126   * Indicates that an authentication attempt succeeded, but that the password
127   * will expire in the near future.  This notification will only be generated
128   * the first time that an expiration warning is generated for a password.
129   */
130  PASSWORD_EXPIRING("password-expiring"),
131
132
133
134  /**
135   * Indicates that a user's password has been reset by an administrator.
136   */
137  PASSWORD_RESET("password-reset"),
138
139
140
141  /**
142   * Indicates that a user has changed their own password.
143   */
144  PASSWORD_CHANGED("password-changed"),
145
146
147
148  /**
149   * Indicates that an account has been created with an add request that
150   * matches a defined set of criteria.
151   */
152  ACCOUNT_CREATED("account-created"),
153
154
155
156  /**
157   * Indicates that an account has been updated with a modify or modify DN
158   * request that matches a defined set of criteria.
159   */
160  ACCOUNT_UPDATED("account-updated"),
161
162
163
164  /**
165   * Indicates that a bind attempt failed because it used a password that did
166   * not satisfy all of the configured password validators.
167   */
168  BIND_PASSWORD_FAILED_VALIDATION("bind-password-failed-validation");
169
170
171
172  // The notification type name.
173  private final String name;
174
175
176
177  /**
178   * Creates a new account status notification type with the provided
179   * name.
180   *
181   * @param  name  The name for this account status notification type.
182   */
183  AccountStatusNotificationType(final String name)
184  {
185    this.name = name;
186  }
187
188
189
190  /**
191   * Retrieves the account status notification type with the specified
192   * name.
193   *
194   * @param  name  The name for the account status notification type
195   *               to retrieve.
196   *
197   * @return  The requested account status notification type, or
198   *          <CODE>null</CODE> if there is no type with the given
199   *          name.
200   */
201  public static AccountStatusNotificationType typeForName(final String name)
202  {
203    final String lowerName = StaticUtils.toLowerCase(name);
204    if (lowerName.equals("account-temporarily-locked"))
205    {
206      return ACCOUNT_TEMPORARILY_LOCKED;
207    }
208    else if (lowerName.equals("account-permanently-locked"))
209    {
210      return ACCOUNT_PERMANENTLY_LOCKED;
211    }
212    else if (lowerName.equals("account-unlocked"))
213    {
214      return ACCOUNT_UNLOCKED;
215    }
216    else if (lowerName.equals("account-idle-locked"))
217    {
218      return ACCOUNT_IDLE_LOCKED;
219    }
220    else if (lowerName.equals("account-reset-locked"))
221    {
222      return ACCOUNT_RESET_LOCKED;
223    }
224    else if (lowerName.equals("account-disabled"))
225    {
226      return ACCOUNT_DISABLED;
227    }
228    else if (lowerName.equals("account-enabled"))
229    {
230      return ACCOUNT_ENABLED;
231    }
232    else if (lowerName.equals("account-not-yet-active"))
233    {
234      return ACCOUNT_NOT_YET_ACTIVE;
235    }
236    else if (lowerName.equals("account-expired"))
237    {
238      return ACCOUNT_EXPIRED;
239    }
240    else if (lowerName.equals("password-expired"))
241    {
242      return PASSWORD_EXPIRED;
243    }
244    else if (lowerName.equals("password-expiring"))
245    {
246      return PASSWORD_EXPIRING;
247    }
248    else if (lowerName.equals("password-reset"))
249    {
250      return PASSWORD_RESET;
251    }
252    else if (lowerName.equals("password-changed"))
253    {
254      return PASSWORD_CHANGED;
255    }
256    else if (lowerName.equals("account-created"))
257    {
258      return ACCOUNT_CREATED;
259    }
260    else if (lowerName.equals("account-updated"))
261    {
262      return ACCOUNT_UPDATED;
263    }
264    else if (lowerName.equals("bind-password-failed-validation"))
265    {
266      return BIND_PASSWORD_FAILED_VALIDATION;
267    }
268    else
269    {
270      return null;
271    }
272  }
273
274
275
276  /**
277   * Retrieves the name for this account status notification type.
278   *
279   * @return  The name for this account status notification type.
280   */
281  public String getName()
282  {
283    return name;
284  }
285
286
287
288  /**
289   * Retrieves a string representation of this account status
290   * notification type.
291   *
292   * @return  A string representation of this account status
293   *          notification type.
294   */
295  public String toString()
296  {
297    return name;
298  }
299}
300