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 */ 016package org.forgerock.opendj.server.config.meta; 017 018 019 020import java.util.Collection; 021import java.util.SortedSet; 022import org.forgerock.opendj.config.AdministratorAction; 023import org.forgerock.opendj.config.AttributeTypePropertyDefinition; 024import org.forgerock.opendj.config.BooleanPropertyDefinition; 025import org.forgerock.opendj.config.ClassPropertyDefinition; 026import org.forgerock.opendj.config.client.ConcurrentModificationException; 027import org.forgerock.opendj.config.client.ManagedObject; 028import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 029import org.forgerock.opendj.config.client.OperationRejectedException; 030import org.forgerock.opendj.config.DefaultBehaviorProvider; 031import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 032import org.forgerock.opendj.config.DNPropertyDefinition; 033import org.forgerock.opendj.config.EnumPropertyDefinition; 034import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 035import org.forgerock.opendj.config.ManagedObjectDefinition; 036import org.forgerock.opendj.config.PropertyOption; 037import org.forgerock.opendj.config.PropertyProvider; 038import org.forgerock.opendj.config.server.ConfigurationChangeListener; 039import org.forgerock.opendj.config.server.ServerManagedObject; 040import org.forgerock.opendj.config.StringPropertyDefinition; 041import org.forgerock.opendj.config.Tag; 042import org.forgerock.opendj.ldap.DN; 043import org.forgerock.opendj.ldap.LdapException; 044import org.forgerock.opendj.ldap.schema.AttributeType; 045import org.forgerock.opendj.server.config.client.PasswordExpirationTimeVirtualAttributeCfgClient; 046import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.ConflictBehavior; 047import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.Scope; 048import org.forgerock.opendj.server.config.server.PasswordExpirationTimeVirtualAttributeCfg; 049import org.forgerock.opendj.server.config.server.VirtualAttributeCfg; 050 051 052 053/** 054 * An interface for querying the Password Expiration Time Virtual 055 * Attribute managed object definition meta information. 056 * <p> 057 * The Password Expiration Time Virtual Attribute generates a virtual 058 * attribute which shows the password expiration date. 059 */ 060public final class PasswordExpirationTimeVirtualAttributeCfgDefn extends ManagedObjectDefinition<PasswordExpirationTimeVirtualAttributeCfgClient, PasswordExpirationTimeVirtualAttributeCfg> { 061 062 /** The singleton configuration definition instance. */ 063 private static final PasswordExpirationTimeVirtualAttributeCfgDefn INSTANCE = new PasswordExpirationTimeVirtualAttributeCfgDefn(); 064 065 066 067 /** The "attribute-type" property definition. */ 068 private static final AttributeTypePropertyDefinition PD_ATTRIBUTE_TYPE; 069 070 071 072 /** The "conflict-behavior" property definition. */ 073 private static final EnumPropertyDefinition<ConflictBehavior> PD_CONFLICT_BEHAVIOR; 074 075 076 077 /** The "java-class" property definition. */ 078 private static final ClassPropertyDefinition PD_JAVA_CLASS; 079 080 081 082 /** Build the "attribute-type" property definition. */ 083 static { 084 AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "attribute-type"); 085 builder.setOption(PropertyOption.MANDATORY); 086 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "attribute-type")); 087 DefaultBehaviorProvider<AttributeType> provider = new DefinedDefaultBehaviorProvider<AttributeType>("ds-pwp-password-expiration-time"); 088 builder.setDefaultBehaviorProvider(provider); 089 PD_ATTRIBUTE_TYPE = builder.getInstance(); 090 INSTANCE.registerPropertyDefinition(PD_ATTRIBUTE_TYPE); 091 } 092 093 094 095 /** Build the "conflict-behavior" property definition. */ 096 static { 097 EnumPropertyDefinition.Builder<ConflictBehavior> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "conflict-behavior"); 098 builder.setOption(PropertyOption.ADVANCED); 099 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "conflict-behavior")); 100 DefaultBehaviorProvider<ConflictBehavior> provider = new DefinedDefaultBehaviorProvider<ConflictBehavior>("virtual-overrides-real"); 101 builder.setDefaultBehaviorProvider(provider); 102 builder.setEnumClass(ConflictBehavior.class); 103 PD_CONFLICT_BEHAVIOR = builder.getInstance(); 104 INSTANCE.registerPropertyDefinition(PD_CONFLICT_BEHAVIOR); 105 } 106 107 108 109 /** Build the "java-class" property definition. */ 110 static { 111 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 112 builder.setOption(PropertyOption.MANDATORY); 113 builder.setOption(PropertyOption.ADVANCED); 114 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 115 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.PasswordExpirationTimeVirtualAttributeProvider"); 116 builder.setDefaultBehaviorProvider(provider); 117 builder.addInstanceOf("org.opends.server.api.VirtualAttributeProvider"); 118 PD_JAVA_CLASS = builder.getInstance(); 119 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 120 } 121 122 123 124 // Register the tags associated with this managed object definition. 125 static { 126 INSTANCE.registerTag(Tag.valueOf("core-server")); 127 } 128 129 130 131 /** 132 * Get the Password Expiration Time Virtual Attribute configuration 133 * definition singleton. 134 * 135 * @return Returns the Password Expiration Time Virtual Attribute 136 * configuration definition singleton. 137 */ 138 public static PasswordExpirationTimeVirtualAttributeCfgDefn getInstance() { 139 return INSTANCE; 140 } 141 142 143 144 /** 145 * Private constructor. 146 */ 147 private PasswordExpirationTimeVirtualAttributeCfgDefn() { 148 super("password-expiration-time-virtual-attribute", VirtualAttributeCfgDefn.getInstance()); 149 } 150 151 152 153 /** {@inheritDoc} */ 154 public PasswordExpirationTimeVirtualAttributeCfgClient createClientConfiguration( 155 ManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfgClient> impl) { 156 return new PasswordExpirationTimeVirtualAttributeCfgClientImpl(impl); 157 } 158 159 160 161 /** {@inheritDoc} */ 162 public PasswordExpirationTimeVirtualAttributeCfg createServerConfiguration( 163 ServerManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfg> impl) { 164 return new PasswordExpirationTimeVirtualAttributeCfgServerImpl(impl); 165 } 166 167 168 169 /** {@inheritDoc} */ 170 public Class<PasswordExpirationTimeVirtualAttributeCfg> getServerConfigurationClass() { 171 return PasswordExpirationTimeVirtualAttributeCfg.class; 172 } 173 174 175 176 /** 177 * Get the "attribute-type" property definition. 178 * <p> 179 * Specifies the attribute type for the attribute whose values are 180 * to be dynamically assigned by the virtual attribute. 181 * 182 * @return Returns the "attribute-type" property definition. 183 */ 184 public AttributeTypePropertyDefinition getAttributeTypePropertyDefinition() { 185 return PD_ATTRIBUTE_TYPE; 186 } 187 188 189 190 /** 191 * Get the "base-dn" property definition. 192 * <p> 193 * Specifies the base DNs for the branches containing entries that 194 * are eligible to use this virtual attribute. 195 * <p> 196 * If no values are given, then the server generates virtual 197 * attributes anywhere in the server. 198 * 199 * @return Returns the "base-dn" property definition. 200 */ 201 public DNPropertyDefinition getBaseDNPropertyDefinition() { 202 return VirtualAttributeCfgDefn.getInstance().getBaseDNPropertyDefinition(); 203 } 204 205 206 207 /** 208 * Get the "conflict-behavior" property definition. 209 * <p> 210 * Specifies the behavior that the server is to exhibit for entries 211 * that already contain one or more real values for the associated 212 * attribute. 213 * 214 * @return Returns the "conflict-behavior" property definition. 215 */ 216 public EnumPropertyDefinition<ConflictBehavior> getConflictBehaviorPropertyDefinition() { 217 return PD_CONFLICT_BEHAVIOR; 218 } 219 220 221 222 /** 223 * Get the "enabled" property definition. 224 * <p> 225 * Indicates whether the Password Expiration Time Virtual Attribute 226 * is enabled for use. 227 * 228 * @return Returns the "enabled" property definition. 229 */ 230 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 231 return VirtualAttributeCfgDefn.getInstance().getEnabledPropertyDefinition(); 232 } 233 234 235 236 /** 237 * Get the "filter" property definition. 238 * <p> 239 * Specifies the search filters to be applied against entries to 240 * determine if the virtual attribute is to be generated for those 241 * entries. 242 * <p> 243 * If no values are given, then any entry is eligible to have the 244 * value generated. If one or more filters are specified, then only 245 * entries that match at least one of those filters are allowed to 246 * have the virtual attribute. 247 * 248 * @return Returns the "filter" property definition. 249 */ 250 public StringPropertyDefinition getFilterPropertyDefinition() { 251 return VirtualAttributeCfgDefn.getInstance().getFilterPropertyDefinition(); 252 } 253 254 255 256 /** 257 * Get the "group-dn" property definition. 258 * <p> 259 * Specifies the DNs of the groups whose members can be eligible to 260 * use this virtual attribute. 261 * <p> 262 * If no values are given, then group membership is not taken into 263 * account when generating the virtual attribute. If one or more 264 * group DNs are specified, then only members of those groups are 265 * allowed to have the virtual attribute. 266 * 267 * @return Returns the "group-dn" property definition. 268 */ 269 public DNPropertyDefinition getGroupDNPropertyDefinition() { 270 return VirtualAttributeCfgDefn.getInstance().getGroupDNPropertyDefinition(); 271 } 272 273 274 275 /** 276 * Get the "java-class" property definition. 277 * <p> 278 * Specifies the fully-qualified name of the virtual attribute 279 * provider class that generates the attribute values. 280 * 281 * @return Returns the "java-class" property definition. 282 */ 283 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 284 return PD_JAVA_CLASS; 285 } 286 287 288 289 /** 290 * Get the "scope" property definition. 291 * <p> 292 * Specifies the LDAP scope associated with base DNs for entries 293 * that are eligible to use this virtual attribute. 294 * 295 * @return Returns the "scope" property definition. 296 */ 297 public EnumPropertyDefinition<Scope> getScopePropertyDefinition() { 298 return VirtualAttributeCfgDefn.getInstance().getScopePropertyDefinition(); 299 } 300 301 302 303 /** 304 * Managed object client implementation. 305 */ 306 private static class PasswordExpirationTimeVirtualAttributeCfgClientImpl implements 307 PasswordExpirationTimeVirtualAttributeCfgClient { 308 309 /** Private implementation. */ 310 private ManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfgClient> impl; 311 312 313 314 /** Private constructor. */ 315 private PasswordExpirationTimeVirtualAttributeCfgClientImpl( 316 ManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfgClient> impl) { 317 this.impl = impl; 318 } 319 320 321 322 /** {@inheritDoc} */ 323 public AttributeType getAttributeType() { 324 return impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition()); 325 } 326 327 328 329 /** {@inheritDoc} */ 330 public void setAttributeType(AttributeType value) { 331 impl.setPropertyValue(INSTANCE.getAttributeTypePropertyDefinition(), value); 332 } 333 334 335 336 /** {@inheritDoc} */ 337 public SortedSet<DN> getBaseDN() { 338 return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 339 } 340 341 342 343 /** {@inheritDoc} */ 344 public void setBaseDN(Collection<DN> values) { 345 impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values); 346 } 347 348 349 350 /** {@inheritDoc} */ 351 public ConflictBehavior getConflictBehavior() { 352 return impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition()); 353 } 354 355 356 357 /** {@inheritDoc} */ 358 public void setConflictBehavior(ConflictBehavior value) { 359 impl.setPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition(), value); 360 } 361 362 363 364 /** {@inheritDoc} */ 365 public Boolean isEnabled() { 366 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 367 } 368 369 370 371 /** {@inheritDoc} */ 372 public void setEnabled(boolean value) { 373 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 374 } 375 376 377 378 /** {@inheritDoc} */ 379 public SortedSet<String> getFilter() { 380 return impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition()); 381 } 382 383 384 385 /** {@inheritDoc} */ 386 public void setFilter(Collection<String> values) { 387 impl.setPropertyValues(INSTANCE.getFilterPropertyDefinition(), values); 388 } 389 390 391 392 /** {@inheritDoc} */ 393 public SortedSet<DN> getGroupDN() { 394 return impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition()); 395 } 396 397 398 399 /** {@inheritDoc} */ 400 public void setGroupDN(Collection<DN> values) { 401 impl.setPropertyValues(INSTANCE.getGroupDNPropertyDefinition(), values); 402 } 403 404 405 406 /** {@inheritDoc} */ 407 public String getJavaClass() { 408 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 409 } 410 411 412 413 /** {@inheritDoc} */ 414 public void setJavaClass(String value) { 415 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 416 } 417 418 419 420 /** {@inheritDoc} */ 421 public Scope getScope() { 422 return impl.getPropertyValue(INSTANCE.getScopePropertyDefinition()); 423 } 424 425 426 427 /** {@inheritDoc} */ 428 public void setScope(Scope value) { 429 impl.setPropertyValue(INSTANCE.getScopePropertyDefinition(), value); 430 } 431 432 433 434 /** {@inheritDoc} */ 435 public ManagedObjectDefinition<? extends PasswordExpirationTimeVirtualAttributeCfgClient, ? extends PasswordExpirationTimeVirtualAttributeCfg> definition() { 436 return INSTANCE; 437 } 438 439 440 441 /** {@inheritDoc} */ 442 public PropertyProvider properties() { 443 return impl; 444 } 445 446 447 448 /** {@inheritDoc} */ 449 public void commit() throws ManagedObjectAlreadyExistsException, 450 MissingMandatoryPropertiesException, ConcurrentModificationException, 451 OperationRejectedException, LdapException { 452 impl.commit(); 453 } 454 455 456 457 /** {@inheritDoc} */ 458 public String toString() { 459 return impl.toString(); 460 } 461 } 462 463 464 465 /** 466 * Managed object server implementation. 467 */ 468 private static class PasswordExpirationTimeVirtualAttributeCfgServerImpl implements 469 PasswordExpirationTimeVirtualAttributeCfg { 470 471 /** Private implementation. */ 472 private ServerManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfg> impl; 473 474 /** The value of the "attribute-type" property. */ 475 private final AttributeType pAttributeType; 476 477 /** The value of the "base-dn" property. */ 478 private final SortedSet<DN> pBaseDN; 479 480 /** The value of the "conflict-behavior" property. */ 481 private final ConflictBehavior pConflictBehavior; 482 483 /** The value of the "enabled" property. */ 484 private final boolean pEnabled; 485 486 /** The value of the "filter" property. */ 487 private final SortedSet<String> pFilter; 488 489 /** The value of the "group-dn" property. */ 490 private final SortedSet<DN> pGroupDN; 491 492 /** The value of the "java-class" property. */ 493 private final String pJavaClass; 494 495 /** The value of the "scope" property. */ 496 private final Scope pScope; 497 498 499 500 /** Private constructor. */ 501 private PasswordExpirationTimeVirtualAttributeCfgServerImpl(ServerManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfg> impl) { 502 this.impl = impl; 503 this.pAttributeType = impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition()); 504 this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 505 this.pConflictBehavior = impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition()); 506 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 507 this.pFilter = impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition()); 508 this.pGroupDN = impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition()); 509 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 510 this.pScope = impl.getPropertyValue(INSTANCE.getScopePropertyDefinition()); 511 } 512 513 514 515 /** {@inheritDoc} */ 516 public void addPasswordExpirationTimeChangeListener( 517 ConfigurationChangeListener<PasswordExpirationTimeVirtualAttributeCfg> listener) { 518 impl.registerChangeListener(listener); 519 } 520 521 522 523 /** {@inheritDoc} */ 524 public void removePasswordExpirationTimeChangeListener( 525 ConfigurationChangeListener<PasswordExpirationTimeVirtualAttributeCfg> listener) { 526 impl.deregisterChangeListener(listener); 527 } 528 /** {@inheritDoc} */ 529 public void addChangeListener( 530 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 531 impl.registerChangeListener(listener); 532 } 533 534 535 536 /** {@inheritDoc} */ 537 public void removeChangeListener( 538 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 539 impl.deregisterChangeListener(listener); 540 } 541 542 543 544 /** {@inheritDoc} */ 545 public AttributeType getAttributeType() { 546 return pAttributeType; 547 } 548 549 550 551 /** {@inheritDoc} */ 552 public SortedSet<DN> getBaseDN() { 553 return pBaseDN; 554 } 555 556 557 558 /** {@inheritDoc} */ 559 public ConflictBehavior getConflictBehavior() { 560 return pConflictBehavior; 561 } 562 563 564 565 /** {@inheritDoc} */ 566 public boolean isEnabled() { 567 return pEnabled; 568 } 569 570 571 572 /** {@inheritDoc} */ 573 public SortedSet<String> getFilter() { 574 return pFilter; 575 } 576 577 578 579 /** {@inheritDoc} */ 580 public SortedSet<DN> getGroupDN() { 581 return pGroupDN; 582 } 583 584 585 586 /** {@inheritDoc} */ 587 public String getJavaClass() { 588 return pJavaClass; 589 } 590 591 592 593 /** {@inheritDoc} */ 594 public Scope getScope() { 595 return pScope; 596 } 597 598 599 600 /** {@inheritDoc} */ 601 public Class<? extends PasswordExpirationTimeVirtualAttributeCfg> configurationClass() { 602 return PasswordExpirationTimeVirtualAttributeCfg.class; 603 } 604 605 606 607 /** {@inheritDoc} */ 608 public DN dn() { 609 return impl.getDN(); 610 } 611 612 613 614 /** {@inheritDoc} */ 615 public String toString() { 616 return impl.toString(); 617 } 618 } 619}