|
@@ -12,7 +12,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
import org.springframework.web.method.HandlerMethod;
|
|
import org.springframework.web.method.HandlerMethod;
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
@@ -42,9 +44,11 @@ public class TokenInterceptorHandler implements HandlerInterceptor {
|
|
|
|
|
|
private String key;
|
|
private String key;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- @Lazy
|
|
|
|
- GoTokenAuthentication goTokenAuthentication;
|
|
|
|
|
|
+ static GoTokenAuthentication goTokenAuthentication;
|
|
|
|
+
|
|
|
|
+ private GoTokenAuthentication getGoTokenAuthentication(){
|
|
|
|
+ return goTokenAuthentication == null ? SpringHelper.getBean(GoTokenAuthentication.class) : goTokenAuthentication;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Controller执行之前,如果返回false,controller不执行
|
|
* Controller执行之前,如果返回false,controller不执行
|
|
@@ -98,7 +102,7 @@ public class TokenInterceptorHandler implements HandlerInterceptor {
|
|
GoToken goToken = (GoToken)annotation2;
|
|
GoToken goToken = (GoToken)annotation2;
|
|
if(StringUtils.isNotEmpty(goToken.permissions())){
|
|
if(StringUtils.isNotEmpty(goToken.permissions())){
|
|
Long userId = Long.parseLong(claims.getOrDefault(TokenCfg.USERID, "").toString());
|
|
Long userId = Long.parseLong(claims.getOrDefault(TokenCfg.USERID, "").toString());
|
|
- goTokenAuthentication.authenticate(userId, goToken.permissions());
|
|
|
|
|
|
+ getGoTokenAuthentication().authenticate(userId, goToken.permissions());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|