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