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