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.BooleanPropertyDefinition; 034import org.opends.server.admin.ClassPropertyDefinition; 035import org.opends.server.admin.client.AuthorizationException; 036import org.opends.server.admin.client.CommunicationException; 037import org.opends.server.admin.client.ConcurrentModificationException; 038import org.opends.server.admin.client.ManagedObject; 039import org.opends.server.admin.client.MissingMandatoryPropertiesException; 040import org.opends.server.admin.client.OperationRejectedException; 041import org.opends.server.admin.DefaultBehaviorProvider; 042import org.opends.server.admin.DefinedDefaultBehaviorProvider; 043import org.opends.server.admin.ManagedObjectAlreadyExistsException; 044import org.opends.server.admin.ManagedObjectDefinition; 045import org.opends.server.admin.PropertyOption; 046import org.opends.server.admin.PropertyProvider; 047import org.opends.server.admin.server.ConfigurationChangeListener; 048import org.opends.server.admin.server.ServerManagedObject; 049import org.opends.server.admin.std.client.CoreSchemaCfgClient; 050import org.opends.server.admin.std.server.CoreSchemaCfg; 051import org.opends.server.admin.std.server.SchemaProviderCfg; 052import org.opends.server.admin.StringPropertyDefinition; 053import org.opends.server.types.DN; 054 055 056 057/** 058 * An interface for querying the Core Schema managed object definition 059 * meta information. 060 * <p> 061 * Core Schema define the core schema elements to load. 062 */ 063public final class CoreSchemaCfgDefn extends ManagedObjectDefinition<CoreSchemaCfgClient, CoreSchemaCfg> { 064 065 // The singleton configuration definition instance. 066 private static final CoreSchemaCfgDefn INSTANCE = new CoreSchemaCfgDefn(); 067 068 069 070 // The "allow-zero-length-values-directory-string" property definition. 071 private static final BooleanPropertyDefinition PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING; 072 073 074 075 // The "disabled-matching-rule" property definition. 076 private static final StringPropertyDefinition PD_DISABLED_MATCHING_RULE; 077 078 079 080 // The "disabled-syntax" property definition. 081 private static final StringPropertyDefinition PD_DISABLED_SYNTAX; 082 083 084 085 // The "java-class" property definition. 086 private static final ClassPropertyDefinition PD_JAVA_CLASS; 087 088 089 090 // The "strict-format-country-string" property definition. 091 private static final BooleanPropertyDefinition PD_STRICT_FORMAT_COUNTRY_STRING; 092 093 094 095 // The "strip-syntax-min-upper-bound-attribute-type-description" property definition. 096 private static final BooleanPropertyDefinition PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION; 097 098 099 100 // Build the "allow-zero-length-values-directory-string" property definition. 101 static { 102 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "allow-zero-length-values-directory-string"); 103 builder.setOption(PropertyOption.ADVANCED); 104 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "allow-zero-length-values-directory-string")); 105 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 106 builder.setDefaultBehaviorProvider(provider); 107 PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING = builder.getInstance(); 108 INSTANCE.registerPropertyDefinition(PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING); 109 } 110 111 112 113 // Build the "disabled-matching-rule" property definition. 114 static { 115 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "disabled-matching-rule"); 116 builder.setOption(PropertyOption.MULTI_VALUED); 117 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "disabled-matching-rule")); 118 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("NONE"); 119 builder.setDefaultBehaviorProvider(provider); 120 builder.setPattern("^([0-9.]+\\d|NONE)$", "OID"); 121 PD_DISABLED_MATCHING_RULE = builder.getInstance(); 122 INSTANCE.registerPropertyDefinition(PD_DISABLED_MATCHING_RULE); 123 } 124 125 126 127 // Build the "disabled-syntax" property definition. 128 static { 129 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "disabled-syntax"); 130 builder.setOption(PropertyOption.MULTI_VALUED); 131 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "disabled-syntax")); 132 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("NONE"); 133 builder.setDefaultBehaviorProvider(provider); 134 builder.setPattern("^([0-9.]+\\d|NONE)$", "OID"); 135 PD_DISABLED_SYNTAX = builder.getInstance(); 136 INSTANCE.registerPropertyDefinition(PD_DISABLED_SYNTAX); 137 } 138 139 140 141 // Build the "java-class" property definition. 142 static { 143 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 144 builder.setOption(PropertyOption.MANDATORY); 145 builder.setOption(PropertyOption.ADVANCED); 146 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 147 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.CoreSchemaProvider"); 148 builder.setDefaultBehaviorProvider(provider); 149 builder.addInstanceOf("org.opends.server.schema.SchemaProvider"); 150 PD_JAVA_CLASS = builder.getInstance(); 151 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 152 } 153 154 155 156 // Build the "strict-format-country-string" property definition. 157 static { 158 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strict-format-country-string"); 159 builder.setOption(PropertyOption.ADVANCED); 160 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strict-format-country-string")); 161 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("true"); 162 builder.setDefaultBehaviorProvider(provider); 163 PD_STRICT_FORMAT_COUNTRY_STRING = builder.getInstance(); 164 INSTANCE.registerPropertyDefinition(PD_STRICT_FORMAT_COUNTRY_STRING); 165 } 166 167 168 169 // Build the "strip-syntax-min-upper-bound-attribute-type-description" property definition. 170 static { 171 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strip-syntax-min-upper-bound-attribute-type-description"); 172 builder.setOption(PropertyOption.ADVANCED); 173 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strip-syntax-min-upper-bound-attribute-type-description")); 174 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 175 builder.setDefaultBehaviorProvider(provider); 176 PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION = builder.getInstance(); 177 INSTANCE.registerPropertyDefinition(PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION); 178 } 179 180 181 182 /** 183 * Get the Core Schema configuration definition singleton. 184 * 185 * @return Returns the Core Schema configuration definition 186 * singleton. 187 */ 188 public static CoreSchemaCfgDefn getInstance() { 189 return INSTANCE; 190 } 191 192 193 194 /** 195 * Private constructor. 196 */ 197 private CoreSchemaCfgDefn() { 198 super("core-schema", SchemaProviderCfgDefn.getInstance()); 199 } 200 201 202 203 /** 204 * {@inheritDoc} 205 */ 206 public CoreSchemaCfgClient createClientConfiguration( 207 ManagedObject<? extends CoreSchemaCfgClient> impl) { 208 return new CoreSchemaCfgClientImpl(impl); 209 } 210 211 212 213 /** 214 * {@inheritDoc} 215 */ 216 public CoreSchemaCfg createServerConfiguration( 217 ServerManagedObject<? extends CoreSchemaCfg> impl) { 218 return new CoreSchemaCfgServerImpl(impl); 219 } 220 221 222 223 /** 224 * {@inheritDoc} 225 */ 226 public Class<CoreSchemaCfg> getServerConfigurationClass() { 227 return CoreSchemaCfg.class; 228 } 229 230 231 232 /** 233 * Get the "allow-zero-length-values-directory-string" property definition. 234 * <p> 235 * Indicates whether zero-length (that is, an empty string) values 236 * are allowed for directory string. 237 * <p> 238 * This is technically not allowed by the revised LDAPv3 239 * specification, but some environments may require it for backward 240 * compatibility with servers that do allow it. 241 * 242 * @return Returns the "allow-zero-length-values-directory-string" property definition. 243 */ 244 public BooleanPropertyDefinition getAllowZeroLengthValuesDirectoryStringPropertyDefinition() { 245 return PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING; 246 } 247 248 249 250 /** 251 * Get the "disabled-matching-rule" property definition. 252 * <p> 253 * The set of disabled matching rules. 254 * <p> 255 * Matching rules must be specified using the syntax: OID, or use 256 * the default value 'NONE' to specify no value. 257 * 258 * @return Returns the "disabled-matching-rule" property definition. 259 */ 260 public StringPropertyDefinition getDisabledMatchingRulePropertyDefinition() { 261 return PD_DISABLED_MATCHING_RULE; 262 } 263 264 265 266 /** 267 * Get the "disabled-syntax" property definition. 268 * <p> 269 * The set of disabled syntaxes. 270 * <p> 271 * Syntaxes must be specified using the syntax: OID, or use the 272 * default value 'NONE' to specify no value. 273 * 274 * @return Returns the "disabled-syntax" property definition. 275 */ 276 public StringPropertyDefinition getDisabledSyntaxPropertyDefinition() { 277 return PD_DISABLED_SYNTAX; 278 } 279 280 281 282 /** 283 * Get the "enabled" property definition. 284 * <p> 285 * Indicates whether the Core Schema is enabled for use. 286 * 287 * @return Returns the "enabled" property definition. 288 */ 289 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 290 return SchemaProviderCfgDefn.getInstance().getEnabledPropertyDefinition(); 291 } 292 293 294 295 /** 296 * Get the "java-class" property definition. 297 * <p> 298 * Specifies the fully-qualified name of the Java class that 299 * provides the Core Schema implementation. 300 * 301 * @return Returns the "java-class" property definition. 302 */ 303 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 304 return PD_JAVA_CLASS; 305 } 306 307 308 309 /** 310 * Get the "strict-format-country-string" property definition. 311 * <p> 312 * Indicates whether or not country code values are required to 313 * strictly comply with the standard definition for this syntax. 314 * <p> 315 * When set to false, country codes will not be validated and, as a 316 * result any string containing 2 characters will be acceptable. 317 * 318 * @return Returns the "strict-format-country-string" property definition. 319 */ 320 public BooleanPropertyDefinition getStrictFormatCountryStringPropertyDefinition() { 321 return PD_STRICT_FORMAT_COUNTRY_STRING; 322 } 323 324 325 326 /** 327 * Get the "strip-syntax-min-upper-bound-attribute-type-description" property definition. 328 * <p> 329 * Indicates whether the suggested minimum upper bound appended to 330 * an attribute's syntax OID in it's schema definition Attribute Type 331 * Description is stripped off. 332 * <p> 333 * When retrieving the server's schema, some APIs (JNDI) fail in 334 * their syntax lookup methods, because they do not parse this value 335 * correctly. This configuration option allows the server to be 336 * configured to provide schema definitions these APIs can parse 337 * correctly. 338 * 339 * @return Returns the "strip-syntax-min-upper-bound-attribute-type-description" property definition. 340 */ 341 public BooleanPropertyDefinition getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition() { 342 return PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION; 343 } 344 345 346 347 /** 348 * Managed object client implementation. 349 */ 350 private static class CoreSchemaCfgClientImpl implements 351 CoreSchemaCfgClient { 352 353 // Private implementation. 354 private ManagedObject<? extends CoreSchemaCfgClient> impl; 355 356 357 358 // Private constructor. 359 private CoreSchemaCfgClientImpl( 360 ManagedObject<? extends CoreSchemaCfgClient> impl) { 361 this.impl = impl; 362 } 363 364 365 366 /** 367 * {@inheritDoc} 368 */ 369 public boolean isAllowZeroLengthValuesDirectoryString() { 370 return impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesDirectoryStringPropertyDefinition()); 371 } 372 373 374 375 /** 376 * {@inheritDoc} 377 */ 378 public void setAllowZeroLengthValuesDirectoryString(Boolean value) { 379 impl.setPropertyValue(INSTANCE.getAllowZeroLengthValuesDirectoryStringPropertyDefinition(), value); 380 } 381 382 383 384 /** 385 * {@inheritDoc} 386 */ 387 public SortedSet<String> getDisabledMatchingRule() { 388 return impl.getPropertyValues(INSTANCE.getDisabledMatchingRulePropertyDefinition()); 389 } 390 391 392 393 /** 394 * {@inheritDoc} 395 */ 396 public void setDisabledMatchingRule(Collection<String> values) { 397 impl.setPropertyValues(INSTANCE.getDisabledMatchingRulePropertyDefinition(), values); 398 } 399 400 401 402 /** 403 * {@inheritDoc} 404 */ 405 public SortedSet<String> getDisabledSyntax() { 406 return impl.getPropertyValues(INSTANCE.getDisabledSyntaxPropertyDefinition()); 407 } 408 409 410 411 /** 412 * {@inheritDoc} 413 */ 414 public void setDisabledSyntax(Collection<String> values) { 415 impl.setPropertyValues(INSTANCE.getDisabledSyntaxPropertyDefinition(), values); 416 } 417 418 419 420 /** 421 * {@inheritDoc} 422 */ 423 public Boolean isEnabled() { 424 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 425 } 426 427 428 429 /** 430 * {@inheritDoc} 431 */ 432 public void setEnabled(boolean value) { 433 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 434 } 435 436 437 438 /** 439 * {@inheritDoc} 440 */ 441 public String getJavaClass() { 442 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 443 } 444 445 446 447 /** 448 * {@inheritDoc} 449 */ 450 public void setJavaClass(String value) { 451 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 452 } 453 454 455 456 /** 457 * {@inheritDoc} 458 */ 459 public boolean isStrictFormatCountryString() { 460 return impl.getPropertyValue(INSTANCE.getStrictFormatCountryStringPropertyDefinition()); 461 } 462 463 464 465 /** 466 * {@inheritDoc} 467 */ 468 public void setStrictFormatCountryString(Boolean value) { 469 impl.setPropertyValue(INSTANCE.getStrictFormatCountryStringPropertyDefinition(), value); 470 } 471 472 473 474 /** 475 * {@inheritDoc} 476 */ 477 public boolean isStripSyntaxMinUpperBoundAttributeTypeDescription() { 478 return impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition()); 479 } 480 481 482 483 /** 484 * {@inheritDoc} 485 */ 486 public void setStripSyntaxMinUpperBoundAttributeTypeDescription(Boolean value) { 487 impl.setPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition(), value); 488 } 489 490 491 492 /** 493 * {@inheritDoc} 494 */ 495 public ManagedObjectDefinition<? extends CoreSchemaCfgClient, ? extends CoreSchemaCfg> definition() { 496 return INSTANCE; 497 } 498 499 500 501 /** 502 * {@inheritDoc} 503 */ 504 public PropertyProvider properties() { 505 return impl; 506 } 507 508 509 510 /** 511 * {@inheritDoc} 512 */ 513 public void commit() throws ManagedObjectAlreadyExistsException, 514 MissingMandatoryPropertiesException, ConcurrentModificationException, 515 OperationRejectedException, AuthorizationException, 516 CommunicationException { 517 impl.commit(); 518 } 519 520 } 521 522 523 524 /** 525 * Managed object server implementation. 526 */ 527 private static class CoreSchemaCfgServerImpl implements 528 CoreSchemaCfg { 529 530 // Private implementation. 531 private ServerManagedObject<? extends CoreSchemaCfg> impl; 532 533 // The value of the "allow-zero-length-values-directory-string" property. 534 private final boolean pAllowZeroLengthValuesDirectoryString; 535 536 // The value of the "disabled-matching-rule" property. 537 private final SortedSet<String> pDisabledMatchingRule; 538 539 // The value of the "disabled-syntax" property. 540 private final SortedSet<String> pDisabledSyntax; 541 542 // The value of the "enabled" property. 543 private final boolean pEnabled; 544 545 // The value of the "java-class" property. 546 private final String pJavaClass; 547 548 // The value of the "strict-format-country-string" property. 549 private final boolean pStrictFormatCountryString; 550 551 // The value of the "strip-syntax-min-upper-bound-attribute-type-description" property. 552 private final boolean pStripSyntaxMinUpperBoundAttributeTypeDescription; 553 554 555 556 // Private constructor. 557 private CoreSchemaCfgServerImpl(ServerManagedObject<? extends CoreSchemaCfg> impl) { 558 this.impl = impl; 559 this.pAllowZeroLengthValuesDirectoryString = impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesDirectoryStringPropertyDefinition()); 560 this.pDisabledMatchingRule = impl.getPropertyValues(INSTANCE.getDisabledMatchingRulePropertyDefinition()); 561 this.pDisabledSyntax = impl.getPropertyValues(INSTANCE.getDisabledSyntaxPropertyDefinition()); 562 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 563 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 564 this.pStrictFormatCountryString = impl.getPropertyValue(INSTANCE.getStrictFormatCountryStringPropertyDefinition()); 565 this.pStripSyntaxMinUpperBoundAttributeTypeDescription = impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition()); 566 } 567 568 569 570 /** 571 * {@inheritDoc} 572 */ 573 public void addCoreSchemaChangeListener( 574 ConfigurationChangeListener<CoreSchemaCfg> listener) { 575 impl.registerChangeListener(listener); 576 } 577 578 579 580 /** 581 * {@inheritDoc} 582 */ 583 public void removeCoreSchemaChangeListener( 584 ConfigurationChangeListener<CoreSchemaCfg> listener) { 585 impl.deregisterChangeListener(listener); 586 } 587 /** 588 * {@inheritDoc} 589 */ 590 public void addChangeListener( 591 ConfigurationChangeListener<SchemaProviderCfg> listener) { 592 impl.registerChangeListener(listener); 593 } 594 595 596 597 /** 598 * {@inheritDoc} 599 */ 600 public void removeChangeListener( 601 ConfigurationChangeListener<SchemaProviderCfg> listener) { 602 impl.deregisterChangeListener(listener); 603 } 604 605 606 607 /** 608 * {@inheritDoc} 609 */ 610 public boolean isAllowZeroLengthValuesDirectoryString() { 611 return pAllowZeroLengthValuesDirectoryString; 612 } 613 614 615 616 /** 617 * {@inheritDoc} 618 */ 619 public SortedSet<String> getDisabledMatchingRule() { 620 return pDisabledMatchingRule; 621 } 622 623 624 625 /** 626 * {@inheritDoc} 627 */ 628 public SortedSet<String> getDisabledSyntax() { 629 return pDisabledSyntax; 630 } 631 632 633 634 /** 635 * {@inheritDoc} 636 */ 637 public boolean isEnabled() { 638 return pEnabled; 639 } 640 641 642 643 /** 644 * {@inheritDoc} 645 */ 646 public String getJavaClass() { 647 return pJavaClass; 648 } 649 650 651 652 /** 653 * {@inheritDoc} 654 */ 655 public boolean isStrictFormatCountryString() { 656 return pStrictFormatCountryString; 657 } 658 659 660 661 /** 662 * {@inheritDoc} 663 */ 664 public boolean isStripSyntaxMinUpperBoundAttributeTypeDescription() { 665 return pStripSyntaxMinUpperBoundAttributeTypeDescription; 666 } 667 668 669 670 /** 671 * {@inheritDoc} 672 */ 673 public Class<? extends CoreSchemaCfg> configurationClass() { 674 return CoreSchemaCfg.class; 675 } 676 677 678 679 /** 680 * {@inheritDoc} 681 */ 682 public DN dn() { 683 return impl.getDN(); 684 } 685 686 } 687}