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