Example usage for org.springframework.security.core.userdetails UserDetailsService UserDetailsService

List of usage examples for org.springframework.security.core.userdetails UserDetailsService UserDetailsService

Introduction

In this page you can find the example usage for org.springframework.security.core.userdetails UserDetailsService UserDetailsService.

Prototype

UserDetailsService

Source Link

Usage

From source file:org.springframework.security.web.authentication.www.DigestAuthenticationFilterTests.java

@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"));
        }/*from  w  w  w .j  a v a  2s.c o m*/
    };

    DigestAuthenticationEntryPoint ep = new DigestAuthenticationEntryPoint();
    ep.setRealmName(REALM);
    ep.setKey(KEY);

    filter = new DigestAuthenticationFilter();
    filter.setUserDetailsService(uds);
    filter.setAuthenticationEntryPoint(ep);

    request = new MockHttpServletRequest("GET", REQUEST_URI);
    request.setServletPath(REQUEST_URI);
}