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