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