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.forgerock.opendj.server.config.meta;
027
028
029
030import org.forgerock.opendj.config.AdministratorAction;
031import org.forgerock.opendj.config.BooleanPropertyDefinition;
032import org.forgerock.opendj.config.ClassPropertyDefinition;
033import org.forgerock.opendj.config.client.ConcurrentModificationException;
034import org.forgerock.opendj.config.client.ManagedObject;
035import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException;
036import org.forgerock.opendj.config.client.OperationRejectedException;
037import org.forgerock.opendj.config.DefaultBehaviorProvider;
038import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
039import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException;
040import org.forgerock.opendj.config.ManagedObjectDefinition;
041import org.forgerock.opendj.config.PropertyOption;
042import org.forgerock.opendj.config.PropertyProvider;
043import org.forgerock.opendj.config.server.ConfigurationChangeListener;
044import org.forgerock.opendj.config.server.ServerManagedObject;
045import org.forgerock.opendj.config.Tag;
046import org.forgerock.opendj.ldap.DN;
047import org.forgerock.opendj.ldap.LdapException;
048import org.forgerock.opendj.server.config.client.RC4PasswordStorageSchemeCfgClient;
049import org.forgerock.opendj.server.config.server.PasswordStorageSchemeCfg;
050import org.forgerock.opendj.server.config.server.RC4PasswordStorageSchemeCfg;
051
052
053
054/**
055 * An interface for querying the RC4 Password Storage Scheme managed
056 * object definition meta information.
057 * <p>
058 * The RC4 Password Storage Scheme provides a mechanism for encoding
059 * user passwords using the RC4 reversible encryption mechanism.
060 */
061public final class RC4PasswordStorageSchemeCfgDefn extends ManagedObjectDefinition<RC4PasswordStorageSchemeCfgClient, RC4PasswordStorageSchemeCfg> {
062
063  /** The singleton configuration definition instance. */
064  private static final RC4PasswordStorageSchemeCfgDefn INSTANCE = new RC4PasswordStorageSchemeCfgDefn();
065
066
067
068  /** The "java-class" property definition. */
069  private static final ClassPropertyDefinition PD_JAVA_CLASS;
070
071
072
073  /** Build the "java-class" property definition. */
074  static {
075      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
076      builder.setOption(PropertyOption.MANDATORY);
077      builder.setOption(PropertyOption.ADVANCED);
078      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
079      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.RC4PasswordStorageScheme");
080      builder.setDefaultBehaviorProvider(provider);
081      builder.addInstanceOf("org.opends.server.api.PasswordStorageScheme");
082      PD_JAVA_CLASS = builder.getInstance();
083      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
084  }
085
086
087
088  // Register the tags associated with this managed object definition.
089  static {
090    INSTANCE.registerTag(Tag.valueOf("user-management"));
091  }
092
093
094
095  /**
096   * Get the RC4 Password Storage Scheme configuration definition
097   * singleton.
098   *
099   * @return Returns the RC4 Password Storage Scheme configuration
100   *         definition singleton.
101   */
102  public static RC4PasswordStorageSchemeCfgDefn getInstance() {
103    return INSTANCE;
104  }
105
106
107
108  /**
109   * Private constructor.
110   */
111  private RC4PasswordStorageSchemeCfgDefn() {
112    super("rc4-password-storage-scheme", PasswordStorageSchemeCfgDefn.getInstance());
113  }
114
115
116
117  /** {@inheritDoc} */
118  public RC4PasswordStorageSchemeCfgClient createClientConfiguration(
119      ManagedObject<? extends RC4PasswordStorageSchemeCfgClient> impl) {
120    return new RC4PasswordStorageSchemeCfgClientImpl(impl);
121  }
122
123
124
125  /** {@inheritDoc} */
126  public RC4PasswordStorageSchemeCfg createServerConfiguration(
127      ServerManagedObject<? extends RC4PasswordStorageSchemeCfg> impl) {
128    return new RC4PasswordStorageSchemeCfgServerImpl(impl);
129  }
130
131
132
133  /** {@inheritDoc} */
134  public Class<RC4PasswordStorageSchemeCfg> getServerConfigurationClass() {
135    return RC4PasswordStorageSchemeCfg.class;
136  }
137
138
139
140  /**
141   * Get the "enabled" property definition.
142   * <p>
143   * Indicates whether the RC4 Password Storage Scheme is enabled for
144   * use.
145   *
146   * @return Returns the "enabled" property definition.
147   */
148  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
149    return PasswordStorageSchemeCfgDefn.getInstance().getEnabledPropertyDefinition();
150  }
151
152
153
154  /**
155   * Get the "java-class" property definition.
156   * <p>
157   * Specifies the fully-qualified name of the Java class that
158   * provides the RC4 Password Storage Scheme implementation.
159   *
160   * @return Returns the "java-class" property definition.
161   */
162  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
163    return PD_JAVA_CLASS;
164  }
165
166
167
168  /**
169   * Managed object client implementation.
170   */
171  private static class RC4PasswordStorageSchemeCfgClientImpl implements
172    RC4PasswordStorageSchemeCfgClient {
173
174    /** Private implementation. */
175    private ManagedObject<? extends RC4PasswordStorageSchemeCfgClient> impl;
176
177
178
179    /** Private constructor. */
180    private RC4PasswordStorageSchemeCfgClientImpl(
181        ManagedObject<? extends RC4PasswordStorageSchemeCfgClient> impl) {
182      this.impl = impl;
183    }
184
185
186
187    /** {@inheritDoc} */
188    public Boolean isEnabled() {
189      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
190    }
191
192
193
194    /** {@inheritDoc} */
195    public void setEnabled(boolean value) {
196      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
197    }
198
199
200
201    /** {@inheritDoc} */
202    public String getJavaClass() {
203      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
204    }
205
206
207
208    /** {@inheritDoc} */
209    public void setJavaClass(String value) {
210      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
211    }
212
213
214
215    /** {@inheritDoc} */
216    public ManagedObjectDefinition<? extends RC4PasswordStorageSchemeCfgClient, ? extends RC4PasswordStorageSchemeCfg> definition() {
217      return INSTANCE;
218    }
219
220
221
222    /** {@inheritDoc} */
223    public PropertyProvider properties() {
224      return impl;
225    }
226
227
228
229    /** {@inheritDoc} */
230    public void commit() throws ManagedObjectAlreadyExistsException,
231        MissingMandatoryPropertiesException, ConcurrentModificationException,
232        OperationRejectedException, LdapException {
233      impl.commit();
234    }
235
236
237
238    /** {@inheritDoc} */
239    public String toString() {
240      return impl.toString();
241    }
242  }
243
244
245
246  /**
247   * Managed object server implementation.
248   */
249  private static class RC4PasswordStorageSchemeCfgServerImpl implements
250    RC4PasswordStorageSchemeCfg {
251
252    /** Private implementation. */
253    private ServerManagedObject<? extends RC4PasswordStorageSchemeCfg> impl;
254
255    /** The value of the "enabled" property. */
256    private final boolean pEnabled;
257
258    /** The value of the "java-class" property. */
259    private final String pJavaClass;
260
261
262
263    /** Private constructor. */
264    private RC4PasswordStorageSchemeCfgServerImpl(ServerManagedObject<? extends RC4PasswordStorageSchemeCfg> impl) {
265      this.impl = impl;
266      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
267      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
268    }
269
270
271
272    /** {@inheritDoc} */
273    public void addRC4ChangeListener(
274        ConfigurationChangeListener<RC4PasswordStorageSchemeCfg> listener) {
275      impl.registerChangeListener(listener);
276    }
277
278
279
280    /** {@inheritDoc} */
281    public void removeRC4ChangeListener(
282        ConfigurationChangeListener<RC4PasswordStorageSchemeCfg> listener) {
283      impl.deregisterChangeListener(listener);
284    }
285    /** {@inheritDoc} */
286    public void addChangeListener(
287        ConfigurationChangeListener<PasswordStorageSchemeCfg> listener) {
288      impl.registerChangeListener(listener);
289    }
290
291
292
293    /** {@inheritDoc} */
294    public void removeChangeListener(
295        ConfigurationChangeListener<PasswordStorageSchemeCfg> listener) {
296      impl.deregisterChangeListener(listener);
297    }
298
299
300
301    /** {@inheritDoc} */
302    public boolean isEnabled() {
303      return pEnabled;
304    }
305
306
307
308    /** {@inheritDoc} */
309    public String getJavaClass() {
310      return pJavaClass;
311    }
312
313
314
315    /** {@inheritDoc} */
316    public Class<? extends RC4PasswordStorageSchemeCfg> configurationClass() {
317      return RC4PasswordStorageSchemeCfg.class;
318    }
319
320
321
322    /** {@inheritDoc} */
323    public DN dn() {
324      return impl.getDN();
325    }
326
327
328
329    /** {@inheritDoc} */
330    public String toString() {
331      return impl.toString();
332    }
333  }
334}