001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 */ 026package org.opends.server.admin.std.meta; 027 028 029 030import org.opends.server.admin.AdministratorAction; 031import org.opends.server.admin.BooleanPropertyDefinition; 032import org.opends.server.admin.ClassPropertyDefinition; 033import org.opends.server.admin.client.AuthorizationException; 034import org.opends.server.admin.client.CommunicationException; 035import org.opends.server.admin.client.ConcurrentModificationException; 036import org.opends.server.admin.client.ManagedObject; 037import org.opends.server.admin.client.MissingMandatoryPropertiesException; 038import org.opends.server.admin.client.OperationRejectedException; 039import org.opends.server.admin.DefaultBehaviorProvider; 040import org.opends.server.admin.DefinedDefaultBehaviorProvider; 041import org.opends.server.admin.ManagedObjectAlreadyExistsException; 042import org.opends.server.admin.ManagedObjectDefinition; 043import org.opends.server.admin.PropertyOption; 044import org.opends.server.admin.PropertyProvider; 045import org.opends.server.admin.server.ConfigurationChangeListener; 046import org.opends.server.admin.server.ServerManagedObject; 047import org.opends.server.admin.std.client.WhoAmIExtendedOperationHandlerCfgClient; 048import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg; 049import org.opends.server.admin.std.server.WhoAmIExtendedOperationHandlerCfg; 050import org.opends.server.admin.Tag; 051import org.opends.server.types.DN; 052 053 054 055/** 056 * An interface for querying the Who Am I Extended Operation Handler 057 * managed object definition meta information. 058 * <p> 059 * The Who Am I Extended Operation Handler provides the ability for 060 * clients to request their authorization identity using the "Who Am 061 * I?" extended operation as defined in RFC 4532. 062 */ 063public final class WhoAmIExtendedOperationHandlerCfgDefn extends ManagedObjectDefinition<WhoAmIExtendedOperationHandlerCfgClient, WhoAmIExtendedOperationHandlerCfg> { 064 065 // The singleton configuration definition instance. 066 private static final WhoAmIExtendedOperationHandlerCfgDefn INSTANCE = new WhoAmIExtendedOperationHandlerCfgDefn(); 067 068 069 070 // The "java-class" property definition. 071 private static final ClassPropertyDefinition PD_JAVA_CLASS; 072 073 074 075 // Build the "java-class" property definition. 076 static { 077 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 078 builder.setOption(PropertyOption.MANDATORY); 079 builder.setOption(PropertyOption.ADVANCED); 080 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 081 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.WhoAmIExtendedOperation"); 082 builder.setDefaultBehaviorProvider(provider); 083 builder.addInstanceOf("org.opends.server.api.ExtendedOperationHandler"); 084 PD_JAVA_CLASS = builder.getInstance(); 085 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 086 } 087 088 089 090 // Register the tags associated with this managed object definition. 091 static { 092 INSTANCE.registerTag(Tag.valueOf("core-server")); 093 } 094 095 096 097 /** 098 * Get the Who Am I Extended Operation Handler configuration 099 * definition singleton. 100 * 101 * @return Returns the Who Am I Extended Operation Handler 102 * configuration definition singleton. 103 */ 104 public static WhoAmIExtendedOperationHandlerCfgDefn getInstance() { 105 return INSTANCE; 106 } 107 108 109 110 /** 111 * Private constructor. 112 */ 113 private WhoAmIExtendedOperationHandlerCfgDefn() { 114 super("who-am-i-extended-operation-handler", ExtendedOperationHandlerCfgDefn.getInstance()); 115 } 116 117 118 119 /** 120 * {@inheritDoc} 121 */ 122 public WhoAmIExtendedOperationHandlerCfgClient createClientConfiguration( 123 ManagedObject<? extends WhoAmIExtendedOperationHandlerCfgClient> impl) { 124 return new WhoAmIExtendedOperationHandlerCfgClientImpl(impl); 125 } 126 127 128 129 /** 130 * {@inheritDoc} 131 */ 132 public WhoAmIExtendedOperationHandlerCfg createServerConfiguration( 133 ServerManagedObject<? extends WhoAmIExtendedOperationHandlerCfg> impl) { 134 return new WhoAmIExtendedOperationHandlerCfgServerImpl(impl); 135 } 136 137 138 139 /** 140 * {@inheritDoc} 141 */ 142 public Class<WhoAmIExtendedOperationHandlerCfg> getServerConfigurationClass() { 143 return WhoAmIExtendedOperationHandlerCfg.class; 144 } 145 146 147 148 /** 149 * Get the "enabled" property definition. 150 * <p> 151 * Indicates whether the Who Am I Extended Operation Handler is 152 * enabled (that is, whether the types of extended operations are 153 * allowed in the server). 154 * 155 * @return Returns the "enabled" property definition. 156 */ 157 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 158 return ExtendedOperationHandlerCfgDefn.getInstance().getEnabledPropertyDefinition(); 159 } 160 161 162 163 /** 164 * Get the "java-class" property definition. 165 * <p> 166 * Specifies the fully-qualified name of the Java class that 167 * provides the Who Am I Extended Operation Handler implementation. 168 * 169 * @return Returns the "java-class" property definition. 170 */ 171 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 172 return PD_JAVA_CLASS; 173 } 174 175 176 177 /** 178 * Managed object client implementation. 179 */ 180 private static class WhoAmIExtendedOperationHandlerCfgClientImpl implements 181 WhoAmIExtendedOperationHandlerCfgClient { 182 183 // Private implementation. 184 private ManagedObject<? extends WhoAmIExtendedOperationHandlerCfgClient> impl; 185 186 187 188 // Private constructor. 189 private WhoAmIExtendedOperationHandlerCfgClientImpl( 190 ManagedObject<? extends WhoAmIExtendedOperationHandlerCfgClient> impl) { 191 this.impl = impl; 192 } 193 194 195 196 /** 197 * {@inheritDoc} 198 */ 199 public Boolean isEnabled() { 200 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 201 } 202 203 204 205 /** 206 * {@inheritDoc} 207 */ 208 public void setEnabled(boolean value) { 209 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 210 } 211 212 213 214 /** 215 * {@inheritDoc} 216 */ 217 public String getJavaClass() { 218 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 219 } 220 221 222 223 /** 224 * {@inheritDoc} 225 */ 226 public void setJavaClass(String value) { 227 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 228 } 229 230 231 232 /** 233 * {@inheritDoc} 234 */ 235 public ManagedObjectDefinition<? extends WhoAmIExtendedOperationHandlerCfgClient, ? extends WhoAmIExtendedOperationHandlerCfg> definition() { 236 return INSTANCE; 237 } 238 239 240 241 /** 242 * {@inheritDoc} 243 */ 244 public PropertyProvider properties() { 245 return impl; 246 } 247 248 249 250 /** 251 * {@inheritDoc} 252 */ 253 public void commit() throws ManagedObjectAlreadyExistsException, 254 MissingMandatoryPropertiesException, ConcurrentModificationException, 255 OperationRejectedException, AuthorizationException, 256 CommunicationException { 257 impl.commit(); 258 } 259 260 261 262 /** {@inheritDoc} */ 263 public String toString() { 264 return impl.toString(); 265 } 266 } 267 268 269 270 /** 271 * Managed object server implementation. 272 */ 273 private static class WhoAmIExtendedOperationHandlerCfgServerImpl implements 274 WhoAmIExtendedOperationHandlerCfg { 275 276 // Private implementation. 277 private ServerManagedObject<? extends WhoAmIExtendedOperationHandlerCfg> impl; 278 279 // The value of the "enabled" property. 280 private final boolean pEnabled; 281 282 // The value of the "java-class" property. 283 private final String pJavaClass; 284 285 286 287 // Private constructor. 288 private WhoAmIExtendedOperationHandlerCfgServerImpl(ServerManagedObject<? extends WhoAmIExtendedOperationHandlerCfg> impl) { 289 this.impl = impl; 290 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 291 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 292 } 293 294 295 296 /** 297 * {@inheritDoc} 298 */ 299 public void addWhoAmIChangeListener( 300 ConfigurationChangeListener<WhoAmIExtendedOperationHandlerCfg> listener) { 301 impl.registerChangeListener(listener); 302 } 303 304 305 306 /** 307 * {@inheritDoc} 308 */ 309 public void removeWhoAmIChangeListener( 310 ConfigurationChangeListener<WhoAmIExtendedOperationHandlerCfg> listener) { 311 impl.deregisterChangeListener(listener); 312 } 313 /** 314 * {@inheritDoc} 315 */ 316 public void addChangeListener( 317 ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) { 318 impl.registerChangeListener(listener); 319 } 320 321 322 323 /** 324 * {@inheritDoc} 325 */ 326 public void removeChangeListener( 327 ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) { 328 impl.deregisterChangeListener(listener); 329 } 330 331 332 333 /** 334 * {@inheritDoc} 335 */ 336 public boolean isEnabled() { 337 return pEnabled; 338 } 339 340 341 342 /** 343 * {@inheritDoc} 344 */ 345 public String getJavaClass() { 346 return pJavaClass; 347 } 348 349 350 351 /** 352 * {@inheritDoc} 353 */ 354 public Class<? extends WhoAmIExtendedOperationHandlerCfg> configurationClass() { 355 return WhoAmIExtendedOperationHandlerCfg.class; 356 } 357 358 359 360 /** 361 * {@inheritDoc} 362 */ 363 public DN dn() { 364 return impl.getDN(); 365 } 366 367 368 369 /** {@inheritDoc} */ 370 public String toString() { 371 return impl.toString(); 372 } 373 } 374}