Package org.springframework.security.core.userdetails

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


        setContext(
                "<ldap-server id='someServer' ldif='classpath:test-server.ldif'/>" +
                "<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' user-context-mapper-ref='mapper'/>" +
                "<b:bean id='mapper' class='"+ InetOrgPersonContextMapper.class.getName() +"'/>");

        UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
        UserDetails ben = uds.loadUserByUsername("ben");
        assertTrue(ben instanceof InetOrgPerson);
    }
View Full Code Here


        assertEquals("rm", services.getParameter());
        services.setCookieName("kookie");
        assertEquals("kookie", services.getCookieName());
        services.setTokenValiditySeconds(600);
        assertEquals(600, services.getTokenValiditySeconds());
        UserDetailsService uds = mock(UserDetailsService.class);
        services.setUserDetailsService(uds);
        assertSame(uds, services.getUserDetailsService());
        AuthenticationDetailsSource ads = mock(AuthenticationDetailsSource.class);
        services.setAuthenticationDetailsSource(ads);
        assertSame(ads, services.getAuthenticationDetailsSource());
View Full Code Here

    @Before
    public void setUp() {
        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"));
            }
        };
View Full Code Here

        }
    }

    public void testStartupSuccess() throws Exception {
        DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
        UserDetailsService userDetailsService = new MockAuthenticationDaoUserrod();
        provider.setUserDetailsService(userDetailsService);
        provider.setUserCache(new MockUserCache());
        assertEquals(userDetailsService, provider.getUserDetailsService());
        provider.afterPropertiesSet();
        assertTrue(true);
View Full Code Here

*/
public class UserDetailsServiceLdapAuthoritiesPopulatorTests {

    @Test
    public void delegationToUserDetailsServiceReturnsCorrectRoles() throws Exception {
        UserDetailsService uds = mock(UserDetailsService.class);
        UserDetails user = mock(UserDetails.class);
        when(uds.loadUserByUsername("joe")).thenReturn(user);
        List authorities = AuthorityUtils.createAuthorityList("ROLE_USER");
        when(user.getAuthorities()).thenReturn(authorities);

        UserDetailsServiceLdapAuthoritiesPopulator populator = new UserDetailsServiceLdapAuthoritiesPopulator(uds);
        Collection<? extends GrantedAuthority> auths =  populator.getGrantedAuthorities(new DirContextAdapter(), "joe");
View Full Code Here

    public void setUp() throws Exception {
        RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl();
        roleHierarchy.setHierarchy("ROLE_A > ROLE_B");
        final UserDetails user = new User("EXISTING_USER", "PASSWORD", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_A"));
        final UserDetailsService wrappedUserDetailsService = mock(UserDetailsService.class);
        when(wrappedUserDetailsService.loadUserByUsername("EXISTING_USER")).thenReturn(user);
        when(wrappedUserDetailsService.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION")).thenThrow(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION"));

        this.wrappedUserDetailsService = wrappedUserDetailsService;
        userDetailsServiceWrapper = new UserDetailsServiceWrapper();
        userDetailsServiceWrapper.setRoleHierarchy(roleHierarchy);
        userDetailsServiceWrapper.setUserDetailsService(wrappedUserDetailsService);
View Full Code Here

        callback = new UsernameTokenPrincipalCallback(principal);
    }

    @Test
    public void testHandleUsernameTokenPrincipal() throws Exception {
        UserDetailsService userDetailsService = createMock(UserDetailsService.class);
        callbackHandler.setUserDetailsService(userDetailsService);

        expect(userDetailsService.loadUserByUsername("Ernie")).andReturn(user).anyTimes();

        replay(userDetailsService);

        callbackHandler.handleUsernameTokenPrincipal(callback);
        SecurityContext context = SecurityContextHolder.getContext();
View Full Code Here

      return request;
    }

    private UsernamePasswordAuthenticationToken authentication(ServletContext servletContext) {
      ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
      UserDetailsService  userDetailsService = userDetailsService(context);
      UserDetails userDetails = userDetailsService.loadUserByUsername(this.username);
      return new UsernamePasswordAuthenticationToken(
          userDetails, userDetails.getPassword(), userDetails.getAuthorities());
    }
View Full Code Here

        if (pv == null) {
            // If it doesn't already have a UserDetailsService set, then set it.
            services.setUserDetailsService(getUserDetailsService());
        } else {
            // If already set, then attempt to locate a caching version of the injected UserDetailsService
            UserDetailsService cachingUserService = getCachingUserService(pv.getValue());

            if (cachingUserService != null) {
                services.setUserDetailsService(cachingUserService);
            }
        }
View Full Code Here

        } else {
            RootBeanDefinition preAuthUserService = (RootBeanDefinition) pv.getValue();
            Object userService =
                preAuthUserService.getPropertyValues().getPropertyValue("userDetailsService").getValue();

            UserDetailsService cachingUserService = getCachingUserService(userService);

            if (cachingUserService != null) {
                wrapper.setUserDetailsService(cachingUserService);
                provider.setPreAuthenticatedUserDetailsService(wrapper);
            }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.UserDetailsService

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.