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