Package com.gwtplatform.carstore.shared.dto

Examples of com.gwtplatform.carstore.shared.dto.UserDto


            return null;
        }
       
        Long userId = userSession.getUserId();

        UserDto userDto = null;
        if (userId != null) {
            userDto = User.createDto(userDao.get(userId));
        }

        return userDto;
View Full Code Here


    public static UserDto createDto(User user) {
        if (user == null) {
            return null;
        }
        UserDto userDto = new UserDto();
        userDto.setFirstName(user.getFirstName());
        userDto.setId(user.getId());
        userDto.setLastName(user.getLastName());
        userDto.setUsername(user.getUsername());

        return userDto;
    }
View Full Code Here

        ratingDao.deleteAll();
        carPropertiesDao.deleteAll();
    }

    private void createBasicUser() {
        UserDto userDto = new UserDto("admin", passwordSecurity.hashPassword("qwerty"), "FirstName", "LastName");
        userDao.put(User.create(userDto));
    }
View Full Code Here

        this.loginCookieDao = loginCookieDao;
    }

    @Override
    public LogInResult execute(LogInAction action, ExecutionContext context) throws ActionException {
        UserDto userDto;
        isLoggedIn = true;

        if (action.getActionType() == ActionType.VIA_COOKIE) {
            userDto = getUserFromCookie(action.getLoggedInCookie());
        } else {
View Full Code Here

    @Override
    public void undo(LogInAction action, LogInResult result, ExecutionContext context) throws ActionException {
    }

    private UserDto getUserFromCookie(String loggedInCookie) {
        UserDto userDto = null;
        try {
            userDto = authenticator.authenticatCookie(loggedInCookie);
        } catch (AuthenticationException e) {
            isLoggedIn = false;
        }
View Full Code Here

        return userDto;
    }

    private UserDto getUserFromCredentials(String username, String password) {
        UserDto userDto = null;
        try {
            userDto = authenticator.authenticateCredentials(username, password);
        } catch (AuthenticationException e) {
            isLoggedIn = false;
        }
View Full Code Here

        given(user.getId()).willReturn(A_USER_ID);
        given(userDao.findByUsername(A_VALID_USER)).willReturn(user);
        given(passwordSecurity.check(anyString(), anyString())).willReturn(true);

        // When
        UserDto fetchUser = authenticator.authenticateCredentials(A_VALID_USER, A_VALID_PASSWORD);

        // Then
        assertNotNull(fetchUser);
        verify(httpSession).setAttribute(SecurityParameters.getUserSessionKey(), A_USER_ID);
    }
View Full Code Here

    }

    @Test
    public void logoutShouldDestroyTheSession(UserSessionDao userSessionDao) {
        // Given
        UserDto userDto = mock(UserDto.class);
        given(userDto.getId()).willReturn(0l);

        CurrentUserDto currentUserDto = mock(CurrentUserDto.class);
        given(currentUserDto.getUser()).willReturn(userDto);
        given(currentUserDtoProvider.get()).willReturn(currentUserDto);
View Full Code Here

    public UserDto authenticateCredentials(String username, String password) {
        try {
            User user = userDao.findByUsername(username);

            if (passwordSecurity.check(password, user.getHashPassword())) {
                UserDto userDto = User.createDto(user);
                persistHttpSessionCookie(userDto);

                return userDto;
            } else {
                throw new AuthenticationException();
View Full Code Here

            throw new AuthenticationException();
        }
    }

    public UserDto authenticatCookie(String loggedInCookie) throws AuthenticationException {
        UserDto userDto = userSessionDao.getUserFromCookie(loggedInCookie);

        if (userDto == null) {
            throw new AuthenticationException();
        } else {
            persistHttpSessionCookie(userDto);
View Full Code Here

TOP

Related Classes of com.gwtplatform.carstore.shared.dto.UserDto

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.