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