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