Example usage for org.springframework.security.authentication.dao AbstractUserDetailsAuthenticationProvider AbstractUserDetailsAuthenticationProvider

List of usage examples for org.springframework.security.authentication.dao AbstractUserDetailsAuthenticationProvider AbstractUserDetailsAuthenticationProvider

Introduction

In this page you can find the example usage for org.springframework.security.authentication.dao AbstractUserDetailsAuthenticationProvider AbstractUserDetailsAuthenticationProvider.

Prototype

AbstractUserDetailsAuthenticationProvider

Source Link

Usage

From source file:com.github.lynxdb.server.api.http.WebSecurityConfig.java

@Autowired
public void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
    auth.authenticationProvider(new AbstractUserDetailsAuthenticationProvider() {
        @Override//from  w ww. j av a 2 s.c  om
        protected void additionalAuthenticationChecks(UserDetails ud, UsernamePasswordAuthenticationToken upat)
                throws AuthenticationException {

        }

        @Override
        protected UserDetails retrieveUser(String string, UsernamePasswordAuthenticationToken upat)
                throws AuthenticationException {
            User user = users.byLogin(string);
            if (user == null) {
                throw new UsernameNotFoundException("No such User : " + string);
            }
            if (user.checkPassword(upat.getCredentials().toString())) {
                return user;
            } else {
                throw new BadCredentialsException("Bad credentials");

            }
        }
    });
}