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