Examples of ExampleUserDetails


Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

    private static final Logger LOGGER = LoggerFactory.getLogger(SecurityUtil.class);

    public static void logInUser(User user) {
        LOGGER.info("Logging in user: {}", user);

        ExampleUserDetails userDetails = ExampleUserDetails.getBuilder()
                .firstName(user.getFirstName())
                .id(user.getId())
                .lastName(user.getLastName())
                .password(user.getPassword())
                .role(user.getRole())
                .socialSignInProvider(user.getSignInProvider())
                .username(user.getEmail())
                .build();
        LOGGER.debug("Logging in principal: {}", userDetails);

        Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
        SecurityContextHolder.getContext().setAuthentication(authentication);

        LOGGER.info("User: {} has been logged in.", userDetails);
    }
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

        if (user == null) {
            throw new UsernameNotFoundException("No user found with username: " + username);
        }

        ExampleUserDetails principal = ExampleUserDetails.getBuilder()
                .firstName(user.getFirstName())
                .id(user.getId())
                .lastName(user.getLastName())
                .password(user.getPassword())
                .role(user.getRole())
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

    }

    public SecurityContextAssert loggedInUserIs(User user) {
        isNotNull();

        ExampleUserDetails loggedIn = (ExampleUserDetails) actual.getAuthentication().getPrincipal();

        Assertions.assertThat(loggedIn)
                .overridingErrorMessage("Expected logged in user to be <%s> but was <null>",
                        user
                )
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

    }

    public SecurityContextAssert loggedInUserHasPassword(String password) {
        isNotNull();

        ExampleUserDetails loggedIn = (ExampleUserDetails) actual.getAuthentication().getPrincipal();

        Assertions.assertThat(loggedIn)
                .overridingErrorMessage("Expected logged in user to be <not null> but was <null>")
                .isNotNull();
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

    }

    public SecurityContextAssert loggedInUserIsRegisteredByUsingNormalRegistration() {
        isNotNull();

        ExampleUserDetails loggedIn = (ExampleUserDetails) actual.getAuthentication().getPrincipal();

        Assertions.assertThat(loggedIn)
                .overridingErrorMessage("Expected logged in user to be <not null> but was <null>")
                .isNotNull();
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

    }

    public SecurityContextAssert loggedInUserIsSignedInByUsingSocialProvider(SocialMediaService signInProvider) {
        isNotNull();

        ExampleUserDetails loggedIn = (ExampleUserDetails) actual.getAuthentication().getPrincipal();

        Assertions.assertThat(loggedIn)
                .overridingErrorMessage("Expected logged in user to be <not null> but was <null>")
                .isNotNull();
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

                .build();

        when(repositoryMock.findByEmail(EMAIL)).thenReturn(found);

        UserDetails user = service.loadUserByUsername(EMAIL);
        ExampleUserDetails actual = (ExampleUserDetails) user;

        assertThat(actual)
                .hasFirstName(FIRST_NAME)
                .hasId(ID)
                .hasLastName(LAST_NAME)
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

                .build();

        when(repositoryMock.findByEmail(EMAIL)).thenReturn(found);

        UserDetails user = service.loadUserByUsername(EMAIL);
        ExampleUserDetails actual = (ExampleUserDetails) user;

        assertThat(actual)
                .hasFirstName(FIRST_NAME)
                .hasId(ID)
                .hasLastName(LAST_NAME)
View Full Code Here

Examples of net.petrikainulainen.spring.social.signinmvc.security.dto.ExampleUserDetails

        verifyNoMoreInteractions(userDetailsServicemock);
    }

    @Test
    public void loadByUserId_UserDetailsFound_ShouldReturnTheFoundUserDetails() {
        ExampleUserDetails found = ExampleUserDetails.getBuilder()
                .firstName(FIRST_NAME)
                .lastName(LAST_NAME)
                .password(PASSWORD)
                .username(USER_ID)
                .role(Role.ROLE_USER)
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.