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  /** {@inheritDoc} */
164  public PasswordExpirationTimeVirtualAttributeCfgClient createClientConfiguration(
165      ManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfgClient> impl) {
166    return new PasswordExpirationTimeVirtualAttributeCfgClientImpl(impl);
167  }
168
169
170
171  /** {@inheritDoc} */
172  public PasswordExpirationTimeVirtualAttributeCfg createServerConfiguration(
173      ServerManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfg> impl) {
174    return new PasswordExpirationTimeVirtualAttributeCfgServerImpl(impl);
175  }
176
177
178
179  /** {@inheritDoc} */
180  public Class<PasswordExpirationTimeVirtualAttributeCfg> getServerConfigurationClass() {
181    return PasswordExpirationTimeVirtualAttributeCfg.class;
182  }
183
184
185
186  /**
187   * Get the "attribute-type" property definition.
188   * <p>
189   * Specifies the attribute type for the attribute whose values are
190   * to be dynamically assigned by the virtual attribute.
191   *
192   * @return Returns the "attribute-type" property definition.
193   */
194  public AttributeTypePropertyDefinition getAttributeTypePropertyDefinition() {
195    return PD_ATTRIBUTE_TYPE;
196  }
197
198
199
200  /**
201   * Get the "base-dn" property definition.
202   * <p>
203   * Specifies the base DNs for the branches containing entries that
204   * are eligible to use this virtual attribute.
205   * <p>
206   * If no values are given, then the server generates virtual
207   * attributes anywhere in the server.
208   *
209   * @return Returns the "base-dn" property definition.
210   */
211  public DNPropertyDefinition getBaseDNPropertyDefinition() {
212    return VirtualAttributeCfgDefn.getInstance().getBaseDNPropertyDefinition();
213  }
214
215
216
217  /**
218   * Get the "conflict-behavior" property definition.
219   * <p>
220   * Specifies the behavior that the server is to exhibit for entries
221   * that already contain one or more real values for the associated
222   * attribute.
223   *
224   * @return Returns the "conflict-behavior" property definition.
225   */
226  public EnumPropertyDefinition<ConflictBehavior> getConflictBehaviorPropertyDefinition() {
227    return PD_CONFLICT_BEHAVIOR;
228  }
229
230
231
232  /**
233   * Get the "enabled" property definition.
234   * <p>
235   * Indicates whether the Password Expiration Time Virtual Attribute
236   * is enabled for use.
237   *
238   * @return Returns the "enabled" property definition.
239   */
240  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
241    return VirtualAttributeCfgDefn.getInstance().getEnabledPropertyDefinition();
242  }
243
244
245
246  /**
247   * Get the "filter" property definition.
248   * <p>
249   * Specifies the search filters to be applied against entries to
250   * determine if the virtual attribute is to be generated for those
251   * entries.
252   * <p>
253   * If no values are given, then any entry is eligible to have the
254   * value generated. If one or more filters are specified, then only
255   * entries that match at least one of those filters are allowed to
256   * have the virtual attribute.
257   *
258   * @return Returns the "filter" property definition.
259   */
260  public StringPropertyDefinition getFilterPropertyDefinition() {
261    return VirtualAttributeCfgDefn.getInstance().getFilterPropertyDefinition();
262  }
263
264
265
266  /**
267   * Get the "group-dn" property definition.
268   * <p>
269   * Specifies the DNs of the groups whose members can be eligible to
270   * use this virtual attribute.
271   * <p>
272   * If no values are given, then group membership is not taken into
273   * account when generating the virtual attribute. If one or more
274   * group DNs are specified, then only members of those groups are
275   * allowed to have the virtual attribute.
276   *
277   * @return Returns the "group-dn" property definition.
278   */
279  public DNPropertyDefinition getGroupDNPropertyDefinition() {
280    return VirtualAttributeCfgDefn.getInstance().getGroupDNPropertyDefinition();
281  }
282
283
284
285  /**
286   * Get the "java-class" property definition.
287   * <p>
288   * Specifies the fully-qualified name of the virtual attribute
289   * provider class that generates the attribute values.
290   *
291   * @return Returns the "java-class" property definition.
292   */
293  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
294    return PD_JAVA_CLASS;
295  }
296
297
298
299  /**
300   * Get the "scope" property definition.
301   * <p>
302   * Specifies the LDAP scope associated with base DNs for entries
303   * that are eligible to use this virtual attribute.
304   *
305   * @return Returns the "scope" property definition.
306   */
307  public EnumPropertyDefinition<Scope> getScopePropertyDefinition() {
308    return VirtualAttributeCfgDefn.getInstance().getScopePropertyDefinition();
309  }
310
311
312
313  /**
314   * Managed object client implementation.
315   */
316  private static class PasswordExpirationTimeVirtualAttributeCfgClientImpl implements
317    PasswordExpirationTimeVirtualAttributeCfgClient {
318
319    /** Private implementation. */
320    private ManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfgClient> impl;
321
322
323
324    /** Private constructor. */
325    private PasswordExpirationTimeVirtualAttributeCfgClientImpl(
326        ManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfgClient> impl) {
327      this.impl = impl;
328    }
329
330
331
332    /** {@inheritDoc} */
333    public AttributeType getAttributeType() {
334      return impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition());
335    }
336
337
338
339    /** {@inheritDoc} */
340    public void setAttributeType(AttributeType value) {
341      impl.setPropertyValue(INSTANCE.getAttributeTypePropertyDefinition(), value);
342    }
343
344
345
346    /** {@inheritDoc} */
347    public SortedSet<DN> getBaseDN() {
348      return impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition());
349    }
350
351
352
353    /** {@inheritDoc} */
354    public void setBaseDN(Collection<DN> values) {
355      impl.setPropertyValues(INSTANCE.getBaseDNPropertyDefinition(), values);
356    }
357
358
359
360    /** {@inheritDoc} */
361    public ConflictBehavior getConflictBehavior() {
362      return impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition());
363    }
364
365
366
367    /** {@inheritDoc} */
368    public void setConflictBehavior(ConflictBehavior value) {
369      impl.setPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition(), value);
370    }
371
372
373
374    /** {@inheritDoc} */
375    public Boolean isEnabled() {
376      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
377    }
378
379
380
381    /** {@inheritDoc} */
382    public void setEnabled(boolean value) {
383      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
384    }
385
386
387
388    /** {@inheritDoc} */
389    public SortedSet<String> getFilter() {
390      return impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition());
391    }
392
393
394
395    /** {@inheritDoc} */
396    public void setFilter(Collection<String> values) {
397      impl.setPropertyValues(INSTANCE.getFilterPropertyDefinition(), values);
398    }
399
400
401
402    /** {@inheritDoc} */
403    public SortedSet<DN> getGroupDN() {
404      return impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition());
405    }
406
407
408
409    /** {@inheritDoc} */
410    public void setGroupDN(Collection<DN> values) {
411      impl.setPropertyValues(INSTANCE.getGroupDNPropertyDefinition(), values);
412    }
413
414
415
416    /** {@inheritDoc} */
417    public String getJavaClass() {
418      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
419    }
420
421
422
423    /** {@inheritDoc} */
424    public void setJavaClass(String value) {
425      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
426    }
427
428
429
430    /** {@inheritDoc} */
431    public Scope getScope() {
432      return impl.getPropertyValue(INSTANCE.getScopePropertyDefinition());
433    }
434
435
436
437    /** {@inheritDoc} */
438    public void setScope(Scope value) {
439      impl.setPropertyValue(INSTANCE.getScopePropertyDefinition(), value);
440    }
441
442
443
444    /** {@inheritDoc} */
445    public ManagedObjectDefinition<? extends PasswordExpirationTimeVirtualAttributeCfgClient, ? extends PasswordExpirationTimeVirtualAttributeCfg> definition() {
446      return INSTANCE;
447    }
448
449
450
451    /** {@inheritDoc} */
452    public PropertyProvider properties() {
453      return impl;
454    }
455
456
457
458    /** {@inheritDoc} */
459    public void commit() throws ManagedObjectAlreadyExistsException,
460        MissingMandatoryPropertiesException, ConcurrentModificationException,
461        OperationRejectedException, LdapException {
462      impl.commit();
463    }
464
465
466
467    /** {@inheritDoc} */
468    public String toString() {
469      return impl.toString();
470    }
471  }
472
473
474
475  /**
476   * Managed object server implementation.
477   */
478  private static class PasswordExpirationTimeVirtualAttributeCfgServerImpl implements
479    PasswordExpirationTimeVirtualAttributeCfg {
480
481    /** Private implementation. */
482    private ServerManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfg> impl;
483
484    /** The value of the "attribute-type" property. */
485    private final AttributeType pAttributeType;
486
487    /** The value of the "base-dn" property. */
488    private final SortedSet<DN> pBaseDN;
489
490    /** The value of the "conflict-behavior" property. */
491    private final ConflictBehavior pConflictBehavior;
492
493    /** The value of the "enabled" property. */
494    private final boolean pEnabled;
495
496    /** The value of the "filter" property. */
497    private final SortedSet<String> pFilter;
498
499    /** The value of the "group-dn" property. */
500    private final SortedSet<DN> pGroupDN;
501
502    /** The value of the "java-class" property. */
503    private final String pJavaClass;
504
505    /** The value of the "scope" property. */
506    private final Scope pScope;
507
508
509
510    /** Private constructor. */
511    private PasswordExpirationTimeVirtualAttributeCfgServerImpl(ServerManagedObject<? extends PasswordExpirationTimeVirtualAttributeCfg> impl) {
512      this.impl = impl;
513      this.pAttributeType = impl.getPropertyValue(INSTANCE.getAttributeTypePropertyDefinition());
514      this.pBaseDN = impl.getPropertyValues(INSTANCE.getBaseDNPropertyDefinition());
515      this.pConflictBehavior = impl.getPropertyValue(INSTANCE.getConflictBehaviorPropertyDefinition());
516      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
517      this.pFilter = impl.getPropertyValues(INSTANCE.getFilterPropertyDefinition());
518      this.pGroupDN = impl.getPropertyValues(INSTANCE.getGroupDNPropertyDefinition());
519      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
520      this.pScope = impl.getPropertyValue(INSTANCE.getScopePropertyDefinition());
521    }
522
523
524
525    /** {@inheritDoc} */
526    public void addPasswordExpirationTimeChangeListener(
527        ConfigurationChangeListener<PasswordExpirationTimeVirtualAttributeCfg> listener) {
528      impl.registerChangeListener(listener);
529    }
530
531
532
533    /** {@inheritDoc} */
534    public void removePasswordExpirationTimeChangeListener(
535        ConfigurationChangeListener<PasswordExpirationTimeVirtualAttributeCfg> listener) {
536      impl.deregisterChangeListener(listener);
537    }
538    /** {@inheritDoc} */
539    public void addChangeListener(
540        ConfigurationChangeListener<VirtualAttributeCfg> listener) {
541      impl.registerChangeListener(listener);
542    }
543
544
545
546    /** {@inheritDoc} */
547    public void removeChangeListener(
548        ConfigurationChangeListener<VirtualAttributeCfg> listener) {
549      impl.deregisterChangeListener(listener);
550    }
551
552
553
554    /** {@inheritDoc} */
555    public AttributeType getAttributeType() {
556      return pAttributeType;
557    }
558
559
560
561    /** {@inheritDoc} */
562    public SortedSet<DN> getBaseDN() {
563      return pBaseDN;
564    }
565
566
567
568    /** {@inheritDoc} */
569    public ConflictBehavior getConflictBehavior() {
570      return pConflictBehavior;
571    }
572
573
574
575    /** {@inheritDoc} */
576    public boolean isEnabled() {
577      return pEnabled;
578    }
579
580
581
582    /** {@inheritDoc} */
583    public SortedSet<String> getFilter() {
584      return pFilter;
585    }
586
587
588
589    /** {@inheritDoc} */
590    public SortedSet<DN> getGroupDN() {
591      return pGroupDN;
592    }
593
594
595
596    /** {@inheritDoc} */
597    public String getJavaClass() {
598      return pJavaClass;
599    }
600
601
602
603    /** {@inheritDoc} */
604    public Scope getScope() {
605      return pScope;
606    }
607
608
609
610    /** {@inheritDoc} */
611    public Class<? extends PasswordExpirationTimeVirtualAttributeCfg> configurationClass() {
612      return PasswordExpirationTimeVirtualAttributeCfg.class;
613    }
614
615
616
617    /** {@inheritDoc} */
618    public DN dn() {
619      return impl.getDN();
620    }
621
622
623
624    /** {@inheritDoc} */
625    public String toString() {
626      return impl.toString();
627    }
628  }
629}