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