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