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
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.admin.std.meta;
028    
029    
030    
031    import org.opends.server.admin.AdministratorAction;
032    import org.opends.server.admin.BooleanPropertyDefinition;
033    import org.opends.server.admin.ClassPropertyDefinition;
034    import org.opends.server.admin.client.AuthorizationException;
035    import org.opends.server.admin.client.CommunicationException;
036    import org.opends.server.admin.client.ConcurrentModificationException;
037    import org.opends.server.admin.client.ManagedObject;
038    import org.opends.server.admin.client.MissingMandatoryPropertiesException;
039    import org.opends.server.admin.client.OperationRejectedException;
040    import org.opends.server.admin.DefaultBehaviorProvider;
041    import org.opends.server.admin.DefinedDefaultBehaviorProvider;
042    import org.opends.server.admin.ManagedObjectAlreadyExistsException;
043    import org.opends.server.admin.ManagedObjectDefinition;
044    import org.opends.server.admin.PropertyOption;
045    import org.opends.server.admin.PropertyProvider;
046    import org.opends.server.admin.server.ConfigurationChangeListener;
047    import org.opends.server.admin.server.ServerManagedObject;
048    import org.opends.server.admin.std.client.SHA1PasswordStorageSchemeCfgClient;
049    import org.opends.server.admin.std.server.PasswordStorageSchemeCfg;
050    import org.opends.server.admin.std.server.SHA1PasswordStorageSchemeCfg;
051    import org.opends.server.admin.Tag;
052    import org.opends.server.types.DN;
053    
054    
055    
056    /**
057     * An interface for querying the SHA1 Password Storage Scheme managed
058     * object definition meta information.
059     * <p>
060     * The SHA1 Password Storage Scheme provides a mechanism for encoding
061     * user passwords using an unsalted form of the SHA-1 message digest
062     * algorithm. Because the implementation does not use any kind of
063     * salting mechanism, a given password always has the same encoded
064     * form.
065     */
066    public final class SHA1PasswordStorageSchemeCfgDefn extends ManagedObjectDefinition<SHA1PasswordStorageSchemeCfgClient, SHA1PasswordStorageSchemeCfg> {
067    
068      // The singleton configuration definition instance.
069      private static final SHA1PasswordStorageSchemeCfgDefn INSTANCE = new SHA1PasswordStorageSchemeCfgDefn();
070    
071    
072    
073      // The "java-class" property definition.
074      private static final ClassPropertyDefinition PD_JAVA_CLASS;
075    
076    
077    
078      // Build the "java-class" property definition.
079      static {
080          ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
081          builder.setOption(PropertyOption.MANDATORY);
082          builder.setOption(PropertyOption.ADVANCED);
083          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
084          DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.SHA1PasswordStorageScheme");
085          builder.setDefaultBehaviorProvider(provider);
086          builder.addInstanceOf("org.opends.server.api.PasswordStorageScheme");
087          PD_JAVA_CLASS = builder.getInstance();
088          INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
089      }
090    
091    
092    
093      // Register the tags associated with this managed object definition.
094      static {
095        INSTANCE.registerTag(Tag.valueOf("user-management"));
096      }
097    
098    
099    
100      /**
101       * Get the SHA1 Password Storage Scheme configuration definition
102       * singleton.
103       *
104       * @return Returns the SHA1 Password Storage Scheme configuration
105       *         definition singleton.
106       */
107      public static SHA1PasswordStorageSchemeCfgDefn getInstance() {
108        return INSTANCE;
109      }
110    
111    
112    
113      /**
114       * Private constructor.
115       */
116      private SHA1PasswordStorageSchemeCfgDefn() {
117        super("sha1-password-storage-scheme", PasswordStorageSchemeCfgDefn.getInstance());
118      }
119    
120    
121    
122      /**
123       * {@inheritDoc}
124       */
125      public SHA1PasswordStorageSchemeCfgClient createClientConfiguration(
126          ManagedObject<? extends SHA1PasswordStorageSchemeCfgClient> impl) {
127        return new SHA1PasswordStorageSchemeCfgClientImpl(impl);
128      }
129    
130    
131    
132      /**
133       * {@inheritDoc}
134       */
135      public SHA1PasswordStorageSchemeCfg createServerConfiguration(
136          ServerManagedObject<? extends SHA1PasswordStorageSchemeCfg> impl) {
137        return new SHA1PasswordStorageSchemeCfgServerImpl(impl);
138      }
139    
140    
141    
142      /**
143       * {@inheritDoc}
144       */
145      public Class<SHA1PasswordStorageSchemeCfg> getServerConfigurationClass() {
146        return SHA1PasswordStorageSchemeCfg.class;
147      }
148    
149    
150    
151      /**
152       * Get the "enabled" property definition.
153       * <p>
154       * Indicates whether the SHA1 Password Storage Scheme is enabled for
155       * use.
156       *
157       * @return Returns the "enabled" property definition.
158       */
159      public BooleanPropertyDefinition getEnabledPropertyDefinition() {
160        return PasswordStorageSchemeCfgDefn.getInstance().getEnabledPropertyDefinition();
161      }
162    
163    
164    
165      /**
166       * Get the "java-class" property definition.
167       * <p>
168       * Specifies the fully-qualified name of the Java class that
169       * provides the SHA1 Password Storage Scheme implementation.
170       *
171       * @return Returns the "java-class" property definition.
172       */
173      public ClassPropertyDefinition getJavaClassPropertyDefinition() {
174        return PD_JAVA_CLASS;
175      }
176    
177    
178    
179      /**
180       * Managed object client implementation.
181       */
182      private static class SHA1PasswordStorageSchemeCfgClientImpl implements
183        SHA1PasswordStorageSchemeCfgClient {
184    
185        // Private implementation.
186        private ManagedObject<? extends SHA1PasswordStorageSchemeCfgClient> impl;
187    
188    
189    
190        // Private constructor.
191        private SHA1PasswordStorageSchemeCfgClientImpl(
192            ManagedObject<? extends SHA1PasswordStorageSchemeCfgClient> impl) {
193          this.impl = impl;
194        }
195    
196    
197    
198        /**
199         * {@inheritDoc}
200         */
201        public Boolean isEnabled() {
202          return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
203        }
204    
205    
206    
207        /**
208         * {@inheritDoc}
209         */
210        public void setEnabled(boolean value) {
211          impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
212        }
213    
214    
215    
216        /**
217         * {@inheritDoc}
218         */
219        public String getJavaClass() {
220          return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
221        }
222    
223    
224    
225        /**
226         * {@inheritDoc}
227         */
228        public void setJavaClass(String value) {
229          impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
230        }
231    
232    
233    
234        /**
235         * {@inheritDoc}
236         */
237        public ManagedObjectDefinition<? extends SHA1PasswordStorageSchemeCfgClient, ? extends SHA1PasswordStorageSchemeCfg> definition() {
238          return INSTANCE;
239        }
240    
241    
242    
243        /**
244         * {@inheritDoc}
245         */
246        public PropertyProvider properties() {
247          return impl;
248        }
249    
250    
251    
252        /**
253         * {@inheritDoc}
254         */
255        public void commit() throws ManagedObjectAlreadyExistsException,
256            MissingMandatoryPropertiesException, ConcurrentModificationException,
257            OperationRejectedException, AuthorizationException,
258            CommunicationException {
259          impl.commit();
260        }
261    
262      }
263    
264    
265    
266      /**
267       * Managed object server implementation.
268       */
269      private static class SHA1PasswordStorageSchemeCfgServerImpl implements
270        SHA1PasswordStorageSchemeCfg {
271    
272        // Private implementation.
273        private ServerManagedObject<? extends SHA1PasswordStorageSchemeCfg> impl;
274    
275        // The value of the "enabled" property.
276        private final boolean pEnabled;
277    
278        // The value of the "java-class" property.
279        private final String pJavaClass;
280    
281    
282    
283        // Private constructor.
284        private SHA1PasswordStorageSchemeCfgServerImpl(ServerManagedObject<? extends SHA1PasswordStorageSchemeCfg> impl) {
285          this.impl = impl;
286          this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
287          this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
288        }
289    
290    
291    
292        /**
293         * {@inheritDoc}
294         */
295        public void addSHA1ChangeListener(
296            ConfigurationChangeListener<SHA1PasswordStorageSchemeCfg> listener) {
297          impl.registerChangeListener(listener);
298        }
299    
300    
301    
302        /**
303         * {@inheritDoc}
304         */
305        public void removeSHA1ChangeListener(
306            ConfigurationChangeListener<SHA1PasswordStorageSchemeCfg> listener) {
307          impl.deregisterChangeListener(listener);
308        }
309        /**
310         * {@inheritDoc}
311         */
312        public void addChangeListener(
313            ConfigurationChangeListener<PasswordStorageSchemeCfg> listener) {
314          impl.registerChangeListener(listener);
315        }
316    
317    
318    
319        /**
320         * {@inheritDoc}
321         */
322        public void removeChangeListener(
323            ConfigurationChangeListener<PasswordStorageSchemeCfg> listener) {
324          impl.deregisterChangeListener(listener);
325        }
326    
327    
328    
329        /**
330         * {@inheritDoc}
331         */
332        public boolean isEnabled() {
333          return pEnabled;
334        }
335    
336    
337    
338        /**
339         * {@inheritDoc}
340         */
341        public String getJavaClass() {
342          return pJavaClass;
343        }
344    
345    
346    
347        /**
348         * {@inheritDoc}
349         */
350        public Class<? extends SHA1PasswordStorageSchemeCfg> configurationClass() {
351          return SHA1PasswordStorageSchemeCfg.class;
352        }
353    
354    
355    
356        /**
357         * {@inheritDoc}
358         */
359        public DN dn() {
360          return impl.getDN();
361        }
362    
363      }
364    }