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