| | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.opends.messages.Message; |
| | |
| | | de.getMessageObject())); |
| | | } |
| | | |
| | | passwordPolicy = DirectoryServer.getPasswordPolicy(policyDN); |
| | | passwordPolicy = (PasswordPolicy) DirectoryServer |
| | | .getAuthenticationPolicy(policyDN); |
| | | if (passwordPolicy == null) |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | |
| | | } |
| | | |
| | | if ((!isInternalOperation()) |
| | | && (!passwordPolicy.allowMultiplePasswordValues()) |
| | | && (!passwordPolicy.isAllowMultiplePasswordValues()) |
| | | && (passwordAttr.size() > 1)) |
| | | { |
| | | // FIXME -- What if they're pre-encoded and might all be the |
| | |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | CopyOnWriteArrayList<PasswordStorageScheme<?>> defaultStorageSchemes = |
| | | passwordPolicy.getDefaultStorageSchemes(); |
| | | List<PasswordStorageScheme<?>> defaultStorageSchemes = |
| | | passwordPolicy.getDefaultPasswordStorageSchemes(); |
| | | AttributeBuilder builder = new AttributeBuilder(passwordAttr, true); |
| | | builder.setInitialCapacity(defaultStorageSchemes.size()); |
| | | for (AttributeValue v : passwordAttr) |
| | |
| | | ByteString value = v.getValue(); |
| | | |
| | | // See if the password is pre-encoded. |
| | | if (passwordPolicy.usesAuthPasswordSyntax()) |
| | | if (passwordPolicy.isAuthPasswordSyntax()) |
| | | { |
| | | if (AuthPasswordSyntax.isEncoded(value)) |
| | | { |
| | | if (isInternalOperation() || |
| | | passwordPolicy.allowPreEncodedPasswords()) |
| | | passwordPolicy.isAllowPreEncodedPasswords()) |
| | | { |
| | | builder.add(v); |
| | | continue; |
| | |
| | | if (UserPasswordSyntax.isEncoded(value)) |
| | | { |
| | | if (isInternalOperation() || |
| | | passwordPolicy.allowPreEncodedPasswords()) |
| | | passwordPolicy.isAllowPreEncodedPasswords()) |
| | | { |
| | | builder.add(v); |
| | | continue; |
| | |
| | | |
| | | // See if the password passes validation. We should only do this if |
| | | // validation should be performed for administrators. |
| | | if (! passwordPolicy.skipValidationForAdministrators()) |
| | | if (! passwordPolicy.isSkipValidationForAdministrators()) |
| | | { |
| | | // There are never any current passwords for an add operation. |
| | | HashSet<ByteString> currentPasswords = new HashSet<ByteString>(0); |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | for (PasswordValidator<?> validator : |
| | | passwordPolicy.getPasswordValidators().values()) |
| | | passwordPolicy.getPasswordValidators()) |
| | | { |
| | | if (! validator.passwordIsAcceptable(value, currentPasswords, this, |
| | | entry, invalidReason)) |
| | |
| | | |
| | | |
| | | // Encode the password. |
| | | if (passwordPolicy.usesAuthPasswordSyntax()) |
| | | if (passwordPolicy.isAuthPasswordSyntax()) |
| | | { |
| | | for (PasswordStorageScheme<?> s : defaultStorageSchemes) |
| | | { |
| | |
| | | |
| | | |
| | | // If we should force change on add, then set the appropriate flag. |
| | | if (passwordPolicy.forceChangeOnAdd()) |
| | | if (passwordPolicy.isForceChangeOnAdd()) |
| | | { |
| | | addPWPolicyControl(PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | |