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