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