throws ConfigException, InitializationException
{
// Get the root configuration object.
ServerManagementContext managementContext =
ServerManagementContext.getInstance();
RootCfg rootConfiguration =
managementContext.getRootConfiguration();
// Register as an add and delete listener with the root configuration so we
// can be notified if any password policy entries are added or removed.
rootConfiguration.addPasswordPolicyAddListener(this);
rootConfiguration.addPasswordPolicyDeleteListener(this);
// First, get the configuration base entry.
String[] passwordPoliciesName = rootConfiguration.listPasswordPolicies() ;
// See if the base entry has any children. If not, then that means that
// there are no policies defined, so that's a problem.
if (passwordPoliciesName.length == 0)
{
Message message = ERR_CONFIG_PWPOLICY_NO_POLICIES.get();
throw new ConfigException(message);
}
// Get the DN of the default password policy from the core configuration.
if( null == DirectoryServer.getDefaultPasswordPolicyDN())
{
Message message = ERR_CONFIG_PWPOLICY_NO_DEFAULT_POLICY.get();
throw new ConfigException(message);
}
// Iterate through the child entries and process them as password policy
// configuration entries.
for (String passwordPolicyName : passwordPoliciesName)
{
PasswordPolicyCfg passwordPolicyConfiguration =
rootConfiguration.getPasswordPolicy(passwordPolicyName);
try
{
PasswordPolicy policy = new PasswordPolicy(passwordPolicyConfiguration);
PasswordPolicyConfig config = new PasswordPolicyConfig(policy);