Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.User


    @Test
    public void failedAccountCreationTest_duplicateUsername() throws Exception {
        String duplicateUserName = "duplicateUserName";
        NewUser newUser = new NewUser();
        newUser.setUsername(duplicateUserName);
        User existingUser = new User();
        existingUser.setUsername(duplicateUserName);

        expect(userService.getUserByUsername(duplicateUserName)).andReturn(existingUser);
        replay(userService);

        try {
View Full Code Here


    public void failedAccountCreationTest_duplicateEmail() throws Exception {
        String duplicateEmail = "duplicateEmail";
        NewUser newUser = new NewUser();
        newUser.setUsername("newUser");
        newUser.setEmail(duplicateEmail);
        User existingUser = new User();
        existingUser.setEmail(duplicateEmail);

        expect(userService.getUserByUsername("newUser")).andReturn(null);
        expect(userService.getUserByEmail(duplicateEmail)).andReturn(existingUser);
        replay(userService);
View Full Code Here

    public void setUp() {              
        mockWidgetCommentRepository = createMock(WidgetCommentRepository.class);
        mockAuthentication = createMock(Authentication.class);
        defaultWidgetCommentPermissionEvaluator = new DefaultWidgetCommentPermissionEvaluator(mockWidgetCommentRepository);
       
        user = new User();
        user.setUsername(VALID_USERNAME);
        user.setEntityId(VALID_USER_ID);
        user2 = new User();
        user2.setUsername(VALID_USERNAME2);
        user2.setEntityId(INVALID_USER_ID);
        widgetComment = new WidgetComment();
        widgetComment.setEntityId(VALID_COMMENT_ID);
        widgetComment.setUser(user);
View Full Code Here

        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthoritiesList).anyTimes();
        expect(mockAuthentication.getPrincipal()).andReturn(user).anyTimes();
        replay(mockAuthentication);
       
        WidgetComment localWidgetComment = new WidgetComment();
        User localUser = new User();
        localUser.setEntityId(VALID_USER_ID);
        localWidgetComment.setUser(localUser);
        expect(mockWidgetCommentRepository.get(VALID_COMMENT_ID)).andReturn(localWidgetComment).anyTimes();
        replay(mockWidgetCommentRepository);
       
        assertThat(defaultWidgetCommentPermissionEvaluator.hasPermission(mockAuthentication, localWidgetComment, Permission.CREATE), is(true));
View Full Code Here

        return User.class.isAssignableFrom(aClass);
    }

    public void validate(Object obj, Errors errors) {
        logger.debug("Validator called");
        User user = (User) obj;

        //check if the password is null or empty
        if (StringUtils.isBlank(user.getPassword())) {
            errors.rejectValue("password", "password.required");
            logger.info("Password required");
        }
        //check if the password length is less than 4
        else if (user.getPassword().length() < 4) {
            errors.rejectValue("password", "password.invalid.length");
            logger.info("Password must be at least 4 characters long");
        }
        //check if the confirm password is null or empty
        if (StringUtils.isBlank(user.getConfirmPassword())) {
            errors.rejectValue("confirmPassword", "confirmPassword.required");
            logger.info("Confirm Password required");
        }

        //check if the confirm password matches the previous entered password
        if (user.getConfirmPassword() != null && !(user.getConfirmPassword().equals(user.getPassword()))) {
            errors.rejectValue("confirmPassword", "confirmPassword.mismatch");
            logger.info("Password mismatch");
        }

        validateEmail(errors, user);
View Full Code Here

    private boolean isInvalidEmailAddress(String emailAddress) {
        return !EmailValidator.getInstance().isValid(emailAddress);
    }

    private boolean isExistingEmailAddress(User user, String email) {
        final User userByEmail = userService.getUserByEmail(email);
        return userByEmail != null && !userByEmail.equals(user);
    }
View Full Code Here

        validateEmail(errors, email);
        if (errors.hasErrors()) {
            return;
        }
        // check if account exists and if it is locked or expired:
        User user = getUserService().getUserByEmail(email);
        if (user == null) {
            errors.rejectValue(FIELD_EMAIL, "account.invalid");
            log.info("Couldn't find user for email {}", email);
            return;
        }
        if (user.isLocked() || user.isExpired() || !user.isEnabled()) {
            errors.rejectValue(FIELD_EMAIL, "account.invalid");
        }

    }
View Full Code Here

                                          Collection<? extends GrantedAuthority> authorities) {
        if (StringUtils.isBlank(username)) {
            throw new IllegalArgumentException("Empty username from LDAP");
        }

        User byUsername = userService.getUserByUsername(username);
        if (byUsername == null) {
            createRaveUserFromLdapInfo(ctx, username);
            byUsername = userService.getUserByUsername(username);
        }
View Full Code Here

        newUser.setConfirmPassword(VALID_PASSWORD);
        newUser.setPageLayout(VALID_PAGELAYOUT);
        newUser.setEmail(VALID_EMAIL);
        Errors errors = new BindException(newUser, NEW_USER);

        User user = createMock(User.class);
        expect(mockUserService.getUserByUsername("ExistingUser")).andReturn(user);
        expect(mockUserService.getUserByEmail(VALID_EMAIL)).andReturn(null);
        replay(mockUserService);

        newAccountValidator.validate(newUser, errors);
View Full Code Here

        newUser.setConfirmPassword(VALID_PASSWORD);
        newUser.setPageLayout(VALID_PAGELAYOUT);
        newUser.setEmail("existing@localhost");
        Errors errors = new BindException(newUser, NEW_USER);

        User user = createMock(User.class);
        expect(mockUserService.getUserByUsername(VALID_NAME)).andReturn(null);
        expect(mockUserService.getUserByEmail("existing@localhost")).andReturn(user);
        replay(mockUserService);

        newAccountValidator.validate(newUser, errors);
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.User

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.