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.AttributeTypePropertyDefinition;
036    import org.opends.server.admin.BooleanPropertyDefinition;
037    import org.opends.server.admin.ClassPropertyDefinition;
038    import org.opends.server.admin.client.AuthorizationException;
039    import org.opends.server.admin.client.CommunicationException;
040    import org.opends.server.admin.client.ConcurrentModificationException;
041    import org.opends.server.admin.client.ManagedObject;
042    import org.opends.server.admin.client.MissingMandatoryPropertiesException;
043    import org.opends.server.admin.client.OperationRejectedException;
044    import org.opends.server.admin.DefaultBehaviorProvider;
045    import org.opends.server.admin.DefinedDefaultBehaviorProvider;
046    import org.opends.server.admin.DNPropertyDefinition;
047    import org.opends.server.admin.ManagedObjectAlreadyExistsException;
048    import org.opends.server.admin.ManagedObjectDefinition;
049    import org.opends.server.admin.PropertyOption;
050    import org.opends.server.admin.PropertyProvider;
051    import org.opends.server.admin.server.ConfigurationChangeListener;
052    import org.opends.server.admin.server.ServerManagedObject;
053    import org.opends.server.admin.std.client.ExactMatchIdentityMapperCfgClient;
054    import org.opends.server.admin.std.server.ExactMatchIdentityMapperCfg;
055    import org.opends.server.admin.std.server.IdentityMapperCfg;
056    import org.opends.server.admin.Tag;
057    import org.opends.server.types.AttributeType;
058    import org.opends.server.types.DN;
059    
060    
061    
062    /**
063     * An interface for querying the Exact Match Identity Mapper managed
064     * object definition meta information.
065     * <p>
066     * The Exact Match Identity Mapper maps an identifier string to user
067     * entries by searching for the entry containing a specified attribute
068     * whose value is the provided identifier. For example, the username
069     * provided by the client for DIGEST-MD5 authentication must match the
070     * value of the uid attribute
071     */
072    public final class ExactMatchIdentityMapperCfgDefn extends ManagedObjectDefinition<ExactMatchIdentityMapperCfgClient, ExactMatchIdentityMapperCfg> {
073    
074      // The singleton configuration definition instance.
075      private static final ExactMatchIdentityMapperCfgDefn INSTANCE = new ExactMatchIdentityMapperCfgDefn();
076    
077    
078    
079      // The "java-class" property definition.
080      private static final ClassPropertyDefinition PD_JAVA_CLASS;
081    
082    
083    
084      // The "match-attribute" property definition.
085      private static final AttributeTypePropertyDefinition PD_MATCH_ATTRIBUTE;
086    
087    
088    
089      // The "match-base-dn" property definition.
090      private static final DNPropertyDefinition PD_MATCH_BASE_DN;
091    
092    
093    
094      // Build the "java-class" property definition.
095      static {
096          ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
097          builder.setOption(PropertyOption.MANDATORY);
098          builder.setOption(PropertyOption.ADVANCED);
099          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
100          DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.ExactMatchIdentityMapper");
101          builder.setDefaultBehaviorProvider(provider);
102          builder.addInstanceOf("org.opends.server.api.IdentityMapper");
103          PD_JAVA_CLASS = builder.getInstance();
104          INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
105      }
106    
107    
108    
109      // Build the "match-attribute" property definition.
110      static {
111          AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "match-attribute");
112          builder.setOption(PropertyOption.MULTI_VALUED);
113          builder.setOption(PropertyOption.MANDATORY);
114          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "match-attribute"));
115          DefaultBehaviorProvider<AttributeType> provider = new DefinedDefaultBehaviorProvider<AttributeType>("uid");
116          builder.setDefaultBehaviorProvider(provider);
117          PD_MATCH_ATTRIBUTE = builder.getInstance();
118          INSTANCE.registerPropertyDefinition(PD_MATCH_ATTRIBUTE);
119      }
120    
121    
122    
123      // Build the "match-base-dn" property definition.
124      static {
125          DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "match-base-dn");
126          builder.setOption(PropertyOption.MULTI_VALUED);
127          builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "match-base-dn"));
128          builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<DN>(INSTANCE, "match-base-dn"));
129          PD_MATCH_BASE_DN = builder.getInstance();
130          INSTANCE.registerPropertyDefinition(PD_MATCH_BASE_DN);
131      }
132    
133    
134    
135      // Register the tags associated with this managed object definition.
136      static {
137        INSTANCE.registerTag(Tag.valueOf("security"));
138        INSTANCE.registerTag(Tag.valueOf("user-management"));
139      }
140    
141    
142    
143      /**
144       * Get the Exact Match Identity Mapper configuration definition
145       * singleton.
146       *
147       * @return Returns the Exact Match Identity Mapper configuration
148       *         definition singleton.
149       */
150      public static ExactMatchIdentityMapperCfgDefn getInstance() {
151        return INSTANCE;
152      }
153    
154    
155    
156      /**
157       * Private constructor.
158       */
159      private ExactMatchIdentityMapperCfgDefn() {
160        super("exact-match-identity-mapper", IdentityMapperCfgDefn.getInstance());
161      }
162    
163    
164    
165      /**
166       * {@inheritDoc}
167       */
168      public ExactMatchIdentityMapperCfgClient createClientConfiguration(
169          ManagedObject<? extends ExactMatchIdentityMapperCfgClient> impl) {
170        return new ExactMatchIdentityMapperCfgClientImpl(impl);
171      }
172    
173    
174    
175      /**
176       * {@inheritDoc}
177       */
178      public ExactMatchIdentityMapperCfg createServerConfiguration(
179          ServerManagedObject<? extends ExactMatchIdentityMapperCfg> impl) {
180        return new ExactMatchIdentityMapperCfgServerImpl(impl);
181      }
182    
183    
184    
185      /**
186       * {@inheritDoc}
187       */
188      public Class<ExactMatchIdentityMapperCfg> getServerConfigurationClass() {
189        return ExactMatchIdentityMapperCfg.class;
190      }
191    
192    
193    
194      /**
195       * Get the "enabled" property definition.
196       * <p>
197       * Indicates whether the Exact Match Identity Mapper is enabled for
198       * use.
199       *
200       * @return Returns the "enabled" property definition.
201       */
202      public BooleanPropertyDefinition getEnabledPropertyDefinition() {
203        return IdentityMapperCfgDefn.getInstance().getEnabledPropertyDefinition();
204      }
205    
206    
207    
208      /**
209       * Get the "java-class" property definition.
210       * <p>
211       * Specifies the fully-qualified name of the Java class that
212       * provides the Exact Match Identity Mapper implementation.
213       *
214       * @return Returns the "java-class" property definition.
215       */
216      public ClassPropertyDefinition getJavaClassPropertyDefinition() {
217        return PD_JAVA_CLASS;
218      }
219    
220    
221    
222      /**
223       * Get the "match-attribute" property definition.
224       * <p>
225       * Specifies the attribute whose value should exactly match the ID
226       * string provided to this identity mapper.
227       * <p>
228       * At least one value must be provided. All values must refer to the
229       * name or OID of an attribute type defined in the Directory Server
230       * schema. If multiple attributes or OIDs are provided, at least one
231       * of those attributes must contain the provided ID string value in
232       * exactly one entry. The internal search performed includes a
233       * logical OR across all of these values.
234       *
235       * @return Returns the "match-attribute" property definition.
236       */
237      public AttributeTypePropertyDefinition getMatchAttributePropertyDefinition() {
238        return PD_MATCH_ATTRIBUTE;
239      }
240    
241    
242    
243      /**
244       * Get the "match-base-dn" property definition.
245       * <p>
246       * Specifies the set of base DNs below which to search for users.
247       * <p>
248       * The base DNs will be used when performing searches to map the
249       * provided ID string to a user entry. If multiple values are given,
250       * searches are performed below all specified base DNs.
251       *
252       * @return Returns the "match-base-dn" property definition.
253       */
254      public DNPropertyDefinition getMatchBaseDNPropertyDefinition() {
255        return PD_MATCH_BASE_DN;
256      }
257    
258    
259    
260      /**
261       * Managed object client implementation.
262       */
263      private static class ExactMatchIdentityMapperCfgClientImpl implements
264        ExactMatchIdentityMapperCfgClient {
265    
266        // Private implementation.
267        private ManagedObject<? extends ExactMatchIdentityMapperCfgClient> impl;
268    
269    
270    
271        // Private constructor.
272        private ExactMatchIdentityMapperCfgClientImpl(
273            ManagedObject<? extends ExactMatchIdentityMapperCfgClient> impl) {
274          this.impl = impl;
275        }
276    
277    
278    
279        /**
280         * {@inheritDoc}
281         */
282        public Boolean isEnabled() {
283          return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
284        }
285    
286    
287    
288        /**
289         * {@inheritDoc}
290         */
291        public void setEnabled(boolean value) {
292          impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
293        }
294    
295    
296    
297        /**
298         * {@inheritDoc}
299         */
300        public String getJavaClass() {
301          return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
302        }
303    
304    
305    
306        /**
307         * {@inheritDoc}
308         */
309        public void setJavaClass(String value) {
310          impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
311        }
312    
313    
314    
315        /**
316         * {@inheritDoc}
317         */
318        public SortedSet<AttributeType> getMatchAttribute() {
319          return impl.getPropertyValues(INSTANCE.getMatchAttributePropertyDefinition());
320        }
321    
322    
323    
324        /**
325         * {@inheritDoc}
326         */
327        public void setMatchAttribute(Collection<AttributeType> values) {
328          impl.setPropertyValues(INSTANCE.getMatchAttributePropertyDefinition(), values);
329        }
330    
331    
332    
333        /**
334         * {@inheritDoc}
335         */
336        public SortedSet<DN> getMatchBaseDN() {
337          return impl.getPropertyValues(INSTANCE.getMatchBaseDNPropertyDefinition());
338        }
339    
340    
341    
342        /**
343         * {@inheritDoc}
344         */
345        public void setMatchBaseDN(Collection<DN> values) {
346          impl.setPropertyValues(INSTANCE.getMatchBaseDNPropertyDefinition(), values);
347        }
348    
349    
350    
351        /**
352         * {@inheritDoc}
353         */
354        public ManagedObjectDefinition<? extends ExactMatchIdentityMapperCfgClient, ? extends ExactMatchIdentityMapperCfg> definition() {
355          return INSTANCE;
356        }
357    
358    
359    
360        /**
361         * {@inheritDoc}
362         */
363        public PropertyProvider properties() {
364          return impl;
365        }
366    
367    
368    
369        /**
370         * {@inheritDoc}
371         */
372        public void commit() throws ManagedObjectAlreadyExistsException,
373            MissingMandatoryPropertiesException, ConcurrentModificationException,
374            OperationRejectedException, AuthorizationException,
375            CommunicationException {
376          impl.commit();
377        }
378    
379      }
380    
381    
382    
383      /**
384       * Managed object server implementation.
385       */
386      private static class ExactMatchIdentityMapperCfgServerImpl implements
387        ExactMatchIdentityMapperCfg {
388    
389        // Private implementation.
390        private ServerManagedObject<? extends ExactMatchIdentityMapperCfg> impl;
391    
392        // The value of the "enabled" property.
393        private final boolean pEnabled;
394    
395        // The value of the "java-class" property.
396        private final String pJavaClass;
397    
398        // The value of the "match-attribute" property.
399        private final SortedSet<AttributeType> pMatchAttribute;
400    
401        // The value of the "match-base-dn" property.
402        private final SortedSet<DN> pMatchBaseDN;
403    
404    
405    
406        // Private constructor.
407        private ExactMatchIdentityMapperCfgServerImpl(ServerManagedObject<? extends ExactMatchIdentityMapperCfg> impl) {
408          this.impl = impl;
409          this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
410          this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
411          this.pMatchAttribute = impl.getPropertyValues(INSTANCE.getMatchAttributePropertyDefinition());
412          this.pMatchBaseDN = impl.getPropertyValues(INSTANCE.getMatchBaseDNPropertyDefinition());
413        }
414    
415    
416    
417        /**
418         * {@inheritDoc}
419         */
420        public void addExactMatchChangeListener(
421            ConfigurationChangeListener<ExactMatchIdentityMapperCfg> listener) {
422          impl.registerChangeListener(listener);
423        }
424    
425    
426    
427        /**
428         * {@inheritDoc}
429         */
430        public void removeExactMatchChangeListener(
431            ConfigurationChangeListener<ExactMatchIdentityMapperCfg> listener) {
432          impl.deregisterChangeListener(listener);
433        }
434        /**
435         * {@inheritDoc}
436         */
437        public void addChangeListener(
438            ConfigurationChangeListener<IdentityMapperCfg> listener) {
439          impl.registerChangeListener(listener);
440        }
441    
442    
443    
444        /**
445         * {@inheritDoc}
446         */
447        public void removeChangeListener(
448            ConfigurationChangeListener<IdentityMapperCfg> listener) {
449          impl.deregisterChangeListener(listener);
450        }
451    
452    
453    
454        /**
455         * {@inheritDoc}
456         */
457        public boolean isEnabled() {
458          return pEnabled;
459        }
460    
461    
462    
463        /**
464         * {@inheritDoc}
465         */
466        public String getJavaClass() {
467          return pJavaClass;
468        }
469    
470    
471    
472        /**
473         * {@inheritDoc}
474         */
475        public SortedSet<AttributeType> getMatchAttribute() {
476          return pMatchAttribute;
477        }
478    
479    
480    
481        /**
482         * {@inheritDoc}
483         */
484        public SortedSet<DN> getMatchBaseDN() {
485          return pMatchBaseDN;
486        }
487    
488    
489    
490        /**
491         * {@inheritDoc}
492         */
493        public Class<? extends ExactMatchIdentityMapperCfg> configurationClass() {
494          return ExactMatchIdentityMapperCfg.class;
495        }
496    
497    
498    
499        /**
500         * {@inheritDoc}
501         */
502        public DN dn() {
503          return impl.getDN();
504        }
505    
506      }
507    }