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