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 org.forgerock.opendj.ldap.DN; 021import org.opends.server.admin.AdministratorAction; 022import org.opends.server.admin.BooleanPropertyDefinition; 023import org.opends.server.admin.ClassPropertyDefinition; 024import org.opends.server.admin.client.AuthorizationException; 025import org.opends.server.admin.client.CommunicationException; 026import org.opends.server.admin.client.ConcurrentModificationException; 027import org.opends.server.admin.client.ManagedObject; 028import org.opends.server.admin.client.MissingMandatoryPropertiesException; 029import org.opends.server.admin.client.OperationRejectedException; 030import org.opends.server.admin.DefaultBehaviorProvider; 031import org.opends.server.admin.DefinedDefaultBehaviorProvider; 032import org.opends.server.admin.ManagedObjectAlreadyExistsException; 033import org.opends.server.admin.ManagedObjectDefinition; 034import org.opends.server.admin.PropertyOption; 035import org.opends.server.admin.PropertyProvider; 036import org.opends.server.admin.server.ConfigurationChangeListener; 037import org.opends.server.admin.server.ServerManagedObject; 038import org.opends.server.admin.std.client.SubjectEqualsDNCertificateMapperCfgClient; 039import org.opends.server.admin.std.server.CertificateMapperCfg; 040import org.opends.server.admin.std.server.SubjectEqualsDNCertificateMapperCfg; 041import org.opends.server.admin.Tag; 042 043 044 045/** 046 * An interface for querying the Subject Equals DN Certificate Mapper 047 * managed object definition meta information. 048 * <p> 049 * The Subject Equals DN Certificate Mapper maps client certificates 050 * to user entries based on the assumption that the certificate subject 051 * is the same as the DN of the target user entry. 052 */ 053public final class SubjectEqualsDNCertificateMapperCfgDefn extends ManagedObjectDefinition<SubjectEqualsDNCertificateMapperCfgClient, SubjectEqualsDNCertificateMapperCfg> { 054 055 // The singleton configuration definition instance. 056 private static final SubjectEqualsDNCertificateMapperCfgDefn INSTANCE = new SubjectEqualsDNCertificateMapperCfgDefn(); 057 058 059 060 // The "java-class" property definition. 061 private static final ClassPropertyDefinition PD_JAVA_CLASS; 062 063 064 065 // Build the "java-class" property definition. 066 static { 067 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 068 builder.setOption(PropertyOption.MANDATORY); 069 builder.setOption(PropertyOption.ADVANCED); 070 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 071 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.SubjectEqualsDNCertificateMapper"); 072 builder.setDefaultBehaviorProvider(provider); 073 builder.addInstanceOf("org.opends.server.api.CertificateMapper"); 074 PD_JAVA_CLASS = builder.getInstance(); 075 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 076 } 077 078 079 080 // Register the tags associated with this managed object definition. 081 static { 082 INSTANCE.registerTag(Tag.valueOf("security")); 083 INSTANCE.registerTag(Tag.valueOf("user-management")); 084 } 085 086 087 088 /** 089 * Get the Subject Equals DN Certificate Mapper configuration 090 * definition singleton. 091 * 092 * @return Returns the Subject Equals DN Certificate Mapper 093 * configuration definition singleton. 094 */ 095 public static SubjectEqualsDNCertificateMapperCfgDefn getInstance() { 096 return INSTANCE; 097 } 098 099 100 101 /** 102 * Private constructor. 103 */ 104 private SubjectEqualsDNCertificateMapperCfgDefn() { 105 super("subject-equals-dn-certificate-mapper", CertificateMapperCfgDefn.getInstance()); 106 } 107 108 109 110 /** 111 * {@inheritDoc} 112 */ 113 public SubjectEqualsDNCertificateMapperCfgClient createClientConfiguration( 114 ManagedObject<? extends SubjectEqualsDNCertificateMapperCfgClient> impl) { 115 return new SubjectEqualsDNCertificateMapperCfgClientImpl(impl); 116 } 117 118 119 120 /** 121 * {@inheritDoc} 122 */ 123 public SubjectEqualsDNCertificateMapperCfg createServerConfiguration( 124 ServerManagedObject<? extends SubjectEqualsDNCertificateMapperCfg> impl) { 125 return new SubjectEqualsDNCertificateMapperCfgServerImpl(impl); 126 } 127 128 129 130 /** 131 * {@inheritDoc} 132 */ 133 public Class<SubjectEqualsDNCertificateMapperCfg> getServerConfigurationClass() { 134 return SubjectEqualsDNCertificateMapperCfg.class; 135 } 136 137 138 139 /** 140 * Get the "enabled" property definition. 141 * <p> 142 * Indicates whether the Subject Equals DN Certificate Mapper is 143 * enabled. 144 * 145 * @return Returns the "enabled" property definition. 146 */ 147 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 148 return CertificateMapperCfgDefn.getInstance().getEnabledPropertyDefinition(); 149 } 150 151 152 153 /** 154 * Get the "java-class" property definition. 155 * <p> 156 * Specifies the fully-qualified name of the Java class that 157 * provides the Subject Equals DN Certificate Mapper implementation. 158 * 159 * @return Returns the "java-class" property definition. 160 */ 161 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 162 return PD_JAVA_CLASS; 163 } 164 165 166 167 /** 168 * Managed object client implementation. 169 */ 170 private static class SubjectEqualsDNCertificateMapperCfgClientImpl implements 171 SubjectEqualsDNCertificateMapperCfgClient { 172 173 // Private implementation. 174 private ManagedObject<? extends SubjectEqualsDNCertificateMapperCfgClient> impl; 175 176 177 178 // Private constructor. 179 private SubjectEqualsDNCertificateMapperCfgClientImpl( 180 ManagedObject<? extends SubjectEqualsDNCertificateMapperCfgClient> impl) { 181 this.impl = impl; 182 } 183 184 185 186 /** 187 * {@inheritDoc} 188 */ 189 public Boolean isEnabled() { 190 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 191 } 192 193 194 195 /** 196 * {@inheritDoc} 197 */ 198 public void setEnabled(boolean value) { 199 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 200 } 201 202 203 204 /** 205 * {@inheritDoc} 206 */ 207 public String getJavaClass() { 208 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 209 } 210 211 212 213 /** 214 * {@inheritDoc} 215 */ 216 public void setJavaClass(String value) { 217 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 218 } 219 220 221 222 /** 223 * {@inheritDoc} 224 */ 225 public ManagedObjectDefinition<? extends SubjectEqualsDNCertificateMapperCfgClient, ? extends SubjectEqualsDNCertificateMapperCfg> definition() { 226 return INSTANCE; 227 } 228 229 230 231 /** 232 * {@inheritDoc} 233 */ 234 public PropertyProvider properties() { 235 return impl; 236 } 237 238 239 240 /** 241 * {@inheritDoc} 242 */ 243 public void commit() throws ManagedObjectAlreadyExistsException, 244 MissingMandatoryPropertiesException, ConcurrentModificationException, 245 OperationRejectedException, AuthorizationException, 246 CommunicationException { 247 impl.commit(); 248 } 249 250 251 252 /** {@inheritDoc} */ 253 public String toString() { 254 return impl.toString(); 255 } 256 } 257 258 259 260 /** 261 * Managed object server implementation. 262 */ 263 private static class SubjectEqualsDNCertificateMapperCfgServerImpl implements 264 SubjectEqualsDNCertificateMapperCfg { 265 266 // Private implementation. 267 private ServerManagedObject<? extends SubjectEqualsDNCertificateMapperCfg> impl; 268 269 // The value of the "enabled" property. 270 private final boolean pEnabled; 271 272 // The value of the "java-class" property. 273 private final String pJavaClass; 274 275 276 277 // Private constructor. 278 private SubjectEqualsDNCertificateMapperCfgServerImpl(ServerManagedObject<? extends SubjectEqualsDNCertificateMapperCfg> impl) { 279 this.impl = impl; 280 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 281 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 282 } 283 284 285 286 /** 287 * {@inheritDoc} 288 */ 289 public void addSubjectEqualsDNChangeListener( 290 ConfigurationChangeListener<SubjectEqualsDNCertificateMapperCfg> listener) { 291 impl.registerChangeListener(listener); 292 } 293 294 295 296 /** 297 * {@inheritDoc} 298 */ 299 public void removeSubjectEqualsDNChangeListener( 300 ConfigurationChangeListener<SubjectEqualsDNCertificateMapperCfg> listener) { 301 impl.deregisterChangeListener(listener); 302 } 303 /** 304 * {@inheritDoc} 305 */ 306 public void addChangeListener( 307 ConfigurationChangeListener<CertificateMapperCfg> listener) { 308 impl.registerChangeListener(listener); 309 } 310 311 312 313 /** 314 * {@inheritDoc} 315 */ 316 public void removeChangeListener( 317 ConfigurationChangeListener<CertificateMapperCfg> listener) { 318 impl.deregisterChangeListener(listener); 319 } 320 321 322 323 /** 324 * {@inheritDoc} 325 */ 326 public boolean isEnabled() { 327 return pEnabled; 328 } 329 330 331 332 /** 333 * {@inheritDoc} 334 */ 335 public String getJavaClass() { 336 return pJavaClass; 337 } 338 339 340 341 /** 342 * {@inheritDoc} 343 */ 344 public Class<? extends SubjectEqualsDNCertificateMapperCfg> configurationClass() { 345 return SubjectEqualsDNCertificateMapperCfg.class; 346 } 347 348 349 350 /** 351 * {@inheritDoc} 352 */ 353 public DN dn() { 354 return impl.getDN(); 355 } 356 357 358 359 /** {@inheritDoc} */ 360 public String toString() { 361 return impl.toString(); 362 } 363 } 364}