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.AnonymousSASLMechanismHandlerCfgClient; 039import org.opends.server.admin.std.server.AnonymousSASLMechanismHandlerCfg; 040import org.opends.server.admin.std.server.SASLMechanismHandlerCfg; 041import org.opends.server.admin.Tag; 042 043 044 045/** 046 * An interface for querying the Anonymous SASL Mechanism Handler 047 * managed object definition meta information. 048 * <p> 049 * The ANONYMOUS SASL mechanism provides the ability for clients to 050 * perform an anonymous bind using a SASL mechanism. 051 */ 052public final class AnonymousSASLMechanismHandlerCfgDefn extends ManagedObjectDefinition<AnonymousSASLMechanismHandlerCfgClient, AnonymousSASLMechanismHandlerCfg> { 053 054 // The singleton configuration definition instance. 055 private static final AnonymousSASLMechanismHandlerCfgDefn INSTANCE = new AnonymousSASLMechanismHandlerCfgDefn(); 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.AnonymousSASLMechanismHandler"); 071 builder.setDefaultBehaviorProvider(provider); 072 builder.addInstanceOf("org.opends.server.api.SASLMechanismHandler"); 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 } 083 084 085 086 /** 087 * Get the Anonymous SASL Mechanism Handler configuration definition 088 * singleton. 089 * 090 * @return Returns the Anonymous SASL Mechanism Handler 091 * configuration definition singleton. 092 */ 093 public static AnonymousSASLMechanismHandlerCfgDefn getInstance() { 094 return INSTANCE; 095 } 096 097 098 099 /** 100 * Private constructor. 101 */ 102 private AnonymousSASLMechanismHandlerCfgDefn() { 103 super("anonymous-sasl-mechanism-handler", SASLMechanismHandlerCfgDefn.getInstance()); 104 } 105 106 107 108 /** 109 * {@inheritDoc} 110 */ 111 public AnonymousSASLMechanismHandlerCfgClient createClientConfiguration( 112 ManagedObject<? extends AnonymousSASLMechanismHandlerCfgClient> impl) { 113 return new AnonymousSASLMechanismHandlerCfgClientImpl(impl); 114 } 115 116 117 118 /** 119 * {@inheritDoc} 120 */ 121 public AnonymousSASLMechanismHandlerCfg createServerConfiguration( 122 ServerManagedObject<? extends AnonymousSASLMechanismHandlerCfg> impl) { 123 return new AnonymousSASLMechanismHandlerCfgServerImpl(impl); 124 } 125 126 127 128 /** 129 * {@inheritDoc} 130 */ 131 public Class<AnonymousSASLMechanismHandlerCfg> getServerConfigurationClass() { 132 return AnonymousSASLMechanismHandlerCfg.class; 133 } 134 135 136 137 /** 138 * Get the "enabled" property definition. 139 * <p> 140 * Indicates whether the SASL mechanism handler is enabled for use. 141 * 142 * @return Returns the "enabled" property definition. 143 */ 144 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 145 return SASLMechanismHandlerCfgDefn.getInstance().getEnabledPropertyDefinition(); 146 } 147 148 149 150 /** 151 * Get the "java-class" property definition. 152 * <p> 153 * Specifies the fully-qualified name of the Java class that 154 * provides the SASL mechanism handler implementation. 155 * 156 * @return Returns the "java-class" property definition. 157 */ 158 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 159 return PD_JAVA_CLASS; 160 } 161 162 163 164 /** 165 * Managed object client implementation. 166 */ 167 private static class AnonymousSASLMechanismHandlerCfgClientImpl implements 168 AnonymousSASLMechanismHandlerCfgClient { 169 170 // Private implementation. 171 private ManagedObject<? extends AnonymousSASLMechanismHandlerCfgClient> impl; 172 173 174 175 // Private constructor. 176 private AnonymousSASLMechanismHandlerCfgClientImpl( 177 ManagedObject<? extends AnonymousSASLMechanismHandlerCfgClient> impl) { 178 this.impl = impl; 179 } 180 181 182 183 /** 184 * {@inheritDoc} 185 */ 186 public Boolean isEnabled() { 187 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 188 } 189 190 191 192 /** 193 * {@inheritDoc} 194 */ 195 public void setEnabled(boolean value) { 196 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 197 } 198 199 200 201 /** 202 * {@inheritDoc} 203 */ 204 public String getJavaClass() { 205 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 206 } 207 208 209 210 /** 211 * {@inheritDoc} 212 */ 213 public void setJavaClass(String value) { 214 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 215 } 216 217 218 219 /** 220 * {@inheritDoc} 221 */ 222 public ManagedObjectDefinition<? extends AnonymousSASLMechanismHandlerCfgClient, ? extends AnonymousSASLMechanismHandlerCfg> definition() { 223 return INSTANCE; 224 } 225 226 227 228 /** 229 * {@inheritDoc} 230 */ 231 public PropertyProvider properties() { 232 return impl; 233 } 234 235 236 237 /** 238 * {@inheritDoc} 239 */ 240 public void commit() throws ManagedObjectAlreadyExistsException, 241 MissingMandatoryPropertiesException, ConcurrentModificationException, 242 OperationRejectedException, AuthorizationException, 243 CommunicationException { 244 impl.commit(); 245 } 246 247 248 249 /** {@inheritDoc} */ 250 public String toString() { 251 return impl.toString(); 252 } 253 } 254 255 256 257 /** 258 * Managed object server implementation. 259 */ 260 private static class AnonymousSASLMechanismHandlerCfgServerImpl implements 261 AnonymousSASLMechanismHandlerCfg { 262 263 // Private implementation. 264 private ServerManagedObject<? extends AnonymousSASLMechanismHandlerCfg> impl; 265 266 // The value of the "enabled" property. 267 private final boolean pEnabled; 268 269 // The value of the "java-class" property. 270 private final String pJavaClass; 271 272 273 274 // Private constructor. 275 private AnonymousSASLMechanismHandlerCfgServerImpl(ServerManagedObject<? extends AnonymousSASLMechanismHandlerCfg> impl) { 276 this.impl = impl; 277 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 278 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 279 } 280 281 282 283 /** 284 * {@inheritDoc} 285 */ 286 public void addAnonymousChangeListener( 287 ConfigurationChangeListener<AnonymousSASLMechanismHandlerCfg> listener) { 288 impl.registerChangeListener(listener); 289 } 290 291 292 293 /** 294 * {@inheritDoc} 295 */ 296 public void removeAnonymousChangeListener( 297 ConfigurationChangeListener<AnonymousSASLMechanismHandlerCfg> listener) { 298 impl.deregisterChangeListener(listener); 299 } 300 /** 301 * {@inheritDoc} 302 */ 303 public void addChangeListener( 304 ConfigurationChangeListener<SASLMechanismHandlerCfg> listener) { 305 impl.registerChangeListener(listener); 306 } 307 308 309 310 /** 311 * {@inheritDoc} 312 */ 313 public void removeChangeListener( 314 ConfigurationChangeListener<SASLMechanismHandlerCfg> listener) { 315 impl.deregisterChangeListener(listener); 316 } 317 318 319 320 /** 321 * {@inheritDoc} 322 */ 323 public boolean isEnabled() { 324 return pEnabled; 325 } 326 327 328 329 /** 330 * {@inheritDoc} 331 */ 332 public String getJavaClass() { 333 return pJavaClass; 334 } 335 336 337 338 /** 339 * {@inheritDoc} 340 */ 341 public Class<? extends AnonymousSASLMechanismHandlerCfg> configurationClass() { 342 return AnonymousSASLMechanismHandlerCfg.class; 343 } 344 345 346 347 /** 348 * {@inheritDoc} 349 */ 350 public DN dn() { 351 return impl.getDN(); 352 } 353 354 355 356 /** {@inheritDoc} */ 357 public String toString() { 358 return impl.toString(); 359 } 360 } 361}