Search in sources :

Example 1 with UserDetailsImpl

use of com.github.liuweijw.system.auth.service.UserDetailsImpl in project fw-cloud-framework by liuweijw.

the class AjaxAuthenticationProvider method authenticate.

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    AjaxAuthenticationToken ajaxAuthenticationToken = (AjaxAuthenticationToken) authentication;
    AuthUser user = userService.findUserByMobile((String) ajaxAuthenticationToken.getPrincipal());
    if (null == user)
        throw new UsernameNotFoundException("登录账户[" + ajaxAuthenticationToken.getPrincipal() + "]不存在");
    UserDetailsImpl userDetails = buildUserDeatils(user);
    if (null == userDetails)
        throw new InternalAuthenticationServiceException("登录用户[" + ajaxAuthenticationToken.getPrincipal() + "]不存在!");
    AjaxAuthenticationToken authenticationToken = new AjaxAuthenticationToken(userDetails, userDetails.getAuthorities());
    authenticationToken.setDetails(ajaxAuthenticationToken.getDetails());
    return authenticationToken;
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) UserDetailsImpl(com.github.liuweijw.system.auth.service.UserDetailsImpl) InternalAuthenticationServiceException(org.springframework.security.authentication.InternalAuthenticationServiceException) AuthUser(com.github.liuweijw.core.beans.system.AuthUser)

Aggregations

AuthUser (com.github.liuweijw.core.beans.system.AuthUser)1 UserDetailsImpl (com.github.liuweijw.system.auth.service.UserDetailsImpl)1 InternalAuthenticationServiceException (org.springframework.security.authentication.InternalAuthenticationServiceException)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1