From 18e2c156de069eaee2f989e09fda061841aae605 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 11 七月 2024 11:35:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java
index 1237741..9679f27 100644
--- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java
+++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java
@@ -7,6 +7,7 @@
import com.vci.starter.web.enumpck.ResultCodeEnum;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.SessionInfo;
+import com.vci.starter.web.util.ApplicationContextProvider;
import com.vci.starter.web.util.LangBaseUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.util.WebThreadLocalUtil;
@@ -14,10 +15,15 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
+import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -30,6 +36,7 @@
* @author weidy
* @date 2019/11/7 2:32 PM
*/
+//@Configuration
public class VciSecurityInterceptor implements HandlerInterceptor {
/**
@@ -46,8 +53,8 @@
/**
* 浼氳瘽锛屾潈闄愶紝token鐨勬帴鍙�
*/
- @Autowired(required = false)
- private VciSessionForLoginI sessionForLoginI;
+ @Autowired
+ private VciSessionForLoginI vciSessionForLoginI;
/**
* 鎵ц鎷︽埅
@@ -92,6 +99,11 @@
//铏界劧涓嶆牎楠屾潈闄愶紝浣嗘槸濡傛灉token涓嶄负绌猴紝闇�瑕佹洿鏂板綋鍓嶇敤鎴�
SessionInfo sessionInfo = getSessionInfo(userToken);
+ if(sessionInfo != null){
+ //鍒濆鍖栧钩鍙扮殑token
+ vciSessionForLoginI.initInvocationInfo(sessionInfo);
+ }
+
return true;
}
//鑾峰彇閰嶇疆鏂囦欢涓紝涓嶆牎楠屾潈闄愮殑璺緞
@@ -119,7 +131,7 @@
return false;
}else{
if(!unCheckUrls.contains(url)){
- if(sessionForLoginI == null){
+ if(vciSessionForLoginI == null){
//璇存槑娌″姙娉曟牎楠�
String msg = "璇锋眰璺緞"+ url +"娌℃潈闄愯闂�";
if(logger.isErrorEnabled()) {
@@ -129,11 +141,11 @@
return false;
}else{
//鍒濆鍖栧钩鍙扮殑token
- sessionForLoginI.initInvocationInfo(sessionInfo);
+ vciSessionForLoginI.initInvocationInfo(sessionInfo);
String systemPrivateToken = request.getHeader(TokenKeyConstant.SYSTEM_PRIVATE_KEY);
try {
- if (sessionForLoginI.checkRequestRights(request, systemPrivateToken, sessionInfo, handler)) {
+ if (vciSessionForLoginI.checkRequestRights(request, systemPrivateToken, sessionInfo, handler)) {
updateRequestTime(url,userToken);
}else{
return false;
@@ -159,7 +171,11 @@
SessionInfo sessionInfo = null;
if(StringUtils.isNotBlank(userToken)){
try{
- sessionInfo = sessionForLoginI.getSessionInfoByToken(userToken);
+ if(vciSessionForLoginI == null){
+ vciSessionForLoginI = ApplicationContextProvider.getBean(VciSessionForLoginI.class);
+ }
+
+ sessionInfo = vciSessionForLoginI.getSessionInfoByToken(userToken);
}catch (Throwable e){
logger.error("鑾峰彇token鍑洪敊",e);
}
@@ -207,8 +223,8 @@
while(url1.startsWith("/")){
url1 = url1.substring(1);
}
- if(sessionForLoginI != null && !unStorageRequestTimeUrls.contains(url1)){
- sessionForLoginI.updateRequestTime(userToken);
+ if(vciSessionForLoginI != null && !unStorageRequestTimeUrls.contains(url1)){
+ vciSessionForLoginI.updateRequestTime(userToken);
}
}
}
--
Gitblit v1.9.3