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