Set<ByteString> currentPasswords,
Operation operation, Entry userEntry,
MessageBuilder invalidReason)
{
// Get a handle to the current configuration.
AttributeValuePasswordValidatorCfg config = currentConfig;
// Get the string representation (both forward and reversed) for the
// password.
String password = newPassword.toString();
String reversed = new StringBuilder(password).reverse().toString();
// If we should check a specific set of attributes, then do that now.
// Otherwise, check all user attributes.
Set<AttributeType> matchAttributes = config.getMatchAttribute();
if ((matchAttributes == null) || matchAttributes.isEmpty())
{
matchAttributes = userEntry.getUserAttributes().keySet();
}
for (AttributeType t : matchAttributes)
{
List<Attribute> attrList = userEntry.getAttribute(t);
if ((attrList == null) || attrList.isEmpty())
{
continue;
}
AttributeValue vf = AttributeValues.create(t, password);
AttributeValue vr = AttributeValues.create(t, reversed);
for (Attribute a : attrList)
{
if (a.contains(vf) ||
(config.isTestReversedPassword() && a.contains(vr)))
{
invalidReason.append(ERR_ATTRVALUE_VALIDATOR_PASSWORD_IN_ENTRY.get());
return false;
}