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.PasswordPolicyStateExtendedOperationHandlerCfgClient; 039import org.forgerock.opendj.server.config.server.ExtendedOperationHandlerCfg; 040import org.forgerock.opendj.server.config.server.PasswordPolicyStateExtendedOperationHandlerCfg; 041 042 043 044/** 045 * An interface for querying the Password Policy State Extended 046 * Operation Handler managed object definition meta information. 047 * <p> 048 * The Password Policy State Extended Operation Handler provides the 049 * ability for administrators to request and optionally alter password 050 * policy state information for a specified user. 051 */ 052public final class PasswordPolicyStateExtendedOperationHandlerCfgDefn extends ManagedObjectDefinition<PasswordPolicyStateExtendedOperationHandlerCfgClient, PasswordPolicyStateExtendedOperationHandlerCfg> { 053 054 /** The singleton configuration definition instance. */ 055 private static final PasswordPolicyStateExtendedOperationHandlerCfgDefn INSTANCE = new PasswordPolicyStateExtendedOperationHandlerCfgDefn(); 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.PasswordPolicyStateExtendedOperation"); 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 Password Policy State Extended Operation Handler 088 * configuration definition singleton. 089 * 090 * @return Returns the Password Policy State Extended Operation 091 * Handler configuration definition singleton. 092 */ 093 public static PasswordPolicyStateExtendedOperationHandlerCfgDefn getInstance() { 094 return INSTANCE; 095 } 096 097 098 099 /** 100 * Private constructor. 101 */ 102 private PasswordPolicyStateExtendedOperationHandlerCfgDefn() { 103 super("password-policy-state-extended-operation-handler", ExtendedOperationHandlerCfgDefn.getInstance()); 104 } 105 106 107 108 /** {@inheritDoc} */ 109 public PasswordPolicyStateExtendedOperationHandlerCfgClient createClientConfiguration( 110 ManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient> impl) { 111 return new PasswordPolicyStateExtendedOperationHandlerCfgClientImpl(impl); 112 } 113 114 115 116 /** {@inheritDoc} */ 117 public PasswordPolicyStateExtendedOperationHandlerCfg createServerConfiguration( 118 ServerManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfg> impl) { 119 return new PasswordPolicyStateExtendedOperationHandlerCfgServerImpl(impl); 120 } 121 122 123 124 /** {@inheritDoc} */ 125 public Class<PasswordPolicyStateExtendedOperationHandlerCfg> getServerConfigurationClass() { 126 return PasswordPolicyStateExtendedOperationHandlerCfg.class; 127 } 128 129 130 131 /** 132 * Get the "enabled" property definition. 133 * <p> 134 * Indicates whether the Password Policy State Extended Operation 135 * Handler is enabled (that is, whether the types of extended 136 * operations are 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 Password Policy State Extended Operation Handler 151 * implementation. 152 * 153 * @return Returns the "java-class" property definition. 154 */ 155 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 156 return PD_JAVA_CLASS; 157 } 158 159 160 161 /** 162 * Managed object client implementation. 163 */ 164 private static class PasswordPolicyStateExtendedOperationHandlerCfgClientImpl implements 165 PasswordPolicyStateExtendedOperationHandlerCfgClient { 166 167 /** Private implementation. */ 168 private ManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient> impl; 169 170 171 172 /** Private constructor. */ 173 private PasswordPolicyStateExtendedOperationHandlerCfgClientImpl( 174 ManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient> impl) { 175 this.impl = impl; 176 } 177 178 179 180 /** {@inheritDoc} */ 181 public Boolean isEnabled() { 182 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 183 } 184 185 186 187 /** {@inheritDoc} */ 188 public void setEnabled(boolean value) { 189 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 190 } 191 192 193 194 /** {@inheritDoc} */ 195 public String getJavaClass() { 196 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 197 } 198 199 200 201 /** {@inheritDoc} */ 202 public void setJavaClass(String value) { 203 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 204 } 205 206 207 208 /** {@inheritDoc} */ 209 public ManagedObjectDefinition<? extends PasswordPolicyStateExtendedOperationHandlerCfgClient, ? extends PasswordPolicyStateExtendedOperationHandlerCfg> definition() { 210 return INSTANCE; 211 } 212 213 214 215 /** {@inheritDoc} */ 216 public PropertyProvider properties() { 217 return impl; 218 } 219 220 221 222 /** {@inheritDoc} */ 223 public void commit() throws ManagedObjectAlreadyExistsException, 224 MissingMandatoryPropertiesException, ConcurrentModificationException, 225 OperationRejectedException, LdapException { 226 impl.commit(); 227 } 228 229 230 231 /** {@inheritDoc} */ 232 public String toString() { 233 return impl.toString(); 234 } 235 } 236 237 238 239 /** 240 * Managed object server implementation. 241 */ 242 private static class PasswordPolicyStateExtendedOperationHandlerCfgServerImpl implements 243 PasswordPolicyStateExtendedOperationHandlerCfg { 244 245 /** Private implementation. */ 246 private ServerManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfg> impl; 247 248 /** The value of the "enabled" property. */ 249 private final boolean pEnabled; 250 251 /** The value of the "java-class" property. */ 252 private final String pJavaClass; 253 254 255 256 /** Private constructor. */ 257 private PasswordPolicyStateExtendedOperationHandlerCfgServerImpl(ServerManagedObject<? extends PasswordPolicyStateExtendedOperationHandlerCfg> impl) { 258 this.impl = impl; 259 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 260 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 261 } 262 263 264 265 /** {@inheritDoc} */ 266 public void addPasswordPolicyStateChangeListener( 267 ConfigurationChangeListener<PasswordPolicyStateExtendedOperationHandlerCfg> listener) { 268 impl.registerChangeListener(listener); 269 } 270 271 272 273 /** {@inheritDoc} */ 274 public void removePasswordPolicyStateChangeListener( 275 ConfigurationChangeListener<PasswordPolicyStateExtendedOperationHandlerCfg> listener) { 276 impl.deregisterChangeListener(listener); 277 } 278 /** {@inheritDoc} */ 279 public void addChangeListener( 280 ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) { 281 impl.registerChangeListener(listener); 282 } 283 284 285 286 /** {@inheritDoc} */ 287 public void removeChangeListener( 288 ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) { 289 impl.deregisterChangeListener(listener); 290 } 291 292 293 294 /** {@inheritDoc} */ 295 public boolean isEnabled() { 296 return pEnabled; 297 } 298 299 300 301 /** {@inheritDoc} */ 302 public String getJavaClass() { 303 return pJavaClass; 304 } 305 306 307 308 /** {@inheritDoc} */ 309 public Class<? extends PasswordPolicyStateExtendedOperationHandlerCfg> configurationClass() { 310 return PasswordPolicyStateExtendedOperationHandlerCfg.class; 311 } 312 313 314 315 /** {@inheritDoc} */ 316 public DN dn() { 317 return impl.getDN(); 318 } 319 320 321 322 /** {@inheritDoc} */ 323 public String toString() { 324 return impl.toString(); 325 } 326 } 327}