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.StartTLSExtendedOperationHandlerCfgClient; 039import org.forgerock.opendj.server.config.server.ExtendedOperationHandlerCfg; 040import org.forgerock.opendj.server.config.server.StartTLSExtendedOperationHandlerCfg; 041 042 043 044/** 045 * An interface for querying the Start TLS Extended Operation Handler 046 * managed object definition meta information. 047 * <p> 048 * The Start TLS Extended Operation Handler provides the ability 049 * clients to use the StartTLS extended operation to initiate a secure 050 * communication channel over an otherwise clear-text LDAP connection. 051 */ 052public final class StartTLSExtendedOperationHandlerCfgDefn extends ManagedObjectDefinition<StartTLSExtendedOperationHandlerCfgClient, StartTLSExtendedOperationHandlerCfg> { 053 054 /** The singleton configuration definition instance. */ 055 private static final StartTLSExtendedOperationHandlerCfgDefn INSTANCE = new StartTLSExtendedOperationHandlerCfgDefn(); 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.StartTLSExtendedOperation"); 071 builder.setDefaultBehaviorProvider(provider); 072 builder.addInstanceOf("org.opends.server.api.ExtendedOperationHandler"); 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("core-server")); 082 } 083 084 085 086 /** 087 * Get the Start TLS Extended Operation Handler configuration 088 * definition singleton. 089 * 090 * @return Returns the Start TLS Extended Operation Handler 091 * configuration definition singleton. 092 */ 093 public static StartTLSExtendedOperationHandlerCfgDefn getInstance() { 094 return INSTANCE; 095 } 096 097 098 099 /** 100 * Private constructor. 101 */ 102 private StartTLSExtendedOperationHandlerCfgDefn() { 103 super("start-tls-extended-operation-handler", ExtendedOperationHandlerCfgDefn.getInstance()); 104 } 105 106 107 108 /** {@inheritDoc} */ 109 public StartTLSExtendedOperationHandlerCfgClient createClientConfiguration( 110 ManagedObject<? extends StartTLSExtendedOperationHandlerCfgClient> impl) { 111 return new StartTLSExtendedOperationHandlerCfgClientImpl(impl); 112 } 113 114 115 116 /** {@inheritDoc} */ 117 public StartTLSExtendedOperationHandlerCfg createServerConfiguration( 118 ServerManagedObject<? extends StartTLSExtendedOperationHandlerCfg> impl) { 119 return new StartTLSExtendedOperationHandlerCfgServerImpl(impl); 120 } 121 122 123 124 /** {@inheritDoc} */ 125 public Class<StartTLSExtendedOperationHandlerCfg> getServerConfigurationClass() { 126 return StartTLSExtendedOperationHandlerCfg.class; 127 } 128 129 130 131 /** 132 * Get the "enabled" property definition. 133 * <p> 134 * Indicates whether the Start TLS Extended Operation Handler is 135 * enabled (that is, whether the types of extended operations are 136 * allowed in the server). 137 * 138 * @return Returns the "enabled" property definition. 139 */ 140 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 141 return ExtendedOperationHandlerCfgDefn.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 Start TLS Extended Operation Handler 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 StartTLSExtendedOperationHandlerCfgClientImpl implements 164 StartTLSExtendedOperationHandlerCfgClient { 165 166 /** Private implementation. */ 167 private ManagedObject<? extends StartTLSExtendedOperationHandlerCfgClient> impl; 168 169 170 171 /** Private constructor. */ 172 private StartTLSExtendedOperationHandlerCfgClientImpl( 173 ManagedObject<? extends StartTLSExtendedOperationHandlerCfgClient> 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 StartTLSExtendedOperationHandlerCfgClient, ? extends StartTLSExtendedOperationHandlerCfg> 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 StartTLSExtendedOperationHandlerCfgServerImpl implements 242 StartTLSExtendedOperationHandlerCfg { 243 244 /** Private implementation. */ 245 private ServerManagedObject<? extends StartTLSExtendedOperationHandlerCfg> 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 StartTLSExtendedOperationHandlerCfgServerImpl(ServerManagedObject<? extends StartTLSExtendedOperationHandlerCfg> 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 addStartTLSChangeListener( 266 ConfigurationChangeListener<StartTLSExtendedOperationHandlerCfg> listener) { 267 impl.registerChangeListener(listener); 268 } 269 270 271 272 /** {@inheritDoc} */ 273 public void removeStartTLSChangeListener( 274 ConfigurationChangeListener<StartTLSExtendedOperationHandlerCfg> listener) { 275 impl.deregisterChangeListener(listener); 276 } 277 /** {@inheritDoc} */ 278 public void addChangeListener( 279 ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) { 280 impl.registerChangeListener(listener); 281 } 282 283 284 285 /** {@inheritDoc} */ 286 public void removeChangeListener( 287 ConfigurationChangeListener<ExtendedOperationHandlerCfg> 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 StartTLSExtendedOperationHandlerCfg> configurationClass() { 309 return StartTLSExtendedOperationHandlerCfg.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}