Search in sources :

Example 6 with AuthUser

use of com.github.liuweijw.system.api.model.AuthUser 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 = userFeignApi.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.system.api.model.AuthUser)

Aggregations

AuthUser (com.github.liuweijw.system.api.model.AuthUser)6 QUser (com.github.liuweijw.business.admin.domain.QUser)3 User (com.github.liuweijw.business.admin.domain.User)3 AuthRole (com.github.liuweijw.system.api.model.AuthRole)3 ArrayList (java.util.ArrayList)3 Cacheable (org.springframework.cache.annotation.Cacheable)2 UserBean (com.github.liuweijw.business.admin.beans.UserBean)1 QRole (com.github.liuweijw.business.admin.domain.QRole)1 QUserRole (com.github.liuweijw.business.admin.domain.QUserRole)1 Role (com.github.liuweijw.business.admin.domain.Role)1 UserRole (com.github.liuweijw.business.admin.domain.UserRole)1 UserDetailsImpl (com.github.liuweijw.system.auth.service.UserDetailsImpl)1 HashSet (java.util.HashSet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 InternalAuthenticationServiceException (org.springframework.security.authentication.InternalAuthenticationServiceException)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1