| | |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.ruoyi.common.core.domain.model.LoginUserApplet; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | |
| | | throws ServletException, IOException |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(request); |
| | | if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) |
| | | LoginUserApplet applet = tokenService.getLoginUserApplet(request); |
| | | if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())|| |
| | | StringUtils.isNotNull(applet)) |
| | | { |
| | | tokenService.verifyToken(loginUser); |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); |
| | | authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); |
| | | SecurityContextHolder.getContext().setAuthentication(authenticationToken); |
| | | if (StringUtils.isNotNull(loginUser)){ |
| | | tokenService.verifyToken(loginUser); |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); |
| | | authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); |
| | | SecurityContextHolder.getContext().setAuthentication(authenticationToken); |
| | | } |
| | | if (StringUtils.isNotNull(applet)){ |
| | | tokenService.verifyTokenApplet(applet); |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(applet, null, applet.getAuthorities()); |
| | | authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); |
| | | SecurityContextHolder.getContext().setAuthentication(authenticationToken); |
| | | } |
| | | } |
| | | chain.doFilter(request, response); |
| | | } |