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.forgerock.opendj.server.config.meta; 027 028 029 030import java.util.Collection; 031import java.util.SortedSet; 032import java.util.TreeSet; 033import org.forgerock.opendj.config.AdministratorAction; 034import org.forgerock.opendj.config.AggregationPropertyDefinition; 035import org.forgerock.opendj.config.AliasDefaultBehaviorProvider; 036import org.forgerock.opendj.config.BooleanPropertyDefinition; 037import org.forgerock.opendj.config.ClassPropertyDefinition; 038import org.forgerock.opendj.config.client.ConcurrentModificationException; 039import org.forgerock.opendj.config.client.ManagedObject; 040import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 041import org.forgerock.opendj.config.client.OperationRejectedException; 042import org.forgerock.opendj.config.conditions.Conditions; 043import org.forgerock.opendj.config.DefaultBehaviorProvider; 044import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 045import org.forgerock.opendj.config.EnumPropertyDefinition; 046import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 047import org.forgerock.opendj.config.ManagedObjectDefinition; 048import org.forgerock.opendj.config.PropertyOption; 049import org.forgerock.opendj.config.PropertyProvider; 050import org.forgerock.opendj.config.server.ConfigurationChangeListener; 051import org.forgerock.opendj.config.server.ServerManagedObject; 052import org.forgerock.opendj.config.Tag; 053import org.forgerock.opendj.ldap.DN; 054import org.forgerock.opendj.ldap.LdapException; 055import org.forgerock.opendj.server.config.client.PasswordPolicyImportPluginCfgClient; 056import org.forgerock.opendj.server.config.client.PasswordStorageSchemeCfgClient; 057import org.forgerock.opendj.server.config.meta.PluginCfgDefn.PluginType; 058import org.forgerock.opendj.server.config.server.PasswordPolicyImportPluginCfg; 059import org.forgerock.opendj.server.config.server.PasswordStorageSchemeCfg; 060import org.forgerock.opendj.server.config.server.PluginCfg; 061 062 063 064/** 065 * An interface for querying the Password Policy Import Plugin managed 066 * object definition meta information. 067 * <p> 068 * The Password Policy Import Plugin ensures that clear-text passwords 069 * contained in LDIF entries are properly encoded before they are 070 * stored in the appropriate directory server backend. 071 */ 072public final class PasswordPolicyImportPluginCfgDefn extends ManagedObjectDefinition<PasswordPolicyImportPluginCfgClient, PasswordPolicyImportPluginCfg> { 073 074 /** The singleton configuration definition instance. */ 075 private static final PasswordPolicyImportPluginCfgDefn INSTANCE = new PasswordPolicyImportPluginCfgDefn(); 076 077 078 079 /** The "default-auth-password-storage-scheme" property definition. */ 080 private static final AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME; 081 082 083 084 /** The "default-user-password-storage-scheme" property definition. */ 085 private static final AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME; 086 087 088 089 /** The "invoke-for-internal-operations" property definition. */ 090 private static final BooleanPropertyDefinition PD_INVOKE_FOR_INTERNAL_OPERATIONS; 091 092 093 094 /** The "java-class" property definition. */ 095 private static final ClassPropertyDefinition PD_JAVA_CLASS; 096 097 098 099 /** The "plugin-type" property definition. */ 100 private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE; 101 102 103 104 /** Build the "default-auth-password-storage-scheme" property definition. */ 105 static { 106 AggregationPropertyDefinition.Builder<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "default-auth-password-storage-scheme"); 107 builder.setOption(PropertyOption.MULTI_VALUED); 108 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "default-auth-password-storage-scheme")); 109 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "default-auth-password-storage-scheme")); 110 builder.setParentPath("/"); 111 builder.setRelationDefinition("password-storage-scheme"); 112 builder.setTargetNeedsEnablingCondition(Conditions.contains("enabled", "true")); 113 builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true")); 114 PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME = builder.getInstance(); 115 INSTANCE.registerPropertyDefinition(PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME); 116 INSTANCE.registerConstraint(PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME.getSourceConstraint()); 117 } 118 119 120 121 /** Build the "default-user-password-storage-scheme" property definition. */ 122 static { 123 AggregationPropertyDefinition.Builder<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> builder = AggregationPropertyDefinition.createBuilder(INSTANCE, "default-user-password-storage-scheme"); 124 builder.setOption(PropertyOption.MULTI_VALUED); 125 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "default-user-password-storage-scheme")); 126 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<String>(INSTANCE, "default-user-password-storage-scheme")); 127 builder.setParentPath("/"); 128 builder.setRelationDefinition("password-storage-scheme"); 129 builder.setTargetNeedsEnablingCondition(Conditions.contains("enabled", "true")); 130 builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true")); 131 PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME = builder.getInstance(); 132 INSTANCE.registerPropertyDefinition(PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME); 133 INSTANCE.registerConstraint(PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME.getSourceConstraint()); 134 } 135 136 137 138 /** Build the "invoke-for-internal-operations" property definition. */ 139 static { 140 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "invoke-for-internal-operations"); 141 builder.setOption(PropertyOption.ADVANCED); 142 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "invoke-for-internal-operations")); 143 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 144 builder.setDefaultBehaviorProvider(provider); 145 PD_INVOKE_FOR_INTERNAL_OPERATIONS = builder.getInstance(); 146 INSTANCE.registerPropertyDefinition(PD_INVOKE_FOR_INTERNAL_OPERATIONS); 147 } 148 149 150 151 /** Build the "java-class" property definition. */ 152 static { 153 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 154 builder.setOption(PropertyOption.MANDATORY); 155 builder.setOption(PropertyOption.ADVANCED); 156 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 157 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.PasswordPolicyImportPlugin"); 158 builder.setDefaultBehaviorProvider(provider); 159 builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin"); 160 PD_JAVA_CLASS = builder.getInstance(); 161 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 162 } 163 164 165 166 /** Build the "plugin-type" property definition. */ 167 static { 168 EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type"); 169 builder.setOption(PropertyOption.MULTI_VALUED); 170 builder.setOption(PropertyOption.MANDATORY); 171 builder.setOption(PropertyOption.ADVANCED); 172 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type")); 173 DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("ldifimport"); 174 builder.setDefaultBehaviorProvider(provider); 175 builder.setEnumClass(PluginType.class); 176 PD_PLUGIN_TYPE = builder.getInstance(); 177 INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE); 178 } 179 180 181 182 // Register the tags associated with this managed object definition. 183 static { 184 INSTANCE.registerTag(Tag.valueOf("core-server")); 185 } 186 187 188 189 /** 190 * Get the Password Policy Import Plugin configuration definition 191 * singleton. 192 * 193 * @return Returns the Password Policy Import Plugin configuration 194 * definition singleton. 195 */ 196 public static PasswordPolicyImportPluginCfgDefn getInstance() { 197 return INSTANCE; 198 } 199 200 201 202 /** 203 * Private constructor. 204 */ 205 private PasswordPolicyImportPluginCfgDefn() { 206 super("password-policy-import-plugin", PluginCfgDefn.getInstance()); 207 } 208 209 210 211 /** {@inheritDoc} */ 212 public PasswordPolicyImportPluginCfgClient createClientConfiguration( 213 ManagedObject<? extends PasswordPolicyImportPluginCfgClient> impl) { 214 return new PasswordPolicyImportPluginCfgClientImpl(impl); 215 } 216 217 218 219 /** {@inheritDoc} */ 220 public PasswordPolicyImportPluginCfg createServerConfiguration( 221 ServerManagedObject<? extends PasswordPolicyImportPluginCfg> impl) { 222 return new PasswordPolicyImportPluginCfgServerImpl(impl); 223 } 224 225 226 227 /** {@inheritDoc} */ 228 public Class<PasswordPolicyImportPluginCfg> getServerConfigurationClass() { 229 return PasswordPolicyImportPluginCfg.class; 230 } 231 232 233 234 /** 235 * Get the "default-auth-password-storage-scheme" property definition. 236 * <p> 237 * Specifies the names of password storage schemes that to be used 238 * for encoding passwords contained in attributes with the auth 239 * password syntax for entries that do not include the 240 * ds-pwp-password-policy-dn attribute specifying which password 241 * policy should be used to govern them. 242 * 243 * @return Returns the "default-auth-password-storage-scheme" property definition. 244 */ 245 public AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> getDefaultAuthPasswordStorageSchemePropertyDefinition() { 246 return PD_DEFAULT_AUTH_PASSWORD_STORAGE_SCHEME; 247 } 248 249 250 251 /** 252 * Get the "default-user-password-storage-scheme" property definition. 253 * <p> 254 * Specifies the names of the password storage schemes to be used 255 * for encoding passwords contained in attributes with the user 256 * password syntax for entries that do not include the 257 * ds-pwp-password-policy-dn attribute specifying which password 258 * policy is to be used to govern them. 259 * 260 * @return Returns the "default-user-password-storage-scheme" property definition. 261 */ 262 public AggregationPropertyDefinition<PasswordStorageSchemeCfgClient, PasswordStorageSchemeCfg> getDefaultUserPasswordStorageSchemePropertyDefinition() { 263 return PD_DEFAULT_USER_PASSWORD_STORAGE_SCHEME; 264 } 265 266 267 268 /** 269 * Get the "enabled" property definition. 270 * <p> 271 * Indicates whether the plug-in is enabled for use. 272 * 273 * @return Returns the "enabled" property definition. 274 */ 275 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 276 return PluginCfgDefn.getInstance().getEnabledPropertyDefinition(); 277 } 278 279 280 281 /** 282 * Get the "invoke-for-internal-operations" property definition. 283 * <p> 284 * Indicates whether the plug-in should be invoked for internal 285 * operations. 286 * <p> 287 * Any plug-in that can be invoked for internal operations must 288 * ensure that it does not create any new internal operatons that can 289 * cause the same plug-in to be re-invoked. 290 * 291 * @return Returns the "invoke-for-internal-operations" property definition. 292 */ 293 public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() { 294 return PD_INVOKE_FOR_INTERNAL_OPERATIONS; 295 } 296 297 298 299 /** 300 * Get the "java-class" property definition. 301 * <p> 302 * Specifies the fully-qualified name of the Java class that 303 * provides the plug-in implementation. 304 * 305 * @return Returns the "java-class" property definition. 306 */ 307 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 308 return PD_JAVA_CLASS; 309 } 310 311 312 313 /** 314 * Get the "plugin-type" property definition. 315 * <p> 316 * Specifies the set of plug-in types for the plug-in, which 317 * specifies the times at which the plug-in is invoked. 318 * 319 * @return Returns the "plugin-type" property definition. 320 */ 321 public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() { 322 return PD_PLUGIN_TYPE; 323 } 324 325 326 327 /** 328 * Managed object client implementation. 329 */ 330 private static class PasswordPolicyImportPluginCfgClientImpl implements 331 PasswordPolicyImportPluginCfgClient { 332 333 /** Private implementation. */ 334 private ManagedObject<? extends PasswordPolicyImportPluginCfgClient> impl; 335 336 337 338 /** Private constructor. */ 339 private PasswordPolicyImportPluginCfgClientImpl( 340 ManagedObject<? extends PasswordPolicyImportPluginCfgClient> impl) { 341 this.impl = impl; 342 } 343 344 345 346 /** {@inheritDoc} */ 347 public SortedSet<String> getDefaultAuthPasswordStorageScheme() { 348 return impl.getPropertyValues(INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition()); 349 } 350 351 352 353 /** {@inheritDoc} */ 354 public void setDefaultAuthPasswordStorageScheme(Collection<String> values) { 355 impl.setPropertyValues(INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition(), values); 356 } 357 358 359 360 /** {@inheritDoc} */ 361 public SortedSet<String> getDefaultUserPasswordStorageScheme() { 362 return impl.getPropertyValues(INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition()); 363 } 364 365 366 367 /** {@inheritDoc} */ 368 public void setDefaultUserPasswordStorageScheme(Collection<String> values) { 369 impl.setPropertyValues(INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition(), values); 370 } 371 372 373 374 /** {@inheritDoc} */ 375 public Boolean isEnabled() { 376 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 377 } 378 379 380 381 /** {@inheritDoc} */ 382 public void setEnabled(boolean value) { 383 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 384 } 385 386 387 388 /** {@inheritDoc} */ 389 public boolean isInvokeForInternalOperations() { 390 return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 391 } 392 393 394 395 /** {@inheritDoc} */ 396 public void setInvokeForInternalOperations(Boolean value) { 397 impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value); 398 } 399 400 401 402 /** {@inheritDoc} */ 403 public String getJavaClass() { 404 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 405 } 406 407 408 409 /** {@inheritDoc} */ 410 public void setJavaClass(String value) { 411 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 412 } 413 414 415 416 /** {@inheritDoc} */ 417 public SortedSet<PluginType> getPluginType() { 418 return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 419 } 420 421 422 423 /** {@inheritDoc} */ 424 public void setPluginType(Collection<PluginType> values) { 425 impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values); 426 } 427 428 429 430 /** {@inheritDoc} */ 431 public ManagedObjectDefinition<? extends PasswordPolicyImportPluginCfgClient, ? extends PasswordPolicyImportPluginCfg> definition() { 432 return INSTANCE; 433 } 434 435 436 437 /** {@inheritDoc} */ 438 public PropertyProvider properties() { 439 return impl; 440 } 441 442 443 444 /** {@inheritDoc} */ 445 public void commit() throws ManagedObjectAlreadyExistsException, 446 MissingMandatoryPropertiesException, ConcurrentModificationException, 447 OperationRejectedException, LdapException { 448 impl.commit(); 449 } 450 451 452 453 /** {@inheritDoc} */ 454 public String toString() { 455 return impl.toString(); 456 } 457 } 458 459 460 461 /** 462 * Managed object server implementation. 463 */ 464 private static class PasswordPolicyImportPluginCfgServerImpl implements 465 PasswordPolicyImportPluginCfg { 466 467 /** Private implementation. */ 468 private ServerManagedObject<? extends PasswordPolicyImportPluginCfg> impl; 469 470 /** The value of the "default-auth-password-storage-scheme" property. */ 471 private final SortedSet<String> pDefaultAuthPasswordStorageScheme; 472 473 /** The value of the "default-user-password-storage-scheme" property. */ 474 private final SortedSet<String> pDefaultUserPasswordStorageScheme; 475 476 /** The value of the "enabled" property. */ 477 private final boolean pEnabled; 478 479 /** The value of the "invoke-for-internal-operations" property. */ 480 private final boolean pInvokeForInternalOperations; 481 482 /** The value of the "java-class" property. */ 483 private final String pJavaClass; 484 485 /** The value of the "plugin-type" property. */ 486 private final SortedSet<PluginType> pPluginType; 487 488 489 490 /** Private constructor. */ 491 private PasswordPolicyImportPluginCfgServerImpl(ServerManagedObject<? extends PasswordPolicyImportPluginCfg> impl) { 492 this.impl = impl; 493 this.pDefaultAuthPasswordStorageScheme = impl.getPropertyValues(INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition()); 494 this.pDefaultUserPasswordStorageScheme = impl.getPropertyValues(INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition()); 495 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 496 this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 497 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 498 this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 499 } 500 501 502 503 /** {@inheritDoc} */ 504 public void addPasswordPolicyImportChangeListener( 505 ConfigurationChangeListener<PasswordPolicyImportPluginCfg> listener) { 506 impl.registerChangeListener(listener); 507 } 508 509 510 511 /** {@inheritDoc} */ 512 public void removePasswordPolicyImportChangeListener( 513 ConfigurationChangeListener<PasswordPolicyImportPluginCfg> listener) { 514 impl.deregisterChangeListener(listener); 515 } 516 /** {@inheritDoc} */ 517 public void addChangeListener( 518 ConfigurationChangeListener<PluginCfg> listener) { 519 impl.registerChangeListener(listener); 520 } 521 522 523 524 /** {@inheritDoc} */ 525 public void removeChangeListener( 526 ConfigurationChangeListener<PluginCfg> listener) { 527 impl.deregisterChangeListener(listener); 528 } 529 530 531 532 /** {@inheritDoc} */ 533 public SortedSet<String> getDefaultAuthPasswordStorageScheme() { 534 return pDefaultAuthPasswordStorageScheme; 535 } 536 537 538 539 /** 540 * {@inheritDoc} 541 */ 542 public SortedSet<DN> getDefaultAuthPasswordStorageSchemeDNs() { 543 SortedSet<String> values = getDefaultAuthPasswordStorageScheme(); 544 SortedSet<DN> dnValues = new TreeSet<DN>(); 545 for (String value : values) { 546 DN dn = INSTANCE.getDefaultAuthPasswordStorageSchemePropertyDefinition().getChildDN(value); 547 dnValues.add(dn); 548 } 549 return dnValues; 550 } 551 552 553 554 /** {@inheritDoc} */ 555 public SortedSet<String> getDefaultUserPasswordStorageScheme() { 556 return pDefaultUserPasswordStorageScheme; 557 } 558 559 560 561 /** 562 * {@inheritDoc} 563 */ 564 public SortedSet<DN> getDefaultUserPasswordStorageSchemeDNs() { 565 SortedSet<String> values = getDefaultUserPasswordStorageScheme(); 566 SortedSet<DN> dnValues = new TreeSet<DN>(); 567 for (String value : values) { 568 DN dn = INSTANCE.getDefaultUserPasswordStorageSchemePropertyDefinition().getChildDN(value); 569 dnValues.add(dn); 570 } 571 return dnValues; 572 } 573 574 575 576 /** {@inheritDoc} */ 577 public boolean isEnabled() { 578 return pEnabled; 579 } 580 581 582 583 /** {@inheritDoc} */ 584 public boolean isInvokeForInternalOperations() { 585 return pInvokeForInternalOperations; 586 } 587 588 589 590 /** {@inheritDoc} */ 591 public String getJavaClass() { 592 return pJavaClass; 593 } 594 595 596 597 /** {@inheritDoc} */ 598 public SortedSet<PluginType> getPluginType() { 599 return pPluginType; 600 } 601 602 603 604 /** {@inheritDoc} */ 605 public Class<? extends PasswordPolicyImportPluginCfg> configurationClass() { 606 return PasswordPolicyImportPluginCfg.class; 607 } 608 609 610 611 /** {@inheritDoc} */ 612 public DN dn() { 613 return impl.getDN(); 614 } 615 616 617 618 /** {@inheritDoc} */ 619 public String toString() { 620 return impl.toString(); 621 } 622 } 623}