Browse Source

安扫透传header,屏蔽登录和验证码接口

lirong 3 years ago
parent
commit
466e4d9bd5

+ 3 - 3
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RedirectUtil.java

@@ -34,7 +34,7 @@ public class RedirectUtil {
 		String resultString;
 		try {
 			Map<String, String> otherMap = new ConcurrentHashMap<String, String>();
-			Object result = RedirectUtil.redirectInner(ConfigRedirect, sql_json, otherMap);
+			Object result = RedirectUtil.redirectInner(ConfigRedirect, sql_json, otherMap, request);
 			if (wrapper) {
 				JSONObject resultJSON = new JSONObject();
 				resultJSON.put("Result", "success");
@@ -64,7 +64,7 @@ public class RedirectUtil {
 		return resultString;
 	}
 
-	public static Object redirectInner(ConfigRedirect ConfigRedirect, JSONObject sql_json, Map<String, String> otherMap) throws Exception {
+	public static Object redirectInner(ConfigRedirect ConfigRedirect, JSONObject sql_json, Map<String, String> otherMap,HttpServletRequest request) throws Exception {
 		String resultString;
 		String url = ConfigRedirect.url;
 		String url_ori = url;
@@ -104,7 +104,7 @@ public class RedirectUtil {
 			} else {
 				postString = postBody.toString();
 			}
-			resultString = HttpClientUtil.instance("redirect").post(url, postString, null, ConfigRedirect.headerMap,null,null);
+			resultString = HttpClientUtil.instance("redirect").post(url, postString, null, ConfigRedirect.headerMap,null,request);
 		}
 		Object result;
 		try {

+ 8 - 3
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/HttpClientUtil.java

@@ -26,6 +26,7 @@ import cn.hutool.core.lang.Tuple;
 import sun.misc.BASE64Encoder;
 
 import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 @SuppressWarnings("restriction")
@@ -152,15 +153,19 @@ public class HttpClientUtil {
 	}
 
 
-	public synchronized String post(String url, String content, Integer timeout, Map<String, String> headerMap,HttpServletResponse response, HttpServletResponse request) throws Exception {
+	public synchronized String post(String url, String content, Integer timeout, Map<String, String> headerMap,HttpServletResponse response, HttpServletRequest request) throws Exception {
 		if (Constant.http_interval > 0) {
 			Thread.sleep(Constant.http_interval);
 		}
 
 		HttpPost httpost = new HttpPost(url);
-		if(!url.contains("login")||!url.contains("getCaptchaBase64"))
+		if (!url.contains("login")&&!url.contains("getCaptchaBase64"))
 		{
-			httpost.setHeader("Authorization", request.getHeader("Authorization"));
+			String authorization=request.getHeader("Authorization");
+			if(authorization!=null)
+			{
+				httpost.setHeader("Authorization", authorization);
+			}
 		}
 		if (headerMap != null) {
 			for (String key : headerMap.keySet()) {