Package org.apache.syncope.core.persistence.beans

Examples of org.apache.syncope.core.persistence.beans.PasswordPolicy


    public void saveSecondPasswordPolicy() {
        PasswordPolicySpec passwordPolicy = new PasswordPolicySpec();
        passwordPolicy.setMaxLength(8);
        passwordPolicy.setMinLength(6);

        PasswordPolicy policy = new PasswordPolicy(true);
        policy.setSpecification(passwordPolicy);
        policy.setDescription("global password policy");

        policyDAO.save(policy);
    }
View Full Code Here


    public String generate(final SyncopeUser user)
            throws InvalidPasswordPolicySpecException {

        List<PasswordPolicySpec> ppSpecs = new ArrayList<PasswordPolicySpec>();

        PasswordPolicy globalPP = policyDAO.getGlobalPasswordPolicy();
        if (globalPP != null && globalPP.getSpecification(PasswordPolicySpec.class) != null) {
            ppSpecs.add(globalPP.getSpecification(PasswordPolicySpec.class));
        }

        for (SyncopeRole role : user.getRoles()) {
            if (role.getPasswordPolicy() != null
                    && role.getPasswordPolicy().getSpecification(PasswordPolicySpec.class) != null) {
View Full Code Here

    private List<PasswordPolicy> getPasswordPolicies(final SyncopeUser user) {
        final List<PasswordPolicy> policies = new ArrayList<PasswordPolicy>();

        // Add global policy
        PasswordPolicy policy = policyDAO.getGlobalPasswordPolicy();
        if (policy != null) {
            policies.add(policy);
        }

        // add resource policies
View Full Code Here

        return policyTOs;
    }

    @PreAuthorize("hasRole('POLICY_READ')")
    public PasswordPolicyTO getGlobalPasswordPolicy() {
        PasswordPolicy policy = policyDAO.getGlobalPasswordPolicy();
        if (policy == null) {
            throw new NotFoundException("No password policy found");
        }

        return (PasswordPolicyTO) binder.getPolicyTO(policy);
View Full Code Here

        assertTrue(ownedRoles.contains(child1));
        assertFalse(ownedRoles.contains(child2));
    }

    public void createWithPasswordPolicy() {
        PasswordPolicy policy = (PasswordPolicy) policyDAO.find(4L);
        SyncopeRole role = new SyncopeRole();
        role.setName("roleWithPasswordPolicy");
        role.setPasswordPolicy(policy);

        SyncopeRole actual = roleDAO.save(role);
View Full Code Here

    private void setPassword(final SyncopeUser user, final String password,
            final SyncopeClientCompositeException scce) {

        int passwordHistorySize = 0;
        PasswordPolicy policy = policyDAO.getGlobalPasswordPolicy();
        if (policy != null && policy.getSpecification(PasswordPolicySpec.class) != null) {
            passwordHistorySize = policy.getSpecification(PasswordPolicySpec.class).getHistoryLength();
        }

        try {
            user.setPassword(password, getPredefinedCipherAlgoritm(), passwordHistorySize);
        } catch (NotFoundException e) {
View Full Code Here

        assertFalse(policies.isEmpty());
    }

    @Test
    public void findGlobalPasswordPolicy() {
        PasswordPolicy policy = policyDAO.getGlobalPasswordPolicy();
        assertNotNull("findById did not work", policy);

        assertEquals(PolicyType.GLOBAL_PASSWORD, policy.getType());

        assertEquals("invalid policy values", 8, (policy.getSpecification(PasswordPolicySpec.class)).getMinLength());
    }
View Full Code Here

    public void saveSecondPasswordPolicy() {
        PasswordPolicySpec passwordPolicy = new PasswordPolicySpec();
        passwordPolicy.setMaxLength(8);
        passwordPolicy.setMinLength(6);

        PasswordPolicy policy = new PasswordPolicy(true);
        policy.setSpecification(passwordPolicy);
        policy.setDescription("global password policy");

        policyDAO.save(policy);
    }
View Full Code Here

    @Override
    public <T extends Policy> T save(final T policy) {
        switch (policy.getType()) {
            case GLOBAL_PASSWORD:
                // just one GLOBAL_PASSWORD policy
                final PasswordPolicy passwordPolicy = getGlobalPasswordPolicy();

                if (passwordPolicy != null && !passwordPolicy.getId().equals(policy.getId())) {
                    throw new InvalidEntityException(PasswordPolicy.class, EntityViolationType.InvalidPasswordPolicy,
                            "Global Password policy already exists");
                }
                break;
View Full Code Here

                if (!(policyTO instanceof PasswordPolicyTO)) {
                    throw new ClassCastException("Expected " + PasswordPolicyTO.class.getName()
                            + ", found " + policyTO.getClass().getName());
                }
                if (policy == null) {
                    policy = (T) new PasswordPolicy(isGlobal);
                }
                policy.setSpecification(((PasswordPolicyTO) policyTO).getSpecification());
                break;

            case GLOBAL_ACCOUNT:
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.PasswordPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.