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