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.AttributeTypePropertyDefinition; 035 import org.opends.server.admin.BooleanPropertyDefinition; 036 import org.opends.server.admin.ClassPropertyDefinition; 037 import org.opends.server.admin.client.AuthorizationException; 038 import org.opends.server.admin.client.CommunicationException; 039 import org.opends.server.admin.client.ConcurrentModificationException; 040 import org.opends.server.admin.client.ManagedObject; 041 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 042 import org.opends.server.admin.client.OperationRejectedException; 043 import org.opends.server.admin.DefaultBehaviorProvider; 044 import org.opends.server.admin.DefinedDefaultBehaviorProvider; 045 import org.opends.server.admin.DNPropertyDefinition; 046 import org.opends.server.admin.EnumPropertyDefinition; 047 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 048 import org.opends.server.admin.ManagedObjectDefinition; 049 import org.opends.server.admin.PropertyOption; 050 import org.opends.server.admin.PropertyProvider; 051 import org.opends.server.admin.server.ConfigurationChangeListener; 052 import org.opends.server.admin.server.ServerManagedObject; 053 import org.opends.server.admin.std.client.MemberVirtualAttributeCfgClient; 054 import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.ConflictBehavior; 055 import org.opends.server.admin.std.server.MemberVirtualAttributeCfg; 056 import org.opends.server.admin.std.server.VirtualAttributeCfg; 057 import org.opends.server.admin.StringPropertyDefinition; 058 import org.opends.server.admin.Tag; 059 import org.opends.server.types.AttributeType; 060 import 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 */ 072 public 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 * Managed object client implementation. 332 */ 333 private static class MemberVirtualAttributeCfgClientImpl implements 334 MemberVirtualAttributeCfgClient { 335 336 // Private implementation. 337 private ManagedObject<? extends MemberVirtualAttributeCfgClient> impl; 338 339 340 341 // Private constructor. 342 private MemberVirtualAttributeCfgClientImpl( 343 ManagedObject<? extends MemberVirtualAttributeCfgClient> impl) { 344 this.impl = impl; 345 } 346 347 348 349 /** 350 * {@inheritDoc} 351 */ 352 public boolean isAllowRetrievingMembership() { 353 return impl.getPropertyValue(INSTANCE.getAllowRetrievingMembershipPropertyDefinition()); 354 } 355 356 357 358 /** 359 * {@inheritDoc} 360 */ 361 public void setAllowRetrievingMembership(boolean value) { 362 impl.setPropertyValue(INSTANCE.getAllowRetrievingMembershipPropertyDefinition(), value); 363 } 364 365 366 367 /** 368 * {@inheritDoc} 369 */ 370 public AttributeType getAttributeType() { 371 return impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition()); 372 } 373 374 375 376 /** 377 * {@inheritDoc} 378 */ 379 public void setAttributeType(AttributeType value) { 380 impl.setPropertyValue(INSTANCE.getAttributeTypePropertyDefinition(), value); 381 } 382 383 384 385 /** 386 * {@inheritDoc} 387 */ 388 public SortedSet<DN> getBaseDN() { 389 return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 390 } 391 392 393 394 /** 395 * {@inheritDoc} 396 */ 397 public void setBaseDN(Collection<DN> values) { 398 impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values); 399 } 400 401 402 403 /** 404 * {@inheritDoc} 405 */ 406 public ConflictBehavior getConflictBehavior() { 407 return impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition()); 408 } 409 410 411 412 /** 413 * {@inheritDoc} 414 */ 415 public void setConflictBehavior(ConflictBehavior value) { 416 impl.setPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition(), value); 417 } 418 419 420 421 /** 422 * {@inheritDoc} 423 */ 424 public Boolean isEnabled() { 425 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 426 } 427 428 429 430 /** 431 * {@inheritDoc} 432 */ 433 public void setEnabled(boolean value) { 434 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 435 } 436 437 438 439 /** 440 * {@inheritDoc} 441 */ 442 public SortedSet<String> getFilter() { 443 return impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition()); 444 } 445 446 447 448 /** 449 * {@inheritDoc} 450 */ 451 public void setFilter(Collection<String> values) { 452 impl.setPropertyValues(INSTANCE.getFilterPropertyDefinition(), values); 453 } 454 455 456 457 /** 458 * {@inheritDoc} 459 */ 460 public SortedSet<DN> getGroupDN() { 461 return impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition()); 462 } 463 464 465 466 /** 467 * {@inheritDoc} 468 */ 469 public void setGroupDN(Collection<DN> values) { 470 impl.setPropertyValues(INSTANCE.getGroupDNPropertyDefinition(), values); 471 } 472 473 474 475 /** 476 * {@inheritDoc} 477 */ 478 public String getJavaClass() { 479 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 480 } 481 482 483 484 /** 485 * {@inheritDoc} 486 */ 487 public void setJavaClass(String value) { 488 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 489 } 490 491 492 493 /** 494 * {@inheritDoc} 495 */ 496 public ManagedObjectDefinition<? extends MemberVirtualAttributeCfgClient, ? extends MemberVirtualAttributeCfg> definition() { 497 return INSTANCE; 498 } 499 500 501 502 /** 503 * {@inheritDoc} 504 */ 505 public PropertyProvider properties() { 506 return impl; 507 } 508 509 510 511 /** 512 * {@inheritDoc} 513 */ 514 public void commit() throws ManagedObjectAlreadyExistsException, 515 MissingMandatoryPropertiesException, ConcurrentModificationException, 516 OperationRejectedException, AuthorizationException, 517 CommunicationException { 518 impl.commit(); 519 } 520 521 } 522 523 524 525 /** 526 * Managed object server implementation. 527 */ 528 private static class MemberVirtualAttributeCfgServerImpl implements 529 MemberVirtualAttributeCfg { 530 531 // Private implementation. 532 private ServerManagedObject<? extends MemberVirtualAttributeCfg> impl; 533 534 // The value of the "allow-retrieving-membership" property. 535 private final boolean pAllowRetrievingMembership; 536 537 // The value of the "attribute-type" property. 538 private final AttributeType pAttributeType; 539 540 // The value of the "base-dn" property. 541 private final SortedSet<DN> pBaseDN; 542 543 // The value of the "conflict-behavior" property. 544 private final ConflictBehavior pConflictBehavior; 545 546 // The value of the "enabled" property. 547 private final boolean pEnabled; 548 549 // The value of the "filter" property. 550 private final SortedSet<String> pFilter; 551 552 // The value of the "group-dn" property. 553 private final SortedSet<DN> pGroupDN; 554 555 // The value of the "java-class" property. 556 private final String pJavaClass; 557 558 559 560 // Private constructor. 561 private MemberVirtualAttributeCfgServerImpl(ServerManagedObject<? extends MemberVirtualAttributeCfg> impl) { 562 this.impl = impl; 563 this.pAllowRetrievingMembership = impl.getPropertyValue(INSTANCE.getAllowRetrievingMembershipPropertyDefinition()); 564 this.pAttributeType = impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition()); 565 this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 566 this.pConflictBehavior = impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition()); 567 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 568 this.pFilter = impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition()); 569 this.pGroupDN = impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition()); 570 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 571 } 572 573 574 575 /** 576 * {@inheritDoc} 577 */ 578 public void addMemberChangeListener( 579 ConfigurationChangeListener<MemberVirtualAttributeCfg> listener) { 580 impl.registerChangeListener(listener); 581 } 582 583 584 585 /** 586 * {@inheritDoc} 587 */ 588 public void removeMemberChangeListener( 589 ConfigurationChangeListener<MemberVirtualAttributeCfg> listener) { 590 impl.deregisterChangeListener(listener); 591 } 592 /** 593 * {@inheritDoc} 594 */ 595 public void addChangeListener( 596 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 597 impl.registerChangeListener(listener); 598 } 599 600 601 602 /** 603 * {@inheritDoc} 604 */ 605 public void removeChangeListener( 606 ConfigurationChangeListener<VirtualAttributeCfg> listener) { 607 impl.deregisterChangeListener(listener); 608 } 609 610 611 612 /** 613 * {@inheritDoc} 614 */ 615 public boolean isAllowRetrievingMembership() { 616 return pAllowRetrievingMembership; 617 } 618 619 620 621 /** 622 * {@inheritDoc} 623 */ 624 public AttributeType getAttributeType() { 625 return pAttributeType; 626 } 627 628 629 630 /** 631 * {@inheritDoc} 632 */ 633 public SortedSet<DN> getBaseDN() { 634 return pBaseDN; 635 } 636 637 638 639 /** 640 * {@inheritDoc} 641 */ 642 public ConflictBehavior getConflictBehavior() { 643 return pConflictBehavior; 644 } 645 646 647 648 /** 649 * {@inheritDoc} 650 */ 651 public boolean isEnabled() { 652 return pEnabled; 653 } 654 655 656 657 /** 658 * {@inheritDoc} 659 */ 660 public SortedSet<String> getFilter() { 661 return pFilter; 662 } 663 664 665 666 /** 667 * {@inheritDoc} 668 */ 669 public SortedSet<DN> getGroupDN() { 670 return pGroupDN; 671 } 672 673 674 675 /** 676 * {@inheritDoc} 677 */ 678 public String getJavaClass() { 679 return pJavaClass; 680 } 681 682 683 684 /** 685 * {@inheritDoc} 686 */ 687 public Class<? extends MemberVirtualAttributeCfg> configurationClass() { 688 return MemberVirtualAttributeCfg.class; 689 } 690 691 692 693 /** 694 * {@inheritDoc} 695 */ 696 public DN dn() { 697 return impl.getDN(); 698 } 699 700 } 701 }