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 org.opends.server.admin.AdministratorAction;
032 import org.opends.server.admin.AggregationPropertyDefinition;
033 import org.opends.server.admin.AliasDefaultBehaviorProvider;
034 import org.opends.server.admin.BooleanPropertyDefinition;
035 import org.opends.server.admin.ClassPropertyDefinition;
036 import org.opends.server.admin.client.AuthorizationException;
037 import org.opends.server.admin.client.CommunicationException;
038 import org.opends.server.admin.client.ConcurrentModificationException;
039 import org.opends.server.admin.client.ManagedObject;
040 import org.opends.server.admin.client.MissingMandatoryPropertiesException;
041 import org.opends.server.admin.client.OperationRejectedException;
042 import org.opends.server.admin.DefaultBehaviorProvider;
043 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
044 import org.opends.server.admin.ManagedObjectAlreadyExistsException;
045 import org.opends.server.admin.ManagedObjectDefinition;
046 import org.opends.server.admin.PropertyOption;
047 import org.opends.server.admin.PropertyProvider;
048 import org.opends.server.admin.server.ConfigurationChangeListener;
049 import org.opends.server.admin.server.ServerManagedObject;
050 import org.opends.server.admin.std.client.DigestMD5SASLMechanismHandlerCfgClient;
051 import org.opends.server.admin.std.client.IdentityMapperCfgClient;
052 import org.opends.server.admin.std.server.DigestMD5SASLMechanismHandlerCfg;
053 import org.opends.server.admin.std.server.IdentityMapperCfg;
054 import org.opends.server.admin.std.server.SASLMechanismHandlerCfg;
055 import org.opends.server.admin.StringPropertyDefinition;
056 import org.opends.server.admin.Tag;
057 import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
058 import org.opends.server.types.DN;
059
060
061
062 /**
063 * An interface for querying the Digest MD5 SASL Mechanism Handler
064 * managed object definition meta information.
065 * <p>
066 * The DIGEST-MD5 SASL mechanism is used to perform all processing
067 * related to SASL DIGEST-MD5 authentication.
068 */
069 public final class DigestMD5SASLMechanismHandlerCfgDefn extends ManagedObjectDefinition<DigestMD5SASLMechanismHandlerCfgClient, DigestMD5SASLMechanismHandlerCfg> {
070
071 // The singleton configuration definition instance.
072 private static final DigestMD5SASLMechanismHandlerCfgDefn INSTANCE = new DigestMD5SASLMechanismHandlerCfgDefn();
073
074
075
076 // The "identity-mapper" property definition.
077 private static final AggregationPropertyDefinition<IdentityMapperCfgClient, IdentityMapperCfg> PD_IDENTITY_MAPPER;
078
079
080
081 // The "java-class" property definition.
082 private static final ClassPropertyDefinition PD_JAVA_CLASS;
083
084
085
086 // The "realm" property definition.
087 private static final StringPropertyDefinition PD_REALM;
088
089
090
091 // The "server-fqdn" property definition.
092 private static final StringPropertyDefinition PD_SERVER_FQDN;
093
094
095
096 // Build the "identity-mapper" property definition.
097 static {
098 AggregationPropertyDefinition.Builder<IdentityMapperCfgClient, IdentityMapperCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "identity-mapper");
099 builder.setOption(PropertyOption.MANDATORY);
100 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "identity-mapper"));
101 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
102 builder.setParentPath("/");
103 builder.setRelationDefinition("identity-mapper");
104 PD_IDENTITY_MAPPER = builder.getInstance();
105 INSTANCE.registerPropertyDefinition(PD_IDENTITY_MAPPER);
106 INSTANCE.registerConstraint(PD_IDENTITY_MAPPER.getSourceConstraint());
107 }
108
109
110
111 // Build the "java-class" property definition.
112 static {
113 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
114 builder.setOption(PropertyOption.MANDATORY);
115 builder.setOption(PropertyOption.ADVANCED);
116 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
117 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.DigestMD5SASLMechanismHandler");
118 builder.setDefaultBehaviorProvider(provider);
119 builder.addInstanceOf("org.opends.server.api.SASLMechanismHandler");
120 PD_JAVA_CLASS = builder.getInstance();
121 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
122 }
123
124
125
126 // Build the "realm" property definition.
127 static {
128 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "realm");
129 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "realm"));
130 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "realm"));
131 builder.setPattern(".*", "STRING");
132 PD_REALM = builder.getInstance();
133 INSTANCE.registerPropertyDefinition(PD_REALM);
134 }
135
136
137
138 // Build the "server-fqdn" property definition.
139 static {
140 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "server-fqdn");
141 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "server-fqdn"));
142 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "server-fqdn"));
143 builder.setPattern(".*", "STRING");
144 PD_SERVER_FQDN = builder.getInstance();
145 INSTANCE.registerPropertyDefinition(PD_SERVER_FQDN);
146 }
147
148
149
150 // Register the tags associated with this managed object definition.
151 static {
152 INSTANCE.registerTag(Tag.valueOf("security"));
153 }
154
155
156
157 /**
158 * Get the Digest MD5 SASL Mechanism Handler configuration
159 * definition singleton.
160 *
161 * @return Returns the Digest MD5 SASL Mechanism Handler
162 * configuration definition singleton.
163 */
164 public static DigestMD5SASLMechanismHandlerCfgDefn getInstance() {
165 return INSTANCE;
166 }
167
168
169
170 /**
171 * Private constructor.
172 */
173 private DigestMD5SASLMechanismHandlerCfgDefn() {
174 super("digest-md5-sasl-mechanism-handler", SASLMechanismHandlerCfgDefn.getInstance());
175 }
176
177
178
179 /**
180 * {@inheritDoc}
181 */
182 public DigestMD5SASLMechanismHandlerCfgClient createClientConfiguration(
183 ManagedObject<? extends DigestMD5SASLMechanismHandlerCfgClient> impl) {
184 return new DigestMD5SASLMechanismHandlerCfgClientImpl(impl);
185 }
186
187
188
189 /**
190 * {@inheritDoc}
191 */
192 public DigestMD5SASLMechanismHandlerCfg createServerConfiguration(
193 ServerManagedObject<? extends DigestMD5SASLMechanismHandlerCfg> impl) {
194 return new DigestMD5SASLMechanismHandlerCfgServerImpl(impl);
195 }
196
197
198
199 /**
200 * {@inheritDoc}
201 */
202 public Class<DigestMD5SASLMechanismHandlerCfg> getServerConfigurationClass() {
203 return DigestMD5SASLMechanismHandlerCfg.class;
204 }
205
206
207
208 /**
209 * Get the "enabled" property definition.
210 * <p>
211 * Indicates whether the SASL mechanism handler is enabled for use.
212 *
213 * @return Returns the "enabled" property definition.
214 */
215 public BooleanPropertyDefinition getEnabledPropertyDefinition() {
216 return SASLMechanismHandlerCfgDefn.getInstance().getEnabledPropertyDefinition();
217 }
218
219
220
221 /**
222 * Get the "identity-mapper" property definition.
223 * <p>
224 * Specifies the name of the identity mapper that is to be used with
225 * this SASL mechanism handler to match the authentication or
226 * authorization ID included in the SASL bind request to the
227 * corresponding user in the directory.
228 *
229 * @return Returns the "identity-mapper" property definition.
230 */
231 public AggregationPropertyDefinition<IdentityMapperCfgClient, IdentityMapperCfg> getIdentityMapperPropertyDefinition() {
232 return PD_IDENTITY_MAPPER;
233 }
234
235
236
237 /**
238 * Get the "java-class" property definition.
239 * <p>
240 * Specifies the fully-qualified name of the Java class that
241 * provides the SASL mechanism handler implementation.
242 *
243 * @return Returns the "java-class" property definition.
244 */
245 public ClassPropertyDefinition getJavaClassPropertyDefinition() {
246 return PD_JAVA_CLASS;
247 }
248
249
250
251 /**
252 * Get the "realm" property definition.
253 * <p>
254 * Specifies the realm that is to be used by the server for
255 * DIGEST-MD5 authentication.
256 * <p>
257 * If this value is not provided, then the server defaults to use a
258 * set of realm names that correspond to the defined suffixes.
259 *
260 * @return Returns the "realm" property definition.
261 */
262 public StringPropertyDefinition getRealmPropertyDefinition() {
263 return PD_REALM;
264 }
265
266
267
268 /**
269 * Get the "server-fqdn" property definition.
270 * <p>
271 * Specifies the DNS-resolvable fully-qualified domain name for the
272 * server that is used when validating the digest-uri parameter
273 * during the authentication process.
274 * <p>
275 * If this configuration attribute is present, then the server
276 * expects that clients use a digest-uri equal to "ldap/" followed by
277 * the value of this attribute. For example, if the attribute has a
278 * value of "directory.example.com", then the server expects clients
279 * to use a digest-uri of "ldap/directory.example.com". If no value
280 * is provided, then the server does not attempt to validate the
281 * digest-uri provided by the client and accepts any value.
282 *
283 * @return Returns the "server-fqdn" property definition.
284 */
285 public StringPropertyDefinition getServerFqdnPropertyDefinition() {
286 return PD_SERVER_FQDN;
287 }
288
289
290
291 /**
292 * Managed object client implementation.
293 */
294 private static class DigestMD5SASLMechanismHandlerCfgClientImpl implements
295 DigestMD5SASLMechanismHandlerCfgClient {
296
297 // Private implementation.
298 private ManagedObject<? extends DigestMD5SASLMechanismHandlerCfgClient> impl;
299
300
301
302 // Private constructor.
303 private DigestMD5SASLMechanismHandlerCfgClientImpl(
304 ManagedObject<? extends DigestMD5SASLMechanismHandlerCfgClient> impl) {
305 this.impl = impl;
306 }
307
308
309
310 /**
311 * {@inheritDoc}
312 */
313 public Boolean isEnabled() {
314 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
315 }
316
317
318
319 /**
320 * {@inheritDoc}
321 */
322 public void setEnabled(boolean value) {
323 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
324 }
325
326
327
328 /**
329 * {@inheritDoc}
330 */
331 public String getIdentityMapper() {
332 return impl.getPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition());
333 }
334
335
336
337 /**
338 * {@inheritDoc}
339 */
340 public void setIdentityMapper(String value) {
341 impl.setPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition(), value);
342 }
343
344
345
346 /**
347 * {@inheritDoc}
348 */
349 public String getJavaClass() {
350 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
351 }
352
353
354
355 /**
356 * {@inheritDoc}
357 */
358 public void setJavaClass(String value) {
359 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
360 }
361
362
363
364 /**
365 * {@inheritDoc}
366 */
367 public String getRealm() {
368 return impl.getPropertyValue(INSTANCE.getRealmPropertyDefinition());
369 }
370
371
372
373 /**
374 * {@inheritDoc}
375 */
376 public void setRealm(String value) {
377 impl.setPropertyValue(INSTANCE.getRealmPropertyDefinition(), value);
378 }
379
380
381
382 /**
383 * {@inheritDoc}
384 */
385 public String getServerFqdn() {
386 return impl.getPropertyValue(INSTANCE.getServerFqdnPropertyDefinition());
387 }
388
389
390
391 /**
392 * {@inheritDoc}
393 */
394 public void setServerFqdn(String value) {
395 impl.setPropertyValue(INSTANCE.getServerFqdnPropertyDefinition(), value);
396 }
397
398
399
400 /**
401 * {@inheritDoc}
402 */
403 public ManagedObjectDefinition<? extends DigestMD5SASLMechanismHandlerCfgClient, ? extends DigestMD5SASLMechanismHandlerCfg> definition() {
404 return INSTANCE;
405 }
406
407
408
409 /**
410 * {@inheritDoc}
411 */
412 public PropertyProvider properties() {
413 return impl;
414 }
415
416
417
418 /**
419 * {@inheritDoc}
420 */
421 public void commit() throws ManagedObjectAlreadyExistsException,
422 MissingMandatoryPropertiesException, ConcurrentModificationException,
423 OperationRejectedException, AuthorizationException,
424 CommunicationException {
425 impl.commit();
426 }
427
428 }
429
430
431
432 /**
433 * Managed object server implementation.
434 */
435 private static class DigestMD5SASLMechanismHandlerCfgServerImpl implements
436 DigestMD5SASLMechanismHandlerCfg {
437
438 // Private implementation.
439 private ServerManagedObject<? extends DigestMD5SASLMechanismHandlerCfg> impl;
440
441 // The value of the "enabled" property.
442 private final boolean pEnabled;
443
444 // The value of the "identity-mapper" property.
445 private final String pIdentityMapper;
446
447 // The value of the "java-class" property.
448 private final String pJavaClass;
449
450 // The value of the "realm" property.
451 private final String pRealm;
452
453 // The value of the "server-fqdn" property.
454 private final String pServerFqdn;
455
456
457
458 // Private constructor.
459 private DigestMD5SASLMechanismHandlerCfgServerImpl(ServerManagedObject<? extends DigestMD5SASLMechanismHandlerCfg> impl) {
460 this.impl = impl;
461 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
462 this.pIdentityMapper = impl.getPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition());
463 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
464 this.pRealm = impl.getPropertyValue(INSTANCE.getRealmPropertyDefinition());
465 this.pServerFqdn = impl.getPropertyValue(INSTANCE.getServerFqdnPropertyDefinition());
466 }
467
468
469
470 /**
471 * {@inheritDoc}
472 */
473 public void addDigestMD5ChangeListener(
474 ConfigurationChangeListener<DigestMD5SASLMechanismHandlerCfg> listener) {
475 impl.registerChangeListener(listener);
476 }
477
478
479
480 /**
481 * {@inheritDoc}
482 */
483 public void removeDigestMD5ChangeListener(
484 ConfigurationChangeListener<DigestMD5SASLMechanismHandlerCfg> listener) {
485 impl.deregisterChangeListener(listener);
486 }
487 /**
488 * {@inheritDoc}
489 */
490 public void addChangeListener(
491 ConfigurationChangeListener<SASLMechanismHandlerCfg> listener) {
492 impl.registerChangeListener(listener);
493 }
494
495
496
497 /**
498 * {@inheritDoc}
499 */
500 public void removeChangeListener(
501 ConfigurationChangeListener<SASLMechanismHandlerCfg> listener) {
502 impl.deregisterChangeListener(listener);
503 }
504
505
506
507 /**
508 * {@inheritDoc}
509 */
510 public boolean isEnabled() {
511 return pEnabled;
512 }
513
514
515
516 /**
517 * {@inheritDoc}
518 */
519 public String getIdentityMapper() {
520 return pIdentityMapper;
521 }
522
523
524
525 /**
526 * {@inheritDoc}
527 */
528 public DN getIdentityMapperDN() {
529 String value = getIdentityMapper();
530 if (value == null) return null;
531 return INSTANCE.getIdentityMapperPropertyDefinition().getChildDN(value);
532 }
533
534
535
536 /**
537 * {@inheritDoc}
538 */
539 public String getJavaClass() {
540 return pJavaClass;
541 }
542
543
544
545 /**
546 * {@inheritDoc}
547 */
548 public String getRealm() {
549 return pRealm;
550 }
551
552
553
554 /**
555 * {@inheritDoc}
556 */
557 public String getServerFqdn() {
558 return pServerFqdn;
559 }
560
561
562
563 /**
564 * {@inheritDoc}
565 */
566 public Class<? extends DigestMD5SASLMechanismHandlerCfg> configurationClass() {
567 return DigestMD5SASLMechanismHandlerCfg.class;
568 }
569
570
571
572 /**
573 * {@inheritDoc}
574 */
575 public DN dn() {
576 return impl.getDN();
577 }
578
579 }
580 }