Examples of PasswordForm


Examples of com.sparc.knappsack.forms.PasswordForm

    private PasswordForm passwordForm;
    private User user = new User("test", "originalPassword", "test@test.com", "test", "test", new ArrayList<Role>());

    @Before
    public void setup() {
        passwordForm = new PasswordForm();
        errors = new BeanPropertyBindingResult(passwordForm, "passwordForm");
        ReflectionTestUtils.setField(passwordValidator, "passwordPattern", PASSWORD_PATTERN);

        // Set mock behaviour/expectations on the mockSecurityContext
        Mockito.when(mockUserService.getUserFromSecurityContext()).thenReturn(user);
View Full Code Here

Examples of com.sparc.knappsack.forms.PasswordForm

        return PasswordForm.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        PasswordForm passwordForm = (PasswordForm) o;

        User user = userService.getUserFromSecurityContext();

        if (isPasswordEmpty(passwordForm.getOriginalPassword())) {
            errors.rejectValue(ORIGINAL_PASSWORD_FIELD, "passwordValidator.emptyOriginalPassword");
        } else if (!passwordEncoder.isPasswordValid(user.getPassword(), passwordForm.getOriginalPassword(), user.getUsername())) {
            errors.rejectValue(ORIGINAL_PASSWORD_FIELD, "passwordValidator.originalPasswordMismatch");
        }

        if (!isPasswordValid(passwordForm.getFirstNewPassword())) {
            errors.rejectValue(FIRST_NEW_PASSWORD_FIELD, "passwordValidator.password.invalid");
        }

        if (!doPasswordsMatch(passwordForm.getFirstNewPassword(), passwordForm.getSecondNewPassword())) {
            errors.rejectValue(FIRST_NEW_PASSWORD_FIELD, "passwordValidator.newPasswordMismatch");
        }

        if (doPasswordsMatch(passwordForm.getFirstNewPassword(), passwordForm.getSecondNewPassword()) && doPasswordsMatch(passwordForm.getOriginalPassword(), passwordForm.getFirstNewPassword())) {
            errors.rejectValue(FIRST_NEW_PASSWORD_FIELD, "passwordValidator.newPasswordMatchesOriginal");
        }
    }
View Full Code Here

Examples of com.sparc.knappsack.forms.PasswordForm

        if (success != null) {
            model.addAttribute("success", success);
        }

        if (!model.containsAttribute("passwordForm")) {
            model.addAttribute("passwordForm", new PasswordForm());
        }

        return "changePasswordTH";
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.