Commit ed2e8bcb authored by 赵啸非's avatar 赵啸非

回退站点业务请求列表

parent da1ac3b9
......@@ -16,5 +16,8 @@ public class MidReq{
private String path;
//1 sha加密 2 rsa加密提交
private Integer type;
}
......@@ -14,6 +14,7 @@ import com.mortals.xhx.common.utils.EncryptionUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -142,46 +143,34 @@ public class MidSignApiController {
log.info("签名源字符串: " + signStr);
String sign = EncryptionUtils.SHA256(signStr);
log.info("签名计算结果: " + sign);
headerMap.put("sign", sign);
if (ObjectUtils.isEmpty(midReq.getType()) || midReq.getType() == 2) {
//rsa提交
//todo 添加rsa非对称加密
String pwdRsa = pwd + "#" + timeStamp;
pwdRsa = EncryptionUtils.encrypt(pwdRsa, publickey);
String param = "{\"USER\":\"" + user + "\",\"PWD\":\"" + pwdRsa + "\"}";
param = Base64.encodeBase64String(param.getBytes("UTF-8"));
headerMap.put("param", param);
String request = Base64.encodeBase64String(object.toJSONString().getBytes("UTF-8"));
JSONObject reqBody = new JSONObject();
reqBody.put("request", request);
String fullUrl = midUrl + midReq.getPath();
log.info("url:{} \n body:{} \n", fullUrl, reqBody.toJSONString());
String body = HttpUtil.createRequest(Method.POST, fullUrl).headerMap(headerMap, true).body(reqBody.toJSONString()).execute().body();
JSONObject bodyJson = JSONObject.parseObject(body);
log.info("mid resp:" + bodyJson.toJSONString());
return Rest.ok(bodyJson.toJSONString());
} else {
//todo 添加rsa非对称加密
String pwdRsa = pwd + "#" + timeStamp;
pwdRsa = EncryptionUtils.encrypt(pwdRsa, publickey);
String param = "{\"USER\":\"" + user + "\",\"PWD\":\"" + pwdRsa + "\"}";
param = Base64.encodeBase64String(param.getBytes("UTF-8"));
headerMap.put("param", param);
/* String pwdRsa = pwd + "#" + timeStamp;
pwdRsa = EncryptionUtils.encrypt(pwdRsa, publickey);
String param = "{\"USER\":\"" + user + "\",\"PWD\":\"" + pwdRsa + "\"}";
param = Base64.encodeBase64String(param.getBytes("UTF-8"));
headerMap.put("param", param);
String request = Base64.encodeBase64String(object.toJSONString().getBytes("UTF-8"));
JSONObject reqBody = new JSONObject();
reqBody.put("request", request);
log.info("mid url:{},body:{}", fullUrl, reqBody.toJSONString());
headerMap.entrySet().forEach(item->{
log.info("head name:{},value:{}", item.getKey(), item.getValue());
});
*/
String request = Base64.encodeBase64String(object.toJSONString().getBytes("UTF-8"));
headerMap.entrySet().forEach(item->{
log.info("{}={} \n", item.getKey(), item.getValue());
});
JSONObject reqBody = new JSONObject();
reqBody.put("request", request);
//请求转发
String fullUrl= midUrl+midReq.getPath();
// String fullUrl = UrlBuilder.ofHttp(midUrl).addPath(midReq.getPath()).build();
//String fullUrl = URLUtil.completeUrl(midUrl, midReq.getPath());
// log.info("mid url:{},body:{}", fullUrl, headerMap.get("body"));
log.info("url:{} \n body:{} \n", fullUrl, reqBody.toJSONString());
//String body = HttpUtil.createRequest(Method.POST, fullUrl).headerMap(headerMap, true).body(headerMap.get("body")).execute().body();
String body = HttpUtil.createRequest(Method.POST, fullUrl).headerMap(headerMap, true).body(reqBody.toJSONString()).execute().body();
JSONObject bodyJson = JSONObject.parseObject(body);
log.info("mid resp:" + bodyJson.toJSONString());
return Rest.ok(bodyJson.toJSONString());
//sha加密提交
String fullUrl = midUrl + midReq.getPath();
log.info("mid url:{},body:{}", fullUrl, headerMap.get("body"));
String body = HttpUtil.createRequest(Method.POST, fullUrl).headerMap(headerMap, true).body(headerMap.get("body")).execute().body();
JSONObject bodyJson = JSONObject.parseObject(body);
log.info("mid resp:" + bodyJson.toJSONString());
return Rest.ok(bodyJson.toJSONString());
}
} catch (Exception e) {
log.error("透传请求异常", e);
return Rest.fail("透传请求异常!");
......
......@@ -6,7 +6,7 @@ Content-Type: application/json
{
"siteId": 1,
"page": 1,
"deptId": "455",
"deptId": 414,
"display": 1,
"source": 0,
"size": 10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment