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 legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
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 and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2014-2015 ForgeRock AS
026 */
027package org.opends.server.types;
028
029import static org.opends.server.util.StaticUtils.*;
030
031
032
033/**
034 * This class implements an enumeration that holds the possible event
035 * types that can trigger an account status notification.
036 */
037@org.opends.server.types.PublicAPI(
038     stability=org.opends.server.types.StabilityLevel.VOLATILE,
039     mayInstantiate=false,
040     mayExtend=false,
041     mayInvoke=true)
042public enum AccountStatusNotificationType
043{
044  /**
045   * Indicates that an account status message should be generated
046   * whenever a user account has been temporarily locked after too
047   * 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
055   * whenever a user account has been permanently locked after too
056   * many failed attempts.
057   */
058  ACCOUNT_PERMANENTLY_LOCKED(
059       "account-permanently-locked"),
060
061
062
063  /**
064   * Indicates that an account status message should be generated
065   * whenever a user account has been unlocked by an administrator.
066   */
067  ACCOUNT_UNLOCKED("account-unlocked"),
068
069
070
071  /**
072   * Indicates that an account status message should be generated
073   * whenever a user account has been locked because it was idle for
074   * too long.
075   */
076  ACCOUNT_IDLE_LOCKED("account-idle-locked"),
077
078
079
080  /**
081   * Indicates that an account status message should be generated
082   * whenever a user account has been locked because it the password
083   * had been reset by an administrator but not changed by the user
084   * within the required interval.
085   */
086  ACCOUNT_RESET_LOCKED("account-reset-locked"),
087
088
089
090  /**
091   * Indicates that an account status message should be generated
092   * whenever a user account has been disabled by an administrator.
093   */
094  ACCOUNT_DISABLED("account-disabled"),
095
096
097
098  /**
099   * Indicates that an account status message should be generated
100   * whenever a user account has been enabled by an administrator.
101   */
102  ACCOUNT_ENABLED("account-enabled"),
103
104
105
106  /**
107   * Indicates that an account status message should be generated
108   * whenever a user authentication has failed because the account
109   * has expired.
110   */
111  ACCOUNT_EXPIRED("account-expired"),
112
113
114
115  /**
116   * Indicates that an account status notification message should be
117   * generated whenever a user authentication has failed because the
118   * password has expired.
119   */
120  PASSWORD_EXPIRED("password-expired"),
121
122
123
124
125  /**
126   * Indicates that an account status notification message should be
127   * generated the first time that a password expiration warning is
128   * encountered for a user password.
129   */
130  PASSWORD_EXPIRING("password-expiring"),
131
132
133
134  /**
135   * Indicates that an account status notification message should be
136   * generated whenever a user's password is reset by an
137   * administrator.
138   */
139  PASSWORD_RESET("password-reset"),
140
141
142
143  /**
144   * Indicates whether an account status notification message should
145   * be generated whenever a user changes his/her own password.
146   */
147  PASSWORD_CHANGED("password-changed");
148
149
150
151  /** The notification type name. */
152  private String name;
153
154
155
156  /**
157   * Creates a new account status notification type with the provided
158   * name.
159   *
160   * @param  name  The name for this account status notification type.
161   */
162  private AccountStatusNotificationType(String name)
163  {
164    this.name = name;
165  }
166
167
168
169  /**
170   * Retrieves the account status notification type with the specified
171   * name.
172   *
173   * @param  name  The name for the account status notification type
174   *               to retrieve.
175   *
176   * @return  The requested account status notification type, or
177   *          <CODE>null</CODE> if there is no type with the given
178   *          name.
179   */
180  public static AccountStatusNotificationType typeForName(String name)
181  {
182    String lowerName = toLowerCase(name);
183    if (lowerName.equals("account-temporarily-locked"))
184    {
185      return ACCOUNT_TEMPORARILY_LOCKED;
186    }
187    else if (lowerName.equals("account-permanently-locked"))
188    {
189      return ACCOUNT_PERMANENTLY_LOCKED;
190    }
191    else if (lowerName.equals("account-unlocked"))
192    {
193      return ACCOUNT_UNLOCKED;
194    }
195    else if (lowerName.equals("account-idle-locked"))
196    {
197      return ACCOUNT_IDLE_LOCKED;
198    }
199    else if (lowerName.equals("account-reset-locked"))
200    {
201      return ACCOUNT_RESET_LOCKED;
202    }
203    else if (lowerName.equals("account-disabled"))
204    {
205      return ACCOUNT_DISABLED;
206    }
207    else if (lowerName.equals("account-enabled"))
208    {
209      return ACCOUNT_ENABLED;
210    }
211    else if (lowerName.equals("account-expired"))
212    {
213      return ACCOUNT_EXPIRED;
214    }
215    else if (lowerName.equals("password-expired"))
216    {
217      return PASSWORD_EXPIRED;
218    }
219    else if (lowerName.equals("password-expiring"))
220    {
221      return PASSWORD_EXPIRING;
222    }
223    else if (lowerName.equals("password-reset"))
224    {
225      return PASSWORD_RESET;
226    }
227    else if (lowerName.equals("password-changed"))
228    {
229      return PASSWORD_CHANGED;
230    }
231    else
232    {
233      return null;
234    }
235  }
236
237
238
239  /**
240   * Retrieves the name for this account status notification type.
241   *
242   * @return  The name for this account status notification type.
243   */
244  public String getName()
245  {
246    return name;
247  }
248
249
250
251  /**
252   * Retrieves a string representation of this account status
253   * notification type.
254   *
255   * @return  A string representation of this account status
256   *          notification type.
257   */
258  public String toString()
259  {
260    return name;
261  }
262}
263