// 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);
DirectoryServer.registerPasswordPolicy(
passwordPolicyConfiguration.dn(), config);
passwordPolicyConfiguration.addChangeListener(config);
}
catch (ConfigException ce)
{
Message message = ERR_CONFIG_PWPOLICY_INVALID_POLICY_CONFIG.get(
String.valueOf(passwordPolicyConfiguration.dn()), ce.getMessage());
throw new ConfigException(message, ce);
}
catch (InitializationException ie)
{
Message message = ERR_CONFIG_PWPOLICY_INVALID_POLICY_CONFIG.get(
String.valueOf(passwordPolicyConfiguration.dn()), ie.getMessage());
throw new InitializationException(message, ie);
}
catch (Exception e)
{
Message message = ERR_CONFIG_PWPOLICY_INVALID_POLICY_CONFIG.
get(String.valueOf(passwordPolicyConfiguration.dn()),
stackTraceToSingleLineString(e));
throw new InitializationException(message, e);
}
}
// If the entry specified by the default password policy DN has not been
// registered, then fail.
if (null == DirectoryServer.getDefaultPasswordPolicy())
{
DN defaultPolicyDN = DirectoryServer.getDefaultPasswordPolicyDN();
Message message = ERR_CONFIG_PWPOLICY_MISSING_DEFAULT_POLICY.get(
String.valueOf(defaultPolicyDN));
throw new ConfigException(message);
}
// Process and register any password policy subentries.
List<SubEntry> pwpSubEntries =
DirectoryServer.getSubentryManager().getSubentries();