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