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 org.opends.server.admin.AdministratorAction;
031import org.opends.server.admin.BooleanPropertyDefinition;
032import org.opends.server.admin.ClassPropertyDefinition;
033import org.opends.server.admin.client.AuthorizationException;
034import org.opends.server.admin.client.CommunicationException;
035import org.opends.server.admin.client.ConcurrentModificationException;
036import org.opends.server.admin.client.ManagedObject;
037import org.opends.server.admin.client.MissingMandatoryPropertiesException;
038import org.opends.server.admin.client.OperationRejectedException;
039import org.opends.server.admin.DefaultBehaviorProvider;
040import org.opends.server.admin.DefinedDefaultBehaviorProvider;
041import org.opends.server.admin.ManagedObjectAlreadyExistsException;
042import org.opends.server.admin.ManagedObjectDefinition;
043import org.opends.server.admin.PropertyException;
044import org.opends.server.admin.PropertyOption;
045import org.opends.server.admin.PropertyProvider;
046import org.opends.server.admin.server.ConfigurationChangeListener;
047import org.opends.server.admin.server.ServerManagedObject;
048import org.opends.server.admin.std.client.CertificateAttributeSyntaxCfgClient;
049import org.opends.server.admin.std.server.AttributeSyntaxCfg;
050import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg;
051import org.opends.server.admin.Tag;
052import org.opends.server.types.DN;
053
054
055
056/**
057 * An interface for querying the Certificate Attribute Syntax managed
058 * object definition meta information.
059 * <p>
060 * Certificate Attribute Syntaxes define an attribute syntax for
061 * storing X.509 Certificates.
062 */
063public final class CertificateAttributeSyntaxCfgDefn extends ManagedObjectDefinition<CertificateAttributeSyntaxCfgClient, CertificateAttributeSyntaxCfg> {
064
065  // The singleton configuration definition instance.
066  private static final CertificateAttributeSyntaxCfgDefn INSTANCE = new CertificateAttributeSyntaxCfgDefn();
067
068
069
070  // The "java-class" property definition.
071  private static final ClassPropertyDefinition PD_JAVA_CLASS;
072
073
074
075  // The "strict-format" property definition.
076  private static final BooleanPropertyDefinition PD_STRICT_FORMAT;
077
078
079
080  // Build the "java-class" property definition.
081  static {
082      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
083      builder.setOption(PropertyOption.READ_ONLY);
084      builder.setOption(PropertyOption.MANDATORY);
085      builder.setOption(PropertyOption.ADVANCED);
086      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
087      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.CertificateSyntax");
088      builder.setDefaultBehaviorProvider(provider);
089      builder.addInstanceOf("org.opends.server.api.AttributeSyntax");
090      PD_JAVA_CLASS = builder.getInstance();
091      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
092  }
093
094
095
096  // Build the "strict-format" property definition.
097  static {
098      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strict-format");
099      builder.setOption(PropertyOption.ADVANCED);
100      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strict-format"));
101      DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("true");
102      builder.setDefaultBehaviorProvider(provider);
103      PD_STRICT_FORMAT = builder.getInstance();
104      INSTANCE.registerPropertyDefinition(PD_STRICT_FORMAT);
105  }
106
107
108
109  // Register the tags associated with this managed object definition.
110  static {
111    INSTANCE.registerTag(Tag.valueOf("core-server"));
112  }
113
114
115
116  /**
117   * Get the Certificate Attribute Syntax configuration definition
118   * singleton.
119   *
120   * @return Returns the Certificate Attribute Syntax configuration
121   *         definition singleton.
122   */
123  public static CertificateAttributeSyntaxCfgDefn getInstance() {
124    return INSTANCE;
125  }
126
127
128
129  /**
130   * Private constructor.
131   */
132  private CertificateAttributeSyntaxCfgDefn() {
133    super("certificate-attribute-syntax", AttributeSyntaxCfgDefn.getInstance());
134  }
135
136
137
138  /**
139   * {@inheritDoc}
140   */
141  public CertificateAttributeSyntaxCfgClient createClientConfiguration(
142      ManagedObject<? extends CertificateAttributeSyntaxCfgClient> impl) {
143    return new CertificateAttributeSyntaxCfgClientImpl(impl);
144  }
145
146
147
148  /**
149   * {@inheritDoc}
150   */
151  public CertificateAttributeSyntaxCfg createServerConfiguration(
152      ServerManagedObject<? extends CertificateAttributeSyntaxCfg> impl) {
153    return new CertificateAttributeSyntaxCfgServerImpl(impl);
154  }
155
156
157
158  /**
159   * {@inheritDoc}
160   */
161  public Class<CertificateAttributeSyntaxCfg> getServerConfigurationClass() {
162    return CertificateAttributeSyntaxCfg.class;
163  }
164
165
166
167  /**
168   * Get the "enabled" property definition.
169   * <p>
170   * Indicates whether the Certificate Attribute Syntax is enabled.
171   *
172   * @return Returns the "enabled" property definition.
173   */
174  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
175    return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition();
176  }
177
178
179
180  /**
181   * Get the "java-class" property definition.
182   * <p>
183   * Specifies the fully-qualified name of the Java class that
184   * provides the Certificate Attribute Syntax implementation.
185   *
186   * @return Returns the "java-class" property definition.
187   */
188  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
189    return PD_JAVA_CLASS;
190  }
191
192
193
194  /**
195   * Get the "strict-format" property definition.
196   * <p>
197   * Indicates whether or not X.509 Certificate values are required to
198   * strictly comply with the standard definition for this syntax.
199   * <p>
200   * When set to false, certificates will not be validated and, as a
201   * result any sequence of bytes will be acceptable.
202   *
203   * @return Returns the "strict-format" property definition.
204   */
205  public BooleanPropertyDefinition getStrictFormatPropertyDefinition() {
206    return PD_STRICT_FORMAT;
207  }
208
209
210
211  /**
212   * Managed object client implementation.
213   */
214  private static class CertificateAttributeSyntaxCfgClientImpl implements
215    CertificateAttributeSyntaxCfgClient {
216
217    // Private implementation.
218    private ManagedObject<? extends CertificateAttributeSyntaxCfgClient> impl;
219
220
221
222    // Private constructor.
223    private CertificateAttributeSyntaxCfgClientImpl(
224        ManagedObject<? extends CertificateAttributeSyntaxCfgClient> impl) {
225      this.impl = impl;
226    }
227
228
229
230    /**
231     * {@inheritDoc}
232     */
233    public Boolean isEnabled() {
234      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
235    }
236
237
238
239    /**
240     * {@inheritDoc}
241     */
242    public void setEnabled(boolean value) {
243      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
244    }
245
246
247
248    /**
249     * {@inheritDoc}
250     */
251    public String getJavaClass() {
252      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
253    }
254
255
256
257    /**
258     * {@inheritDoc}
259     */
260    public void setJavaClass(String value) throws PropertyException {
261      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
262    }
263
264
265
266    /**
267     * {@inheritDoc}
268     */
269    public boolean isStrictFormat() {
270      return impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition());
271    }
272
273
274
275    /**
276     * {@inheritDoc}
277     */
278    public void setStrictFormat(Boolean value) {
279      impl.setPropertyValue(INSTANCE.getStrictFormatPropertyDefinition(), value);
280    }
281
282
283
284    /**
285     * {@inheritDoc}
286     */
287    public ManagedObjectDefinition<? extends CertificateAttributeSyntaxCfgClient, ? extends CertificateAttributeSyntaxCfg> definition() {
288      return INSTANCE;
289    }
290
291
292
293    /**
294     * {@inheritDoc}
295     */
296    public PropertyProvider properties() {
297      return impl;
298    }
299
300
301
302    /**
303     * {@inheritDoc}
304     */
305    public void commit() throws ManagedObjectAlreadyExistsException,
306        MissingMandatoryPropertiesException, ConcurrentModificationException,
307        OperationRejectedException, AuthorizationException,
308        CommunicationException {
309      impl.commit();
310    }
311
312  }
313
314
315
316  /**
317   * Managed object server implementation.
318   */
319  private static class CertificateAttributeSyntaxCfgServerImpl implements
320    CertificateAttributeSyntaxCfg {
321
322    // Private implementation.
323    private ServerManagedObject<? extends CertificateAttributeSyntaxCfg> impl;
324
325    // The value of the "enabled" property.
326    private final boolean pEnabled;
327
328    // The value of the "java-class" property.
329    private final String pJavaClass;
330
331    // The value of the "strict-format" property.
332    private final boolean pStrictFormat;
333
334
335
336    // Private constructor.
337    private CertificateAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends CertificateAttributeSyntaxCfg> impl) {
338      this.impl = impl;
339      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
340      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
341      this.pStrictFormat = impl.getPropertyValue(INSTANCE.getStrictFormatPropertyDefinition());
342    }
343
344
345
346    /**
347     * {@inheritDoc}
348     */
349    public void addCertificateChangeListener(
350        ConfigurationChangeListener<CertificateAttributeSyntaxCfg> listener) {
351      impl.registerChangeListener(listener);
352    }
353
354
355
356    /**
357     * {@inheritDoc}
358     */
359    public void removeCertificateChangeListener(
360        ConfigurationChangeListener<CertificateAttributeSyntaxCfg> listener) {
361      impl.deregisterChangeListener(listener);
362    }
363    /**
364     * {@inheritDoc}
365     */
366    public void addChangeListener(
367        ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
368      impl.registerChangeListener(listener);
369    }
370
371
372
373    /**
374     * {@inheritDoc}
375     */
376    public void removeChangeListener(
377        ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
378      impl.deregisterChangeListener(listener);
379    }
380
381
382
383    /**
384     * {@inheritDoc}
385     */
386    public boolean isEnabled() {
387      return pEnabled;
388    }
389
390
391
392    /**
393     * {@inheritDoc}
394     */
395    public String getJavaClass() {
396      return pJavaClass;
397    }
398
399
400
401    /**
402     * {@inheritDoc}
403     */
404    public boolean isStrictFormat() {
405      return pStrictFormat;
406    }
407
408
409
410    /**
411     * {@inheritDoc}
412     */
413    public Class<? extends CertificateAttributeSyntaxCfg> configurationClass() {
414      return CertificateAttributeSyntaxCfg.class;
415    }
416
417
418
419    /**
420     * {@inheritDoc}
421     */
422    public DN dn() {
423      return impl.getDN();
424    }
425
426  }
427}