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.AggregationPropertyDefinition; 023import org.opends.server.admin.BooleanPropertyDefinition; 024import org.opends.server.admin.ClassPropertyDefinition; 025import org.opends.server.admin.client.AuthorizationException; 026import org.opends.server.admin.client.CommunicationException; 027import org.opends.server.admin.client.ConcurrentModificationException; 028import org.opends.server.admin.client.ManagedObject; 029import org.opends.server.admin.client.MissingMandatoryPropertiesException; 030import org.opends.server.admin.client.OperationRejectedException; 031import org.opends.server.admin.condition.Conditions; 032import org.opends.server.admin.DefaultBehaviorProvider; 033import org.opends.server.admin.DefinedDefaultBehaviorProvider; 034import org.opends.server.admin.ManagedObjectAlreadyExistsException; 035import org.opends.server.admin.ManagedObjectDefinition; 036import org.opends.server.admin.PropertyOption; 037import org.opends.server.admin.PropertyProvider; 038import org.opends.server.admin.server.ConfigurationChangeListener; 039import org.opends.server.admin.server.ServerManagedObject; 040import org.opends.server.admin.std.client.IdentityMapperCfgClient; 041import org.opends.server.admin.std.client.PasswordModifyExtendedOperationHandlerCfgClient; 042import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg; 043import org.opends.server.admin.std.server.IdentityMapperCfg; 044import org.opends.server.admin.std.server.PasswordModifyExtendedOperationHandlerCfg; 045import org.opends.server.admin.Tag; 046import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 047 048 049 050/** 051 * An interface for querying the Password Modify Extended Operation 052 * Handler managed object definition meta information. 053 * <p> 054 * The Password Modify Extended Operation Handler allows end users to 055 * change their own passwords, or administrators to reset user 056 * passwords. 057 */ 058public final class PasswordModifyExtendedOperationHandlerCfgDefn extends ManagedObjectDefinition<PasswordModifyExtendedOperationHandlerCfgClient, PasswordModifyExtendedOperationHandlerCfg> { 059 060 // The singleton configuration definition instance. 061 private static final PasswordModifyExtendedOperationHandlerCfgDefn INSTANCE = new PasswordModifyExtendedOperationHandlerCfgDefn(); 062 063 064 065 // The "identity-mapper" property definition. 066 private static final AggregationPropertyDefinition<IdentityMapperCfgClient, IdentityMapperCfg> PD_IDENTITY_MAPPER; 067 068 069 070 // The "java-class" property definition. 071 private static final ClassPropertyDefinition PD_JAVA_CLASS; 072 073 074 075 // Build the "identity-mapper" property definition. 076 static { 077 AggregationPropertyDefinition.Builder<IdentityMapperCfgClient, IdentityMapperCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "identity-mapper"); 078 builder.setOption(PropertyOption.MANDATORY); 079 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "identity-mapper")); 080 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 081 builder.setParentPath("/"); 082 builder.setRelationDefinition("identity-mapper"); 083 builder.setTargetNeedsEnablingCondition(Conditions.contains("enabled", "true")); 084 builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true")); 085 PD_IDENTITY_MAPPER = builder.getInstance(); 086 INSTANCE.registerPropertyDefinition(PD_IDENTITY_MAPPER); 087 INSTANCE.registerConstraint(PD_IDENTITY_MAPPER.getSourceConstraint()); 088 } 089 090 091 092 // Build the "java-class" property definition. 093 static { 094 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 095 builder.setOption(PropertyOption.MANDATORY); 096 builder.setOption(PropertyOption.ADVANCED); 097 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 098 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.PasswordModifyExtendedOperation"); 099 builder.setDefaultBehaviorProvider(provider); 100 builder.addInstanceOf("org.opends.server.api.ExtendedOperationHandler"); 101 PD_JAVA_CLASS = builder.getInstance(); 102 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 103 } 104 105 106 107 // Register the tags associated with this managed object definition. 108 static { 109 INSTANCE.registerTag(Tag.valueOf("core-server")); 110 } 111 112 113 114 /** 115 * Get the Password Modify Extended Operation Handler configuration 116 * definition singleton. 117 * 118 * @return Returns the Password Modify Extended Operation Handler 119 * configuration definition singleton. 120 */ 121 public static PasswordModifyExtendedOperationHandlerCfgDefn getInstance() { 122 return INSTANCE; 123 } 124 125 126 127 /** 128 * Private constructor. 129 */ 130 private PasswordModifyExtendedOperationHandlerCfgDefn() { 131 super("password-modify-extended-operation-handler", ExtendedOperationHandlerCfgDefn.getInstance()); 132 } 133 134 135 136 /** 137 * {@inheritDoc} 138 */ 139 public PasswordModifyExtendedOperationHandlerCfgClient createClientConfiguration( 140 ManagedObject<? extends PasswordModifyExtendedOperationHandlerCfgClient> impl) { 141 return new PasswordModifyExtendedOperationHandlerCfgClientImpl(impl); 142 } 143 144 145 146 /** 147 * {@inheritDoc} 148 */ 149 public PasswordModifyExtendedOperationHandlerCfg createServerConfiguration( 150 ServerManagedObject<? extends PasswordModifyExtendedOperationHandlerCfg> impl) { 151 return new PasswordModifyExtendedOperationHandlerCfgServerImpl(impl); 152 } 153 154 155 156 /** 157 * {@inheritDoc} 158 */ 159 public Class<PasswordModifyExtendedOperationHandlerCfg> getServerConfigurationClass() { 160 return PasswordModifyExtendedOperationHandlerCfg.class; 161 } 162 163 164 165 /** 166 * Get the "enabled" property definition. 167 * <p> 168 * Indicates whether the Password Modify Extended Operation Handler 169 * is enabled (that is, whether the types of extended operations are 170 * allowed in the server). 171 * 172 * @return Returns the "enabled" property definition. 173 */ 174 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 175 return ExtendedOperationHandlerCfgDefn.getInstance().getEnabledPropertyDefinition(); 176 } 177 178 179 180 /** 181 * Get the "identity-mapper" property definition. 182 * <p> 183 * Specifies the name of the identity mapper that should be used in 184 * conjunction with the password modify extended operation. 185 * <p> 186 * This property is used to identify a user based on an 187 * authorization ID in the 'u:' form. Changes to this property take 188 * effect immediately. 189 * 190 * @return Returns the "identity-mapper" property definition. 191 */ 192 public AggregationPropertyDefinition<IdentityMapperCfgClient, IdentityMapperCfg> getIdentityMapperPropertyDefinition() { 193 return PD_IDENTITY_MAPPER; 194 } 195 196 197 198 /** 199 * Get the "java-class" property definition. 200 * <p> 201 * Specifies the fully-qualified name of the Java class that 202 * provides the Password Modify Extended Operation Handler 203 * implementation. 204 * 205 * @return Returns the "java-class" property definition. 206 */ 207 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 208 return PD_JAVA_CLASS; 209 } 210 211 212 213 /** 214 * Managed object client implementation. 215 */ 216 private static class PasswordModifyExtendedOperationHandlerCfgClientImpl implements 217 PasswordModifyExtendedOperationHandlerCfgClient { 218 219 // Private implementation. 220 private ManagedObject<? extends PasswordModifyExtendedOperationHandlerCfgClient> impl; 221 222 223 224 // Private constructor. 225 private PasswordModifyExtendedOperationHandlerCfgClientImpl( 226 ManagedObject<? extends PasswordModifyExtendedOperationHandlerCfgClient> impl) { 227 this.impl = impl; 228 } 229 230 231 232 /** 233 * {@inheritDoc} 234 */ 235 public Boolean isEnabled() { 236 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 237 } 238 239 240 241 /** 242 * {@inheritDoc} 243 */ 244 public void setEnabled(boolean value) { 245 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 246 } 247 248 249 250 /** 251 * {@inheritDoc} 252 */ 253 public String getIdentityMapper() { 254 return impl.getPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition()); 255 } 256 257 258 259 /** 260 * {@inheritDoc} 261 */ 262 public void setIdentityMapper(String value) { 263 impl.setPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition(), value); 264 } 265 266 267 268 /** 269 * {@inheritDoc} 270 */ 271 public String getJavaClass() { 272 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 273 } 274 275 276 277 /** 278 * {@inheritDoc} 279 */ 280 public void setJavaClass(String value) { 281 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 282 } 283 284 285 286 /** 287 * {@inheritDoc} 288 */ 289 public ManagedObjectDefinition<? extends PasswordModifyExtendedOperationHandlerCfgClient, ? extends PasswordModifyExtendedOperationHandlerCfg> definition() { 290 return INSTANCE; 291 } 292 293 294 295 /** 296 * {@inheritDoc} 297 */ 298 public PropertyProvider properties() { 299 return impl; 300 } 301 302 303 304 /** 305 * {@inheritDoc} 306 */ 307 public void commit() throws ManagedObjectAlreadyExistsException, 308 MissingMandatoryPropertiesException, ConcurrentModificationException, 309 OperationRejectedException, AuthorizationException, 310 CommunicationException { 311 impl.commit(); 312 } 313 314 315 316 /** {@inheritDoc} */ 317 public String toString() { 318 return impl.toString(); 319 } 320 } 321 322 323 324 /** 325 * Managed object server implementation. 326 */ 327 private static class PasswordModifyExtendedOperationHandlerCfgServerImpl implements 328 PasswordModifyExtendedOperationHandlerCfg { 329 330 // Private implementation. 331 private ServerManagedObject<? extends PasswordModifyExtendedOperationHandlerCfg> impl; 332 333 // The value of the "enabled" property. 334 private final boolean pEnabled; 335 336 // The value of the "identity-mapper" property. 337 private final String pIdentityMapper; 338 339 // The value of the "java-class" property. 340 private final String pJavaClass; 341 342 343 344 // Private constructor. 345 private PasswordModifyExtendedOperationHandlerCfgServerImpl(ServerManagedObject<? extends PasswordModifyExtendedOperationHandlerCfg> impl) { 346 this.impl = impl; 347 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 348 this.pIdentityMapper = impl.getPropertyValue(INSTANCE.getIdentityMapperPropertyDefinition()); 349 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 350 } 351 352 353 354 /** 355 * {@inheritDoc} 356 */ 357 public void addPasswordModifyChangeListener( 358 ConfigurationChangeListener<PasswordModifyExtendedOperationHandlerCfg> listener) { 359 impl.registerChangeListener(listener); 360 } 361 362 363 364 /** 365 * {@inheritDoc} 366 */ 367 public void removePasswordModifyChangeListener( 368 ConfigurationChangeListener<PasswordModifyExtendedOperationHandlerCfg> listener) { 369 impl.deregisterChangeListener(listener); 370 } 371 /** 372 * {@inheritDoc} 373 */ 374 public void addChangeListener( 375 ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) { 376 impl.registerChangeListener(listener); 377 } 378 379 380 381 /** 382 * {@inheritDoc} 383 */ 384 public void removeChangeListener( 385 ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) { 386 impl.deregisterChangeListener(listener); 387 } 388 389 390 391 /** 392 * {@inheritDoc} 393 */ 394 public boolean isEnabled() { 395 return pEnabled; 396 } 397 398 399 400 /** 401 * {@inheritDoc} 402 */ 403 public String getIdentityMapper() { 404 return pIdentityMapper; 405 } 406 407 408 409 /** 410 * {@inheritDoc} 411 */ 412 public DN getIdentityMapperDN() { 413 String value = getIdentityMapper(); 414 if (value == null) return null; 415 return INSTANCE.getIdentityMapperPropertyDefinition().getChildDN(value); 416 } 417 418 419 420 /** 421 * {@inheritDoc} 422 */ 423 public String getJavaClass() { 424 return pJavaClass; 425 } 426 427 428 429 /** 430 * {@inheritDoc} 431 */ 432 public Class<? extends PasswordModifyExtendedOperationHandlerCfg> configurationClass() { 433 return PasswordModifyExtendedOperationHandlerCfg.class; 434 } 435 436 437 438 /** 439 * {@inheritDoc} 440 */ 441 public DN dn() { 442 return impl.getDN(); 443 } 444 445 446 447 /** {@inheritDoc} */ 448 public String toString() { 449 return impl.toString(); 450 } 451 } 452}