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