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 2008-2018 Ping Identity Corporation
024 *      Portions Copyright 2008 Sun Microsystems, Inc.
025 */
026package com.unboundid.directory.sdk.ds.types;
027
028
029
030import com.unboundid.util.StaticUtils;
031import com.unboundid.util.ThreadSafety;
032import com.unboundid.util.ThreadSafetyLevel;
033
034
035
036/**
037 * This class implements an enumeration that holds the possible set of
038 * additional properties that can be included in an account status notification.
039 */
040@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
041public enum AccountStatusNotificationProperty
042{
043  /**
044   * The property whose value will be the string representation of the DN of the
045   * password policy for the target user.  This will be available for all
046   * notification types.
047   */
048  PASSWORD_POLICY_DN("password-policy-dn"),
049
050
051
052  /**
053   * The property whose value will be a generalized time representation of the
054   * time at which the user's account will be unlocked.  This will be available
055   * for the {@link AccountStatusNotificationType#ACCOUNT_TEMPORARILY_LOCKED}
056   * notification type.
057   */
058  ACCOUNT_UNLOCK_TIME("account-unlock-time"),
059
060
061
062  /**
063   * The property whose value will be the number of seconds until the user's
064   * account is unlocked.  This will be available for the
065   * {@link AccountStatusNotificationType#ACCOUNT_TEMPORARILY_LOCKED}
066   * notification type.
067   */
068  SECONDS_UNTIL_UNLOCK("seconds-until-unlock"),
069
070
071
072  /**
073   * The property whose value will be a localized, human-readable representation
074   * of the length of time until the user's account is unlocked.  This will be
075   * available for the
076   * {@link AccountStatusNotificationType#ACCOUNT_TEMPORARILY_LOCKED}
077   * notification type.
078   */
079  TIME_UNTIL_UNLOCK("time-until-unlock"),
080
081
082
083  /**
084   * The property whose value will be the generalized time representation of the
085   * time that the user's password will expire.  This will be available for the
086   * {@link AccountStatusNotificationType#PASSWORD_EXPIRING} notification type.
087   */
088  PASSWORD_EXPIRATION_TIME("password-expiration-time"),
089
090
091
092  /**
093   * The property whose value will be the number of seconds until the user's
094   * password expires.  This will be available for the
095   * {@link AccountStatusNotificationType#PASSWORD_EXPIRING} notification type.
096   */
097  SECONDS_UNTIL_EXPIRATION("seconds-until-expiration"),
098
099
100
101  /**
102   * The property whose value will be a localized, human-readable representation
103   * of the length of time until the user's password expires.  This will be
104   * available for the {@link AccountStatusNotificationType#PASSWORD_EXPIRING}
105   * notification type.
106   */
107  TIME_UNTIL_EXPIRATION("time-until-expiration"),
108
109
110
111  /**
112   * The property whose value will be a clear-text representation of the user's
113   * old password.  This may be (but is not guaranteed to be) available for the
114   * {@link AccountStatusNotificationType#PASSWORD_RESET} and
115   * {@link AccountStatusNotificationType#PASSWORD_CHANGED} notification types.
116   */
117  OLD_PASSWORD("old-password"),
118
119
120
121  /**
122   * The property whose value will be a clear-text representation of the user's
123   * new password.  This may be (but is not guaranteed to be) available for the
124   * {@link AccountStatusNotificationType#PASSWORD_RESET} and
125   * {@link AccountStatusNotificationType#PASSWORD_CHANGED} notification types.
126   */
127  NEW_PASSWORD("new-password");
128
129
130
131  // The notification type name.
132  private final String name;
133
134
135
136  /**
137   * Creates a new account status notification property with the provided name.
138   *
139   * @param  name  The name for this account status notification property.
140   */
141  AccountStatusNotificationProperty(final String name)
142  {
143    this.name = name;
144  }
145
146
147
148  /**
149   * Retrieves the account status notification type with the specified name.
150   *
151   * @param  name  The name for the account status notification type to
152   *               retrieve.
153   *
154   * @return  The requested account status notification type, or {@code null}
155   *          if there is no type with the given name.
156   */
157  public static AccountStatusNotificationProperty forName(final String name)
158  {
159    final String lowerName = StaticUtils.toLowerCase(name);
160    if (lowerName.equals("password-policy-dn"))
161    {
162      return PASSWORD_POLICY_DN;
163    }
164    else if (lowerName.equals("account-unlock-time"))
165    {
166      return ACCOUNT_UNLOCK_TIME;
167    }
168    else if (lowerName.equals("seconds-until-unlock"))
169    {
170      return SECONDS_UNTIL_UNLOCK;
171    }
172    else if (lowerName.equals("time-until-unlock"))
173    {
174      return TIME_UNTIL_UNLOCK;
175    }
176    else if (lowerName.equals("password-expiration-time"))
177    {
178      return PASSWORD_EXPIRATION_TIME;
179    }
180    else if (lowerName.equals("seconds-until-expiration"))
181    {
182      return SECONDS_UNTIL_EXPIRATION;
183    }
184    else if (lowerName.equals("time-until-expiration"))
185    {
186      return TIME_UNTIL_EXPIRATION;
187    }
188    else if (lowerName.equals("old-password"))
189    {
190      return OLD_PASSWORD;
191    }
192    else if (lowerName.equals("new-password"))
193    {
194      return NEW_PASSWORD;
195    }
196    else
197    {
198      return null;
199    }
200  }
201
202
203
204  /**
205   * Retrieves the name for this account status notification property.
206   *
207   * @return  The name for this account status notification property.
208   */
209  public String getName()
210  {
211    return name;
212  }
213
214
215
216  /**
217   * Retrieves a string representation of this account status
218   * notification property.
219   *
220   * @return  A string representation of this account status
221   *          notification property.
222   */
223  @Override()
224  public String toString()
225  {
226    return name;
227  }
228}
229