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 java.util.Collection;
032    import java.util.SortedSet;
033    import java.util.TreeSet;
034    import org.opends.server.admin.AdministratorAction;
035    import org.opends.server.admin.AggregationPropertyDefinition;
036    import org.opends.server.admin.AliasDefaultBehaviorProvider;
037    import org.opends.server.admin.BooleanPropertyDefinition;
038    import org.opends.server.admin.ClassPropertyDefinition;
039    import org.opends.server.admin.client.AuthorizationException;
040    import org.opends.server.admin.client.CommunicationException;
041    import org.opends.server.admin.client.ConcurrentModificationException;
042    import org.opends.server.admin.client.ManagedObject;
043    import org.opends.server.admin.client.MissingMandatoryPropertiesException;
044    import org.opends.server.admin.client.OperationRejectedException;
045    import org.opends.server.admin.DefaultBehaviorProvider;
046    import org.opends.server.admin.DefinedDefaultBehaviorProvider;
047    import org.opends.server.admin.EnumPropertyDefinition;
048    import org.opends.server.admin.ManagedObjectAlreadyExistsException;
049    import org.opends.server.admin.ManagedObjectDefinition;
050    import org.opends.server.admin.PropertyOption;
051    import org.opends.server.admin.PropertyProvider;
052    import org.opends.server.admin.server.ConfigurationChangeListener;
053    import org.opends.server.admin.server.ServerManagedObject;
054    import org.opends.server.admin.std.client.PasswordPolicyImportPluginCfgClient;
055    import org.opends.server.admin.std.client.PasswordStorageSchemeCfgClient;
056    import org.opends.server.admin.std.meta.PluginCfgDefn.PluginType;
057    import org.opends.server.admin.std.server.PasswordPolicyImportPluginCfg;
058    import org.opends.server.admin.std.server.PasswordStorageSchemeCfg;
059    import org.opends.server.admin.std.server.PluginCfg;
060    import org.opends.server.admin.Tag;
061    import org.opends.server.types.DN;
062    
063    
064    
065    /**
066     * An interface for querying the Password Policy Import Plugin managed
067     * object definition meta information.
068     * <p>
069     * The Password Policy Import Plugin ensures that clear-text passwords
070     * contained in LDIF entries are properly encoded before they are
071     * stored in the appropriate Directory Server backend.
072     */
073    public final class PasswordPolicyImportPluginCfgDefn extends ManagedObjectDefinition<PasswordPolicyImportPluginCfgClient, PasswordPolicyImportPluginCfg> {
074    
075      // The singleton configuration definition instance.
076      private static final PasswordPolicyImportPluginCfgDefn INSTANCE = new PasswordPolicyImportPluginCfgDefn();
077    
078    
079    
080      // The "default-auth-password-storage-scheme" property definition.
081      private static final AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME;
082    
083    
084    
085      // The "default-user-password-storage-scheme" property definition.
086      private static final AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME;
087    
088    
089    
090      // The "invoke-for-internal-operations" property definition.
091      private static final BooleanPropertyDefinition PD_INVOKE_FOR_INTERNAL_OPERATIONS;
092    
093    
094    
095      // The "java-class" property definition.
096      private static final ClassPropertyDefinition PD_JAVA_CLASS;
097    
098    
099    
100      // The "plugin-type" property definition.
101      private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE;
102    
103    
104    
105      // Build the "default-auth-password-storage-scheme" property definition.
106      static {
107          AggregationPropertyDefinition.Builder<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "default-auth-password-storage-scheme");
108          builder.setOption(PropertyOption.MULTI_VALUED);
109          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "default-auth-password-storage-scheme"));
110          builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "default-auth-password-storage-scheme"));
111          builder.setParentPath("/");
112          builder.setRelationDefinition("password-storage-scheme");
113          PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME = builder.getInstance();
114          INSTANCE.registerPropertyDefinition(PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME);
115          INSTANCE.registerConstraint(PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME.getSourceConstraint());
116      }
117    
118    
119    
120      // Build the "default-user-password-storage-scheme" property definition.
121      static {
122          AggregationPropertyDefinition.Builder<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "default-user-password-storage-scheme");
123          builder.setOption(PropertyOption.MULTI_VALUED);
124          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "default-user-password-storage-scheme"));
125          builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "default-user-password-storage-scheme"));
126          builder.setParentPath("/");
127          builder.setRelationDefinition("password-storage-scheme");
128          PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME = builder.getInstance();
129          INSTANCE.registerPropertyDefinition(PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME);
130          INSTANCE.registerConstraint(PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME.getSourceConstraint());
131      }
132    
133    
134    
135      // Build the "invoke-for-internal-operations" property definition.
136      static {
137          BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "invoke-for-internal-operations");
138          builder.setOption(PropertyOption.ADVANCED);
139          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "invoke-for-internal-operations"));
140          DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
141          builder.setDefaultBehaviorProvider(provider);
142          PD_INVOKE_FOR_INTERNAL_OPERATIONS = builder.getInstance();
143          INSTANCE.registerPropertyDefinition(PD_INVOKE_FOR_INTERNAL_OPERATIONS);
144      }
145    
146    
147    
148      // Build the "java-class" property definition.
149      static {
150          ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
151          builder.setOption(PropertyOption.MANDATORY);
152          builder.setOption(PropertyOption.ADVANCED);
153          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
154          DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.PasswordPolicyImportPlugin");
155          builder.setDefaultBehaviorProvider(provider);
156          builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin");
157          PD_JAVA_CLASS = builder.getInstance();
158          INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
159      }
160    
161    
162    
163      // Build the "plugin-type" property definition.
164      static {
165          EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type");
166          builder.setOption(PropertyOption.MULTI_VALUED);
167          builder.setOption(PropertyOption.MANDATORY);
168          builder.setOption(PropertyOption.ADVANCED);
169          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type"));
170          DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("ldifimport");
171          builder.setDefaultBehaviorProvider(provider);
172          builder.setEnumClass(PluginType.class);
173          PD_PLUGIN_TYPE = builder.getInstance();
174          INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE);
175      }
176    
177    
178    
179      // Register the tags associated with this managed object definition.
180      static {
181        INSTANCE.registerTag(Tag.valueOf("core-server"));
182      }
183    
184    
185    
186      /**
187       * Get the Password Policy Import Plugin configuration definition
188       * singleton.
189       *
190       * @return Returns the Password Policy Import Plugin configuration
191       *         definition singleton.
192       */
193      public static PasswordPolicyImportPluginCfgDefn getInstance() {
194        return INSTANCE;
195      }
196    
197    
198    
199      /**
200       * Private constructor.
201       */
202      private PasswordPolicyImportPluginCfgDefn() {
203        super("password-policy-import-plugin", PluginCfgDefn.getInstance());
204      }
205    
206    
207    
208      /**
209       * {@inheritDoc}
210       */
211      public PasswordPolicyImportPluginCfgClient createClientConfiguration(
212          ManagedObject<? extends PasswordPolicyImportPluginCfgClient> impl) {
213        return new PasswordPolicyImportPluginCfgClientImpl(impl);
214      }
215    
216    
217    
218      /**
219       * {@inheritDoc}
220       */
221      public PasswordPolicyImportPluginCfg createServerConfiguration(
222          ServerManagedObject<? extends PasswordPolicyImportPluginCfg> impl) {
223        return new PasswordPolicyImportPluginCfgServerImpl(impl);
224      }
225    
226    
227    
228      /**
229       * {@inheritDoc}
230       */
231      public Class<PasswordPolicyImportPluginCfg> getServerConfigurationClass() {
232        return PasswordPolicyImportPluginCfg.class;
233      }
234    
235    
236    
237      /**
238       * Get the "default-auth-password-storage-scheme" property definition.
239       * <p>
240       * Specifies the names of password storage schemes that to be used
241       * for encoding passwords contained in attributes with the auth
242       * password syntax for entries that do not include the
243       * ds-pwp-password-policy-dn attribute specifying which password
244       * policy should be used to govern them.
245       *
246       * @return Returns the "default-auth-password-storage-scheme" property definition.
247       */
248      public AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> getDefaultAuthPasswordStorageSchemePropertyDefinition() {
249        return PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME;
250      }
251    
252    
253    
254      /**
255       * Get the "default-user-password-storage-scheme" property definition.
256       * <p>
257       * Specifies the names of the password storage schemes to be used
258       * for encoding passwords contained in attributes with the user
259       * password syntax for entries that do not include the
260       * ds-pwp-password-policy-dn attribute specifying which password
261       * policy is to be used to govern them.
262       *
263       * @return Returns the "default-user-password-storage-scheme" property definition.
264       */
265      public AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> getDefaultUserPasswordStorageSchemePropertyDefinition() {
266        return PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME;
267      }
268    
269    
270    
271      /**
272       * Get the "enabled" property definition.
273       * <p>
274       * Indicates whether the plug-in is enabled for use.
275       *
276       * @return Returns the "enabled" property definition.
277       */
278      public BooleanPropertyDefinition getEnabledPropertyDefinition() {
279        return PluginCfgDefn.getInstance().getEnabledPropertyDefinition();
280      }
281    
282    
283    
284      /**
285       * Get the "invoke-for-internal-operations" property definition.
286       * <p>
287       * Indicates whether the plug-in should be invoked for internal
288       * operations.
289       * <p>
290       * Any plug-in that can be invoked for internal operations must
291       * ensure that it does not create any new internal operatons that can
292       * cause the same plug-in to be re-invoked.
293       *
294       * @return Returns the "invoke-for-internal-operations" property definition.
295       */
296      public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() {
297        return PD_INVOKE_FOR_INTERNAL_OPERATIONS;
298      }
299    
300    
301    
302      /**
303       * Get the "java-class" property definition.
304       * <p>
305       * Specifies the fully-qualified name of the Java class that
306       * provides the plug-in implementation.
307       *
308       * @return Returns the "java-class" property definition.
309       */
310      public ClassPropertyDefinition getJavaClassPropertyDefinition() {
311        return PD_JAVA_CLASS;
312      }
313    
314    
315    
316      /**
317       * Get the "plugin-type" property definition.
318       * <p>
319       * Specifies the set of plug-in types for the plug-in, which
320       * specifies the times at which the plug-in is invoked.
321       *
322       * @return Returns the "plugin-type" property definition.
323       */
324      public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() {
325        return PD_PLUGIN_TYPE;
326      }
327    
328    
329    
330      /**
331       * Managed object client implementation.
332       */
333      private static class PasswordPolicyImportPluginCfgClientImpl implements
334        PasswordPolicyImportPluginCfgClient {
335    
336        // Private implementation.
337        private ManagedObject<? extends PasswordPolicyImportPluginCfgClient> impl;
338    
339    
340    
341        // Private constructor.
342        private PasswordPolicyImportPluginCfgClientImpl(
343            ManagedObject<? extends PasswordPolicyImportPluginCfgClient> impl) {
344          this.impl = impl;
345        }
346    
347    
348    
349        /**
350         * {@inheritDoc}
351         */
352        public SortedSet<String> getDefaultAuthPasswordStorageScheme() {
353          return impl.getPropertyValues(INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition());
354        }
355    
356    
357    
358        /**
359         * {@inheritDoc}
360         */
361        public void setDefaultAuthPasswordStorageScheme(Collection<String> values) {
362          impl.setPropertyValues(INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition(), values);
363        }
364    
365    
366    
367        /**
368         * {@inheritDoc}
369         */
370        public SortedSet<String> getDefaultUserPasswordStorageScheme() {
371          return impl.getPropertyValues(INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition());
372        }
373    
374    
375    
376        /**
377         * {@inheritDoc}
378         */
379        public void setDefaultUserPasswordStorageScheme(Collection<String> values) {
380          impl.setPropertyValues(INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition(), values);
381        }
382    
383    
384    
385        /**
386         * {@inheritDoc}
387         */
388        public Boolean isEnabled() {
389          return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
390        }
391    
392    
393    
394        /**
395         * {@inheritDoc}
396         */
397        public void setEnabled(boolean value) {
398          impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
399        }
400    
401    
402    
403        /**
404         * {@inheritDoc}
405         */
406        public boolean isInvokeForInternalOperations() {
407          return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
408        }
409    
410    
411    
412        /**
413         * {@inheritDoc}
414         */
415        public void setInvokeForInternalOperations(Boolean value) {
416          impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value);
417        }
418    
419    
420    
421        /**
422         * {@inheritDoc}
423         */
424        public String getJavaClass() {
425          return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
426        }
427    
428    
429    
430        /**
431         * {@inheritDoc}
432         */
433        public void setJavaClass(String value) {
434          impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
435        }
436    
437    
438    
439        /**
440         * {@inheritDoc}
441         */
442        public SortedSet<PluginType> getPluginType() {
443          return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
444        }
445    
446    
447    
448        /**
449         * {@inheritDoc}
450         */
451        public void setPluginType(Collection<PluginType> values) {
452          impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values);
453        }
454    
455    
456    
457        /**
458         * {@inheritDoc}
459         */
460        public ManagedObjectDefinition<? extends PasswordPolicyImportPluginCfgClient, ? extends PasswordPolicyImportPluginCfg> definition() {
461          return INSTANCE;
462        }
463    
464    
465    
466        /**
467         * {@inheritDoc}
468         */
469        public PropertyProvider properties() {
470          return impl;
471        }
472    
473    
474    
475        /**
476         * {@inheritDoc}
477         */
478        public void commit() throws ManagedObjectAlreadyExistsException,
479            MissingMandatoryPropertiesException, ConcurrentModificationException,
480            OperationRejectedException, AuthorizationException,
481            CommunicationException {
482          impl.commit();
483        }
484    
485      }
486    
487    
488    
489      /**
490       * Managed object server implementation.
491       */
492      private static class PasswordPolicyImportPluginCfgServerImpl implements
493        PasswordPolicyImportPluginCfg {
494    
495        // Private implementation.
496        private ServerManagedObject<? extends PasswordPolicyImportPluginCfg> impl;
497    
498        // The value of the "default-auth-password-storage-scheme" property.
499        private final SortedSet<String> pDefaultAuthPasswordStorageScheme;
500    
501        // The value of the "default-user-password-storage-scheme" property.
502        private final SortedSet<String> pDefaultUserPasswordStorageScheme;
503    
504        // The value of the "enabled" property.
505        private final boolean pEnabled;
506    
507        // The value of the "invoke-for-internal-operations" property.
508        private final boolean pInvokeForInternalOperations;
509    
510        // The value of the "java-class" property.
511        private final String pJavaClass;
512    
513        // The value of the "plugin-type" property.
514        private final SortedSet<PluginType> pPluginType;
515    
516    
517    
518        // Private constructor.
519        private PasswordPolicyImportPluginCfgServerImpl(ServerManagedObject<? extends PasswordPolicyImportPluginCfg> impl) {
520          this.impl = impl;
521          this.pDefaultAuthPasswordStorageScheme = impl.getPropertyValues(INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition());
522          this.pDefaultUserPasswordStorageScheme = impl.getPropertyValues(INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition());
523          this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
524          this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
525          this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
526          this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
527        }
528    
529    
530    
531        /**
532         * {@inheritDoc}
533         */
534        public void addPasswordPolicyImportChangeListener(
535            ConfigurationChangeListener<PasswordPolicyImportPluginCfg> listener) {
536          impl.registerChangeListener(listener);
537        }
538    
539    
540    
541        /**
542         * {@inheritDoc}
543         */
544        public void removePasswordPolicyImportChangeListener(
545            ConfigurationChangeListener<PasswordPolicyImportPluginCfg> listener) {
546          impl.deregisterChangeListener(listener);
547        }
548        /**
549         * {@inheritDoc}
550         */
551        public void addChangeListener(
552            ConfigurationChangeListener<PluginCfg> listener) {
553          impl.registerChangeListener(listener);
554        }
555    
556    
557    
558        /**
559         * {@inheritDoc}
560         */
561        public void removeChangeListener(
562            ConfigurationChangeListener<PluginCfg> listener) {
563          impl.deregisterChangeListener(listener);
564        }
565    
566    
567    
568        /**
569         * {@inheritDoc}
570         */
571        public SortedSet<String> getDefaultAuthPasswordStorageScheme() {
572          return pDefaultAuthPasswordStorageScheme;
573        }
574    
575    
576    
577        /**
578         * {@inheritDoc}
579         */
580        public SortedSet<DN> getDefaultAuthPasswordStorageSchemeDNs() {
581          SortedSet<String> values = getDefaultAuthPasswordStorageScheme();
582          SortedSet<DN> dnValues = new TreeSet<DN>();
583          for (String value : values) {
584            DN dn = INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition().getChildDN(value);
585            dnValues.add(dn);
586          }
587          return dnValues;
588        }
589    
590    
591    
592        /**
593         * {@inheritDoc}
594         */
595        public SortedSet<String> getDefaultUserPasswordStorageScheme() {
596          return pDefaultUserPasswordStorageScheme;
597        }
598    
599    
600    
601        /**
602         * {@inheritDoc}
603         */
604        public SortedSet<DN> getDefaultUserPasswordStorageSchemeDNs() {
605          SortedSet<String> values = getDefaultUserPasswordStorageScheme();
606          SortedSet<DN> dnValues = new TreeSet<DN>();
607          for (String value : values) {
608            DN dn = INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition().getChildDN(value);
609            dnValues.add(dn);
610          }
611          return dnValues;
612        }
613    
614    
615    
616        /**
617         * {@inheritDoc}
618         */
619        public boolean isEnabled() {
620          return pEnabled;
621        }
622    
623    
624    
625        /**
626         * {@inheritDoc}
627         */
628        public boolean isInvokeForInternalOperations() {
629          return pInvokeForInternalOperations;
630        }
631    
632    
633    
634        /**
635         * {@inheritDoc}
636         */
637        public String getJavaClass() {
638          return pJavaClass;
639        }
640    
641    
642    
643        /**
644         * {@inheritDoc}
645         */
646        public SortedSet<PluginType> getPluginType() {
647          return pPluginType;
648        }
649    
650    
651    
652        /**
653         * {@inheritDoc}
654         */
655        public Class<? extends PasswordPolicyImportPluginCfg> configurationClass() {
656          return PasswordPolicyImportPluginCfg.class;
657        }
658    
659    
660    
661        /**
662         * {@inheritDoc}
663         */
664        public DN dn() {
665          return impl.getDN();
666        }
667    
668      }
669    }