Package org.springframework.security.core.userdetails

Examples of org.springframework.security.core.userdetails.User


      List<Userinfo> userinfos = userService.findByUserName(username);

      Userinfo userinfo = userinfos.get(0);

      User user = new User(userinfo.getUserName(),
          userinfo.getPassword(), true, true, true, true,
          userAuthorities);
      currentUser.set(user);
      return user;
View Full Code Here


    @Test
    public void getLoggedInUser() {
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(AUTHORITY);

        UserDetails principal = new User(USERNAME, PASSWORD, authorities);

        when(securityContextUtilMock.getPrincipal()).thenReturn(principal);

        UserDTO loggedInUser = controller.getLoggedInUser();
View Full Code Here

        UserDetails principal = createPrincipal(authorities);
        return createAuthentication(principal, authorities);
    }

    private UserDetails createPrincipal(List<GrantedAuthority> authorities ) {
        return new User(USERNAME, PASSWORD, authorities);
    }
View Full Code Here

        PowerMockito.mockStatic(SecurityContextHolder.class);
        when(SecurityContextHolder.getContext()).thenReturn(securityContextMock);
        when(securityContextMock.getAuthentication()).thenReturn(authenticationMock);

        UserDetails expectedPrincipal = new User("user", "password", new ArrayList<GrantedAuthority>());
        when(authenticationMock.getPrincipal()).thenReturn(expectedPrincipal);

        UserDetails actualPrincipal = securityContextUtil.getPrincipal();

        PowerMockito.verifyStatic(times(1));
View Full Code Here

        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        final UserDetails userDetails = new User("admin", "FAKE_PASSWORD", true, true, true, true, authorities);

        SecurityContextHolder.getContext().setAuthentication(
                new UsernamePasswordAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities));
    }
View Full Code Here

        entryPoint.setKey("key");
        entryPoint.setRealmName("Spring Security");
        filter = new DigestAuthenticationFilter();
        filter.setUserDetailsService(new UserDetailsService() {
            public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
                return new User(username,password, AuthorityUtils.createAuthorityList("ROLE_USER"));
            }
        });
        filter.setAuthenticationEntryPoint(entryPoint);
        filter.afterPropertiesSet();
    }
View Full Code Here

     * @param token the authentication request token
     * @param authorities the pre-authenticated authorities.
     */
    @Deprecated
    protected UserDetails createuserDetails(Authentication token, Collection<? extends GrantedAuthority> authorities) {
        return new User(token.getName(), "N/A", true, true, true, true, authorities);
    }
View Full Code Here

@SuppressWarnings("unchecked")
public class CasAuthenticationProviderTests {
    //~ Methods ========================================================================================================

    private UserDetails makeUserDetails() {
        return new User("user", "password", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
    }
View Full Code Here

        return new User("user", "password", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
    }

    private UserDetails makeUserDetailsFromAuthoritiesPopulator() {
        return new User("user", "password", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_A", "ROLE_B"));
    }
View Full Code Here

    private UserDetails makeUserDetails() {
        return makeUserDetails("user");
    }

    private UserDetails makeUserDetails(final String name) {
        return new User(name, "password", true, true, true, true, ROLES);
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.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.