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