List<String> values;
switch (policy.getType()) {
case PASSWORD:
case GLOBAL_PASSWORD:
final PasswordPolicySpec pspec = policy.getSpecification();
final PasswordPolicySpec passwordPolicy = new PasswordPolicySpec();
BeanUtils.copyProperties(pspec, passwordPolicy, new String[]{"schemasNotPermitted"});
for (String schema : pspec.getSchemasNotPermitted()) {
attribute = attributable.getAttribute(schema);
if (attribute != null) {
values = attribute.getValuesAsStrings();
if (values != null && !values.isEmpty()) {
passwordPolicy.getWordsNotPermitted().add(values.get(0));
}
}
}
// Password history verification and update
if (!(attributable instanceof SyncopeUser)) {
LOG.error("Cannot check previous passwords. attributable is not a user object: " + attributable.getClass().toString());
result = (T) passwordPolicy;
break;
}
SyncopeUser user = (SyncopeUser) attributable;
final String password = user.getPassword();
final List<String> passwordHistory = user.getPasswordHistory();
if (user.verifyPasswordHistory(user.getClearPassword(), pspec.getHistoryLength())) {
passwordPolicy.getWordsNotPermitted().add(user.getClearPassword());
} else {
if (pspec.getHistoryLength() > 0 && password != null) {
passwordHistory.add(password);
}
if (pspec.getHistoryLength() < passwordHistory.size()) {