Package org.apache.syncope.common.types

Examples of org.apache.syncope.common.types.PasswordPolicySpec


    @Test(expected = InvalidPasswordPolicySpecException.class)
    public void incopatiblePolicies()
            throws InvalidPasswordPolicySpecException {

        PasswordPolicySpec passwordPolicySpec = createBasePasswordPolicySpec();
        passwordPolicySpec.setMinLength(12);

        PasswordPolicySpec passwordPolicySpec2 = createBasePasswordPolicySpec();
        passwordPolicySpec.setMaxLength(10);

        List<PasswordPolicySpec> passwordPolicySpecs = new ArrayList<PasswordPolicySpec>();
        passwordPolicySpecs.add(passwordPolicySpec);
        passwordPolicySpecs.add(passwordPolicySpec2);
View Full Code Here


        passwordPolicySpecs.add(passwordPolicySpec2);
        passwordGenerator.generate(passwordPolicySpecs);
    }

    private PasswordPolicySpec createBasePasswordPolicySpec() {
        PasswordPolicySpec basePasswordPolicySpec = new PasswordPolicySpec();
        basePasswordPolicySpec.setAlphanumericRequired(false);
        basePasswordPolicySpec.setDigitRequired(false);
        basePasswordPolicySpec.setLowercaseRequired(false);
        basePasswordPolicySpec.setMaxLength(1000);
        basePasswordPolicySpec.setMinLength(8);
        basePasswordPolicySpec.setMustEndWithAlpha(false);
        basePasswordPolicySpec.setMustEndWithDigit(false);
        basePasswordPolicySpec.setMustEndWithNonAlpha(false);
        basePasswordPolicySpec.setMustStartWithAlpha(false);
        basePasswordPolicySpec.setMustStartWithDigit(false);
        basePasswordPolicySpec.setMustStartWithNonAlpha(false);
        basePasswordPolicySpec.setMustntEndWithAlpha(false);
        basePasswordPolicySpec.setMustntEndWithDigit(false);
        basePasswordPolicySpec.setMustntEndWithNonAlpha(false);
        basePasswordPolicySpec.setMustntStartWithAlpha(false);
        basePasswordPolicySpec.setMustntStartWithDigit(false);
        basePasswordPolicySpec.setMustntStartWithNonAlpha(false);
        basePasswordPolicySpec.setNonAlphanumericRequired(false);
        basePasswordPolicySpec.setUppercaseRequired(false);
        return basePasswordPolicySpec;
    }
View Full Code Here

        T result = null;
        switch (policy.getType()) {
            case PASSWORD:
            case GLOBAL_PASSWORD:
                final PasswordPolicySpec ppSpec = policy.getSpecification(PasswordPolicySpec.class);
                final PasswordPolicySpec evaluatedPPSpec = new PasswordPolicySpec();

                BeanUtils.copyProperties(ppSpec, evaluatedPPSpec, new String[]{"schemasNotPermitted"});

                for (String schema : ppSpec.getSchemasNotPermitted()) {
                    AbstractAttr attribute = attributable.getAttr(schema);
                    if (attribute != null) {
                        List<String> values = attribute.getValuesAsStrings();
                        if (values != null && !values.isEmpty()) {
                            evaluatedPPSpec.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().getName());
                    result = (T) evaluatedPPSpec;
                    break;
                }
                SyncopeUser user = (SyncopeUser) attributable;
                if (user.verifyPasswordHistory(user.getClearPassword(), ppSpec.getHistoryLength())) {
                    evaluatedPPSpec.getWordsNotPermitted().add(user.getClearPassword());
                }
                result = (T) evaluatedPPSpec;
                break;
            case ACCOUNT:
            case GLOBAL_ACCOUNT:
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.types.PasswordPolicySpec

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.