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