use of org.springframework.security.authentication.AuthenticationProvider in project cas by apereo.
the class CasLdapUserDetailsManagerConfigurer method configure.
@Override
public void configure(final B builder) throws Exception {
final AuthenticationProvider provider = postProcess(buildLdapAuthenticationProvider());
builder.authenticationProvider(provider);
}
use of org.springframework.security.authentication.AuthenticationProvider in project spring-security by spring-projects.
the class SecurityConfig method authenticationProvider.
@Bean
public AuthenticationProvider authenticationProvider() {
Assert.notNull(myUserRepository);
return new AuthenticationProvider() {
public boolean supports(Class<?> authentication) {
return true;
}
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Object principal = authentication.getPrincipal();
String username = String.valueOf(principal);
User user = myUserRepository.findByUsername(username);
if (user == null) {
throw new UsernameNotFoundException("No user for principal " + principal);
}
if (!authentication.getCredentials().equals(user.getPassword())) {
throw new BadCredentialsException("Invalid password");
}
return new TestingAuthenticationToken(principal, null, "ROLE_USER");
}
};
}
use of org.springframework.security.authentication.AuthenticationProvider in project spring-security-oauth by spring-projects.
the class AuthorizationServerEndpointsConfigurer method addUserDetailsService.
private void addUserDetailsService(DefaultTokenServices tokenServices, UserDetailsService userDetailsService) {
if (userDetailsService != null) {
PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();
provider.setPreAuthenticatedUserDetailsService(new UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken>(userDetailsService));
tokenServices.setAuthenticationManager(new ProviderManager(Arrays.<AuthenticationProvider>asList(provider)));
}
}
Aggregations