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.admin.std.meta; 028 029 030 031 import java.util.Collection; 032 import java.util.SortedSet; 033 import org.opends.server.admin.AdministratorAction; 034 import org.opends.server.admin.BooleanPropertyDefinition; 035 import org.opends.server.admin.ClassPropertyDefinition; 036 import org.opends.server.admin.client.AuthorizationException; 037 import org.opends.server.admin.client.CommunicationException; 038 import org.opends.server.admin.client.ConcurrentModificationException; 039 import org.opends.server.admin.client.ManagedObject; 040 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 041 import org.opends.server.admin.client.OperationRejectedException; 042 import org.opends.server.admin.DefaultBehaviorProvider; 043 import org.opends.server.admin.DefinedDefaultBehaviorProvider; 044 import org.opends.server.admin.EnumPropertyDefinition; 045 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 046 import org.opends.server.admin.ManagedObjectDefinition; 047 import org.opends.server.admin.PropertyOption; 048 import org.opends.server.admin.PropertyProvider; 049 import org.opends.server.admin.server.ConfigurationChangeListener; 050 import org.opends.server.admin.server.ServerManagedObject; 051 import org.opends.server.admin.std.client.ErrorLogAccountStatusNotificationHandlerCfgClient; 052 import org.opends.server.admin.std.server.AccountStatusNotificationHandlerCfg; 053 import org.opends.server.admin.std.server.ErrorLogAccountStatusNotificationHandlerCfg; 054 import org.opends.server.admin.Tag; 055 import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 056 import org.opends.server.types.DN; 057 058 059 060 /** 061 * An interface for querying the Error Log Account Status Notification 062 * Handler managed object definition meta information. 063 * <p> 064 * The Error Log Account Status Notification Handler is a notification 065 * handler that writes information to the server error log whenever an 066 * appropriate account status event occurs. 067 */ 068 public final class ErrorLogAccountStatusNotificationHandlerCfgDefn extends ManagedObjectDefinition<ErrorLogAccountStatusNotificationHandlerCfgClient, ErrorLogAccountStatusNotificationHandlerCfg> { 069 070 // The singleton configuration definition instance. 071 private static final ErrorLogAccountStatusNotificationHandlerCfgDefn INSTANCE = new ErrorLogAccountStatusNotificationHandlerCfgDefn(); 072 073 074 075 /** 076 * Defines the set of permissable values for the "account-status-notification-type" property. 077 * <p> 078 * Indicates which types of event can trigger an account status 079 * notification. 080 */ 081 public static enum AccountStatusNotificationType { 082 083 /** 084 * Generate a notification whenever a user account has been 085 * disabled by an administrator. 086 */ 087 ACCOUNT_DISABLED("account-disabled"), 088 089 090 091 /** 092 * Generate a notification whenever a user account has been 093 * enabled by an administrator. 094 */ 095 ACCOUNT_ENABLED("account-enabled"), 096 097 098 099 /** 100 * Generate a notification whenever a user authentication has 101 * failed because the account has expired. 102 */ 103 ACCOUNT_EXPIRED("account-expired"), 104 105 106 107 /** 108 * Generate a notification whenever a user account has been locked 109 * because it was idle for too long. 110 */ 111 ACCOUNT_IDLE_LOCKED("account-idle-locked"), 112 113 114 115 /** 116 * Generate a notification whenever a user account has been 117 * permanently locked after too many failed attempts. 118 */ 119 ACCOUNT_PERMANENTLY_LOCKED("account-permanently-locked"), 120 121 122 123 /** 124 * Generate a notification whenever a user account has been 125 * locked, because the password had been reset by an administrator 126 * but not changed by the user within the required interval. 127 */ 128 ACCOUNT_RESET_LOCKED("account-reset-locked"), 129 130 131 132 /** 133 * Generate a notification whenever a user account has been 134 * temporarily locked after too many failed attempts. 135 */ 136 ACCOUNT_TEMPORARILY_LOCKED("account-temporarily-locked"), 137 138 139 140 /** 141 * Generate a notification whenever a user account has been 142 * unlocked by an administrator. 143 */ 144 ACCOUNT_UNLOCKED("account-unlocked"), 145 146 147 148 /** 149 * Generate a notification whenever a user changes his/her own 150 * password. 151 */ 152 PASSWORD_CHANGED("password-changed"), 153 154 155 156 /** 157 * Generate a notification whenever a user authentication has 158 * failed because the password has expired. 159 */ 160 PASSWORD_EXPIRED("password-expired"), 161 162 163 164 /** 165 * Generate a notification whenever a password expiration warning 166 * is encountered for a user password for the first time. 167 */ 168 PASSWORD_EXPIRING("password-expiring"), 169 170 171 172 /** 173 * Generate a notification whenever a user's password is reset by 174 * an administrator. 175 */ 176 PASSWORD_RESET("password-reset"); 177 178 179 180 // String representation of the value. 181 private final String name; 182 183 184 185 // Private constructor. 186 private AccountStatusNotificationType(String name) { this.name = name; } 187 188 189 190 /** 191 * {@inheritDoc} 192 */ 193 public String toString() { return name; } 194 195 } 196 197 198 199 // The "account-status-notification-type" property definition. 200 private static final EnumPropertyDefinition<AccountStatusNotificationType> PD_ACCOUNT_STATUS_NOTIFICATION_TYPE; 201 202 203 204 // The "java-class" property definition. 205 private static final ClassPropertyDefinition PD_JAVA_CLASS; 206 207 208 209 // Build the "account-status-notification-type" property definition. 210 static { 211 EnumPropertyDefinition.Builder<AccountStatusNotificationType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "account-status-notification-type"); 212 builder.setOption(PropertyOption.MULTI_VALUED); 213 builder.setOption(PropertyOption.MANDATORY); 214 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "account-status-notification-type")); 215 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<AccountStatusNotificationType>()); 216 builder.setEnumClass(AccountStatusNotificationType.class); 217 PD_ACCOUNT_STATUS_NOTIFICATION_TYPE = builder.getInstance(); 218 INSTANCE.registerPropertyDefinition(PD_ACCOUNT_STATUS_NOTIFICATION_TYPE); 219 } 220 221 222 223 // Build the "java-class" property definition. 224 static { 225 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 226 builder.setOption(PropertyOption.MANDATORY); 227 builder.setOption(PropertyOption.ADVANCED); 228 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 229 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.ErrorLogAccountStatusNotificationHandler"); 230 builder.setDefaultBehaviorProvider(provider); 231 builder.addInstanceOf("org.opends.server.api.AccountStatusNotificationHandler"); 232 PD_JAVA_CLASS = builder.getInstance(); 233 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 234 } 235 236 237 238 // Register the tags associated with this managed object definition. 239 static { 240 INSTANCE.registerTag(Tag.valueOf("user-management")); 241 } 242 243 244 245 /** 246 * Get the Error Log Account Status Notification Handler 247 * configuration definition singleton. 248 * 249 * @return Returns the Error Log Account Status Notification Handler 250 * configuration definition singleton. 251 */ 252 public static ErrorLogAccountStatusNotificationHandlerCfgDefn getInstance() { 253 return INSTANCE; 254 } 255 256 257 258 /** 259 * Private constructor. 260 */ 261 private ErrorLogAccountStatusNotificationHandlerCfgDefn() { 262 super("error-log-account-status-notification-handler", AccountStatusNotificationHandlerCfgDefn.getInstance()); 263 } 264 265 266 267 /** 268 * {@inheritDoc} 269 */ 270 public ErrorLogAccountStatusNotificationHandlerCfgClient createClientConfiguration( 271 ManagedObject<? extends ErrorLogAccountStatusNotificationHandlerCfgClient> impl) { 272 return new ErrorLogAccountStatusNotificationHandlerCfgClientImpl(impl); 273 } 274 275 276 277 /** 278 * {@inheritDoc} 279 */ 280 public ErrorLogAccountStatusNotificationHandlerCfg createServerConfiguration( 281 ServerManagedObject<? extends ErrorLogAccountStatusNotificationHandlerCfg> impl) { 282 return new ErrorLogAccountStatusNotificationHandlerCfgServerImpl(impl); 283 } 284 285 286 287 /** 288 * {@inheritDoc} 289 */ 290 public Class<ErrorLogAccountStatusNotificationHandlerCfg> getServerConfigurationClass() { 291 return ErrorLogAccountStatusNotificationHandlerCfg.class; 292 } 293 294 295 296 /** 297 * Get the "account-status-notification-type" property definition. 298 * <p> 299 * Indicates which types of event can trigger an account status 300 * notification. 301 * 302 * @return Returns the "account-status-notification-type" property definition. 303 */ 304 public EnumPropertyDefinition<AccountStatusNotificationType> getAccountStatusNotificationTypePropertyDefinition() { 305 return PD_ACCOUNT_STATUS_NOTIFICATION_TYPE; 306 } 307 308 309 310 /** 311 * Get the "enabled" property definition. 312 * <p> 313 * Indicates whether the Error Log Account Status Notification 314 * Handler is enabled. Only enabled handlers are invoked whenever a 315 * related event occurs in the server. 316 * 317 * @return Returns the "enabled" property definition. 318 */ 319 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 320 return AccountStatusNotificationHandlerCfgDefn.getInstance().getEnabledPropertyDefinition(); 321 } 322 323 324 325 /** 326 * Get the "java-class" property definition. 327 * <p> 328 * Specifies the fully-qualified name of the Java class that 329 * provides the Error Log Account Status Notification Handler 330 * implementation. 331 * 332 * @return Returns the "java-class" property definition. 333 */ 334 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 335 return PD_JAVA_CLASS; 336 } 337 338 339 340 /** 341 * Managed object client implementation. 342 */ 343 private static class ErrorLogAccountStatusNotificationHandlerCfgClientImpl implements 344 ErrorLogAccountStatusNotificationHandlerCfgClient { 345 346 // Private implementation. 347 private ManagedObject<? extends ErrorLogAccountStatusNotificationHandlerCfgClient> impl; 348 349 350 351 // Private constructor. 352 private ErrorLogAccountStatusNotificationHandlerCfgClientImpl( 353 ManagedObject<? extends ErrorLogAccountStatusNotificationHandlerCfgClient> impl) { 354 this.impl = impl; 355 } 356 357 358 359 /** 360 * {@inheritDoc} 361 */ 362 public SortedSet<AccountStatusNotificationType> getAccountStatusNotificationType() { 363 return impl.getPropertyValues(INSTANCE.getAccountStatusNotificationTypePropertyDefinition()); 364 } 365 366 367 368 /** 369 * {@inheritDoc} 370 */ 371 public void setAccountStatusNotificationType(Collection<AccountStatusNotificationType> values) { 372 impl.setPropertyValues(INSTANCE.getAccountStatusNotificationTypePropertyDefinition(), values); 373 } 374 375 376 377 /** 378 * {@inheritDoc} 379 */ 380 public Boolean isEnabled() { 381 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 382 } 383 384 385 386 /** 387 * {@inheritDoc} 388 */ 389 public void setEnabled(boolean value) { 390 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 391 } 392 393 394 395 /** 396 * {@inheritDoc} 397 */ 398 public String getJavaClass() { 399 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 400 } 401 402 403 404 /** 405 * {@inheritDoc} 406 */ 407 public void setJavaClass(String value) { 408 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 409 } 410 411 412 413 /** 414 * {@inheritDoc} 415 */ 416 public ManagedObjectDefinition<? extends ErrorLogAccountStatusNotificationHandlerCfgClient, ? extends ErrorLogAccountStatusNotificationHandlerCfg> definition() { 417 return INSTANCE; 418 } 419 420 421 422 /** 423 * {@inheritDoc} 424 */ 425 public PropertyProvider properties() { 426 return impl; 427 } 428 429 430 431 /** 432 * {@inheritDoc} 433 */ 434 public void commit() throws ManagedObjectAlreadyExistsException, 435 MissingMandatoryPropertiesException, ConcurrentModificationException, 436 OperationRejectedException, AuthorizationException, 437 CommunicationException { 438 impl.commit(); 439 } 440 441 } 442 443 444 445 /** 446 * Managed object server implementation. 447 */ 448 private static class ErrorLogAccountStatusNotificationHandlerCfgServerImpl implements 449 ErrorLogAccountStatusNotificationHandlerCfg { 450 451 // Private implementation. 452 private ServerManagedObject<? extends ErrorLogAccountStatusNotificationHandlerCfg> impl; 453 454 // The value of the "account-status-notification-type" property. 455 private final SortedSet<AccountStatusNotificationType> pAccountStatusNotificationType; 456 457 // The value of the "enabled" property. 458 private final boolean pEnabled; 459 460 // The value of the "java-class" property. 461 private final String pJavaClass; 462 463 464 465 // Private constructor. 466 private ErrorLogAccountStatusNotificationHandlerCfgServerImpl(ServerManagedObject<? extends ErrorLogAccountStatusNotificationHandlerCfg> impl) { 467 this.impl = impl; 468 this.pAccountStatusNotificationType = impl.getPropertyValues(INSTANCE.getAccountStatusNotificationTypePropertyDefinition()); 469 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 470 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 471 } 472 473 474 475 /** 476 * {@inheritDoc} 477 */ 478 public void addErrorLogChangeListener( 479 ConfigurationChangeListener<ErrorLogAccountStatusNotificationHandlerCfg> listener) { 480 impl.registerChangeListener(listener); 481 } 482 483 484 485 /** 486 * {@inheritDoc} 487 */ 488 public void removeErrorLogChangeListener( 489 ConfigurationChangeListener<ErrorLogAccountStatusNotificationHandlerCfg> listener) { 490 impl.deregisterChangeListener(listener); 491 } 492 /** 493 * {@inheritDoc} 494 */ 495 public void addChangeListener( 496 ConfigurationChangeListener<AccountStatusNotificationHandlerCfg> listener) { 497 impl.registerChangeListener(listener); 498 } 499 500 501 502 /** 503 * {@inheritDoc} 504 */ 505 public void removeChangeListener( 506 ConfigurationChangeListener<AccountStatusNotificationHandlerCfg> listener) { 507 impl.deregisterChangeListener(listener); 508 } 509 510 511 512 /** 513 * {@inheritDoc} 514 */ 515 public SortedSet<AccountStatusNotificationType> getAccountStatusNotificationType() { 516 return pAccountStatusNotificationType; 517 } 518 519 520 521 /** 522 * {@inheritDoc} 523 */ 524 public boolean isEnabled() { 525 return pEnabled; 526 } 527 528 529 530 /** 531 * {@inheritDoc} 532 */ 533 public String getJavaClass() { 534 return pJavaClass; 535 } 536 537 538 539 /** 540 * {@inheritDoc} 541 */ 542 public Class<? extends ErrorLogAccountStatusNotificationHandlerCfg> configurationClass() { 543 return ErrorLogAccountStatusNotificationHandlerCfg.class; 544 } 545 546 547 548 /** 549 * {@inheritDoc} 550 */ 551 public DN dn() { 552 return impl.getDN(); 553 } 554 555 } 556 }