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