package com.tofly.common.oauth.config;

/**
 * @author Administrator
 * @date 2019/9/18  15:55
 * 通过token，校验用户登录情况，
 */
//@Component
//@Slf4j
//public class AuthenticationTokenFilter extends OncePerRequestFilter {
//    @Override
//    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
//        log.info("order 自定义filter 来了。。。。。。。");
//
//        String authHeader = request.getHeader("token");//获取header中的验证信息
//        TokenEndpoint tokenEndpoint;
//        if (authHeader != null && authHeader.startsWith("Bearer ")) {
//            final String authToken = authHeader.substring("Bearer ".length());
//            User user= SecurityUtils.getUser();
//            if (user != null) {
//                UsernamePasswordAuthenticationToken authentication =
//                        new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
//                authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
//                //设置为已登录
//                SecurityContextHolder.getContext().setAuthentication(authentication);
//            }
//        }
//
//        filterChain.doFilter(request, response);
//    }
//}
