Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
ed2e8bcb
Commit
ed2e8bcb
authored
May 09, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
回退站点业务请求列表
parent
da1ac3b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
39 deletions
+31
-39
base-manager/src/main/java/com/mortals/xhx/busiz/req/MidReq.java
...nager/src/main/java/com/mortals/xhx/busiz/req/MidReq.java
+3
-0
base-manager/src/main/java/com/mortals/xhx/busiz/web/MidSignApiController.java
.../java/com/mortals/xhx/busiz/web/MidSignApiController.java
+27
-38
base-manager/src/test/java/com/mortals/httpclient/site/SiteMatterController.http
...ava/com/mortals/httpclient/site/SiteMatterController.http
+1
-1
No files found.
base-manager/src/main/java/com/mortals/xhx/busiz/req/MidReq.java
View file @
ed2e8bcb
...
@@ -16,5 +16,8 @@ public class MidReq{
...
@@ -16,5 +16,8 @@ public class MidReq{
private
String
path
;
private
String
path
;
//1 sha加密 2 rsa加密提交
private
Integer
type
;
}
}
base-manager/src/main/java/com/mortals/xhx/busiz/web/MidSignApiController.java
View file @
ed2e8bcb
...
@@ -14,6 +14,7 @@ import com.mortals.xhx.common.utils.EncryptionUtils;
...
@@ -14,6 +14,7 @@ import com.mortals.xhx.common.utils.EncryptionUtils;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Base64
;
import
org.springframework.beans.factory.annotation.Value
;
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.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -142,46 +143,34 @@ public class MidSignApiController {
...
@@ -142,46 +143,34 @@ public class MidSignApiController {
log
.
info
(
"签名源字符串: "
+
signStr
);
log
.
info
(
"签名源字符串: "
+
signStr
);
String
sign
=
EncryptionUtils
.
SHA256
(
signStr
);
String
sign
=
EncryptionUtils
.
SHA256
(
signStr
);
log
.
info
(
"签名计算结果: "
+
sign
);
log
.
info
(
"签名计算结果: "
+
sign
);
headerMap
.
put
(
"sign"
,
sign
);
headerMap
.
put
(
"sign"
,
sign
);
if
(
ObjectUtils
.
isEmpty
(
midReq
.
getType
())
||
midReq
.
getType
()
==
2
)
{
//rsa提交
//todo 添加rsa非对称加密
//todo 添加rsa非对称加密
String
pwdRsa
=
pwd
+
"#"
+
timeStamp
;
String
pwdRsa
=
pwd
+
"#"
+
timeStamp
;
pwdRsa
=
EncryptionUtils
.
encrypt
(
pwdRsa
,
publickey
);
pwdRsa
=
EncryptionUtils
.
encrypt
(
pwdRsa
,
publickey
);
String
param
=
"{\"USER\":\""
+
user
+
"\",\"PWD\":\""
+
pwdRsa
+
"\"}"
;
String
param
=
"{\"USER\":\""
+
user
+
"\",\"PWD\":\""
+
pwdRsa
+
"\"}"
;
param
=
Base64
.
encodeBase64String
(
param
.
getBytes
(
"UTF-8"
));
param
=
Base64
.
encodeBase64String
(
param
.
getBytes
(
"UTF-8"
));
headerMap
.
put
(
"param"
,
param
);
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"
));
String
request
=
Base64
.
encodeBase64String
(
object
.
toJSONString
().
getBytes
(
"UTF-8"
));
JSONObject
reqBody
=
new
JSONObject
();
JSONObject
reqBody
=
new
JSONObject
();
reqBody
.
put
(
"request"
,
request
);
reqBody
.
put
(
"request"
,
request
);
log.info("mid url:{},body:{}", fullUrl, reqBody.toJSONString());
String
fullUrl
=
midUrl
+
midReq
.
getPath
();
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
());
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
();
String
body
=
HttpUtil
.
createRequest
(
Method
.
POST
,
fullUrl
).
headerMap
(
headerMap
,
true
).
body
(
reqBody
.
toJSONString
()).
execute
().
body
();
JSONObject
bodyJson
=
JSONObject
.
parseObject
(
body
);
JSONObject
bodyJson
=
JSONObject
.
parseObject
(
body
);
log
.
info
(
"mid resp:"
+
bodyJson
.
toJSONString
());
log
.
info
(
"mid resp:"
+
bodyJson
.
toJSONString
());
return
Rest
.
ok
(
bodyJson
.
toJSONString
());
}
else
{
//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
());
return
Rest
.
ok
(
bodyJson
.
toJSONString
());
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"透传请求异常"
,
e
);
log
.
error
(
"透传请求异常"
,
e
);
return
Rest
.
fail
(
"透传请求异常!"
);
return
Rest
.
fail
(
"透传请求异常!"
);
...
...
base-manager/src/test/java/com/mortals/httpclient/site/SiteMatterController.http
View file @
ed2e8bcb
...
@@ -6,7 +6,7 @@ Content-Type: application/json
...
@@ -6,7 +6,7 @@ Content-Type: application/json
{
{
"siteId": 1,
"siteId": 1,
"page": 1,
"page": 1,
"deptId":
"455"
,
"deptId":
414
,
"display": 1,
"display": 1,
"source": 0,
"source": 0,
"size": 10
"size": 10
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment