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 org.opends.server.admin.AdministratorAction;
033import org.opends.server.admin.AttributeTypePropertyDefinition;
034import org.opends.server.admin.BooleanPropertyDefinition;
035import org.opends.server.admin.ClassPropertyDefinition;
036import org.opends.server.admin.client.AuthorizationException;
037import org.opends.server.admin.client.CommunicationException;
038import org.opends.server.admin.client.ConcurrentModificationException;
039import org.opends.server.admin.client.ManagedObject;
040import org.opends.server.admin.client.MissingMandatoryPropertiesException;
041import org.opends.server.admin.client.OperationRejectedException;
042import org.opends.server.admin.DefaultBehaviorProvider;
043import org.opends.server.admin.DefinedDefaultBehaviorProvider;
044import org.opends.server.admin.DNPropertyDefinition;
045import org.opends.server.admin.EnumPropertyDefinition;
046import org.opends.server.admin.ManagedObjectAlreadyExistsException;
047import org.opends.server.admin.ManagedObjectDefinition;
048import org.opends.server.admin.PropertyOption;
049import org.opends.server.admin.PropertyProvider;
050import org.opends.server.admin.server.ConfigurationChangeListener;
051import org.opends.server.admin.server.ServerManagedObject;
052import org.opends.server.admin.std.client.PasswordPolicySubentryVirtualAttributeCfgClient;
053import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.ConflictBehavior;
054import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.Scope;
055import org.opends.server.admin.std.server.PasswordPolicySubentryVirtualAttributeCfg;
056import org.opends.server.admin.std.server.VirtualAttributeCfg;
057import org.opends.server.admin.StringPropertyDefinition;
058import org.opends.server.admin.Tag;
059import org.opends.server.types.AttributeType;
060import org.opends.server.types.DN;
061
062
063
064/**
065 * An interface for querying the Password Policy Subentry Virtual
066 * Attribute managed object definition meta information.
067 * <p>
068 * The Password Policy Subentry Virtual Attribute generates a virtual
069 * attribute that points to the Password Policy subentry in effect for
070 * the entry.
071 */
072public final class PasswordPolicySubentryVirtualAttributeCfgDefn extends ManagedObjectDefinition<PasswordPolicySubentryVirtualAttributeCfgClient, PasswordPolicySubentryVirtualAttributeCfg> {
073
074  // The singleton configuration definition instance.
075  private static final PasswordPolicySubentryVirtualAttributeCfgDefn INSTANCE = new PasswordPolicySubentryVirtualAttributeCfgDefn();
076
077
078
079  // The "attribute-type" property definition.
080  private static final AttributeTypePropertyDefinition PD_ATTRIBUTE_TYPE;
081
082
083
084  // The "conflict-behavior" property definition.
085  private static final EnumPropertyDefinition<ConflictBehavior> PD_CONFLICT_BEHAVIOR;
086
087
088
089  // The "java-class" property definition.
090  private static final ClassPropertyDefinition PD_JAVA_CLASS;
091
092
093
094  // Build the "attribute-type" property definition.
095  static {
096      AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "attribute-type");
097      builder.setOption(PropertyOption.MANDATORY);
098      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "attribute-type"));
099      DefaultBehaviorProvider<AttributeType> provider = new DefinedDefaultBehaviorProvider<AttributeType>("pwdPolicySubentry");
100      builder.setDefaultBehaviorProvider(provider);
101      PD_ATTRIBUTE_TYPE = builder.getInstance();
102      INSTANCE.registerPropertyDefinition(PD_ATTRIBUTE_TYPE);
103  }
104
105
106
107  // Build the "conflict-behavior" property definition.
108  static {
109      EnumPropertyDefinition.Builder<ConflictBehavior> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "conflict-behavior");
110      builder.setOption(PropertyOption.ADVANCED);
111      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "conflict-behavior"));
112      DefaultBehaviorProvider<ConflictBehavior> provider = new DefinedDefaultBehaviorProvider<ConflictBehavior>("virtual-overrides-real");
113      builder.setDefaultBehaviorProvider(provider);
114      builder.setEnumClass(ConflictBehavior.class);
115      PD_CONFLICT_BEHAVIOR = builder.getInstance();
116      INSTANCE.registerPropertyDefinition(PD_CONFLICT_BEHAVIOR);
117  }
118
119
120
121  // Build the "java-class" property definition.
122  static {
123      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
124      builder.setOption(PropertyOption.MANDATORY);
125      builder.setOption(PropertyOption.ADVANCED);
126      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
127      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.PasswordPolicySubentryVirtualAttributeProvider");
128      builder.setDefaultBehaviorProvider(provider);
129      builder.addInstanceOf("org.opends.server.api.VirtualAttributeProvider");
130      PD_JAVA_CLASS = builder.getInstance();
131      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
132  }
133
134
135
136  // Register the tags associated with this managed object definition.
137  static {
138    INSTANCE.registerTag(Tag.valueOf("core-server"));
139  }
140
141
142
143  /**
144   * Get the Password Policy Subentry Virtual Attribute configuration
145   * definition singleton.
146   *
147   * @return Returns the Password Policy Subentry Virtual Attribute
148   *         configuration definition singleton.
149   */
150  public static PasswordPolicySubentryVirtualAttributeCfgDefn getInstance() {
151    return INSTANCE;
152  }
153
154
155
156  /**
157   * Private constructor.
158   */
159  private PasswordPolicySubentryVirtualAttributeCfgDefn() {
160    super("password-policy-subentry-virtual-attribute", VirtualAttributeCfgDefn.getInstance());
161  }
162
163
164
165  /**
166   * {@inheritDoc}
167   */
168  public PasswordPolicySubentryVirtualAttributeCfgClient createClientConfiguration(
169      ManagedObject<? extends PasswordPolicySubentryVirtualAttributeCfgClient> impl) {
170    return new PasswordPolicySubentryVirtualAttributeCfgClientImpl(impl);
171  }
172
173
174
175  /**
176   * {@inheritDoc}
177   */
178  public PasswordPolicySubentryVirtualAttributeCfg createServerConfiguration(
179      ServerManagedObject<? extends PasswordPolicySubentryVirtualAttributeCfg> impl) {
180    return new PasswordPolicySubentryVirtualAttributeCfgServerImpl(impl);
181  }
182
183
184
185  /**
186   * {@inheritDoc}
187   */
188  public Class<PasswordPolicySubentryVirtualAttributeCfg> getServerConfigurationClass() {
189    return PasswordPolicySubentryVirtualAttributeCfg.class;
190  }
191
192
193
194  /**
195   * Get the "attribute-type" property definition.
196   * <p>
197   * Specifies the attribute type for the attribute whose values are
198   * to be dynamically assigned by the virtual attribute.
199   *
200   * @return Returns the "attribute-type" property definition.
201   */
202  public AttributeTypePropertyDefinition getAttributeTypePropertyDefinition() {
203    return PD_ATTRIBUTE_TYPE;
204  }
205
206
207
208  /**
209   * Get the "base-dn" property definition.
210   * <p>
211   * Specifies the base DNs for the branches containing entries that
212   * are eligible to use this virtual attribute.
213   * <p>
214   * If no values are given, then the server generates virtual
215   * attributes anywhere in the server.
216   *
217   * @return Returns the "base-dn" property definition.
218   */
219  public DNPropertyDefinition getBaseDNPropertyDefinition() {
220    return VirtualAttributeCfgDefn.getInstance().getBaseDNPropertyDefinition();
221  }
222
223
224
225  /**
226   * Get the "conflict-behavior" property definition.
227   * <p>
228   * Specifies the behavior that the server is to exhibit for entries
229   * that already contain one or more real values for the associated
230   * attribute.
231   *
232   * @return Returns the "conflict-behavior" property definition.
233   */
234  public EnumPropertyDefinition<ConflictBehavior> getConflictBehaviorPropertyDefinition() {
235    return PD_CONFLICT_BEHAVIOR;
236  }
237
238
239
240  /**
241   * Get the "enabled" property definition.
242   * <p>
243   * Indicates whether the Password Policy Subentry Virtual Attribute
244   * is enabled for use.
245   *
246   * @return Returns the "enabled" property definition.
247   */
248  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
249    return VirtualAttributeCfgDefn.getInstance().getEnabledPropertyDefinition();
250  }
251
252
253
254  /**
255   * Get the "filter" property definition.
256   * <p>
257   * Specifies the search filters to be applied against entries to
258   * determine if the virtual attribute is to be generated for those
259   * entries.
260   * <p>
261   * If no values are given, then any entry is eligible to have the
262   * value generated. If one or more filters are specified, then only
263   * entries that match at least one of those filters are allowed to
264   * have the virtual attribute.
265   *
266   * @return Returns the "filter" property definition.
267   */
268  public StringPropertyDefinition getFilterPropertyDefinition() {
269    return VirtualAttributeCfgDefn.getInstance().getFilterPropertyDefinition();
270  }
271
272
273
274  /**
275   * Get the "group-dn" property definition.
276   * <p>
277   * Specifies the DNs of the groups whose members can be eligible to
278   * use this virtual attribute.
279   * <p>
280   * If no values are given, then group membership is not taken into
281   * account when generating the virtual attribute. If one or more
282   * group DNs are specified, then only members of those groups are
283   * allowed to have the virtual attribute.
284   *
285   * @return Returns the "group-dn" property definition.
286   */
287  public DNPropertyDefinition getGroupDNPropertyDefinition() {
288    return VirtualAttributeCfgDefn.getInstance().getGroupDNPropertyDefinition();
289  }
290
291
292
293  /**
294   * Get the "java-class" property definition.
295   * <p>
296   * Specifies the fully-qualified name of the virtual attribute
297   * provider class that generates the attribute values.
298   *
299   * @return Returns the "java-class" property definition.
300   */
301  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
302    return PD_JAVA_CLASS;
303  }
304
305
306
307  /**
308   * Get the "scope" property definition.
309   * <p>
310   * Specifies the LDAP scope associated with base DNs for entries
311   * that are eligible to use this virtual attribute.
312   *
313   * @return Returns the "scope" property definition.
314   */
315  public EnumPropertyDefinition<Scope> getScopePropertyDefinition() {
316    return VirtualAttributeCfgDefn.getInstance().getScopePropertyDefinition();
317  }
318
319
320
321  /**
322   * Managed object client implementation.
323   */
324  private static class PasswordPolicySubentryVirtualAttributeCfgClientImpl implements
325    PasswordPolicySubentryVirtualAttributeCfgClient {
326
327    // Private implementation.
328    private ManagedObject<? extends PasswordPolicySubentryVirtualAttributeCfgClient> impl;
329
330
331
332    // Private constructor.
333    private PasswordPolicySubentryVirtualAttributeCfgClientImpl(
334        ManagedObject<? extends PasswordPolicySubentryVirtualAttributeCfgClient> impl) {
335      this.impl = impl;
336    }
337
338
339
340    /**
341     * {@inheritDoc}
342     */
343    public AttributeType getAttributeType() {
344      return impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition());
345    }
346
347
348
349    /**
350     * {@inheritDoc}
351     */
352    public void setAttributeType(AttributeType value) {
353      impl.setPropertyValue(INSTANCE.getAttributeTypePropertyDefinition(), value);
354    }
355
356
357
358    /**
359     * {@inheritDoc}
360     */
361    public SortedSet<DN> getBaseDN() {
362      return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition());
363    }
364
365
366
367    /**
368     * {@inheritDoc}
369     */
370    public void setBaseDN(Collection<DN> values) {
371      impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values);
372    }
373
374
375
376    /**
377     * {@inheritDoc}
378     */
379    public ConflictBehavior getConflictBehavior() {
380      return impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition());
381    }
382
383
384
385    /**
386     * {@inheritDoc}
387     */
388    public void setConflictBehavior(ConflictBehavior value) {
389      impl.setPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition(), value);
390    }
391
392
393
394    /**
395     * {@inheritDoc}
396     */
397    public Boolean isEnabled() {
398      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
399    }
400
401
402
403    /**
404     * {@inheritDoc}
405     */
406    public void setEnabled(boolean value) {
407      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
408    }
409
410
411
412    /**
413     * {@inheritDoc}
414     */
415    public SortedSet<String> getFilter() {
416      return impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition());
417    }
418
419
420
421    /**
422     * {@inheritDoc}
423     */
424    public void setFilter(Collection<String> values) {
425      impl.setPropertyValues(INSTANCE.getFilterPropertyDefinition(), values);
426    }
427
428
429
430    /**
431     * {@inheritDoc}
432     */
433    public SortedSet<DN> getGroupDN() {
434      return impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition());
435    }
436
437
438
439    /**
440     * {@inheritDoc}
441     */
442    public void setGroupDN(Collection<DN> values) {
443      impl.setPropertyValues(INSTANCE.getGroupDNPropertyDefinition(), values);
444    }
445
446
447
448    /**
449     * {@inheritDoc}
450     */
451    public String getJavaClass() {
452      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
453    }
454
455
456
457    /**
458     * {@inheritDoc}
459     */
460    public void setJavaClass(String value) {
461      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
462    }
463
464
465
466    /**
467     * {@inheritDoc}
468     */
469    public Scope getScope() {
470      return impl.getPropertyValue(INSTANCE.getScopePropertyDefinition());
471    }
472
473
474
475    /**
476     * {@inheritDoc}
477     */
478    public void setScope(Scope value) {
479      impl.setPropertyValue(INSTANCE.getScopePropertyDefinition(), value);
480    }
481
482
483
484    /**
485     * {@inheritDoc}
486     */
487    public ManagedObjectDefinition<? extends PasswordPolicySubentryVirtualAttributeCfgClient, ? extends PasswordPolicySubentryVirtualAttributeCfg> definition() {
488      return INSTANCE;
489    }
490
491
492
493    /**
494     * {@inheritDoc}
495     */
496    public PropertyProvider properties() {
497      return impl;
498    }
499
500
501
502    /**
503     * {@inheritDoc}
504     */
505    public void commit() throws ManagedObjectAlreadyExistsException,
506        MissingMandatoryPropertiesException, ConcurrentModificationException,
507        OperationRejectedException, AuthorizationException,
508        CommunicationException {
509      impl.commit();
510    }
511
512
513
514    /** {@inheritDoc} */
515    public String toString() {
516      return impl.toString();
517    }
518  }
519
520
521
522  /**
523   * Managed object server implementation.
524   */
525  private static class PasswordPolicySubentryVirtualAttributeCfgServerImpl implements
526    PasswordPolicySubentryVirtualAttributeCfg {
527
528    // Private implementation.
529    private ServerManagedObject<? extends PasswordPolicySubentryVirtualAttributeCfg> impl;
530
531    // The value of the "attribute-type" property.
532    private final AttributeType pAttributeType;
533
534    // The value of the "base-dn" property.
535    private final SortedSet<DN> pBaseDN;
536
537    // The value of the "conflict-behavior" property.
538    private final ConflictBehavior pConflictBehavior;
539
540    // The value of the "enabled" property.
541    private final boolean pEnabled;
542
543    // The value of the "filter" property.
544    private final SortedSet<String> pFilter;
545
546    // The value of the "group-dn" property.
547    private final SortedSet<DN> pGroupDN;
548
549    // The value of the "java-class" property.
550    private final String pJavaClass;
551
552    // The value of the "scope" property.
553    private final Scope pScope;
554
555
556
557    // Private constructor.
558    private PasswordPolicySubentryVirtualAttributeCfgServerImpl(ServerManagedObject<? extends PasswordPolicySubentryVirtualAttributeCfg> impl) {
559      this.impl = impl;
560      this.pAttributeType = impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition());
561      this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition());
562      this.pConflictBehavior = impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition());
563      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
564      this.pFilter = impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition());
565      this.pGroupDN = impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition());
566      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
567      this.pScope = impl.getPropertyValue(INSTANCE.getScopePropertyDefinition());
568    }
569
570
571
572    /**
573     * {@inheritDoc}
574     */
575    public void addPasswordPolicySubentryChangeListener(
576        ConfigurationChangeListener<PasswordPolicySubentryVirtualAttributeCfg> listener) {
577      impl.registerChangeListener(listener);
578    }
579
580
581
582    /**
583     * {@inheritDoc}
584     */
585    public void removePasswordPolicySubentryChangeListener(
586        ConfigurationChangeListener<PasswordPolicySubentryVirtualAttributeCfg> listener) {
587      impl.deregisterChangeListener(listener);
588    }
589    /**
590     * {@inheritDoc}
591     */
592    public void addChangeListener(
593        ConfigurationChangeListener<VirtualAttributeCfg> listener) {
594      impl.registerChangeListener(listener);
595    }
596
597
598
599    /**
600     * {@inheritDoc}
601     */
602    public void removeChangeListener(
603        ConfigurationChangeListener<VirtualAttributeCfg> listener) {
604      impl.deregisterChangeListener(listener);
605    }
606
607
608
609    /**
610     * {@inheritDoc}
611     */
612    public AttributeType getAttributeType() {
613      return pAttributeType;
614    }
615
616
617
618    /**
619     * {@inheritDoc}
620     */
621    public SortedSet<DN> getBaseDN() {
622      return pBaseDN;
623    }
624
625
626
627    /**
628     * {@inheritDoc}
629     */
630    public ConflictBehavior getConflictBehavior() {
631      return pConflictBehavior;
632    }
633
634
635
636    /**
637     * {@inheritDoc}
638     */
639    public boolean isEnabled() {
640      return pEnabled;
641    }
642
643
644
645    /**
646     * {@inheritDoc}
647     */
648    public SortedSet<String> getFilter() {
649      return pFilter;
650    }
651
652
653
654    /**
655     * {@inheritDoc}
656     */
657    public SortedSet<DN> getGroupDN() {
658      return pGroupDN;
659    }
660
661
662
663    /**
664     * {@inheritDoc}
665     */
666    public String getJavaClass() {
667      return pJavaClass;
668    }
669
670
671
672    /**
673     * {@inheritDoc}
674     */
675    public Scope getScope() {
676      return pScope;
677    }
678
679
680
681    /**
682     * {@inheritDoc}
683     */
684    public Class<? extends PasswordPolicySubentryVirtualAttributeCfg> configurationClass() {
685      return PasswordPolicySubentryVirtualAttributeCfg.class;
686    }
687
688
689
690    /**
691     * {@inheritDoc}
692     */
693    public DN dn() {
694      return impl.getDN();
695    }
696
697
698
699    /** {@inheritDoc} */
700    public String toString() {
701      return impl.toString();
702    }
703  }
704}