Package org.springframework.security.core.userdetails

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


        // @TODO: Add more asserts?
    }

    @Test(expected=UsernameNotFoundException.class)
    public final void authenticateUnknownUserThrowsException() throws Exception {
        UserDetails ud = new User("dummyUser1", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser2", "dummyPwd");
        provider.authenticate(request);
    }
View Full Code Here


        assertThat(resolver.resolveArgument(showUserAnnotationObject(), null, null, null)).isEqualTo(expectedPrincipal);
    }

    @Test
    public void resolveArgumentUserDetails() throws Exception {
        setAuthenticationPrincipal(new User("user", "password", AuthorityUtils.createAuthorityList("ROLE_USER")));
        assertThat(resolver.resolveArgument(showUserAnnotationUserDetails(), null, null, null)).isEqualTo(expectedPrincipal);
    }
View Full Code Here

import org.springframework.security.openid.OpenIDAuthenticationToken;

public class CustomUserDetailsService implements AuthenticationUserDetailsService<OpenIDAuthenticationToken> {
    public UserDetails loadUserDetails(OpenIDAuthenticationToken token)
            throws UsernameNotFoundException {
        return new User(token.getName(), "", AuthorityUtils.createAuthorityList("ROLE_USER"));
    }
View Full Code Here

            if(role.startsWith("ROLE_")) {
                throw new IllegalArgumentException("roles cannot start with ROLE_ Got " + role);
            }
            authorities.add(new SimpleGrantedAuthority("ROLE_"+role));
        }
        User principal = new User(username, withUser.password(), true, true, true, true, authorities);
        Authentication authentication = new UsernamePasswordAuthenticationToken(principal, principal.getPassword(), principal.getAuthorities());
        SecurityContext context = SecurityContextHolder.createEmptyContext();
        context.setAuthentication(authentication);
        return context;
    }
View Full Code Here

        assertEquals("rodAsString", authz.getPrincipal());
    }

    public void testOperationWhenPrincipalIsAUserDetailsInstance() {
        Authentication auth = new TestingAuthenticationToken(new User("rodUserDetails", "koala", true, true, true,
                    true, AuthorityUtils.NO_AUTHORITIES), "koala", AuthorityUtils.NO_AUTHORITIES);
        SecurityContextHolder.getContext().setAuthentication(auth);

        assertEquals("rodUserDetails", authz.getPrincipal());
    }
View Full Code Here

    @Test
    public void autoLoginShouldFailIfUserAccountIsLocked() {
        MockRememberMeServices services = new MockRememberMeServices();
        services.setUserDetailsChecker(new AccountStatusUserDetailsChecker());
        User joeLocked = new User("joe", "password",false,true,true,true,joe.getAuthorities());
        services.setUserDetailsService(new MockUserDetailsService(joeLocked, false));

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setCookies(createLoginCookie("cookie:1:2"));
        MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

        SecurityContextHolder.clearContext();

        // Create User Details Service
        UserDetailsService uds = new UserDetailsService() {
            public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
                return new User("rod,ok", "koala", AuthorityUtils.createAuthorityList("ROLE_ONE","ROLE_TWO"));
            }
        };

        DigestAuthenticationEntryPoint ep = new DigestAuthenticationEntryPoint();
        ep.setRealmName(REALM);
View Full Code Here

            // jacklord, dano  (active)
            // mcgarrett (disabled)
            // wofat (account expired)
            // steve (credentials expired)
            if ("jacklord".equals(username) || "dano".equals(username)) {
                return new User(username, password, true, true, true, true, ROLES_12);
            } else if ("mcgarrett".equals(username)) {
                return new User(username, password, false, true, true, true, ROLES_12);
            } else if ("wofat".equals(username)) {
                return new User(username, password, true, false, true, true, ROLES_12);
            } else if ("steve".equals(username)) {
                return new User(username, password, true, true, false, true, ROLES_12);
            } else {
                throw new UsernameNotFoundException("Could not find: " + username);
            }
        }
View Full Code Here

    protected CasAuthenticationToken getToken() {
        List<String> proxyList = new ArrayList<String>();
        proxyList.add("https://localhost/newPortal/j_spring_cas_security_check");

        User user = new User("rod", "password", true, true, true, true, AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
        final Assertion assertion = new AssertionImpl("rod");

        return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ",
                AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"), user, assertion);
    }
View Full Code Here

    private class MockAuthenticationDaoUserrod implements UserDetailsService {
        private String password = "koala";

        public UserDetails loadUserByUsername(String username) {
            if ("rod".equals(username)) {
                return new User("rod", password, true, true, true, true, ROLES_12);
            } else {
                throw new UsernameNotFoundException("Could not find: " + username);
            }
        }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.User$AuthorityComparator

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.