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