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
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.admin.std.meta;
028    
029    
030    
031    import java.util.Collection;
032    import java.util.SortedSet;
033    import org.opends.server.admin.AdministratorAction;
034    import org.opends.server.admin.AliasDefaultBehaviorProvider;
035    import org.opends.server.admin.client.AuthorizationException;
036    import org.opends.server.admin.client.CommunicationException;
037    import org.opends.server.admin.client.ConcurrentModificationException;
038    import org.opends.server.admin.client.ManagedObject;
039    import org.opends.server.admin.client.MissingMandatoryPropertiesException;
040    import org.opends.server.admin.client.OperationRejectedException;
041    import org.opends.server.admin.DNPropertyDefinition;
042    import org.opends.server.admin.ManagedObjectAlreadyExistsException;
043    import org.opends.server.admin.ManagedObjectDefinition;
044    import org.opends.server.admin.PropertyOption;
045    import org.opends.server.admin.PropertyProvider;
046    import org.opends.server.admin.server.ConfigurationChangeListener;
047    import org.opends.server.admin.server.ServerManagedObject;
048    import org.opends.server.admin.std.client.RootDNUserCfgClient;
049    import org.opends.server.admin.std.server.RootDNUserCfg;
050    import org.opends.server.admin.Tag;
051    import org.opends.server.admin.TopCfgDefn;
052    import org.opends.server.types.DN;
053    
054    
055    
056    /**
057     * An interface for querying the Root DN User managed object
058     * definition meta information.
059     * <p>
060     * A Root DN User are administrative users who can granted special
061     * privileges that are not available to non-root users (for example,
062     * the ability to bind to the server in lockdown mode).
063     */
064    public final class RootDNUserCfgDefn extends ManagedObjectDefinition<RootDNUserCfgClient, RootDNUserCfg> {
065    
066      // The singleton configuration definition instance.
067      private static final RootDNUserCfgDefn INSTANCE = new RootDNUserCfgDefn();
068    
069    
070    
071      // The "alternate-bind-dn" property definition.
072      private static final DNPropertyDefinition PD_ALTERNATE_BIND_DN;
073    
074    
075    
076      // Build the "alternate-bind-dn" property definition.
077      static {
078          DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "alternate-bind-dn");
079          builder.setOption(PropertyOption.MULTI_VALUED);
080          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "alternate-bind-dn"));
081          builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<DN>(INSTANCE, "alternate-bind-dn"));
082          PD_ALTERNATE_BIND_DN = builder.getInstance();
083          INSTANCE.registerPropertyDefinition(PD_ALTERNATE_BIND_DN);
084      }
085    
086    
087    
088      // Register the tags associated with this managed object definition.
089      static {
090        INSTANCE.registerTag(Tag.valueOf("core-server"));
091      }
092    
093    
094    
095      /**
096       * Get the Root DN User configuration definition singleton.
097       *
098       * @return Returns the Root DN User configuration definition
099       *         singleton.
100       */
101      public static RootDNUserCfgDefn getInstance() {
102        return INSTANCE;
103      }
104    
105    
106    
107      /**
108       * Private constructor.
109       */
110      private RootDNUserCfgDefn() {
111        super("root-dn-user", TopCfgDefn.getInstance());
112      }
113    
114    
115    
116      /**
117       * {@inheritDoc}
118       */
119      public RootDNUserCfgClient createClientConfiguration(
120          ManagedObject<? extends RootDNUserCfgClient> impl) {
121        return new RootDNUserCfgClientImpl(impl);
122      }
123    
124    
125    
126      /**
127       * {@inheritDoc}
128       */
129      public RootDNUserCfg createServerConfiguration(
130          ServerManagedObject<? extends RootDNUserCfg> impl) {
131        return new RootDNUserCfgServerImpl(impl);
132      }
133    
134    
135    
136      /**
137       * {@inheritDoc}
138       */
139      public Class<RootDNUserCfg> getServerConfigurationClass() {
140        return RootDNUserCfg.class;
141      }
142    
143    
144    
145      /**
146       * Get the "alternate-bind-dn" property definition.
147       * <p>
148       * Specifies one or more alternate DNs that can be used to bind to
149       * the server as this root user.
150       *
151       * @return Returns the "alternate-bind-dn" property definition.
152       */
153      public DNPropertyDefinition getAlternateBindDNPropertyDefinition() {
154        return PD_ALTERNATE_BIND_DN;
155      }
156    
157    
158    
159      /**
160       * Managed object client implementation.
161       */
162      private static class RootDNUserCfgClientImpl implements
163        RootDNUserCfgClient {
164    
165        // Private implementation.
166        private ManagedObject<? extends RootDNUserCfgClient> impl;
167    
168    
169    
170        // Private constructor.
171        private RootDNUserCfgClientImpl(
172            ManagedObject<? extends RootDNUserCfgClient> impl) {
173          this.impl = impl;
174        }
175    
176    
177    
178        /**
179         * {@inheritDoc}
180         */
181        public SortedSet<DN> getAlternateBindDN() {
182          return impl.getPropertyValues(INSTANCE.getAlternateBindDNPropertyDefinition());
183        }
184    
185    
186    
187        /**
188         * {@inheritDoc}
189         */
190        public void setAlternateBindDN(Collection<DN> values) {
191          impl.setPropertyValues(INSTANCE.getAlternateBindDNPropertyDefinition(), values);
192        }
193    
194    
195    
196        /**
197         * {@inheritDoc}
198         */
199        public ManagedObjectDefinition<? extends RootDNUserCfgClient, ? extends RootDNUserCfg> definition() {
200          return INSTANCE;
201        }
202    
203    
204    
205        /**
206         * {@inheritDoc}
207         */
208        public PropertyProvider properties() {
209          return impl;
210        }
211    
212    
213    
214        /**
215         * {@inheritDoc}
216         */
217        public void commit() throws ManagedObjectAlreadyExistsException,
218            MissingMandatoryPropertiesException, ConcurrentModificationException,
219            OperationRejectedException, AuthorizationException,
220            CommunicationException {
221          impl.commit();
222        }
223    
224      }
225    
226    
227    
228      /**
229       * Managed object server implementation.
230       */
231      private static class RootDNUserCfgServerImpl implements
232        RootDNUserCfg {
233    
234        // Private implementation.
235        private ServerManagedObject<? extends RootDNUserCfg> impl;
236    
237        // The value of the "alternate-bind-dn" property.
238        private final SortedSet<DN> pAlternateBindDN;
239    
240    
241    
242        // Private constructor.
243        private RootDNUserCfgServerImpl(ServerManagedObject<? extends RootDNUserCfg> impl) {
244          this.impl = impl;
245          this.pAlternateBindDN = impl.getPropertyValues(INSTANCE.getAlternateBindDNPropertyDefinition());
246        }
247    
248    
249    
250        /**
251         * {@inheritDoc}
252         */
253        public void addChangeListener(
254            ConfigurationChangeListener<RootDNUserCfg> listener) {
255          impl.registerChangeListener(listener);
256        }
257    
258    
259    
260        /**
261         * {@inheritDoc}
262         */
263        public void removeChangeListener(
264            ConfigurationChangeListener<RootDNUserCfg> listener) {
265          impl.deregisterChangeListener(listener);
266        }
267    
268    
269    
270        /**
271         * {@inheritDoc}
272         */
273        public SortedSet<DN> getAlternateBindDN() {
274          return pAlternateBindDN;
275        }
276    
277    
278    
279        /**
280         * {@inheritDoc}
281         */
282        public Class<? extends RootDNUserCfg> configurationClass() {
283          return RootDNUserCfg.class;
284        }
285    
286    
287    
288        /**
289         * {@inheritDoc}
290         */
291        public DN dn() {
292          return impl.getDN();
293        }
294    
295      }
296    }