I have a question. In Struts, I have an Action that deals with user authentication, i.e., I took the user\'s credentials and used a DAO to validate user credentials. I want to m
You can create a custom authentication provider that implements org.springframework.security.authentication.AuthenticationProvider like this
package com.bzone.example;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
public class CustomAuthenticationProvider implements AuthenticationProvider{
@Override
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
// TODO call custom service or do whatever you want
return null;
}
@Override
public boolean supports(Class extends Object> authentication) {
// copied it from AbstractUserDetailsAuthenticationProvider
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
}
}
one more step is to configure spring security to use this custom authentication provider