use of org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy in project syncope by apache.
the class JPAUserDAO method getPasswordPolicies.
private List<PasswordPolicy> getPasswordPolicies(final User user) {
List<PasswordPolicy> policies = new ArrayList<>();
PasswordPolicy policy;
// add resource policies
for (ExternalResource resource : findAllResources(user)) {
policy = resource.getPasswordPolicy();
if (policy != null) {
policies.add(policy);
}
}
// add realm policies
for (Realm realm : realmDAO().findAncestors(user.getRealm())) {
policy = realm.getPasswordPolicy();
if (policy != null) {
policies.add(policy);
}
}
return policies;
}
use of org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy in project syncope by apache.
the class PolicyTest method update.
@Test
public void update() {
PasswordPolicy policy = policyDAO.find("ce93fcda-dc3a-4369-a7b0-a6108c261c85");
assertNotNull(policy);
assertEquals(1, policy.getRules().size());
DefaultPasswordRuleConf ruleConf = new DefaultPasswordRuleConf();
ruleConf.setMaxLength(8);
ruleConf.setMinLength(6);
Implementation rule = entityFactory.newEntity(Implementation.class);
rule.setKey("PasswordRule" + UUID.randomUUID().toString());
rule.setEngine(ImplementationEngine.JAVA);
rule.setType(ImplementationType.PASSWORD_RULE);
rule.setBody(POJOHelper.serialize(ruleConf));
rule = implementationDAO.save(rule);
policy.add(rule);
policy = policyDAO.save(policy);
assertNotNull(policy);
rule = policy.getRules().get(1);
DefaultPasswordRuleConf actual = POJOHelper.deserialize(rule.getBody(), DefaultPasswordRuleConf.class);
assertEquals(actual.getMaxLength(), 8);
assertEquals(actual.getMinLength(), 6);
}
Aggregations