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.net.InetAddress; 031import java.util.Collection; 032import java.util.SortedSet; 033import org.opends.server.admin.AdministratorAction; 034import org.opends.server.admin.AggregationPropertyDefinition; 035import org.opends.server.admin.AliasDefaultBehaviorProvider; 036import org.opends.server.admin.client.AuthorizationException; 037import org.opends.server.admin.client.CommunicationException; 038import org.opends.server.admin.client.ConcurrentModificationException; 039import org.opends.server.admin.client.ManagedObject; 040import org.opends.server.admin.client.MissingMandatoryPropertiesException; 041import org.opends.server.admin.client.OperationRejectedException; 042import org.opends.server.admin.condition.Conditions; 043import org.opends.server.admin.DefaultBehaviorProvider; 044import org.opends.server.admin.DefinedDefaultBehaviorProvider; 045import org.opends.server.admin.IntegerPropertyDefinition; 046import org.opends.server.admin.IPAddressPropertyDefinition; 047import org.opends.server.admin.ManagedObjectAlreadyExistsException; 048import org.opends.server.admin.ManagedObjectDefinition; 049import org.opends.server.admin.PropertyOption; 050import org.opends.server.admin.PropertyProvider; 051import org.opends.server.admin.server.ConfigurationChangeListener; 052import org.opends.server.admin.server.ServerManagedObject; 053import org.opends.server.admin.std.client.AdministrationConnectorCfgClient; 054import org.opends.server.admin.std.client.KeyManagerProviderCfgClient; 055import org.opends.server.admin.std.client.TrustManagerProviderCfgClient; 056import org.opends.server.admin.std.server.AdministrationConnectorCfg; 057import org.opends.server.admin.std.server.KeyManagerProviderCfg; 058import org.opends.server.admin.std.server.TrustManagerProviderCfg; 059import org.opends.server.admin.StringPropertyDefinition; 060import org.opends.server.admin.Tag; 061import org.opends.server.admin.TopCfgDefn; 062import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 063import org.opends.server.types.DN; 064 065 066 067/** 068 * An interface for querying the Administration Connector managed 069 * object definition meta information. 070 * <p> 071 * The Administration Connector is used to interact with 072 * administration tools using LDAP. 073 */ 074public final class AdministrationConnectorCfgDefn extends ManagedObjectDefinition<AdministrationConnectorCfgClient, AdministrationConnectorCfg> { 075 076 // The singleton configuration definition instance. 077 private static final AdministrationConnectorCfgDefn INSTANCE = new AdministrationConnectorCfgDefn(); 078 079 080 081 // The "key-manager-provider" property definition. 082 private static final AggregationPropertyDefinition<KeyManagerProviderCfgClient, KeyManagerProviderCfg> PD_KEY_MANAGER_PROVIDER; 083 084 085 086 // The "listen-address" property definition. 087 private static final IPAddressPropertyDefinition PD_LISTEN_ADDRESS; 088 089 090 091 // The "listen-port" property definition. 092 private static final IntegerPropertyDefinition PD_LISTEN_PORT; 093 094 095 096 // The "ssl-cert-nickname" property definition. 097 private static final StringPropertyDefinition PD_SSL_CERT_NICKNAME; 098 099 100 101 // The "ssl-cipher-suite" property definition. 102 private static final StringPropertyDefinition PD_SSL_CIPHER_SUITE; 103 104 105 106 // The "ssl-protocol" property definition. 107 private static final StringPropertyDefinition PD_SSL_PROTOCOL; 108 109 110 111 // The "trust-manager-provider" property definition. 112 private static final AggregationPropertyDefinition<TrustManagerProviderCfgClient, TrustManagerProviderCfg> PD_TRUST_MANAGER_PROVIDER; 113 114 115 116 // Build the "key-manager-provider" property definition. 117 static { 118 AggregationPropertyDefinition.Builder<KeyManagerProviderCfgClient, KeyManagerProviderCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "key-manager-provider"); 119 builder.setOption(PropertyOption.MANDATORY); 120 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.SERVER_RESTART, INSTANCE, "key-manager-provider")); 121 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 122 builder.setParentPath("/"); 123 builder.setRelationDefinition("key-manager-provider"); 124 builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true")); 125 PD_KEY_MANAGER_PROVIDER = builder.getInstance(); 126 INSTANCE.registerPropertyDefinition(PD_KEY_MANAGER_PROVIDER); 127 INSTANCE.registerConstraint(PD_KEY_MANAGER_PROVIDER.getSourceConstraint()); 128 } 129 130 131 132 // Build the "listen-address" property definition. 133 static { 134 IPAddressPropertyDefinition.Builder builder = IPAddressPropertyDefinition.createBuilder(INSTANCE, "listen-address"); 135 builder.setOption(PropertyOption.MULTI_VALUED); 136 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.SERVER_RESTART, INSTANCE, "listen-address")); 137 DefaultBehaviorProvider<InetAddress> provider = new DefinedDefaultBehaviorProvider<InetAddress>("0.0.0.0"); 138 builder.setDefaultBehaviorProvider(provider); 139 PD_LISTEN_ADDRESS = builder.getInstance(); 140 INSTANCE.registerPropertyDefinition(PD_LISTEN_ADDRESS); 141 } 142 143 144 145 // Build the "listen-port" property definition. 146 static { 147 IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition.createBuilder(INSTANCE, "listen-port"); 148 builder.setOption(PropertyOption.MANDATORY); 149 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "listen-port")); 150 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Integer>()); 151 builder.setUpperLimit(65535); 152 builder.setLowerLimit(1); 153 PD_LISTEN_PORT = builder.getInstance(); 154 INSTANCE.registerPropertyDefinition(PD_LISTEN_PORT); 155 } 156 157 158 159 // Build the "ssl-cert-nickname" property definition. 160 static { 161 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "ssl-cert-nickname"); 162 builder.setOption(PropertyOption.MULTI_VALUED); 163 builder.setOption(PropertyOption.MANDATORY); 164 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.SERVER_RESTART, INSTANCE, "ssl-cert-nickname")); 165 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "ssl-cert-nickname")); 166 PD_SSL_CERT_NICKNAME = builder.getInstance(); 167 INSTANCE.registerPropertyDefinition(PD_SSL_CERT_NICKNAME); 168 } 169 170 171 172 // Build the "ssl-cipher-suite" property definition. 173 static { 174 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "ssl-cipher-suite"); 175 builder.setOption(PropertyOption.MULTI_VALUED); 176 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "ssl-cipher-suite")); 177 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "ssl-cipher-suite")); 178 PD_SSL_CIPHER_SUITE = builder.getInstance(); 179 INSTANCE.registerPropertyDefinition(PD_SSL_CIPHER_SUITE); 180 } 181 182 183 184 // Build the "ssl-protocol" property definition. 185 static { 186 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "ssl-protocol"); 187 builder.setOption(PropertyOption.MULTI_VALUED); 188 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "ssl-protocol")); 189 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "ssl-protocol")); 190 PD_SSL_PROTOCOL = builder.getInstance(); 191 INSTANCE.registerPropertyDefinition(PD_SSL_PROTOCOL); 192 } 193 194 195 196 // Build the "trust-manager-provider" property definition. 197 static { 198 AggregationPropertyDefinition.Builder<TrustManagerProviderCfgClient, TrustManagerProviderCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "trust-manager-provider"); 199 builder.setOption(PropertyOption.MANDATORY); 200 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.SERVER_RESTART, INSTANCE, "trust-manager-provider")); 201 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 202 builder.setParentPath("/"); 203 builder.setRelationDefinition("trust-manager-provider"); 204 builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true")); 205 PD_TRUST_MANAGER_PROVIDER = builder.getInstance(); 206 INSTANCE.registerPropertyDefinition(PD_TRUST_MANAGER_PROVIDER); 207 INSTANCE.registerConstraint(PD_TRUST_MANAGER_PROVIDER.getSourceConstraint()); 208 } 209 210 211 212 // Register the tags associated with this managed object definition. 213 static { 214 INSTANCE.registerTag(Tag.valueOf("core-server")); 215 } 216 217 218 219 /** 220 * Get the Administration Connector configuration definition 221 * singleton. 222 * 223 * @return Returns the Administration Connector configuration 224 * definition singleton. 225 */ 226 public static AdministrationConnectorCfgDefn getInstance() { 227 return INSTANCE; 228 } 229 230 231 232 /** 233 * Private constructor. 234 */ 235 private AdministrationConnectorCfgDefn() { 236 super("administration-connector", TopCfgDefn.getInstance()); 237 } 238 239 240 241 /** 242 * {@inheritDoc} 243 */ 244 public AdministrationConnectorCfgClient createClientConfiguration( 245 ManagedObject<? extends AdministrationConnectorCfgClient> impl) { 246 return new AdministrationConnectorCfgClientImpl(impl); 247 } 248 249 250 251 /** 252 * {@inheritDoc} 253 */ 254 public AdministrationConnectorCfg createServerConfiguration( 255 ServerManagedObject<? extends AdministrationConnectorCfg> impl) { 256 return new AdministrationConnectorCfgServerImpl(impl); 257 } 258 259 260 261 /** 262 * {@inheritDoc} 263 */ 264 public Class<AdministrationConnectorCfg> getServerConfigurationClass() { 265 return AdministrationConnectorCfg.class; 266 } 267 268 269 270 /** 271 * Get the "key-manager-provider" property definition. 272 * <p> 273 * Specifies the name of the key manager that is used with the 274 * Administration Connector . 275 * 276 * @return Returns the "key-manager-provider" property definition. 277 */ 278 public AggregationPropertyDefinition<KeyManagerProviderCfgClient, KeyManagerProviderCfg> getKeyManagerProviderPropertyDefinition() { 279 return PD_KEY_MANAGER_PROVIDER; 280 } 281 282 283 284 /** 285 * Get the "listen-address" property definition. 286 * <p> 287 * Specifies the address or set of addresses on which this 288 * Administration Connector should listen for connections from LDAP 289 * clients. 290 * <p> 291 * Multiple addresses may be provided as separate values for this 292 * attribute. If no values are provided, then the Administration 293 * Connector listens on all interfaces. 294 * 295 * @return Returns the "listen-address" property definition. 296 */ 297 public IPAddressPropertyDefinition getListenAddressPropertyDefinition() { 298 return PD_LISTEN_ADDRESS; 299 } 300 301 302 303 /** 304 * Get the "listen-port" property definition. 305 * <p> 306 * Specifies the port number on which the Administration Connector 307 * will listen for connections from clients. 308 * <p> 309 * Only a single port number may be provided. 310 * 311 * @return Returns the "listen-port" property definition. 312 */ 313 public IntegerPropertyDefinition getListenPortPropertyDefinition() { 314 return PD_LISTEN_PORT; 315 } 316 317 318 319 /** 320 * Get the "ssl-cert-nickname" property definition. 321 * <p> 322 * Specifies the nicknames (also called the aliases) of the 323 * certificates that the Administration Connector should use when 324 * performing SSL communication. The property can be used multiple 325 * times (referencing different nicknames) when an RSA, a DSA, and an 326 * ECC based server certificate is used in parallel. 327 * 328 * @return Returns the "ssl-cert-nickname" property definition. 329 */ 330 public StringPropertyDefinition getSSLCertNicknamePropertyDefinition() { 331 return PD_SSL_CERT_NICKNAME; 332 } 333 334 335 336 /** 337 * Get the "ssl-cipher-suite" property definition. 338 * <p> 339 * Specifies the names of the SSL cipher suites that are allowed for 340 * use in SSL communication. 341 * 342 * @return Returns the "ssl-cipher-suite" property definition. 343 */ 344 public StringPropertyDefinition getSSLCipherSuitePropertyDefinition() { 345 return PD_SSL_CIPHER_SUITE; 346 } 347 348 349 350 /** 351 * Get the "ssl-protocol" property definition. 352 * <p> 353 * Specifies the names of the SSL protocols that are allowed for use 354 * in SSL or StartTLS communication. 355 * 356 * @return Returns the "ssl-protocol" property definition. 357 */ 358 public StringPropertyDefinition getSSLProtocolPropertyDefinition() { 359 return PD_SSL_PROTOCOL; 360 } 361 362 363 364 /** 365 * Get the "trust-manager-provider" property definition. 366 * <p> 367 * Specifies the name of the trust manager that is used with the 368 * Administration Connector . 369 * 370 * @return Returns the "trust-manager-provider" property definition. 371 */ 372 public AggregationPropertyDefinition<TrustManagerProviderCfgClient, TrustManagerProviderCfg> getTrustManagerProviderPropertyDefinition() { 373 return PD_TRUST_MANAGER_PROVIDER; 374 } 375 376 377 378 /** 379 * Managed object client implementation. 380 */ 381 private static class AdministrationConnectorCfgClientImpl implements 382 AdministrationConnectorCfgClient { 383 384 // Private implementation. 385 private ManagedObject<? extends AdministrationConnectorCfgClient> impl; 386 387 388 389 // Private constructor. 390 private AdministrationConnectorCfgClientImpl( 391 ManagedObject<? extends AdministrationConnectorCfgClient> impl) { 392 this.impl = impl; 393 } 394 395 396 397 /** 398 * {@inheritDoc} 399 */ 400 public String getKeyManagerProvider() { 401 return impl.getPropertyValue(INSTANCE.getKeyManagerProviderPropertyDefinition()); 402 } 403 404 405 406 /** 407 * {@inheritDoc} 408 */ 409 public void setKeyManagerProvider(String value) { 410 impl.setPropertyValue(INSTANCE.getKeyManagerProviderPropertyDefinition(), value); 411 } 412 413 414 415 /** 416 * {@inheritDoc} 417 */ 418 public SortedSet<InetAddress> getListenAddress() { 419 return impl.getPropertyValues(INSTANCE.getListenAddressPropertyDefinition()); 420 } 421 422 423 424 /** 425 * {@inheritDoc} 426 */ 427 public void setListenAddress(Collection<InetAddress> values) { 428 impl.setPropertyValues(INSTANCE.getListenAddressPropertyDefinition(), values); 429 } 430 431 432 433 /** 434 * {@inheritDoc} 435 */ 436 public Integer getListenPort() { 437 return impl.getPropertyValue(INSTANCE.getListenPortPropertyDefinition()); 438 } 439 440 441 442 /** 443 * {@inheritDoc} 444 */ 445 public void setListenPort(int value) { 446 impl.setPropertyValue(INSTANCE.getListenPortPropertyDefinition(), value); 447 } 448 449 450 451 /** 452 * {@inheritDoc} 453 */ 454 public SortedSet<String> getSSLCertNickname() { 455 return impl.getPropertyValues(INSTANCE.getSSLCertNicknamePropertyDefinition()); 456 } 457 458 459 460 /** 461 * {@inheritDoc} 462 */ 463 public void setSSLCertNickname(Collection<String> values) { 464 impl.setPropertyValues(INSTANCE.getSSLCertNicknamePropertyDefinition(), values); 465 } 466 467 468 469 /** 470 * {@inheritDoc} 471 */ 472 public SortedSet<String> getSSLCipherSuite() { 473 return impl.getPropertyValues(INSTANCE.getSSLCipherSuitePropertyDefinition()); 474 } 475 476 477 478 /** 479 * {@inheritDoc} 480 */ 481 public void setSSLCipherSuite(Collection<String> values) { 482 impl.setPropertyValues(INSTANCE.getSSLCipherSuitePropertyDefinition(), values); 483 } 484 485 486 487 /** 488 * {@inheritDoc} 489 */ 490 public SortedSet<String> getSSLProtocol() { 491 return impl.getPropertyValues(INSTANCE.getSSLProtocolPropertyDefinition()); 492 } 493 494 495 496 /** 497 * {@inheritDoc} 498 */ 499 public void setSSLProtocol(Collection<String> values) { 500 impl.setPropertyValues(INSTANCE.getSSLProtocolPropertyDefinition(), values); 501 } 502 503 504 505 /** 506 * {@inheritDoc} 507 */ 508 public String getTrustManagerProvider() { 509 return impl.getPropertyValue(INSTANCE.getTrustManagerProviderPropertyDefinition()); 510 } 511 512 513 514 /** 515 * {@inheritDoc} 516 */ 517 public void setTrustManagerProvider(String value) { 518 impl.setPropertyValue(INSTANCE.getTrustManagerProviderPropertyDefinition(), value); 519 } 520 521 522 523 /** 524 * {@inheritDoc} 525 */ 526 public ManagedObjectDefinition<? extends AdministrationConnectorCfgClient, ? extends AdministrationConnectorCfg> definition() { 527 return INSTANCE; 528 } 529 530 531 532 /** 533 * {@inheritDoc} 534 */ 535 public PropertyProvider properties() { 536 return impl; 537 } 538 539 540 541 /** 542 * {@inheritDoc} 543 */ 544 public void commit() throws ManagedObjectAlreadyExistsException, 545 MissingMandatoryPropertiesException, ConcurrentModificationException, 546 OperationRejectedException, AuthorizationException, 547 CommunicationException { 548 impl.commit(); 549 } 550 551 552 553 /** {@inheritDoc} */ 554 public String toString() { 555 return impl.toString(); 556 } 557 } 558 559 560 561 /** 562 * Managed object server implementation. 563 */ 564 private static class AdministrationConnectorCfgServerImpl implements 565 AdministrationConnectorCfg { 566 567 // Private implementation. 568 private ServerManagedObject<? extends AdministrationConnectorCfg> impl; 569 570 // The value of the "key-manager-provider" property. 571 private final String pKeyManagerProvider; 572 573 // The value of the "listen-address" property. 574 private final SortedSet<InetAddress> pListenAddress; 575 576 // The value of the "listen-port" property. 577 private final int pListenPort; 578 579 // The value of the "ssl-cert-nickname" property. 580 private final SortedSet<String> pSSLCertNickname; 581 582 // The value of the "ssl-cipher-suite" property. 583 private final SortedSet<String> pSSLCipherSuite; 584 585 // The value of the "ssl-protocol" property. 586 private final SortedSet<String> pSSLProtocol; 587 588 // The value of the "trust-manager-provider" property. 589 private final String pTrustManagerProvider; 590 591 592 593 // Private constructor. 594 private AdministrationConnectorCfgServerImpl(ServerManagedObject<? extends AdministrationConnectorCfg> impl) { 595 this.impl = impl; 596 this.pKeyManagerProvider = impl.getPropertyValue(INSTANCE.getKeyManagerProviderPropertyDefinition()); 597 this.pListenAddress = impl.getPropertyValues(INSTANCE.getListenAddressPropertyDefinition()); 598 this.pListenPort = impl.getPropertyValue(INSTANCE.getListenPortPropertyDefinition()); 599 this.pSSLCertNickname = impl.getPropertyValues(INSTANCE.getSSLCertNicknamePropertyDefinition()); 600 this.pSSLCipherSuite = impl.getPropertyValues(INSTANCE.getSSLCipherSuitePropertyDefinition()); 601 this.pSSLProtocol = impl.getPropertyValues(INSTANCE.getSSLProtocolPropertyDefinition()); 602 this.pTrustManagerProvider = impl.getPropertyValue(INSTANCE.getTrustManagerProviderPropertyDefinition()); 603 } 604 605 606 607 /** 608 * {@inheritDoc} 609 */ 610 public void addChangeListener( 611 ConfigurationChangeListener<AdministrationConnectorCfg> listener) { 612 impl.registerChangeListener(listener); 613 } 614 615 616 617 /** 618 * {@inheritDoc} 619 */ 620 public void removeChangeListener( 621 ConfigurationChangeListener<AdministrationConnectorCfg> listener) { 622 impl.deregisterChangeListener(listener); 623 } 624 625 626 627 /** 628 * {@inheritDoc} 629 */ 630 public String getKeyManagerProvider() { 631 return pKeyManagerProvider; 632 } 633 634 635 636 /** 637 * {@inheritDoc} 638 */ 639 public DN getKeyManagerProviderDN() { 640 String value = getKeyManagerProvider(); 641 if (value == null) return null; 642 return INSTANCE.getKeyManagerProviderPropertyDefinition().getChildDN(value); 643 } 644 645 646 647 /** 648 * {@inheritDoc} 649 */ 650 public SortedSet<InetAddress> getListenAddress() { 651 return pListenAddress; 652 } 653 654 655 656 /** 657 * {@inheritDoc} 658 */ 659 public int getListenPort() { 660 return pListenPort; 661 } 662 663 664 665 /** 666 * {@inheritDoc} 667 */ 668 public SortedSet<String> getSSLCertNickname() { 669 return pSSLCertNickname; 670 } 671 672 673 674 /** 675 * {@inheritDoc} 676 */ 677 public SortedSet<String> getSSLCipherSuite() { 678 return pSSLCipherSuite; 679 } 680 681 682 683 /** 684 * {@inheritDoc} 685 */ 686 public SortedSet<String> getSSLProtocol() { 687 return pSSLProtocol; 688 } 689 690 691 692 /** 693 * {@inheritDoc} 694 */ 695 public String getTrustManagerProvider() { 696 return pTrustManagerProvider; 697 } 698 699 700 701 /** 702 * {@inheritDoc} 703 */ 704 public DN getTrustManagerProviderDN() { 705 String value = getTrustManagerProvider(); 706 if (value == null) return null; 707 return INSTANCE.getTrustManagerProviderPropertyDefinition().getChildDN(value); 708 } 709 710 711 712 /** 713 * {@inheritDoc} 714 */ 715 public Class<? extends AdministrationConnectorCfg> configurationClass() { 716 return AdministrationConnectorCfg.class; 717 } 718 719 720 721 /** 722 * {@inheritDoc} 723 */ 724 public DN dn() { 725 return impl.getDN(); 726 } 727 728 729 730 /** {@inheritDoc} */ 731 public String toString() { 732 return impl.toString(); 733 } 734 } 735}