spring security的form-login是如何关联dao的

来源:互联网 发布:apache 二级域名配置 编辑:程序博客网 时间:2024/06/14 17:14

http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-faq-what-is-userdetailservice
手册中说:
UserDetailsService is a DAO interface for loading data that is specific to a user account.

   <http auto-config="true" authentication-manager-ref="authenticationManager"          access-denied-page="/login.hb?error=2">         <form-login authentication-failure-url="/login.hb?error=1"                     username-parameter="username"                    password-parameter="password"                    login-processing-url="/login"                    login-page="/login.hb"/>    </http>    <authentication-manager id="authenticationManager">        <authentication-provider user-service-ref="userService">            <password-encoder hash="md5"/>        </authentication-provider>    </authentication-manager>

UserService 继承了UserDetailsService

public interface UserService extends UserDetailsService {}
public interface UserDetailsService {    //~ Methods ========================================================================================================    /**     * Locates the user based on the username. In the actual implementation, the search may possibly be case     * insensitive, or case insensitive depending on how the implementation instance is configured. In this case, the     * <code>UserDetails</code> object that comes back may have a username that is of a different case than what was     * actually requested..     *     * @param username the username identifying the user whose data is required.     *     * @return a fully populated user record (never <code>null</code>)     *     * @throws UsernameNotFoundException if the user could not be found or the user has no GrantedAuthority     */    UserDetails loadUserByUsername(String username) throws UsernameNotFoundException;}
@Service("userService")public class UserServiceImpl implements UserService {    @Autowired    private UserRepository userRepository;    @Override    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {       return     }}

所以登录认证靠的是loadUserByUsername方法

没有action

0 0