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