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.AliasDefaultBehaviorProvider; 034import org.opends.server.admin.AttributeTypePropertyDefinition; 035import org.opends.server.admin.BooleanPropertyDefinition; 036import org.opends.server.admin.ClassPropertyDefinition; 037import org.opends.server.admin.client.AuthorizationException; 038import org.opends.server.admin.client.CommunicationException; 039import org.opends.server.admin.client.ConcurrentModificationException; 040import org.opends.server.admin.client.ManagedObject; 041import org.opends.server.admin.client.MissingMandatoryPropertiesException; 042import org.opends.server.admin.client.OperationRejectedException; 043import org.opends.server.admin.DefaultBehaviorProvider; 044import org.opends.server.admin.DefinedDefaultBehaviorProvider; 045import org.opends.server.admin.DNPropertyDefinition; 046import org.opends.server.admin.EnumPropertyDefinition; 047import org.opends.server.admin.ManagedObjectAlreadyExistsException; 048import org.opends.server.admin.ManagedObjectDefinition; 049import org.opends.server.admin.PropertyOption; 050import org.opends.server.admin.PropertyProvider; 051import org.opends.server.admin.server.ConfigurationChangeListener; 052import org.opends.server.admin.server.ServerManagedObject; 053import org.opends.server.admin.std.client.SevenBitCleanPluginCfgClient; 054import org.opends.server.admin.std.meta.PluginCfgDefn.PluginType; 055import org.opends.server.admin.std.server.PluginCfg; 056import org.opends.server.admin.std.server.SevenBitCleanPluginCfg; 057import org.opends.server.admin.Tag; 058import org.opends.server.types.AttributeType; 059import org.opends.server.types.DN; 060 061 062 063/** 064 * An interface for querying the Seven Bit Clean Plugin managed object 065 * definition meta information. 066 * <p> 067 * The Seven Bit Clean Plugin ensures that values for a specified set 068 * of attributes are 7-bit clean. 069 */ 070public final class SevenBitCleanPluginCfgDefn extends ManagedObjectDefinition<SevenBitCleanPluginCfgClient, SevenBitCleanPluginCfg> { 071 072 // The singleton configuration definition instance. 073 private static final SevenBitCleanPluginCfgDefn INSTANCE = new SevenBitCleanPluginCfgDefn(); 074 075 076 077 // The "attribute-type" property definition. 078 private static final AttributeTypePropertyDefinition PD_ATTRIBUTE_TYPE; 079 080 081 082 // The "base-dn" property definition. 083 private static final DNPropertyDefinition PD_BASE_DN; 084 085 086 087 // The "java-class" property definition. 088 private static final ClassPropertyDefinition PD_JAVA_CLASS; 089 090 091 092 // The "plugin-type" property definition. 093 private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE; 094 095 096 097 // Build the "attribute-type" property definition. 098 static { 099 AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "attribute-type"); 100 builder.setOption(PropertyOption.MULTI_VALUED); 101 builder.setOption(PropertyOption.MANDATORY); 102 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "attribute-type")); 103 DefaultBehaviorProvider<AttributeType> provider = new DefinedDefaultBehaviorProvider<AttributeType>("uid", "mail", "userPassword"); 104 builder.setDefaultBehaviorProvider(provider); 105 PD_ATTRIBUTE_TYPE = builder.getInstance(); 106 INSTANCE.registerPropertyDefinition(PD_ATTRIBUTE_TYPE); 107 } 108 109 110 111 // Build the "base-dn" property definition. 112 static { 113 DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "base-dn"); 114 builder.setOption(PropertyOption.MULTI_VALUED); 115 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "base-dn")); 116 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<DN>(INSTANCE, "base-dn")); 117 PD_BASE_DN = builder.getInstance(); 118 INSTANCE.registerPropertyDefinition(PD_BASE_DN); 119 } 120 121 122 123 // Build the "java-class" property definition. 124 static { 125 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 126 builder.setOption(PropertyOption.MANDATORY); 127 builder.setOption(PropertyOption.ADVANCED); 128 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 129 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.SevenBitCleanPlugin"); 130 builder.setDefaultBehaviorProvider(provider); 131 builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin"); 132 PD_JAVA_CLASS = builder.getInstance(); 133 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 134 } 135 136 137 138 // Build the "plugin-type" property definition. 139 static { 140 EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type"); 141 builder.setOption(PropertyOption.MULTI_VALUED); 142 builder.setOption(PropertyOption.MANDATORY); 143 builder.setOption(PropertyOption.ADVANCED); 144 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type")); 145 DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("ldifimport", "preparseadd", "preparsemodify", "preparsemodifydn"); 146 builder.setDefaultBehaviorProvider(provider); 147 builder.setEnumClass(PluginType.class); 148 PD_PLUGIN_TYPE = builder.getInstance(); 149 INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE); 150 } 151 152 153 154 // Register the tags associated with this managed object definition. 155 static { 156 INSTANCE.registerTag(Tag.valueOf("core-server")); 157 } 158 159 160 161 /** 162 * Get the Seven Bit Clean Plugin configuration definition 163 * singleton. 164 * 165 * @return Returns the Seven Bit Clean Plugin configuration 166 * definition singleton. 167 */ 168 public static SevenBitCleanPluginCfgDefn getInstance() { 169 return INSTANCE; 170 } 171 172 173 174 /** 175 * Private constructor. 176 */ 177 private SevenBitCleanPluginCfgDefn() { 178 super("seven-bit-clean-plugin", PluginCfgDefn.getInstance()); 179 } 180 181 182 183 /** 184 * {@inheritDoc} 185 */ 186 public SevenBitCleanPluginCfgClient createClientConfiguration( 187 ManagedObject<? extends SevenBitCleanPluginCfgClient> impl) { 188 return new SevenBitCleanPluginCfgClientImpl(impl); 189 } 190 191 192 193 /** 194 * {@inheritDoc} 195 */ 196 public SevenBitCleanPluginCfg createServerConfiguration( 197 ServerManagedObject<? extends SevenBitCleanPluginCfg> impl) { 198 return new SevenBitCleanPluginCfgServerImpl(impl); 199 } 200 201 202 203 /** 204 * {@inheritDoc} 205 */ 206 public Class<SevenBitCleanPluginCfg> getServerConfigurationClass() { 207 return SevenBitCleanPluginCfg.class; 208 } 209 210 211 212 /** 213 * Get the "attribute-type" property definition. 214 * <p> 215 * Specifies the name or OID of an attribute type for which values 216 * should be checked to ensure that they are 7-bit clean. 217 * 218 * @return Returns the "attribute-type" property definition. 219 */ 220 public AttributeTypePropertyDefinition getAttributeTypePropertyDefinition() { 221 return PD_ATTRIBUTE_TYPE; 222 } 223 224 225 226 /** 227 * Get the "base-dn" property definition. 228 * <p> 229 * Specifies the base DN below which the checking is performed. 230 * <p> 231 * Any attempt to update a value for one of the configured 232 * attributes below this base DN must be 7-bit clean for the 233 * operation to be allowed. 234 * 235 * @return Returns the "base-dn" property definition. 236 */ 237 public DNPropertyDefinition getBaseDNPropertyDefinition() { 238 return PD_BASE_DN; 239 } 240 241 242 243 /** 244 * Get the "enabled" property definition. 245 * <p> 246 * Indicates whether the plug-in is enabled for use. 247 * 248 * @return Returns the "enabled" property definition. 249 */ 250 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 251 return PluginCfgDefn.getInstance().getEnabledPropertyDefinition(); 252 } 253 254 255 256 /** 257 * Get the "invoke-for-internal-operations" property definition. 258 * <p> 259 * Indicates whether the plug-in should be invoked for internal 260 * operations. 261 * <p> 262 * Any plug-in that can be invoked for internal operations must 263 * ensure that it does not create any new internal operatons that can 264 * cause the same plug-in to be re-invoked. 265 * 266 * @return Returns the "invoke-for-internal-operations" property definition. 267 */ 268 public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() { 269 return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition(); 270 } 271 272 273 274 /** 275 * Get the "java-class" property definition. 276 * <p> 277 * Specifies the fully-qualified name of the Java class that 278 * provides the plug-in implementation. 279 * 280 * @return Returns the "java-class" property definition. 281 */ 282 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 283 return PD_JAVA_CLASS; 284 } 285 286 287 288 /** 289 * Get the "plugin-type" property definition. 290 * <p> 291 * Specifies the set of plug-in types for the plug-in, which 292 * specifies the times at which the plug-in is invoked. 293 * 294 * @return Returns the "plugin-type" property definition. 295 */ 296 public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() { 297 return PD_PLUGIN_TYPE; 298 } 299 300 301 302 /** 303 * Managed object client implementation. 304 */ 305 private static class SevenBitCleanPluginCfgClientImpl implements 306 SevenBitCleanPluginCfgClient { 307 308 // Private implementation. 309 private ManagedObject<? extends SevenBitCleanPluginCfgClient> impl; 310 311 312 313 // Private constructor. 314 private SevenBitCleanPluginCfgClientImpl( 315 ManagedObject<? extends SevenBitCleanPluginCfgClient> impl) { 316 this.impl = impl; 317 } 318 319 320 321 /** 322 * {@inheritDoc} 323 */ 324 public SortedSet<AttributeType> getAttributeType() { 325 return impl.getPropertyValues(INSTANCE.getAttributeTypePropertyDefinition()); 326 } 327 328 329 330 /** 331 * {@inheritDoc} 332 */ 333 public void setAttributeType(Collection<AttributeType> values) { 334 impl.setPropertyValues(INSTANCE.getAttributeTypePropertyDefinition(), values); 335 } 336 337 338 339 /** 340 * {@inheritDoc} 341 */ 342 public SortedSet<DN> getBaseDN() { 343 return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 344 } 345 346 347 348 /** 349 * {@inheritDoc} 350 */ 351 public void setBaseDN(Collection<DN> values) { 352 impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values); 353 } 354 355 356 357 /** 358 * {@inheritDoc} 359 */ 360 public Boolean isEnabled() { 361 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 362 } 363 364 365 366 /** 367 * {@inheritDoc} 368 */ 369 public void setEnabled(boolean value) { 370 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 371 } 372 373 374 375 /** 376 * {@inheritDoc} 377 */ 378 public boolean isInvokeForInternalOperations() { 379 return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 380 } 381 382 383 384 /** 385 * {@inheritDoc} 386 */ 387 public void setInvokeForInternalOperations(Boolean value) { 388 impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value); 389 } 390 391 392 393 /** 394 * {@inheritDoc} 395 */ 396 public String getJavaClass() { 397 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 398 } 399 400 401 402 /** 403 * {@inheritDoc} 404 */ 405 public void setJavaClass(String value) { 406 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 407 } 408 409 410 411 /** 412 * {@inheritDoc} 413 */ 414 public SortedSet<PluginType> getPluginType() { 415 return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 416 } 417 418 419 420 /** 421 * {@inheritDoc} 422 */ 423 public void setPluginType(Collection<PluginType> values) { 424 impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values); 425 } 426 427 428 429 /** 430 * {@inheritDoc} 431 */ 432 public ManagedObjectDefinition<? extends SevenBitCleanPluginCfgClient, ? extends SevenBitCleanPluginCfg> definition() { 433 return INSTANCE; 434 } 435 436 437 438 /** 439 * {@inheritDoc} 440 */ 441 public PropertyProvider properties() { 442 return impl; 443 } 444 445 446 447 /** 448 * {@inheritDoc} 449 */ 450 public void commit() throws ManagedObjectAlreadyExistsException, 451 MissingMandatoryPropertiesException, ConcurrentModificationException, 452 OperationRejectedException, AuthorizationException, 453 CommunicationException { 454 impl.commit(); 455 } 456 457 458 459 /** {@inheritDoc} */ 460 public String toString() { 461 return impl.toString(); 462 } 463 } 464 465 466 467 /** 468 * Managed object server implementation. 469 */ 470 private static class SevenBitCleanPluginCfgServerImpl implements 471 SevenBitCleanPluginCfg { 472 473 // Private implementation. 474 private ServerManagedObject<? extends SevenBitCleanPluginCfg> impl; 475 476 // The value of the "attribute-type" property. 477 private final SortedSet<AttributeType> pAttributeType; 478 479 // The value of the "base-dn" property. 480 private final SortedSet<DN> pBaseDN; 481 482 // The value of the "enabled" property. 483 private final boolean pEnabled; 484 485 // The value of the "invoke-for-internal-operations" property. 486 private final boolean pInvokeForInternalOperations; 487 488 // The value of the "java-class" property. 489 private final String pJavaClass; 490 491 // The value of the "plugin-type" property. 492 private final SortedSet<PluginType> pPluginType; 493 494 495 496 // Private constructor. 497 private SevenBitCleanPluginCfgServerImpl(ServerManagedObject<? extends SevenBitCleanPluginCfg> impl) { 498 this.impl = impl; 499 this.pAttributeType = impl.getPropertyValues(INSTANCE.getAttributeTypePropertyDefinition()); 500 this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition()); 501 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 502 this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 503 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 504 this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 505 } 506 507 508 509 /** 510 * {@inheritDoc} 511 */ 512 public void addSevenBitCleanChangeListener( 513 ConfigurationChangeListener<SevenBitCleanPluginCfg> listener) { 514 impl.registerChangeListener(listener); 515 } 516 517 518 519 /** 520 * {@inheritDoc} 521 */ 522 public void removeSevenBitCleanChangeListener( 523 ConfigurationChangeListener<SevenBitCleanPluginCfg> listener) { 524 impl.deregisterChangeListener(listener); 525 } 526 /** 527 * {@inheritDoc} 528 */ 529 public void addChangeListener( 530 ConfigurationChangeListener<PluginCfg> listener) { 531 impl.registerChangeListener(listener); 532 } 533 534 535 536 /** 537 * {@inheritDoc} 538 */ 539 public void removeChangeListener( 540 ConfigurationChangeListener<PluginCfg> listener) { 541 impl.deregisterChangeListener(listener); 542 } 543 544 545 546 /** 547 * {@inheritDoc} 548 */ 549 public SortedSet<AttributeType> getAttributeType() { 550 return pAttributeType; 551 } 552 553 554 555 /** 556 * {@inheritDoc} 557 */ 558 public SortedSet<DN> getBaseDN() { 559 return pBaseDN; 560 } 561 562 563 564 /** 565 * {@inheritDoc} 566 */ 567 public boolean isEnabled() { 568 return pEnabled; 569 } 570 571 572 573 /** 574 * {@inheritDoc} 575 */ 576 public boolean isInvokeForInternalOperations() { 577 return pInvokeForInternalOperations; 578 } 579 580 581 582 /** 583 * {@inheritDoc} 584 */ 585 public String getJavaClass() { 586 return pJavaClass; 587 } 588 589 590 591 /** 592 * {@inheritDoc} 593 */ 594 public SortedSet<PluginType> getPluginType() { 595 return pPluginType; 596 } 597 598 599 600 /** 601 * {@inheritDoc} 602 */ 603 public Class<? extends SevenBitCleanPluginCfg> configurationClass() { 604 return SevenBitCleanPluginCfg.class; 605 } 606 607 608 609 /** 610 * {@inheritDoc} 611 */ 612 public DN dn() { 613 return impl.getDN(); 614 } 615 616 617 618 /** {@inheritDoc} */ 619 public String toString() { 620 return impl.toString(); 621 } 622 } 623}