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-2021 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  /**
173   * Indicates that a user successfully authenticated, but their account is in a
174   * "must change password" state, and the user must choose a new password
175   * before being allowed to perform any other type of operation.
176   */
177  MUST_CHANGE_PASSWORD("must-change-password");
178
179
180
181  // The notification type name.
182  private final String name;
183
184
185
186  /**
187   * Creates a new account status notification type with the provided
188   * name.
189   *
190   * @param  name  The name for this account status notification type.
191   */
192  AccountStatusNotificationType(final String name)
193  {
194    this.name = name;
195  }
196
197
198
199  /**
200   * Retrieves the account status notification type with the specified
201   * name.
202   *
203   * @param  name  The name for the account status notification type
204   *               to retrieve.
205   *
206   * @return  The requested account status notification type, or
207   *          <CODE>null</CODE> if there is no type with the given
208   *          name.
209   */
210  public static AccountStatusNotificationType typeForName(final String name)
211  {
212    final String lowerName = StaticUtils.toLowerCase(name);
213    switch (lowerName)
214    {
215      case "account-temporarily-locked":
216        return ACCOUNT_TEMPORARILY_LOCKED;
217      case "account-permanently-locked":
218        return ACCOUNT_PERMANENTLY_LOCKED;
219      case "account-unlocked":
220        return ACCOUNT_UNLOCKED;
221      case "account-idle-locked":
222        return ACCOUNT_IDLE_LOCKED;
223      case "account-reset-locked":
224        return ACCOUNT_RESET_LOCKED;
225      case "account-disabled":
226        return ACCOUNT_DISABLED;
227      case "account-enabled":
228        return ACCOUNT_ENABLED;
229      case "account-not-yet-active":
230        return ACCOUNT_NOT_YET_ACTIVE;
231      case "account-expired":
232        return ACCOUNT_EXPIRED;
233      case "password-expired":
234        return PASSWORD_EXPIRED;
235      case "password-expiring":
236        return PASSWORD_EXPIRING;
237      case "password-reset":
238        return PASSWORD_RESET;
239      case "password-changed":
240        return PASSWORD_CHANGED;
241      case "account-created":
242        return ACCOUNT_CREATED;
243      case "account-updated":
244        return ACCOUNT_UPDATED;
245      case "bind-password-failed-validation":
246        return BIND_PASSWORD_FAILED_VALIDATION;
247      case "must-change-password":
248        return MUST_CHANGE_PASSWORD;
249      default:
250        return null;
251    }
252  }
253
254
255
256  /**
257   * Retrieves the name for this account status notification type.
258   *
259   * @return  The name for this account status notification type.
260   */
261  public String getName()
262  {
263    return name;
264  }
265
266
267
268  /**
269   * Retrieves a string representation of this account status
270   * notification type.
271   *
272   * @return  A string representation of this account status
273   *          notification type.
274   */
275  @Override()
276  public String toString()
277  {
278    return name;
279  }
280}
281