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.forgerock.opendj.server.config.meta; 027 028 029 030import org.forgerock.opendj.config.AdministratorAction; 031import org.forgerock.opendj.config.AggregationPropertyDefinition; 032import org.forgerock.opendj.config.AliasDefaultBehaviorProvider; 033import org.forgerock.opendj.config.BooleanPropertyDefinition; 034import org.forgerock.opendj.config.ClassPropertyDefinition; 035import org.forgerock.opendj.config.client.ConcurrentModificationException; 036import org.forgerock.opendj.config.client.ManagedObject; 037import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 038import org.forgerock.opendj.config.client.OperationRejectedException; 039import org.forgerock.opendj.config.conditions.Conditions; 040import org.forgerock.opendj.config.DefaultBehaviorProvider; 041import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 042import org.forgerock.opendj.config.EnumPropertyDefinition; 043import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 044import org.forgerock.opendj.config.ManagedObjectDefinition; 045import org.forgerock.opendj.config.PropertyOption; 046import org.forgerock.opendj.config.PropertyProvider; 047import org.forgerock.opendj.config.server.ConfigurationChangeListener; 048import org.forgerock.opendj.config.server.ServerManagedObject; 049import org.forgerock.opendj.config.StringPropertyDefinition; 050import org.forgerock.opendj.config.Tag; 051import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; 052import org.forgerock.opendj.ldap.DN; 053import org.forgerock.opendj.ldap.LdapException; 054import org.forgerock.opendj.server.config.client.DigestMD5SASLMechanismHandlerCfgClient; 055import org.forgerock.opendj.server.config.client.IdentityMapperCfgClient; 056import org.forgerock.opendj.server.config.server.DigestMD5SASLMechanismHandlerCfg; 057import org.forgerock.opendj.server.config.server.IdentityMapperCfg; 058import org.forgerock.opendj.server.config.server.SASLMechanismHandlerCfg; 059 060 061 062/** 063 * An interface for querying the Digest MD5 SASL Mechanism Handler 064 * managed object definition meta information. 065 * <p> 066 * The DIGEST-MD5 SASL mechanism is used to perform all processing 067 * related to SASL DIGEST-MD5 authentication. 068 */ 069public final class DigestMD5SASLMechanismHandlerCfgDefn extends ManagedObjectDefinition<DigestMD5SASLMechanismHandlerCfgClient, DigestMD5SASLMechanismHandlerCfg> { 070 071 /** The singleton configuration definition instance. */ 072 private static final DigestMD5SASLMechanismHandlerCfgDefn INSTANCE = new DigestMD5SASLMechanismHandlerCfgDefn(); 073 074 075 076 /** 077 * Defines the set of permissable values for the "quality-of-protection" property. 078 * <p> 079 * The name of a property that specifies the quality of protection 080 * the server will support. 081 */ 082 public static enum QualityOfProtection { 083 084 /** 085 * Quality of protection equals authentication with integrity and 086 * confidentiality protection. 087 */ 088 CONFIDENTIALITY("confidentiality"), 089 090 091 092 /** 093 * Quality of protection equals authentication with integrity 094 * protection. 095 */ 096 INTEGRITY("integrity"), 097 098 099 100 /** 101 * QOP equals authentication only. 102 */ 103 NONE("none"); 104 105 106 107 /** String representation of the value. */ 108 private final String name; 109 110 111 112 /** Private constructor. */ 113 private QualityOfProtection(String name) { this.name = name; } 114 115 116 117 /** {@inheritDoc} */ 118 public String toString() { return name; } 119 120 } 121 122 123 124 /** The "identity-mapper" property definition. */ 125 private static final AggregationPropertyDefinition<IdentityMapperCfgClient, IdentityMapperCfg> PD_IDENTITY_MAPPER; 126 127 128 129 /** The "java-class" property definition. */ 130 private static final ClassPropertyDefinition PD_JAVA_CLASS; 131 132 133 134 /** The "quality-of-protection" property definition. */ 135 private static final EnumPropertyDefinition<QualityOfProtection> PD_QUALITY_OF_PROTECTION; 136 137 138 139 /** The "realm" property definition. */ 140 private static final StringPropertyDefinition PD_REALM; 141 142 143 144 /** The "server-fqdn" property definition. */ 145 private static final StringPropertyDefinition PD_SERVER_FQDN; 146 147 148 149 /** Build the "identity-mapper" property definition. */ 150 static { 151 AggregationPropertyDefinition.Builder<IdentityMapperCfgClient, IdentityMapperCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "identity-mapper"); 152 builder.setOption(PropertyOption.MANDATORY); 153 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "identity-mapper")); 154 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 155 builder.setParentPath("/"); 156 builder.setRelationDefinition("identity-mapper"); 157 builder.setTargetNeedsEnablingCondition(Conditions.contains("enabled", "true")); 158 builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true")); 159 PD_IDENTITY_MAPPER = builder.getInstance(); 160 INSTANCE.registerPropertyDefinition(PD_IDENTITY_MAPPER); 161 INSTANCE.registerConstraint(PD_IDENTITY_MAPPER.getSourceConstraint()); 162 } 163 164 165 166 /** Build the "java-class" property definition. */ 167 static { 168 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 169 builder.setOption(PropertyOption.MANDATORY); 170 builder.setOption(PropertyOption.ADVANCED); 171 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 172 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.DigestMD5SASLMechanismHandler"); 173 builder.setDefaultBehaviorProvider(provider); 174 builder.addInstanceOf("org.opends.server.api.SASLMechanismHandler"); 175 PD_JAVA_CLASS = builder.getInstance(); 176 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 177 } 178 179 180 181 /** Build the "quality-of-protection" property definition. */ 182 static { 183 EnumPropertyDefinition.Builder<QualityOfProtection> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "quality-of-protection"); 184 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "quality-of-protection")); 185 DefaultBehaviorProvider<QualityOfProtection> provider = new DefinedDefaultBehaviorProvider<QualityOfProtection>("none"); 186 builder.setDefaultBehaviorProvider(provider); 187 builder.setEnumClass(QualityOfProtection.class); 188 PD_QUALITY_OF_PROTECTION = builder.getInstance(); 189 INSTANCE.registerPropertyDefinition(PD_QUALITY_OF_PROTECTION); 190 } 191 192 193 194 /** Build the "realm" property definition. */ 195 static { 196 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "realm"); 197 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "realm")); 198 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "realm")); 199 builder.setPattern(".*", "STRING"); 200 PD_REALM = builder.getInstance(); 201 INSTANCE.registerPropertyDefinition(PD_REALM); 202 } 203 204 205 206 /** Build the "server-fqdn" property definition. */ 207 static { 208 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "server-fqdn"); 209 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "server-fqdn")); 210 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "server-fqdn")); 211 builder.setPattern(".*", "STRING"); 212 PD_SERVER_FQDN = builder.getInstance(); 213 INSTANCE.registerPropertyDefinition(PD_SERVER_FQDN); 214 } 215 216 217 218 // Register the tags associated with this managed object definition. 219 static { 220 INSTANCE.registerTag(Tag.valueOf("security")); 221 } 222 223 224 225 /** 226 * Get the Digest MD5 SASL Mechanism Handler configuration 227 * definition singleton. 228 * 229 * @return Returns the Digest MD5 SASL Mechanism Handler 230 * configuration definition singleton. 231 */ 232 public static DigestMD5SASLMechanismHandlerCfgDefn getInstance() { 233 return INSTANCE; 234 } 235 236 237 238 /** 239 * Private constructor. 240 */ 241 private DigestMD5SASLMechanismHandlerCfgDefn() { 242 super("digest-md5-sasl-mechanism-handler", SASLMechanismHandlerCfgDefn.getInstance()); 243 } 244 245 246 247 /** {@inheritDoc} */ 248 public DigestMD5SASLMechanismHandlerCfgClient createClientConfiguration( 249 ManagedObject<? extends DigestMD5SASLMechanismHandlerCfgClient> impl) { 250 return new DigestMD5SASLMechanismHandlerCfgClientImpl(impl); 251 } 252 253 254 255 /** {@inheritDoc} */ 256 public DigestMD5SASLMechanismHandlerCfg createServerConfiguration( 257 ServerManagedObject<? extends DigestMD5SASLMechanismHandlerCfg> impl) { 258 return new DigestMD5SASLMechanismHandlerCfgServerImpl(impl); 259 } 260 261 262 263 /** {@inheritDoc} */ 264 public Class<DigestMD5SASLMechanismHandlerCfg> getServerConfigurationClass() { 265 return DigestMD5SASLMechanismHandlerCfg.class; 266 } 267 268 269 270 /** 271 * Get the "enabled" property definition. 272 * <p> 273 * Indicates whether the SASL mechanism handler is enabled for use. 274 * 275 * @return Returns the "enabled" property definition. 276 */ 277 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 278 return SASLMechanismHandlerCfgDefn.getInstance().getEnabledPropertyDefinition(); 279 } 280 281 282 283 /** 284 * Get the "identity-mapper" property definition. 285 * <p> 286 * Specifies the name of the identity mapper that is to be used with 287 * this SASL mechanism handler to match the authentication or 288 * authorization ID included in the SASL bind request to the 289 * corresponding user in the directory. 290 * 291 * @return Returns the "identity-mapper" property definition. 292 */ 293 public AggregationPropertyDefinition<IdentityMapperCfgClient, IdentityMapperCfg> getIdentityMapperPropertyDefinition() { 294 return PD_IDENTITY_MAPPER; 295 } 296 297 298 299 /** 300 * Get the "java-class" property definition. 301 * <p> 302 * Specifies the fully-qualified name of the Java class that 303 * provides the SASL mechanism handler implementation. 304 * 305 * @return Returns the "java-class" property definition. 306 */ 307 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 308 return PD_JAVA_CLASS; 309 } 310 311 312 313 /** 314 * Get the "quality-of-protection" property definition. 315 * <p> 316 * The name of a property that specifies the quality of protection 317 * the server will support. 318 * 319 * @return Returns the "quality-of-protection" property definition. 320 */ 321 public EnumPropertyDefinition<QualityOfProtection> getQualityOfProtectionPropertyDefinition() { 322 return PD_QUALITY_OF_PROTECTION; 323 } 324 325 326 327 /** 328 * Get the "realm" property definition. 329 * <p> 330 * Specifies the realms that is to be used by the server for 331 * DIGEST-MD5 authentication. 332 * <p> 333 * If this value is not provided, then the server defaults to use 334 * the fully qualified hostname of the machine. 335 * 336 * @return Returns the "realm" property definition. 337 */ 338 public StringPropertyDefinition getRealmPropertyDefinition() { 339 return PD_REALM; 340 } 341 342 343 344 /** 345 * Get the "server-fqdn" property definition. 346 * <p> 347 * Specifies the DNS-resolvable fully-qualified domain name for the 348 * server that is used when validating the digest-uri parameter 349 * during the authentication process. 350 * <p> 351 * If this configuration attribute is present, then the server 352 * expects that clients use a digest-uri equal to "ldap/" followed by 353 * the value of this attribute. For example, if the attribute has a 354 * value of "directory.example.com", then the server expects clients 355 * to use a digest-uri of "ldap/directory.example.com". If no value 356 * is provided, then the server does not attempt to validate the 357 * digest-uri provided by the client and accepts any value. 358 * 359 * @return Returns the "server-fqdn" property definition. 360 */ 361 public StringPropertyDefinition getServerFqdnPropertyDefinition() { 362 return PD_SERVER_FQDN; 363 } 364 365 366 367 /** 368 * Managed object client implementation. 369 */ 370 private static class DigestMD5SASLMechanismHandlerCfgClientImpl implements 371 DigestMD5SASLMechanismHandlerCfgClient { 372 373 /** Private implementation. */ 374 private ManagedObject<? extends DigestMD5SASLMechanismHandlerCfgClient> impl; 375 376 377 378 /** Private constructor. */ 379 private DigestMD5SASLMechanismHandlerCfgClientImpl( 380 ManagedObject<? extends DigestMD5SASLMechanismHandlerCfgClient> impl) { 381 this.impl = impl; 382 } 383 384 385 386 /** {@inheritDoc} */ 387 public Boolean isEnabled() { 388 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 389 } 390 391 392 393 /** {@inheritDoc} */ 394 public void setEnabled(boolean value) { 395 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 396 } 397 398 399 400 /** {@inheritDoc} */ 401 public String getIdentityMapper() { 402 return impl.getPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition()); 403 } 404 405 406 407 /** {@inheritDoc} */ 408 public void setIdentityMapper(String value) { 409 impl.setPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition(), value); 410 } 411 412 413 414 /** {@inheritDoc} */ 415 public String getJavaClass() { 416 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 417 } 418 419 420 421 /** {@inheritDoc} */ 422 public void setJavaClass(String value) { 423 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 424 } 425 426 427 428 /** {@inheritDoc} */ 429 public QualityOfProtection getQualityOfProtection() { 430 return impl.getPropertyValue(INSTANCE.getQualityOfProtectionPropertyDefinition()); 431 } 432 433 434 435 /** {@inheritDoc} */ 436 public void setQualityOfProtection(QualityOfProtection value) { 437 impl.setPropertyValue(INSTANCE.getQualityOfProtectionPropertyDefinition(), value); 438 } 439 440 441 442 /** {@inheritDoc} */ 443 public String getRealm() { 444 return impl.getPropertyValue(INSTANCE.getRealmPropertyDefinition()); 445 } 446 447 448 449 /** {@inheritDoc} */ 450 public void setRealm(String value) { 451 impl.setPropertyValue(INSTANCE.getRealmPropertyDefinition(), value); 452 } 453 454 455 456 /** {@inheritDoc} */ 457 public String getServerFqdn() { 458 return impl.getPropertyValue(INSTANCE.getServerFqdnPropertyDefinition()); 459 } 460 461 462 463 /** {@inheritDoc} */ 464 public void setServerFqdn(String value) { 465 impl.setPropertyValue(INSTANCE.getServerFqdnPropertyDefinition(), value); 466 } 467 468 469 470 /** {@inheritDoc} */ 471 public ManagedObjectDefinition<? extends DigestMD5SASLMechanismHandlerCfgClient, ? extends DigestMD5SASLMechanismHandlerCfg> definition() { 472 return INSTANCE; 473 } 474 475 476 477 /** {@inheritDoc} */ 478 public PropertyProvider properties() { 479 return impl; 480 } 481 482 483 484 /** {@inheritDoc} */ 485 public void commit() throws ManagedObjectAlreadyExistsException, 486 MissingMandatoryPropertiesException, ConcurrentModificationException, 487 OperationRejectedException, LdapException { 488 impl.commit(); 489 } 490 491 492 493 /** {@inheritDoc} */ 494 public String toString() { 495 return impl.toString(); 496 } 497 } 498 499 500 501 /** 502 * Managed object server implementation. 503 */ 504 private static class DigestMD5SASLMechanismHandlerCfgServerImpl implements 505 DigestMD5SASLMechanismHandlerCfg { 506 507 /** Private implementation. */ 508 private ServerManagedObject<? extends DigestMD5SASLMechanismHandlerCfg> impl; 509 510 /** The value of the "enabled" property. */ 511 private final boolean pEnabled; 512 513 /** The value of the "identity-mapper" property. */ 514 private final String pIdentityMapper; 515 516 /** The value of the "java-class" property. */ 517 private final String pJavaClass; 518 519 /** The value of the "quality-of-protection" property. */ 520 private final QualityOfProtection pQualityOfProtection; 521 522 /** The value of the "realm" property. */ 523 private final String pRealm; 524 525 /** The value of the "server-fqdn" property. */ 526 private final String pServerFqdn; 527 528 529 530 /** Private constructor. */ 531 private DigestMD5SASLMechanismHandlerCfgServerImpl(ServerManagedObject<? extends DigestMD5SASLMechanismHandlerCfg> impl) { 532 this.impl = impl; 533 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 534 this.pIdentityMapper = impl.getPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition()); 535 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 536 this.pQualityOfProtection = impl.getPropertyValue(INSTANCE.getQualityOfProtectionPropertyDefinition()); 537 this.pRealm = impl.getPropertyValue(INSTANCE.getRealmPropertyDefinition()); 538 this.pServerFqdn = impl.getPropertyValue(INSTANCE.getServerFqdnPropertyDefinition()); 539 } 540 541 542 543 /** {@inheritDoc} */ 544 public void addDigestMD5ChangeListener( 545 ConfigurationChangeListener<DigestMD5SASLMechanismHandlerCfg> listener) { 546 impl.registerChangeListener(listener); 547 } 548 549 550 551 /** {@inheritDoc} */ 552 public void removeDigestMD5ChangeListener( 553 ConfigurationChangeListener<DigestMD5SASLMechanismHandlerCfg> listener) { 554 impl.deregisterChangeListener(listener); 555 } 556 /** {@inheritDoc} */ 557 public void addChangeListener( 558 ConfigurationChangeListener<SASLMechanismHandlerCfg> listener) { 559 impl.registerChangeListener(listener); 560 } 561 562 563 564 /** {@inheritDoc} */ 565 public void removeChangeListener( 566 ConfigurationChangeListener<SASLMechanismHandlerCfg> listener) { 567 impl.deregisterChangeListener(listener); 568 } 569 570 571 572 /** {@inheritDoc} */ 573 public boolean isEnabled() { 574 return pEnabled; 575 } 576 577 578 579 /** {@inheritDoc} */ 580 public String getIdentityMapper() { 581 return pIdentityMapper; 582 } 583 584 585 586 /** 587 * {@inheritDoc} 588 */ 589 public DN getIdentityMapperDN() { 590 String value = getIdentityMapper(); 591 if (value == null) return null; 592 return INSTANCE.getIdentityMapperPropertyDefinition().getChildDN(value); 593 } 594 595 596 597 /** {@inheritDoc} */ 598 public String getJavaClass() { 599 return pJavaClass; 600 } 601 602 603 604 /** {@inheritDoc} */ 605 public QualityOfProtection getQualityOfProtection() { 606 return pQualityOfProtection; 607 } 608 609 610 611 /** {@inheritDoc} */ 612 public String getRealm() { 613 return pRealm; 614 } 615 616 617 618 /** {@inheritDoc} */ 619 public String getServerFqdn() { 620 return pServerFqdn; 621 } 622 623 624 625 /** {@inheritDoc} */ 626 public Class<? extends DigestMD5SASLMechanismHandlerCfg> configurationClass() { 627 return DigestMD5SASLMechanismHandlerCfg.class; 628 } 629 630 631 632 /** {@inheritDoc} */ 633 public DN dn() { 634 return impl.getDN(); 635 } 636 637 638 639 /** {@inheritDoc} */ 640 public String toString() { 641 return impl.toString(); 642 } 643 } 644}