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.BooleanPropertyDefinition;
033 import org.opends.server.admin.ClassPropertyDefinition;
034 import org.opends.server.admin.client.AuthorizationException;
035 import org.opends.server.admin.client.CommunicationException;
036 import org.opends.server.admin.client.ConcurrentModificationException;
037 import org.opends.server.admin.client.ManagedObject;
038 import org.opends.server.admin.client.MissingMandatoryPropertiesException;
039 import org.opends.server.admin.client.OperationRejectedException;
040 import org.opends.server.admin.DefaultBehaviorProvider;
041 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
042 import org.opends.server.admin.IntegerPropertyDefinition;
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.RepeatedCharactersPasswordValidatorCfgClient;
050 import org.opends.server.admin.std.server.PasswordValidatorCfg;
051 import org.opends.server.admin.std.server.RepeatedCharactersPasswordValidatorCfg;
052 import org.opends.server.admin.Tag;
053 import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
054 import org.opends.server.types.DN;
055
056
057
058 /**
059 * An interface for querying the Repeated Characters Password
060 * Validator managed object definition meta information.
061 * <p>
062 * The Repeated Characters Password Validator is used to determine
063 * whether a proposed password is acceptable based on the number of
064 * times any character appears consecutively in a password value.
065 */
066 public final class RepeatedCharactersPasswordValidatorCfgDefn extends ManagedObjectDefinition<RepeatedCharactersPasswordValidatorCfgClient, RepeatedCharactersPasswordValidatorCfg> {
067
068 // The singleton configuration definition instance.
069 private static final RepeatedCharactersPasswordValidatorCfgDefn INSTANCE = new RepeatedCharactersPasswordValidatorCfgDefn();
070
071
072
073 // The "case-sensitive-validation" property definition.
074 private static final BooleanPropertyDefinition PD_CASE_SENSITIVE_VALIDATION;
075
076
077
078 // The "java-class" property definition.
079 private static final ClassPropertyDefinition PD_JAVA_CLASS;
080
081
082
083 // The "max-consecutive-length" property definition.
084 private static final IntegerPropertyDefinition PD_MAX_CONSECUTIVE_LENGTH;
085
086
087
088 // Build the "case-sensitive-validation" property definition.
089 static {
090 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "case-sensitive-validation");
091 builder.setOption(PropertyOption.MANDATORY);
092 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "case-sensitive-validation"));
093 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>());
094 PD_CASE_SENSITIVE_VALIDATION = builder.getInstance();
095 INSTANCE.registerPropertyDefinition(PD_CASE_SENSITIVE_VALIDATION);
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.RepeatedCharactersPasswordValidator");
107 builder.setDefaultBehaviorProvider(provider);
108 builder.addInstanceOf("org.opends.server.api.PasswordValidator");
109 PD_JAVA_CLASS = builder.getInstance();
110 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
111 }
112
113
114
115 // Build the "max-consecutive-length" property definition.
116 static {
117 IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition.createBuilder(INSTANCE, "max-consecutive-length");
118 builder.setOption(PropertyOption.MANDATORY);
119 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "max-consecutive-length"));
120 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Integer>());
121 builder.setLowerLimit(0);
122 PD_MAX_CONSECUTIVE_LENGTH = builder.getInstance();
123 INSTANCE.registerPropertyDefinition(PD_MAX_CONSECUTIVE_LENGTH);
124 }
125
126
127
128 // Register the tags associated with this managed object definition.
129 static {
130 INSTANCE.registerTag(Tag.valueOf("user-management"));
131 }
132
133
134
135 /**
136 * Get the Repeated Characters Password Validator configuration
137 * definition singleton.
138 *
139 * @return Returns the Repeated Characters Password Validator
140 * configuration definition singleton.
141 */
142 public static RepeatedCharactersPasswordValidatorCfgDefn getInstance() {
143 return INSTANCE;
144 }
145
146
147
148 /**
149 * Private constructor.
150 */
151 private RepeatedCharactersPasswordValidatorCfgDefn() {
152 super("repeated-characters-password-validator", PasswordValidatorCfgDefn.getInstance());
153 }
154
155
156
157 /**
158 * {@inheritDoc}
159 */
160 public RepeatedCharactersPasswordValidatorCfgClient createClientConfiguration(
161 ManagedObject<? extends RepeatedCharactersPasswordValidatorCfgClient> impl) {
162 return new RepeatedCharactersPasswordValidatorCfgClientImpl(impl);
163 }
164
165
166
167 /**
168 * {@inheritDoc}
169 */
170 public RepeatedCharactersPasswordValidatorCfg createServerConfiguration(
171 ServerManagedObject<? extends RepeatedCharactersPasswordValidatorCfg> impl) {
172 return new RepeatedCharactersPasswordValidatorCfgServerImpl(impl);
173 }
174
175
176
177 /**
178 * {@inheritDoc}
179 */
180 public Class<RepeatedCharactersPasswordValidatorCfg> getServerConfigurationClass() {
181 return RepeatedCharactersPasswordValidatorCfg.class;
182 }
183
184
185
186 /**
187 * Get the "case-sensitive-validation" property definition.
188 * <p>
189 * Indicates whether this password validator should treat password
190 * characters in a case-sensitive manner.
191 * <p>
192 * If the value of this property is false, the validator ignores any
193 * differences in capitalization when looking for consecutive
194 * characters in the password. If the value is true, the validator
195 * considers a character to be repeating only if all consecutive
196 * occurrences use the same capitalization.
197 *
198 * @return Returns the "case-sensitive-validation" property definition.
199 */
200 public BooleanPropertyDefinition getCaseSensitiveValidationPropertyDefinition() {
201 return PD_CASE_SENSITIVE_VALIDATION;
202 }
203
204
205
206 /**
207 * Get the "enabled" property definition.
208 * <p>
209 * Indicates whether the password validator is enabled for use.
210 *
211 * @return Returns the "enabled" property definition.
212 */
213 public BooleanPropertyDefinition getEnabledPropertyDefinition() {
214 return PasswordValidatorCfgDefn.getInstance().getEnabledPropertyDefinition();
215 }
216
217
218
219 /**
220 * Get the "java-class" property definition.
221 * <p>
222 * Specifies the fully-qualified name of the Java class that
223 * provides the password validator implementation.
224 *
225 * @return Returns the "java-class" property definition.
226 */
227 public ClassPropertyDefinition getJavaClassPropertyDefinition() {
228 return PD_JAVA_CLASS;
229 }
230
231
232
233 /**
234 * Get the "max-consecutive-length" property definition.
235 * <p>
236 * Specifies the maximum number of times that any character can
237 * appear consecutively in a password value.
238 * <p>
239 * A value of zero indicates that no maximum limit is enforced.
240 *
241 * @return Returns the "max-consecutive-length" property definition.
242 */
243 public IntegerPropertyDefinition getMaxConsecutiveLengthPropertyDefinition() {
244 return PD_MAX_CONSECUTIVE_LENGTH;
245 }
246
247
248
249 /**
250 * Managed object client implementation.
251 */
252 private static class RepeatedCharactersPasswordValidatorCfgClientImpl implements
253 RepeatedCharactersPasswordValidatorCfgClient {
254
255 // Private implementation.
256 private ManagedObject<? extends RepeatedCharactersPasswordValidatorCfgClient> impl;
257
258
259
260 // Private constructor.
261 private RepeatedCharactersPasswordValidatorCfgClientImpl(
262 ManagedObject<? extends RepeatedCharactersPasswordValidatorCfgClient> impl) {
263 this.impl = impl;
264 }
265
266
267
268 /**
269 * {@inheritDoc}
270 */
271 public Boolean isCaseSensitiveValidation() {
272 return impl.getPropertyValue(INSTANCE.getCaseSensitiveValidationPropertyDefinition());
273 }
274
275
276
277 /**
278 * {@inheritDoc}
279 */
280 public void setCaseSensitiveValidation(boolean value) {
281 impl.setPropertyValue(INSTANCE.getCaseSensitiveValidationPropertyDefinition(), value);
282 }
283
284
285
286 /**
287 * {@inheritDoc}
288 */
289 public Boolean isEnabled() {
290 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
291 }
292
293
294
295 /**
296 * {@inheritDoc}
297 */
298 public void setEnabled(boolean value) {
299 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
300 }
301
302
303
304 /**
305 * {@inheritDoc}
306 */
307 public String getJavaClass() {
308 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
309 }
310
311
312
313 /**
314 * {@inheritDoc}
315 */
316 public void setJavaClass(String value) {
317 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
318 }
319
320
321
322 /**
323 * {@inheritDoc}
324 */
325 public Integer getMaxConsecutiveLength() {
326 return impl.getPropertyValue(INSTANCE.getMaxConsecutiveLengthPropertyDefinition());
327 }
328
329
330
331 /**
332 * {@inheritDoc}
333 */
334 public void setMaxConsecutiveLength(int value) {
335 impl.setPropertyValue(INSTANCE.getMaxConsecutiveLengthPropertyDefinition(), value);
336 }
337
338
339
340 /**
341 * {@inheritDoc}
342 */
343 public ManagedObjectDefinition<? extends RepeatedCharactersPasswordValidatorCfgClient, ? extends RepeatedCharactersPasswordValidatorCfg> definition() {
344 return INSTANCE;
345 }
346
347
348
349 /**
350 * {@inheritDoc}
351 */
352 public PropertyProvider properties() {
353 return impl;
354 }
355
356
357
358 /**
359 * {@inheritDoc}
360 */
361 public void commit() throws ManagedObjectAlreadyExistsException,
362 MissingMandatoryPropertiesException, ConcurrentModificationException,
363 OperationRejectedException, AuthorizationException,
364 CommunicationException {
365 impl.commit();
366 }
367
368 }
369
370
371
372 /**
373 * Managed object server implementation.
374 */
375 private static class RepeatedCharactersPasswordValidatorCfgServerImpl implements
376 RepeatedCharactersPasswordValidatorCfg {
377
378 // Private implementation.
379 private ServerManagedObject<? extends RepeatedCharactersPasswordValidatorCfg> impl;
380
381 // The value of the "case-sensitive-validation" property.
382 private final boolean pCaseSensitiveValidation;
383
384 // The value of the "enabled" property.
385 private final boolean pEnabled;
386
387 // The value of the "java-class" property.
388 private final String pJavaClass;
389
390 // The value of the "max-consecutive-length" property.
391 private final int pMaxConsecutiveLength;
392
393
394
395 // Private constructor.
396 private RepeatedCharactersPasswordValidatorCfgServerImpl(ServerManagedObject<? extends RepeatedCharactersPasswordValidatorCfg> impl) {
397 this.impl = impl;
398 this.pCaseSensitiveValidation = impl.getPropertyValue(INSTANCE.getCaseSensitiveValidationPropertyDefinition());
399 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
400 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
401 this.pMaxConsecutiveLength = impl.getPropertyValue(INSTANCE.getMaxConsecutiveLengthPropertyDefinition());
402 }
403
404
405
406 /**
407 * {@inheritDoc}
408 */
409 public void addRepeatedCharactersChangeListener(
410 ConfigurationChangeListener<RepeatedCharactersPasswordValidatorCfg> listener) {
411 impl.registerChangeListener(listener);
412 }
413
414
415
416 /**
417 * {@inheritDoc}
418 */
419 public void removeRepeatedCharactersChangeListener(
420 ConfigurationChangeListener<RepeatedCharactersPasswordValidatorCfg> listener) {
421 impl.deregisterChangeListener(listener);
422 }
423 /**
424 * {@inheritDoc}
425 */
426 public void addChangeListener(
427 ConfigurationChangeListener<PasswordValidatorCfg> listener) {
428 impl.registerChangeListener(listener);
429 }
430
431
432
433 /**
434 * {@inheritDoc}
435 */
436 public void removeChangeListener(
437 ConfigurationChangeListener<PasswordValidatorCfg> listener) {
438 impl.deregisterChangeListener(listener);
439 }
440
441
442
443 /**
444 * {@inheritDoc}
445 */
446 public boolean isCaseSensitiveValidation() {
447 return pCaseSensitiveValidation;
448 }
449
450
451
452 /**
453 * {@inheritDoc}
454 */
455 public boolean isEnabled() {
456 return pEnabled;
457 }
458
459
460
461 /**
462 * {@inheritDoc}
463 */
464 public String getJavaClass() {
465 return pJavaClass;
466 }
467
468
469
470 /**
471 * {@inheritDoc}
472 */
473 public int getMaxConsecutiveLength() {
474 return pMaxConsecutiveLength;
475 }
476
477
478
479 /**
480 * {@inheritDoc}
481 */
482 public Class<? extends RepeatedCharactersPasswordValidatorCfg> configurationClass() {
483 return RepeatedCharactersPasswordValidatorCfg.class;
484 }
485
486
487
488 /**
489 * {@inheritDoc}
490 */
491 public DN dn() {
492 return impl.getDN();
493 }
494
495 }
496 }