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