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 org.forgerock.opendj.ldap.DN;
021import org.opends.server.admin.AdministratorAction;
022import org.opends.server.admin.BooleanPropertyDefinition;
023import org.opends.server.admin.ClassPropertyDefinition;
024import org.opends.server.admin.client.AuthorizationException;
025import org.opends.server.admin.client.CommunicationException;
026import org.opends.server.admin.client.ConcurrentModificationException;
027import org.opends.server.admin.client.ManagedObject;
028import org.opends.server.admin.client.MissingMandatoryPropertiesException;
029import org.opends.server.admin.client.OperationRejectedException;
030import org.opends.server.admin.DefaultBehaviorProvider;
031import org.opends.server.admin.DefinedDefaultBehaviorProvider;
032import org.opends.server.admin.ManagedObjectAlreadyExistsException;
033import org.opends.server.admin.ManagedObjectDefinition;
034import org.opends.server.admin.PropertyOption;
035import org.opends.server.admin.PropertyProvider;
036import org.opends.server.admin.server.ConfigurationChangeListener;
037import org.opends.server.admin.server.ServerManagedObject;
038import org.opends.server.admin.std.client.PasswordPolicyStateExtendedOperationHandlerCfgClient;
039import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
040import org.opends.server.admin.std.server.PasswordPolicyStateExtendedOperationHandlerCfg;
041import org.opends.server.admin.Tag;
042
043
044
045/**
046 * An interface for querying the Password Policy State Extended
047 * Operation Handler managed object definition meta information.
048 * <p>
049 * The Password Policy State Extended Operation Handler provides the
050 * ability for administrators to request and optionally alter password
051 * policy state information for a specified user.
052 */
053public final class PasswordPolicyStateExtendedOperationHandlerCfgDefn extends ManagedObjectDefinition<PasswordPolicyStateExtendedOperationHandlerCfgClient, PasswordPolicyStateExtendedOperationHandlerCfg> {
054
055  // The singleton configuration definition instance.
056  private static final PasswordPolicyStateExtendedOperationHandlerCfgDefn INSTANCE = new PasswordPolicyStateExtendedOperationHandlerCfgDefn();
057
058
059
060  // The "java-class" property definition.
061  private static final ClassPropertyDefinition PD_JAVA_CLASS;
062
063
064
065  // Build the "java-class" property definition.
066  static {
067      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
068      builder.setOption(PropertyOption.MANDATORY);
069      builder.setOption(PropertyOption.ADVANCED);
070      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
071      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.PasswordPolicyStateExtendedOperation");
072      builder.setDefaultBehaviorProvider(provider);
073      builder.addInstanceOf("org.opends.server.api.ExtendedOperationHandler");
074      PD_JAVA_CLASS = builder.getInstance();
075      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
076  }
077
078
079
080  // Register the tags associated with this managed object definition.
081  static {
082    INSTANCE.registerTag(Tag.valueOf("core-server"));
083  }
084
085
086
087  /**
088   * Get the Password Policy State Extended Operation Handler
089   * configuration definition singleton.
090   *
091   * @return Returns the Password Policy State Extended Operation
092   *         Handler configuration definition singleton.
093   */
094  public static PasswordPolicyStateExtendedOperationHandlerCfgDefn getInstance() {
095    return INSTANCE;
096  }
097
098
099
100  /**
101   * Private constructor.
102   */
103  private PasswordPolicyStateExtendedOperationHandlerCfgDefn() {
104    super("password-policy-state-extended-operation-handler", ExtendedOperationHandlerCfgDefn.getInstance());
105  }
106
107
108
109  /**
110   * {@inheritDoc}
111   */
112  public PasswordPolicyStateExtendedOperationHandlerCfgClient createClientConfiguration(
113      ManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient> impl) {
114    return new PasswordPolicyStateExtendedOperationHandlerCfgClientImpl(impl);
115  }
116
117
118
119  /**
120   * {@inheritDoc}
121   */
122  public PasswordPolicyStateExtendedOperationHandlerCfg createServerConfiguration(
123      ServerManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfg> impl) {
124    return new PasswordPolicyStateExtendedOperationHandlerCfgServerImpl(impl);
125  }
126
127
128
129  /**
130   * {@inheritDoc}
131   */
132  public Class<PasswordPolicyStateExtendedOperationHandlerCfg> getServerConfigurationClass() {
133    return PasswordPolicyStateExtendedOperationHandlerCfg.class;
134  }
135
136
137
138  /**
139   * Get the "enabled" property definition.
140   * <p>
141   * Indicates whether the Password Policy State Extended Operation
142   * Handler is enabled (that is, whether the types of extended
143   * operations are allowed in the server).
144   *
145   * @return Returns the "enabled" property definition.
146   */
147  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
148    return ExtendedOperationHandlerCfgDefn.getInstance().getEnabledPropertyDefinition();
149  }
150
151
152
153  /**
154   * Get the "java-class" property definition.
155   * <p>
156   * Specifies the fully-qualified name of the Java class that
157   * provides the Password Policy State Extended Operation Handler
158   * implementation.
159   *
160   * @return Returns the "java-class" property definition.
161   */
162  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
163    return PD_JAVA_CLASS;
164  }
165
166
167
168  /**
169   * Managed object client implementation.
170   */
171  private static class PasswordPolicyStateExtendedOperationHandlerCfgClientImpl implements
172    PasswordPolicyStateExtendedOperationHandlerCfgClient {
173
174    // Private implementation.
175    private ManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient> impl;
176
177
178
179    // Private constructor.
180    private PasswordPolicyStateExtendedOperationHandlerCfgClientImpl(
181        ManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient> impl) {
182      this.impl = impl;
183    }
184
185
186
187    /**
188     * {@inheritDoc}
189     */
190    public Boolean isEnabled() {
191      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
192    }
193
194
195
196    /**
197     * {@inheritDoc}
198     */
199    public void setEnabled(boolean value) {
200      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
201    }
202
203
204
205    /**
206     * {@inheritDoc}
207     */
208    public String getJavaClass() {
209      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
210    }
211
212
213
214    /**
215     * {@inheritDoc}
216     */
217    public void setJavaClass(String value) {
218      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
219    }
220
221
222
223    /**
224     * {@inheritDoc}
225     */
226    public ManagedObjectDefinition<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient, ? extends PasswordPolicyStateExtendedOperationHandlerCfg> definition() {
227      return INSTANCE;
228    }
229
230
231
232    /**
233     * {@inheritDoc}
234     */
235    public PropertyProvider properties() {
236      return impl;
237    }
238
239
240
241    /**
242     * {@inheritDoc}
243     */
244    public void commit() throws ManagedObjectAlreadyExistsException,
245        MissingMandatoryPropertiesException, ConcurrentModificationException,
246        OperationRejectedException, AuthorizationException,
247        CommunicationException {
248      impl.commit();
249    }
250
251
252
253    /** {@inheritDoc} */
254    public String toString() {
255      return impl.toString();
256    }
257  }
258
259
260
261  /**
262   * Managed object server implementation.
263   */
264  private static class PasswordPolicyStateExtendedOperationHandlerCfgServerImpl implements
265    PasswordPolicyStateExtendedOperationHandlerCfg {
266
267    // Private implementation.
268    private ServerManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfg> impl;
269
270    // The value of the "enabled" property.
271    private final boolean pEnabled;
272
273    // The value of the "java-class" property.
274    private final String pJavaClass;
275
276
277
278    // Private constructor.
279    private PasswordPolicyStateExtendedOperationHandlerCfgServerImpl(ServerManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfg> impl) {
280      this.impl = impl;
281      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
282      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
283    }
284
285
286
287    /**
288     * {@inheritDoc}
289     */
290    public void addPasswordPolicyStateChangeListener(
291        ConfigurationChangeListener<PasswordPolicyStateExtendedOperationHandlerCfg> listener) {
292      impl.registerChangeListener(listener);
293    }
294
295
296
297    /**
298     * {@inheritDoc}
299     */
300    public void removePasswordPolicyStateChangeListener(
301        ConfigurationChangeListener<PasswordPolicyStateExtendedOperationHandlerCfg> listener) {
302      impl.deregisterChangeListener(listener);
303    }
304    /**
305     * {@inheritDoc}
306     */
307    public void addChangeListener(
308        ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) {
309      impl.registerChangeListener(listener);
310    }
311
312
313
314    /**
315     * {@inheritDoc}
316     */
317    public void removeChangeListener(
318        ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) {
319      impl.deregisterChangeListener(listener);
320    }
321
322
323
324    /**
325     * {@inheritDoc}
326     */
327    public boolean isEnabled() {
328      return pEnabled;
329    }
330
331
332
333    /**
334     * {@inheritDoc}
335     */
336    public String getJavaClass() {
337      return pJavaClass;
338    }
339
340
341
342    /**
343     * {@inheritDoc}
344     */
345    public Class<? extends PasswordPolicyStateExtendedOperationHandlerCfg> configurationClass() {
346      return PasswordPolicyStateExtendedOperationHandlerCfg.class;
347    }
348
349
350
351    /**
352     * {@inheritDoc}
353     */
354    public DN dn() {
355      return impl.getDN();
356    }
357
358
359
360    /** {@inheritDoc} */
361    public String toString() {
362      return impl.toString();
363    }
364  }
365}