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.BooleanPropertyDefinition; 023import org.opends.server.admin.ClassPropertyDefinition; 024import org.opends.server.admin.client.AuthorizationException; 025import org.opends.server.admin.client.CommunicationException; 026import org.opends.server.admin.client.ConcurrentModificationException; 027import org.opends.server.admin.client.ManagedObject; 028import org.opends.server.admin.client.MissingMandatoryPropertiesException; 029import org.opends.server.admin.client.OperationRejectedException; 030import org.opends.server.admin.DefaultBehaviorProvider; 031import org.opends.server.admin.DefinedDefaultBehaviorProvider; 032import org.opends.server.admin.ManagedObjectAlreadyExistsException; 033import org.opends.server.admin.ManagedObjectDefinition; 034import org.opends.server.admin.PropertyOption; 035import org.opends.server.admin.PropertyProvider; 036import org.opends.server.admin.server.ConfigurationChangeListener; 037import org.opends.server.admin.server.ServerManagedObject; 038import org.opends.server.admin.std.client.FileBasedTrustManagerProviderCfgClient; 039import org.opends.server.admin.std.server.FileBasedTrustManagerProviderCfg; 040import org.opends.server.admin.std.server.TrustManagerProviderCfg; 041import org.opends.server.admin.StringPropertyDefinition; 042import org.opends.server.admin.Tag; 043import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 044 045 046 047/** 048 * An interface for querying the File Based Trust Manager Provider 049 * managed object definition meta information. 050 * <p> 051 * The file-based trust manager provider determines whether to trust a 052 * presented certificate based on whether that certificate exists in a 053 * server trust store file. 054 */ 055public final class FileBasedTrustManagerProviderCfgDefn extends ManagedObjectDefinition<FileBasedTrustManagerProviderCfgClient, FileBasedTrustManagerProviderCfg> { 056 057 // The singleton configuration definition instance. 058 private static final FileBasedTrustManagerProviderCfgDefn INSTANCE = new FileBasedTrustManagerProviderCfgDefn(); 059 060 061 062 // The "java-class" property definition. 063 private static final ClassPropertyDefinition PD_JAVA_CLASS; 064 065 066 067 // The "trust-store-file" property definition. 068 private static final StringPropertyDefinition PD_TRUST_STORE_FILE; 069 070 071 072 // The "trust-store-pin" property definition. 073 private static final StringPropertyDefinition PD_TRUST_STORE_PIN; 074 075 076 077 // The "trust-store-pin-environment-variable" property definition. 078 private static final StringPropertyDefinition PD_TRUST_STORE_PIN_ENVIRONMENT_VARIABLE; 079 080 081 082 // The "trust-store-pin-file" property definition. 083 private static final StringPropertyDefinition PD_TRUST_STORE_PIN_FILE; 084 085 086 087 // The "trust-store-pin-property" property definition. 088 private static final StringPropertyDefinition PD_TRUST_STORE_PIN_PROPERTY; 089 090 091 092 // The "trust-store-type" property definition. 093 private static final StringPropertyDefinition PD_TRUST_STORE_TYPE; 094 095 096 097 // Build the "java-class" property definition. 098 static { 099 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 100 builder.setOption(PropertyOption.MANDATORY); 101 builder.setOption(PropertyOption.ADVANCED); 102 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 103 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.FileBasedTrustManagerProvider"); 104 builder.setDefaultBehaviorProvider(provider); 105 builder.addInstanceOf("org.opends.server.api.TrustManagerProvider"); 106 PD_JAVA_CLASS = builder.getInstance(); 107 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 108 } 109 110 111 112 // Build the "trust-store-file" property definition. 113 static { 114 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "trust-store-file"); 115 builder.setOption(PropertyOption.MANDATORY); 116 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "trust-store-file")); 117 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 118 builder.setPattern(".*", "STRING"); 119 PD_TRUST_STORE_FILE = builder.getInstance(); 120 INSTANCE.registerPropertyDefinition(PD_TRUST_STORE_FILE); 121 } 122 123 124 125 // Build the "trust-store-pin" property definition. 126 static { 127 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "trust-store-pin"); 128 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "trust-store-pin")); 129 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 130 PD_TRUST_STORE_PIN = builder.getInstance(); 131 INSTANCE.registerPropertyDefinition(PD_TRUST_STORE_PIN); 132 } 133 134 135 136 // Build the "trust-store-pin-environment-variable" property definition. 137 static { 138 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "trust-store-pin-environment-variable"); 139 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "trust-store-pin-environment-variable")); 140 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 141 PD_TRUST_STORE_PIN_ENVIRONMENT_VARIABLE = builder.getInstance(); 142 INSTANCE.registerPropertyDefinition(PD_TRUST_STORE_PIN_ENVIRONMENT_VARIABLE); 143 } 144 145 146 147 // Build the "trust-store-pin-file" property definition. 148 static { 149 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "trust-store-pin-file"); 150 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "trust-store-pin-file")); 151 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 152 PD_TRUST_STORE_PIN_FILE = builder.getInstance(); 153 INSTANCE.registerPropertyDefinition(PD_TRUST_STORE_PIN_FILE); 154 } 155 156 157 158 // Build the "trust-store-pin-property" property definition. 159 static { 160 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "trust-store-pin-property"); 161 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "trust-store-pin-property")); 162 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 163 PD_TRUST_STORE_PIN_PROPERTY = builder.getInstance(); 164 INSTANCE.registerPropertyDefinition(PD_TRUST_STORE_PIN_PROPERTY); 165 } 166 167 168 169 // Build the "trust-store-type" property definition. 170 static { 171 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "trust-store-type"); 172 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "trust-store-type")); 173 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 174 builder.setPattern(".*", "STRING"); 175 PD_TRUST_STORE_TYPE = builder.getInstance(); 176 INSTANCE.registerPropertyDefinition(PD_TRUST_STORE_TYPE); 177 } 178 179 180 181 // Register the tags associated with this managed object definition. 182 static { 183 INSTANCE.registerTag(Tag.valueOf("security")); 184 } 185 186 187 188 /** 189 * Get the File Based Trust Manager Provider configuration 190 * definition singleton. 191 * 192 * @return Returns the File Based Trust Manager Provider 193 * configuration definition singleton. 194 */ 195 public static FileBasedTrustManagerProviderCfgDefn getInstance() { 196 return INSTANCE; 197 } 198 199 200 201 /** 202 * Private constructor. 203 */ 204 private FileBasedTrustManagerProviderCfgDefn() { 205 super("file-based-trust-manager-provider", TrustManagerProviderCfgDefn.getInstance()); 206 } 207 208 209 210 /** 211 * {@inheritDoc} 212 */ 213 public FileBasedTrustManagerProviderCfgClient createClientConfiguration( 214 ManagedObject<? extends FileBasedTrustManagerProviderCfgClient> impl) { 215 return new FileBasedTrustManagerProviderCfgClientImpl(impl); 216 } 217 218 219 220 /** 221 * {@inheritDoc} 222 */ 223 public FileBasedTrustManagerProviderCfg createServerConfiguration( 224 ServerManagedObject<? extends FileBasedTrustManagerProviderCfg> impl) { 225 return new FileBasedTrustManagerProviderCfgServerImpl(impl); 226 } 227 228 229 230 /** 231 * {@inheritDoc} 232 */ 233 public Class<FileBasedTrustManagerProviderCfg> getServerConfigurationClass() { 234 return FileBasedTrustManagerProviderCfg.class; 235 } 236 237 238 239 /** 240 * Get the "enabled" property definition. 241 * <p> 242 * Indicate whether the File Based Trust Manager Provider is enabled 243 * for use. 244 * 245 * @return Returns the "enabled" property definition. 246 */ 247 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 248 return TrustManagerProviderCfgDefn.getInstance().getEnabledPropertyDefinition(); 249 } 250 251 252 253 /** 254 * Get the "java-class" property definition. 255 * <p> 256 * The fully-qualified name of the Java class that provides the File 257 * Based Trust Manager Provider implementation. 258 * 259 * @return Returns the "java-class" property definition. 260 */ 261 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 262 return PD_JAVA_CLASS; 263 } 264 265 266 267 /** 268 * Get the "trust-store-file" property definition. 269 * <p> 270 * Specifies the path to the file containing the trust information. 271 * It can be an absolute path or a path that is relative to the 272 * OpenDJ instance root. 273 * <p> 274 * Changes to this configuration attribute take effect the next time 275 * that the trust manager is accessed. 276 * 277 * @return Returns the "trust-store-file" property definition. 278 */ 279 public StringPropertyDefinition getTrustStoreFilePropertyDefinition() { 280 return PD_TRUST_STORE_FILE; 281 } 282 283 284 285 /** 286 * Get the "trust-store-pin" property definition. 287 * <p> 288 * Specifies the clear-text PIN needed to access the File Based 289 * Trust Manager Provider . 290 * 291 * @return Returns the "trust-store-pin" property definition. 292 */ 293 public StringPropertyDefinition getTrustStorePinPropertyDefinition() { 294 return PD_TRUST_STORE_PIN; 295 } 296 297 298 299 /** 300 * Get the "trust-store-pin-environment-variable" property definition. 301 * <p> 302 * Specifies the name of the environment variable that contains the 303 * clear-text PIN needed to access the File Based Trust Manager 304 * Provider . 305 * 306 * @return Returns the "trust-store-pin-environment-variable" property definition. 307 */ 308 public StringPropertyDefinition getTrustStorePinEnvironmentVariablePropertyDefinition() { 309 return PD_TRUST_STORE_PIN_ENVIRONMENT_VARIABLE; 310 } 311 312 313 314 /** 315 * Get the "trust-store-pin-file" property definition. 316 * <p> 317 * Specifies the path to the text file whose only contents should be 318 * a single line containing the clear-text PIN needed to access the 319 * File Based Trust Manager Provider . 320 * 321 * @return Returns the "trust-store-pin-file" property definition. 322 */ 323 public StringPropertyDefinition getTrustStorePinFilePropertyDefinition() { 324 return PD_TRUST_STORE_PIN_FILE; 325 } 326 327 328 329 /** 330 * Get the "trust-store-pin-property" property definition. 331 * <p> 332 * Specifies the name of the Java property that contains the 333 * clear-text PIN needed to access the File Based Trust Manager 334 * Provider . 335 * 336 * @return Returns the "trust-store-pin-property" property definition. 337 */ 338 public StringPropertyDefinition getTrustStorePinPropertyPropertyDefinition() { 339 return PD_TRUST_STORE_PIN_PROPERTY; 340 } 341 342 343 344 /** 345 * Get the "trust-store-type" property definition. 346 * <p> 347 * Specifies the format for the data in the trust store file. 348 * <p> 349 * Valid values always include 'JKS' and 'PKCS12', but different 350 * implementations can allow other values as well. If no value is 351 * provided, then the JVM default value is used. Changes to this 352 * configuration attribute take effect the next time that the trust 353 * manager is accessed. 354 * 355 * @return Returns the "trust-store-type" property definition. 356 */ 357 public StringPropertyDefinition getTrustStoreTypePropertyDefinition() { 358 return PD_TRUST_STORE_TYPE; 359 } 360 361 362 363 /** 364 * Managed object client implementation. 365 */ 366 private static class FileBasedTrustManagerProviderCfgClientImpl implements 367 FileBasedTrustManagerProviderCfgClient { 368 369 // Private implementation. 370 private ManagedObject<? extends FileBasedTrustManagerProviderCfgClient> impl; 371 372 373 374 // Private constructor. 375 private FileBasedTrustManagerProviderCfgClientImpl( 376 ManagedObject<? extends FileBasedTrustManagerProviderCfgClient> impl) { 377 this.impl = impl; 378 } 379 380 381 382 /** 383 * {@inheritDoc} 384 */ 385 public Boolean isEnabled() { 386 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 387 } 388 389 390 391 /** 392 * {@inheritDoc} 393 */ 394 public void setEnabled(boolean value) { 395 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 396 } 397 398 399 400 /** 401 * {@inheritDoc} 402 */ 403 public String getJavaClass() { 404 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 405 } 406 407 408 409 /** 410 * {@inheritDoc} 411 */ 412 public void setJavaClass(String value) { 413 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 414 } 415 416 417 418 /** 419 * {@inheritDoc} 420 */ 421 public String getTrustStoreFile() { 422 return impl.getPropertyValue(INSTANCE.getTrustStoreFilePropertyDefinition()); 423 } 424 425 426 427 /** 428 * {@inheritDoc} 429 */ 430 public void setTrustStoreFile(String value) { 431 impl.setPropertyValue(INSTANCE.getTrustStoreFilePropertyDefinition(), value); 432 } 433 434 435 436 /** 437 * {@inheritDoc} 438 */ 439 public String getTrustStorePin() { 440 return impl.getPropertyValue(INSTANCE.getTrustStorePinPropertyDefinition()); 441 } 442 443 444 445 /** 446 * {@inheritDoc} 447 */ 448 public void setTrustStorePin(String value) { 449 impl.setPropertyValue(INSTANCE.getTrustStorePinPropertyDefinition(), value); 450 } 451 452 453 454 /** 455 * {@inheritDoc} 456 */ 457 public String getTrustStorePinEnvironmentVariable() { 458 return impl.getPropertyValue(INSTANCE.getTrustStorePinEnvironmentVariablePropertyDefinition()); 459 } 460 461 462 463 /** 464 * {@inheritDoc} 465 */ 466 public void setTrustStorePinEnvironmentVariable(String value) { 467 impl.setPropertyValue(INSTANCE.getTrustStorePinEnvironmentVariablePropertyDefinition(), value); 468 } 469 470 471 472 /** 473 * {@inheritDoc} 474 */ 475 public String getTrustStorePinFile() { 476 return impl.getPropertyValue(INSTANCE.getTrustStorePinFilePropertyDefinition()); 477 } 478 479 480 481 /** 482 * {@inheritDoc} 483 */ 484 public void setTrustStorePinFile(String value) { 485 impl.setPropertyValue(INSTANCE.getTrustStorePinFilePropertyDefinition(), value); 486 } 487 488 489 490 /** 491 * {@inheritDoc} 492 */ 493 public String getTrustStorePinProperty() { 494 return impl.getPropertyValue(INSTANCE.getTrustStorePinPropertyPropertyDefinition()); 495 } 496 497 498 499 /** 500 * {@inheritDoc} 501 */ 502 public void setTrustStorePinProperty(String value) { 503 impl.setPropertyValue(INSTANCE.getTrustStorePinPropertyPropertyDefinition(), value); 504 } 505 506 507 508 /** 509 * {@inheritDoc} 510 */ 511 public String getTrustStoreType() { 512 return impl.getPropertyValue(INSTANCE.getTrustStoreTypePropertyDefinition()); 513 } 514 515 516 517 /** 518 * {@inheritDoc} 519 */ 520 public void setTrustStoreType(String value) { 521 impl.setPropertyValue(INSTANCE.getTrustStoreTypePropertyDefinition(), value); 522 } 523 524 525 526 /** 527 * {@inheritDoc} 528 */ 529 public ManagedObjectDefinition<? extends FileBasedTrustManagerProviderCfgClient, ? extends FileBasedTrustManagerProviderCfg> definition() { 530 return INSTANCE; 531 } 532 533 534 535 /** 536 * {@inheritDoc} 537 */ 538 public PropertyProvider properties() { 539 return impl; 540 } 541 542 543 544 /** 545 * {@inheritDoc} 546 */ 547 public void commit() throws ManagedObjectAlreadyExistsException, 548 MissingMandatoryPropertiesException, ConcurrentModificationException, 549 OperationRejectedException, AuthorizationException, 550 CommunicationException { 551 impl.commit(); 552 } 553 554 555 556 /** {@inheritDoc} */ 557 public String toString() { 558 return impl.toString(); 559 } 560 } 561 562 563 564 /** 565 * Managed object server implementation. 566 */ 567 private static class FileBasedTrustManagerProviderCfgServerImpl implements 568 FileBasedTrustManagerProviderCfg { 569 570 // Private implementation. 571 private ServerManagedObject<? extends FileBasedTrustManagerProviderCfg> impl; 572 573 // The value of the "enabled" property. 574 private final boolean pEnabled; 575 576 // The value of the "java-class" property. 577 private final String pJavaClass; 578 579 // The value of the "trust-store-file" property. 580 private final String pTrustStoreFile; 581 582 // The value of the "trust-store-pin" property. 583 private final String pTrustStorePin; 584 585 // The value of the "trust-store-pin-environment-variable" property. 586 private final String pTrustStorePinEnvironmentVariable; 587 588 // The value of the "trust-store-pin-file" property. 589 private final String pTrustStorePinFile; 590 591 // The value of the "trust-store-pin-property" property. 592 private final String pTrustStorePinProperty; 593 594 // The value of the "trust-store-type" property. 595 private final String pTrustStoreType; 596 597 598 599 // Private constructor. 600 private FileBasedTrustManagerProviderCfgServerImpl(ServerManagedObject<? extends FileBasedTrustManagerProviderCfg> impl) { 601 this.impl = impl; 602 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 603 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 604 this.pTrustStoreFile = impl.getPropertyValue(INSTANCE.getTrustStoreFilePropertyDefinition()); 605 this.pTrustStorePin = impl.getPropertyValue(INSTANCE.getTrustStorePinPropertyDefinition()); 606 this.pTrustStorePinEnvironmentVariable = impl.getPropertyValue(INSTANCE.getTrustStorePinEnvironmentVariablePropertyDefinition()); 607 this.pTrustStorePinFile = impl.getPropertyValue(INSTANCE.getTrustStorePinFilePropertyDefinition()); 608 this.pTrustStorePinProperty = impl.getPropertyValue(INSTANCE.getTrustStorePinPropertyPropertyDefinition()); 609 this.pTrustStoreType = impl.getPropertyValue(INSTANCE.getTrustStoreTypePropertyDefinition()); 610 } 611 612 613 614 /** 615 * {@inheritDoc} 616 */ 617 public void addFileBasedChangeListener( 618 ConfigurationChangeListener<FileBasedTrustManagerProviderCfg> listener) { 619 impl.registerChangeListener(listener); 620 } 621 622 623 624 /** 625 * {@inheritDoc} 626 */ 627 public void removeFileBasedChangeListener( 628 ConfigurationChangeListener<FileBasedTrustManagerProviderCfg> listener) { 629 impl.deregisterChangeListener(listener); 630 } 631 /** 632 * {@inheritDoc} 633 */ 634 public void addChangeListener( 635 ConfigurationChangeListener<TrustManagerProviderCfg> listener) { 636 impl.registerChangeListener(listener); 637 } 638 639 640 641 /** 642 * {@inheritDoc} 643 */ 644 public void removeChangeListener( 645 ConfigurationChangeListener<TrustManagerProviderCfg> listener) { 646 impl.deregisterChangeListener(listener); 647 } 648 649 650 651 /** 652 * {@inheritDoc} 653 */ 654 public boolean isEnabled() { 655 return pEnabled; 656 } 657 658 659 660 /** 661 * {@inheritDoc} 662 */ 663 public String getJavaClass() { 664 return pJavaClass; 665 } 666 667 668 669 /** 670 * {@inheritDoc} 671 */ 672 public String getTrustStoreFile() { 673 return pTrustStoreFile; 674 } 675 676 677 678 /** 679 * {@inheritDoc} 680 */ 681 public String getTrustStorePin() { 682 return pTrustStorePin; 683 } 684 685 686 687 /** 688 * {@inheritDoc} 689 */ 690 public String getTrustStorePinEnvironmentVariable() { 691 return pTrustStorePinEnvironmentVariable; 692 } 693 694 695 696 /** 697 * {@inheritDoc} 698 */ 699 public String getTrustStorePinFile() { 700 return pTrustStorePinFile; 701 } 702 703 704 705 /** 706 * {@inheritDoc} 707 */ 708 public String getTrustStorePinProperty() { 709 return pTrustStorePinProperty; 710 } 711 712 713 714 /** 715 * {@inheritDoc} 716 */ 717 public String getTrustStoreType() { 718 return pTrustStoreType; 719 } 720 721 722 723 /** 724 * {@inheritDoc} 725 */ 726 public Class<? extends FileBasedTrustManagerProviderCfg> configurationClass() { 727 return FileBasedTrustManagerProviderCfg.class; 728 } 729 730 731 732 /** 733 * {@inheritDoc} 734 */ 735 public DN dn() { 736 return impl.getDN(); 737 } 738 739 740 741 /** {@inheritDoc} */ 742 public String toString() { 743 return impl.toString(); 744 } 745 } 746}