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.WhoAmIExtendedOperationHandlerCfgClient;
039import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
040import org.opends.server.admin.std.server.WhoAmIExtendedOperationHandlerCfg;
041import org.opends.server.admin.Tag;
042
043
044
045/**
046 * An interface for querying the Who Am I Extended Operation Handler
047 * managed object definition meta information.
048 * <p>
049 * The Who Am I Extended Operation Handler provides the ability for
050 * clients to request their authorization identity using the "Who Am
051 * I?" extended operation as defined in RFC 4532.
052 */
053public final class WhoAmIExtendedOperationHandlerCfgDefn extends ManagedObjectDefinition<WhoAmIExtendedOperationHandlerCfgClient, WhoAmIExtendedOperationHandlerCfg> {
054
055  // The singleton configuration definition instance.
056  private static final WhoAmIExtendedOperationHandlerCfgDefn INSTANCE = new WhoAmIExtendedOperationHandlerCfgDefn();
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.WhoAmIExtendedOperation");
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 Who Am I Extended Operation Handler configuration
089   * definition singleton.
090   *
091   * @return Returns the Who Am I Extended Operation Handler
092   *         configuration definition singleton.
093   */
094  public static WhoAmIExtendedOperationHandlerCfgDefn getInstance() {
095    return INSTANCE;
096  }
097
098
099
100  /**
101   * Private constructor.
102   */
103  private WhoAmIExtendedOperationHandlerCfgDefn() {
104    super("who-am-i-extended-operation-handler", ExtendedOperationHandlerCfgDefn.getInstance());
105  }
106
107
108
109  /**
110   * {@inheritDoc}
111   */
112  public WhoAmIExtendedOperationHandlerCfgClient createClientConfiguration(
113      ManagedObject<? extends WhoAmIExtendedOperationHandlerCfgClient> impl) {
114    return new WhoAmIExtendedOperationHandlerCfgClientImpl(impl);
115  }
116
117
118
119  /**
120   * {@inheritDoc}
121   */
122  public WhoAmIExtendedOperationHandlerCfg createServerConfiguration(
123      ServerManagedObject<? extends WhoAmIExtendedOperationHandlerCfg> impl) {
124    return new WhoAmIExtendedOperationHandlerCfgServerImpl(impl);
125  }
126
127
128
129  /**
130   * {@inheritDoc}
131   */
132  public Class<WhoAmIExtendedOperationHandlerCfg> getServerConfigurationClass() {
133    return WhoAmIExtendedOperationHandlerCfg.class;
134  }
135
136
137
138  /**
139   * Get the "enabled" property definition.
140   * <p>
141   * Indicates whether the Who Am I Extended Operation Handler is
142   * enabled (that is, whether the types of extended operations are
143   * 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 Who Am I Extended Operation Handler implementation.
158   *
159   * @return Returns the "java-class" property definition.
160   */
161  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
162    return PD_JAVA_CLASS;
163  }
164
165
166
167  /**
168   * Managed object client implementation.
169   */
170  private static class WhoAmIExtendedOperationHandlerCfgClientImpl implements
171    WhoAmIExtendedOperationHandlerCfgClient {
172
173    // Private implementation.
174    private ManagedObject<? extends WhoAmIExtendedOperationHandlerCfgClient> impl;
175
176
177
178    // Private constructor.
179    private WhoAmIExtendedOperationHandlerCfgClientImpl(
180        ManagedObject<? extends WhoAmIExtendedOperationHandlerCfgClient> impl) {
181      this.impl = impl;
182    }
183
184
185
186    /**
187     * {@inheritDoc}
188     */
189    public Boolean isEnabled() {
190      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
191    }
192
193
194
195    /**
196     * {@inheritDoc}
197     */
198    public void setEnabled(boolean value) {
199      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
200    }
201
202
203
204    /**
205     * {@inheritDoc}
206     */
207    public String getJavaClass() {
208      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
209    }
210
211
212
213    /**
214     * {@inheritDoc}
215     */
216    public void setJavaClass(String value) {
217      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
218    }
219
220
221
222    /**
223     * {@inheritDoc}
224     */
225    public ManagedObjectDefinition<? extends WhoAmIExtendedOperationHandlerCfgClient, ? extends WhoAmIExtendedOperationHandlerCfg> definition() {
226      return INSTANCE;
227    }
228
229
230
231    /**
232     * {@inheritDoc}
233     */
234    public PropertyProvider properties() {
235      return impl;
236    }
237
238
239
240    /**
241     * {@inheritDoc}
242     */
243    public void commit() throws ManagedObjectAlreadyExistsException,
244        MissingMandatoryPropertiesException, ConcurrentModificationException,
245        OperationRejectedException, AuthorizationException,
246        CommunicationException {
247      impl.commit();
248    }
249
250
251
252    /** {@inheritDoc} */
253    public String toString() {
254      return impl.toString();
255    }
256  }
257
258
259
260  /**
261   * Managed object server implementation.
262   */
263  private static class WhoAmIExtendedOperationHandlerCfgServerImpl implements
264    WhoAmIExtendedOperationHandlerCfg {
265
266    // Private implementation.
267    private ServerManagedObject<? extends WhoAmIExtendedOperationHandlerCfg> impl;
268
269    // The value of the "enabled" property.
270    private final boolean pEnabled;
271
272    // The value of the "java-class" property.
273    private final String pJavaClass;
274
275
276
277    // Private constructor.
278    private WhoAmIExtendedOperationHandlerCfgServerImpl(ServerManagedObject<? extends WhoAmIExtendedOperationHandlerCfg> impl) {
279      this.impl = impl;
280      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
281      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
282    }
283
284
285
286    /**
287     * {@inheritDoc}
288     */
289    public void addWhoAmIChangeListener(
290        ConfigurationChangeListener<WhoAmIExtendedOperationHandlerCfg> listener) {
291      impl.registerChangeListener(listener);
292    }
293
294
295
296    /**
297     * {@inheritDoc}
298     */
299    public void removeWhoAmIChangeListener(
300        ConfigurationChangeListener<WhoAmIExtendedOperationHandlerCfg> listener) {
301      impl.deregisterChangeListener(listener);
302    }
303    /**
304     * {@inheritDoc}
305     */
306    public void addChangeListener(
307        ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) {
308      impl.registerChangeListener(listener);
309    }
310
311
312
313    /**
314     * {@inheritDoc}
315     */
316    public void removeChangeListener(
317        ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) {
318      impl.deregisterChangeListener(listener);
319    }
320
321
322
323    /**
324     * {@inheritDoc}
325     */
326    public boolean isEnabled() {
327      return pEnabled;
328    }
329
330
331
332    /**
333     * {@inheritDoc}
334     */
335    public String getJavaClass() {
336      return pJavaClass;
337    }
338
339
340
341    /**
342     * {@inheritDoc}
343     */
344    public Class<? extends WhoAmIExtendedOperationHandlerCfg> configurationClass() {
345      return WhoAmIExtendedOperationHandlerCfg.class;
346    }
347
348
349
350    /**
351     * {@inheritDoc}
352     */
353    public DN dn() {
354      return impl.getDN();
355    }
356
357
358
359    /** {@inheritDoc} */
360    public String toString() {
361      return impl.toString();
362    }
363  }
364}