@Order(2)
@Aspect
@Component
public class TokenCheckAspect {
private Logger log = Logger.getLogger(this.getClass());
@Autowired
private TokenManager tokenManager;
@Pointcut("execution(public * com.fiicloud.fit.controller.*.*_U(..))")
public void tokenCheck(){}
@Before("tokenCheck()")
public void doBefore(JoinPoint joinPoint) throws TokenInvalidException {
HttpServletRequest request = SpringUtil.getRequest();
String token = TokenManager.getToken(request);
if(!tokenManager.containsKey(token)) {
// token无效
log.info("token无效 ----------> " + joinPoint.getSignature().getName());
throw new TokenInvalidException();
}
}
@After("tokenCheck()")
public void doAfter() {
}
}