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;
}
Aggregations