update 调用内部接口增加Header Referer
This commit is contained in:
+19
-18
@@ -4,6 +4,8 @@ import cn.hutool.core.util.CharsetUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.asymmetric.KeyType;
|
import cn.hutool.crypto.asymmetric.KeyType;
|
||||||
import cn.hutool.crypto.asymmetric.RSA;
|
import cn.hutool.crypto.asymmetric.RSA;
|
||||||
|
import cn.hutool.http.Header;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jero.common.exception.JeroBootException;
|
import com.jero.common.exception.JeroBootException;
|
||||||
@@ -141,7 +143,12 @@ public class AuthenticationUtils {
|
|||||||
if (StrUtil.isNotBlank(requestParam)){
|
if (StrUtil.isNotBlank(requestParam)){
|
||||||
urlBuilder.append(requestParam);
|
urlBuilder.append(requestParam);
|
||||||
}
|
}
|
||||||
String post = HttpUtil.post(urlBuilder.toString(), jsonString);
|
String post = HttpRequest.post(urlBuilder.toString())
|
||||||
|
.header(Header.REFERER, urlBuilder.toString())//头信息,多个头信息多次调用此方法即可
|
||||||
|
.form(jsonString)//表单内容
|
||||||
|
.timeout(20000)//超时,毫秒
|
||||||
|
.execute().body();
|
||||||
|
//String post = HttpUtil.post(urlBuilder.toString(), jsonString);
|
||||||
checkResult(post);
|
checkResult(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,25 +169,15 @@ public class AuthenticationUtils {
|
|||||||
if (StrUtil.isNotBlank(requestParam)){
|
if (StrUtil.isNotBlank(requestParam)){
|
||||||
urlBuilder.append(requestParam);
|
urlBuilder.append(requestParam);
|
||||||
}
|
}
|
||||||
String post = HttpUtil.post(urlBuilder.toString(), jsonString);
|
String post = HttpRequest.post(urlBuilder.toString())
|
||||||
|
.header(Header.REFERER, urlBuilder.toString())//头信息,多个头信息多次调用此方法即可
|
||||||
|
.form(jsonString)//表单内容
|
||||||
|
.timeout(20000)//超时,毫秒
|
||||||
|
.execute().body();
|
||||||
|
//String post = HttpUtil.post(urlBuilder.toString(), jsonString);
|
||||||
return checkGetResult(post);
|
return checkGetResult(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用会员系统post接口
|
|
||||||
* @param methodName
|
|
||||||
*/
|
|
||||||
public static void post(String methodName, HashMap<String, Object> paramMap) {
|
|
||||||
Map<String, String> stringStringMap = encryptByRsaPriKey();
|
|
||||||
paramMap.put("token", stringStringMap.get("token"));
|
|
||||||
paramMap.put("publicKey", stringStringMap.get("publicKey"));
|
|
||||||
//拼接url路径
|
|
||||||
StringBuilder urlBuilder = new StringBuilder(AuthenticationUtils.URL);
|
|
||||||
urlBuilder.append(methodName);
|
|
||||||
String post = HttpUtil.post(urlBuilder.toString(), paramMap);
|
|
||||||
checkResult(post);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用会员系统get接口
|
* 调用会员系统get接口
|
||||||
* @param methodName
|
* @param methodName
|
||||||
@@ -194,7 +191,11 @@ public class AuthenticationUtils {
|
|||||||
urlBuilder.append(methodName);
|
urlBuilder.append(methodName);
|
||||||
urlBuilder.append("?");
|
urlBuilder.append("?");
|
||||||
paramMap.forEach((k,v) -> urlBuilder.append(k).append("=").append(v).append("&"));
|
paramMap.forEach((k,v) -> urlBuilder.append(k).append("=").append(v).append("&"));
|
||||||
String get = HttpUtil.get(urlBuilder.toString());
|
String get = HttpRequest.get(urlBuilder.toString())
|
||||||
|
.header(Header.REFERER, urlBuilder.toString())//头信息,多个头信息多次调用此方法即可
|
||||||
|
.timeout(20000)//超时,毫秒
|
||||||
|
.execute().body();
|
||||||
|
//String get = HttpUtil.get(urlBuilder.toString());
|
||||||
checkResult(get);
|
checkResult(get);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -55,9 +55,9 @@ public class CsrfFilter implements Filter {
|
|||||||
// 获取来源
|
// 获取来源
|
||||||
String referurl = req.getHeader("Referer");
|
String referurl = req.getHeader("Referer");
|
||||||
// websocket 请求放过
|
// websocket 请求放过
|
||||||
if(isWhiteReq(referurl) || url.contains("/websocket/")){
|
if(isWhiteReq(referurl) || url.contains("/websocket/") || url.contains("token")){
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}else{
|
} else {
|
||||||
String log = "";
|
String log = "";
|
||||||
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
||||||
String ip = getIp(req);
|
String ip = getIp(req);
|
||||||
|
|||||||
+1
-6
@@ -440,12 +440,7 @@ public class PayMailBillServiceImpl extends ServiceImpl<PayMailBillMapper, PayMa
|
|||||||
billingInfo.setSendMethod(payMailBill.getSendMethod());
|
billingInfo.setSendMethod(payMailBill.getSendMethod());
|
||||||
billingInfo.setSendDate(payMailBill.getSendDate());
|
billingInfo.setSendDate(payMailBill.getSendDate());
|
||||||
billingInfo.setPostNo(payMailBill.getPostNo());
|
billingInfo.setPostNo(payMailBill.getPostNo());
|
||||||
Map<String, String> stringStringMap = AuthenticationUtils.encryptByRsaPriKey();
|
AuthenticationUtils.post("/billingInfo/billingInfo/postFromPayment",null,billingInfo);
|
||||||
String publicKey = stringStringMap.get("publicKey");
|
|
||||||
String token = stringStringMap.get("token");
|
|
||||||
String jsonString1 = JSONObject.toJSONString(billingInfo);
|
|
||||||
String post = HttpUtil.post(AuthenticationUtils.URL + "/billingInfo/billingInfo/postFromPayment?publicKey=" + publicKey + "&pushToken=" + token, jsonString1);
|
|
||||||
AuthenticationUtils.checkResult(post);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user