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