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