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.opends.server.admin.ACIPropertyDefinition;
024import org.opends.server.admin.AdministratorAction;
025import org.opends.server.admin.AliasDefaultBehaviorProvider;
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.ManagedObjectAlreadyExistsException;
037import org.opends.server.admin.ManagedObjectDefinition;
038import org.opends.server.admin.PropertyOption;
039import org.opends.server.admin.PropertyProvider;
040import org.opends.server.admin.server.ConfigurationChangeListener;
041import org.opends.server.admin.server.ServerManagedObject;
042import org.opends.server.admin.std.client.DseeCompatAccessControlHandlerCfgClient;
043import org.opends.server.admin.std.server.AccessControlHandlerCfg;
044import org.opends.server.admin.std.server.DseeCompatAccessControlHandlerCfg;
045import org.opends.server.admin.Tag;
046import org.opends.server.authorization.dseecompat.Aci;
047
048
049
050/**
051 * An interface for querying the Dsee Compat Access Control Handler
052 * managed object definition meta information.
053 * <p>
054 * The Dsee Compat Access Control Handler provides an implementation
055 * that uses syntax compatible with the Sun Java System Directory
056 * Server Enterprise Edition access control handlers.
057 */
058public final class DseeCompatAccessControlHandlerCfgDefn extends ManagedObjectDefinition<DseeCompatAccessControlHandlerCfgClient, DseeCompatAccessControlHandlerCfg> {
059
060  // The singleton configuration definition instance.
061  private static final DseeCompatAccessControlHandlerCfgDefn INSTANCE = new DseeCompatAccessControlHandlerCfgDefn();
062
063
064
065  // The "global-aci" property definition.
066  private static final ACIPropertyDefinition PD_GLOBAL_ACI;
067
068
069
070  // The "java-class" property definition.
071  private static final ClassPropertyDefinition PD_JAVA_CLASS;
072
073
074
075  // Build the "global-aci" property definition.
076  static {
077      ACIPropertyDefinition.Builder builder = ACIPropertyDefinition.createBuilder(INSTANCE, "global-aci");
078      builder.setOption(PropertyOption.MULTI_VALUED);
079      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "global-aci"));
080      builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<Aci>(INSTANCE, "global-aci"));
081      PD_GLOBAL_ACI = builder.getInstance();
082      INSTANCE.registerPropertyDefinition(PD_GLOBAL_ACI);
083  }
084
085
086
087  // Build the "java-class" property definition.
088  static {
089      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
090      builder.setOption(PropertyOption.MANDATORY);
091      builder.setOption(PropertyOption.ADVANCED);
092      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
093      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.authorization.dseecompat.AciHandler");
094      builder.setDefaultBehaviorProvider(provider);
095      builder.addInstanceOf("org.opends.server.api.AccessControlHandler");
096      PD_JAVA_CLASS = builder.getInstance();
097      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
098  }
099
100
101
102  // Register the tags associated with this managed object definition.
103  static {
104    INSTANCE.registerTag(Tag.valueOf("security"));
105  }
106
107
108
109  /**
110   * Get the Dsee Compat Access Control Handler configuration
111   * definition singleton.
112   *
113   * @return Returns the Dsee Compat Access Control Handler
114   *         configuration definition singleton.
115   */
116  public static DseeCompatAccessControlHandlerCfgDefn getInstance() {
117    return INSTANCE;
118  }
119
120
121
122  /**
123   * Private constructor.
124   */
125  private DseeCompatAccessControlHandlerCfgDefn() {
126    super("dsee-compat-access-control-handler", AccessControlHandlerCfgDefn.getInstance());
127  }
128
129
130
131  /**
132   * {@inheritDoc}
133   */
134  public DseeCompatAccessControlHandlerCfgClient createClientConfiguration(
135      ManagedObject<? extends DseeCompatAccessControlHandlerCfgClient> impl) {
136    return new DseeCompatAccessControlHandlerCfgClientImpl(impl);
137  }
138
139
140
141  /**
142   * {@inheritDoc}
143   */
144  public DseeCompatAccessControlHandlerCfg createServerConfiguration(
145      ServerManagedObject<? extends DseeCompatAccessControlHandlerCfg> impl) {
146    return new DseeCompatAccessControlHandlerCfgServerImpl(impl);
147  }
148
149
150
151  /**
152   * {@inheritDoc}
153   */
154  public Class<DseeCompatAccessControlHandlerCfg> getServerConfigurationClass() {
155    return DseeCompatAccessControlHandlerCfg.class;
156  }
157
158
159
160  /**
161   * Get the "enabled" property definition.
162   * <p>
163   * Indicates whether the Dsee Compat Access Control Handler is
164   * enabled. If set to FALSE, then no access control is enforced, and
165   * any client (including unauthenticated or anonymous clients) could
166   * be allowed to perform any operation if not subject to other
167   * restrictions, such as those enforced by the privilege subsystem.
168   *
169   * @return Returns the "enabled" property definition.
170   */
171  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
172    return AccessControlHandlerCfgDefn.getInstance().getEnabledPropertyDefinition();
173  }
174
175
176
177  /**
178   * Get the "global-aci" property definition.
179   * <p>
180   * Defines global access control rules.
181   * <p>
182   * Global access control rules apply to all entries anywhere in the
183   * data managed by the OpenDJ directory server. The global access
184   * control rules may be overridden by more specific access control
185   * rules placed in the data.
186   *
187   * @return Returns the "global-aci" property definition.
188   */
189  public ACIPropertyDefinition getGlobalACIPropertyDefinition() {
190    return PD_GLOBAL_ACI;
191  }
192
193
194
195  /**
196   * Get the "java-class" property definition.
197   * <p>
198   * Specifies the fully-qualified name of the Java class that
199   * provides the Dsee Compat Access Control Handler implementation.
200   *
201   * @return Returns the "java-class" property definition.
202   */
203  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
204    return PD_JAVA_CLASS;
205  }
206
207
208
209  /**
210   * Managed object client implementation.
211   */
212  private static class DseeCompatAccessControlHandlerCfgClientImpl implements
213    DseeCompatAccessControlHandlerCfgClient {
214
215    // Private implementation.
216    private ManagedObject<? extends DseeCompatAccessControlHandlerCfgClient> impl;
217
218
219
220    // Private constructor.
221    private DseeCompatAccessControlHandlerCfgClientImpl(
222        ManagedObject<? extends DseeCompatAccessControlHandlerCfgClient> impl) {
223      this.impl = impl;
224    }
225
226
227
228    /**
229     * {@inheritDoc}
230     */
231    public Boolean isEnabled() {
232      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
233    }
234
235
236
237    /**
238     * {@inheritDoc}
239     */
240    public void setEnabled(boolean value) {
241      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
242    }
243
244
245
246    /**
247     * {@inheritDoc}
248     */
249    public SortedSet<Aci> getGlobalACI() {
250      return impl.getPropertyValues(INSTANCE.getGlobalACIPropertyDefinition());
251    }
252
253
254
255    /**
256     * {@inheritDoc}
257     */
258    public void setGlobalACI(Collection<Aci> values) {
259      impl.setPropertyValues(INSTANCE.getGlobalACIPropertyDefinition(), values);
260    }
261
262
263
264    /**
265     * {@inheritDoc}
266     */
267    public String getJavaClass() {
268      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
269    }
270
271
272
273    /**
274     * {@inheritDoc}
275     */
276    public void setJavaClass(String value) {
277      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
278    }
279
280
281
282    /**
283     * {@inheritDoc}
284     */
285    public ManagedObjectDefinition<? extends DseeCompatAccessControlHandlerCfgClient, ? extends DseeCompatAccessControlHandlerCfg> definition() {
286      return INSTANCE;
287    }
288
289
290
291    /**
292     * {@inheritDoc}
293     */
294    public PropertyProvider properties() {
295      return impl;
296    }
297
298
299
300    /**
301     * {@inheritDoc}
302     */
303    public void commit() throws ManagedObjectAlreadyExistsException,
304        MissingMandatoryPropertiesException, ConcurrentModificationException,
305        OperationRejectedException, AuthorizationException,
306        CommunicationException {
307      impl.commit();
308    }
309
310
311
312    /** {@inheritDoc} */
313    public String toString() {
314      return impl.toString();
315    }
316  }
317
318
319
320  /**
321   * Managed object server implementation.
322   */
323  private static class DseeCompatAccessControlHandlerCfgServerImpl implements
324    DseeCompatAccessControlHandlerCfg {
325
326    // Private implementation.
327    private ServerManagedObject<? extends DseeCompatAccessControlHandlerCfg> impl;
328
329    // The value of the "enabled" property.
330    private final boolean pEnabled;
331
332    // The value of the "global-aci" property.
333    private final SortedSet<Aci> pGlobalACI;
334
335    // The value of the "java-class" property.
336    private final String pJavaClass;
337
338
339
340    // Private constructor.
341    private DseeCompatAccessControlHandlerCfgServerImpl(ServerManagedObject<? extends DseeCompatAccessControlHandlerCfg> impl) {
342      this.impl = impl;
343      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
344      this.pGlobalACI = impl.getPropertyValues(INSTANCE.getGlobalACIPropertyDefinition());
345      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
346    }
347
348
349
350    /**
351     * {@inheritDoc}
352     */
353    public void addDseeCompatChangeListener(
354        ConfigurationChangeListener<DseeCompatAccessControlHandlerCfg> listener) {
355      impl.registerChangeListener(listener);
356    }
357
358
359
360    /**
361     * {@inheritDoc}
362     */
363    public void removeDseeCompatChangeListener(
364        ConfigurationChangeListener<DseeCompatAccessControlHandlerCfg> listener) {
365      impl.deregisterChangeListener(listener);
366    }
367    /**
368     * {@inheritDoc}
369     */
370    public void addChangeListener(
371        ConfigurationChangeListener<AccessControlHandlerCfg> listener) {
372      impl.registerChangeListener(listener);
373    }
374
375
376
377    /**
378     * {@inheritDoc}
379     */
380    public void removeChangeListener(
381        ConfigurationChangeListener<AccessControlHandlerCfg> listener) {
382      impl.deregisterChangeListener(listener);
383    }
384
385
386
387    /**
388     * {@inheritDoc}
389     */
390    public boolean isEnabled() {
391      return pEnabled;
392    }
393
394
395
396    /**
397     * {@inheritDoc}
398     */
399    public SortedSet<Aci> getGlobalACI() {
400      return pGlobalACI;
401    }
402
403
404
405    /**
406     * {@inheritDoc}
407     */
408    public String getJavaClass() {
409      return pJavaClass;
410    }
411
412
413
414    /**
415     * {@inheritDoc}
416     */
417    public Class<? extends DseeCompatAccessControlHandlerCfg> configurationClass() {
418      return DseeCompatAccessControlHandlerCfg.class;
419    }
420
421
422
423    /**
424     * {@inheritDoc}
425     */
426    public DN dn() {
427      return impl.getDN();
428    }
429
430
431
432    /** {@inheritDoc} */
433    public String toString() {
434      return impl.toString();
435    }
436  }
437}