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.PropertyOption;
044import org.opends.server.admin.PropertyProvider;
045import org.opends.server.admin.server.ConfigurationChangeListener;
046import org.opends.server.admin.server.ServerManagedObject;
047import org.opends.server.admin.std.client.SubjectEqualsDNCertificateMapperCfgClient;
048import org.opends.server.admin.std.server.CertificateMapperCfg;
049import org.opends.server.admin.std.server.SubjectEqualsDNCertificateMapperCfg;
050import org.opends.server.admin.Tag;
051import org.opends.server.types.DN;
052
053
054
055/**
056 * An interface for querying the Subject Equals DN Certificate Mapper
057 * managed object definition meta information.
058 * <p>
059 * The Subject Equals DN Certificate Mapper maps client certificates
060 * to user entries based on the assumption that the certificate subject
061 * is the same as the DN of the target user entry.
062 */
063public final class SubjectEqualsDNCertificateMapperCfgDefn extends ManagedObjectDefinition<SubjectEqualsDNCertificateMapperCfgClient, SubjectEqualsDNCertificateMapperCfg> {
064
065  // The singleton configuration definition instance.
066  private static final SubjectEqualsDNCertificateMapperCfgDefn INSTANCE = new SubjectEqualsDNCertificateMapperCfgDefn();
067
068
069
070  // The "java-class" property definition.
071  private static final ClassPropertyDefinition PD_JAVA_CLASS;
072
073
074
075  // Build the "java-class" property definition.
076  static {
077      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
078      builder.setOption(PropertyOption.MANDATORY);
079      builder.setOption(PropertyOption.ADVANCED);
080      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
081      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.SubjectEqualsDNCertificateMapper");
082      builder.setDefaultBehaviorProvider(provider);
083      builder.addInstanceOf("org.opends.server.api.CertificateMapper");
084      PD_JAVA_CLASS = builder.getInstance();
085      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
086  }
087
088
089
090  // Register the tags associated with this managed object definition.
091  static {
092    INSTANCE.registerTag(Tag.valueOf("security"));
093    INSTANCE.registerTag(Tag.valueOf("user-management"));
094  }
095
096
097
098  /**
099   * Get the Subject Equals DN Certificate Mapper configuration
100   * definition singleton.
101   *
102   * @return Returns the Subject Equals DN Certificate Mapper
103   *         configuration definition singleton.
104   */
105  public static SubjectEqualsDNCertificateMapperCfgDefn getInstance() {
106    return INSTANCE;
107  }
108
109
110
111  /**
112   * Private constructor.
113   */
114  private SubjectEqualsDNCertificateMapperCfgDefn() {
115    super("subject-equals-dn-certificate-mapper", CertificateMapperCfgDefn.getInstance());
116  }
117
118
119
120  /**
121   * {@inheritDoc}
122   */
123  public SubjectEqualsDNCertificateMapperCfgClient createClientConfiguration(
124      ManagedObject<? extends SubjectEqualsDNCertificateMapperCfgClient> impl) {
125    return new SubjectEqualsDNCertificateMapperCfgClientImpl(impl);
126  }
127
128
129
130  /**
131   * {@inheritDoc}
132   */
133  public SubjectEqualsDNCertificateMapperCfg createServerConfiguration(
134      ServerManagedObject<? extends SubjectEqualsDNCertificateMapperCfg> impl) {
135    return new SubjectEqualsDNCertificateMapperCfgServerImpl(impl);
136  }
137
138
139
140  /**
141   * {@inheritDoc}
142   */
143  public Class<SubjectEqualsDNCertificateMapperCfg> getServerConfigurationClass() {
144    return SubjectEqualsDNCertificateMapperCfg.class;
145  }
146
147
148
149  /**
150   * Get the "enabled" property definition.
151   * <p>
152   * Indicates whether the Subject Equals DN Certificate Mapper is
153   * enabled.
154   *
155   * @return Returns the "enabled" property definition.
156   */
157  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
158    return CertificateMapperCfgDefn.getInstance().getEnabledPropertyDefinition();
159  }
160
161
162
163  /**
164   * Get the "java-class" property definition.
165   * <p>
166   * Specifies the fully-qualified name of the Java class that
167   * provides the Subject Equals DN Certificate Mapper implementation.
168   *
169   * @return Returns the "java-class" property definition.
170   */
171  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
172    return PD_JAVA_CLASS;
173  }
174
175
176
177  /**
178   * Managed object client implementation.
179   */
180  private static class SubjectEqualsDNCertificateMapperCfgClientImpl implements
181    SubjectEqualsDNCertificateMapperCfgClient {
182
183    // Private implementation.
184    private ManagedObject<? extends SubjectEqualsDNCertificateMapperCfgClient> impl;
185
186
187
188    // Private constructor.
189    private SubjectEqualsDNCertificateMapperCfgClientImpl(
190        ManagedObject<? extends SubjectEqualsDNCertificateMapperCfgClient> impl) {
191      this.impl = impl;
192    }
193
194
195
196    /**
197     * {@inheritDoc}
198     */
199    public Boolean isEnabled() {
200      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
201    }
202
203
204
205    /**
206     * {@inheritDoc}
207     */
208    public void setEnabled(boolean value) {
209      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
210    }
211
212
213
214    /**
215     * {@inheritDoc}
216     */
217    public String getJavaClass() {
218      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
219    }
220
221
222
223    /**
224     * {@inheritDoc}
225     */
226    public void setJavaClass(String value) {
227      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
228    }
229
230
231
232    /**
233     * {@inheritDoc}
234     */
235    public ManagedObjectDefinition<? extends SubjectEqualsDNCertificateMapperCfgClient, ? extends SubjectEqualsDNCertificateMapperCfg> definition() {
236      return INSTANCE;
237    }
238
239
240
241    /**
242     * {@inheritDoc}
243     */
244    public PropertyProvider properties() {
245      return impl;
246    }
247
248
249
250    /**
251     * {@inheritDoc}
252     */
253    public void commit() throws ManagedObjectAlreadyExistsException,
254        MissingMandatoryPropertiesException, ConcurrentModificationException,
255        OperationRejectedException, AuthorizationException,
256        CommunicationException {
257      impl.commit();
258    }
259
260
261
262    /** {@inheritDoc} */
263    public String toString() {
264      return impl.toString();
265    }
266  }
267
268
269
270  /**
271   * Managed object server implementation.
272   */
273  private static class SubjectEqualsDNCertificateMapperCfgServerImpl implements
274    SubjectEqualsDNCertificateMapperCfg {
275
276    // Private implementation.
277    private ServerManagedObject<? extends SubjectEqualsDNCertificateMapperCfg> impl;
278
279    // The value of the "enabled" property.
280    private final boolean pEnabled;
281
282    // The value of the "java-class" property.
283    private final String pJavaClass;
284
285
286
287    // Private constructor.
288    private SubjectEqualsDNCertificateMapperCfgServerImpl(ServerManagedObject<? extends SubjectEqualsDNCertificateMapperCfg> impl) {
289      this.impl = impl;
290      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
291      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
292    }
293
294
295
296    /**
297     * {@inheritDoc}
298     */
299    public void addSubjectEqualsDNChangeListener(
300        ConfigurationChangeListener<SubjectEqualsDNCertificateMapperCfg> listener) {
301      impl.registerChangeListener(listener);
302    }
303
304
305
306    /**
307     * {@inheritDoc}
308     */
309    public void removeSubjectEqualsDNChangeListener(
310        ConfigurationChangeListener<SubjectEqualsDNCertificateMapperCfg> listener) {
311      impl.deregisterChangeListener(listener);
312    }
313    /**
314     * {@inheritDoc}
315     */
316    public void addChangeListener(
317        ConfigurationChangeListener<CertificateMapperCfg> listener) {
318      impl.registerChangeListener(listener);
319    }
320
321
322
323    /**
324     * {@inheritDoc}
325     */
326    public void removeChangeListener(
327        ConfigurationChangeListener<CertificateMapperCfg> listener) {
328      impl.deregisterChangeListener(listener);
329    }
330
331
332
333    /**
334     * {@inheritDoc}
335     */
336    public boolean isEnabled() {
337      return pEnabled;
338    }
339
340
341
342    /**
343     * {@inheritDoc}
344     */
345    public String getJavaClass() {
346      return pJavaClass;
347    }
348
349
350
351    /**
352     * {@inheritDoc}
353     */
354    public Class<? extends SubjectEqualsDNCertificateMapperCfg> configurationClass() {
355      return SubjectEqualsDNCertificateMapperCfg.class;
356    }
357
358
359
360    /**
361     * {@inheritDoc}
362     */
363    public DN dn() {
364      return impl.getDN();
365    }
366
367
368
369    /** {@inheritDoc} */
370    public String toString() {
371      return impl.toString();
372    }
373  }
374}