Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
windows
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhanhai
windows
Commits
832c92f5
Commit
832c92f5
authored
Oct 23, 2023
by
张庆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
请求参数
parent
c534b21e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
AbcHttpClient.java
src/main/java/com/jqtx/windows/utils/AbcHttpClient.java
+19
-19
No files found.
src/main/java/com/jqtx/windows/utils/AbcHttpClient.java
View file @
832c92f5
...
...
@@ -2,6 +2,7 @@ package com.jqtx.windows.utils;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.http.Header
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpUtil
;
...
...
@@ -53,25 +54,25 @@ public class AbcHttpClient {
log
.
info
(
"请求浙农未加密数据:{}"
,
JSON
.
toJSONString
(
paramJson
));
log
.
info
(
"请求浙农加密数据:{}"
,
JSON
.
toJSONString
(
zyHttpBaseRquest
));
log
.
info
(
"请求浙农url:{}"
,
url
);
HttpResponse
response
=
HttpRequest
.
post
(
url
).
body
(
JSON
.
toJSONString
(
zyHttpBaseRquest
)).
setConnectionTimeout
(
5000
).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
url
)
.
header
(
Header
.
CONTENT_TYPE
,
"application/json;charset=UTF-8"
)
.
body
(
JSON
.
toJSONString
(
zyHttpBaseRquest
))
.
setConnectionTimeout
(
5000
).
execute
();
log
.
info
(
"请求浙农加密返回数据:{}"
,
JSON
.
toJSONString
(
response
.
body
()));
if
(
response
.
getStatus
()
==
200
&&
StringUtils
.
isNotBlank
(
response
.
body
()))
{
final
String
body
=
response
.
body
();
JSONObject
responseJson
=
JSONObject
.
parseObject
(
body
);
String
data
=
responseJson
.
getString
(
"data"
);
String
sign
=
responseJson
.
getString
(
"sign"
);
boolean
f
=
SignUtil
.
veriSign
(
data
,
sign
,
AbcRsaUtil
.
getPublicKey
(
ypdPublicKey
));
if
(
f
)
{
String
dec
=
EncryptUtil
.
decrypt
(
data
,
AbcRsaUtil
.
getPrivateKey
(
privateKey
));
log
.
info
(
"请求浙农解密返回数据:{}"
,
JSON
.
toJSONString
(
dec
));
return
JSONObject
.
parseObject
(
dec
,
ZyHttpBaseResponse
.
class
);
}
else
{
log
.
info
(
"验签异常"
);
}
String
body
=
response
.
body
();
JSONObject
responseJson
=
JSONObject
.
parseObject
(
body
);
String
data
=
responseJson
.
getString
(
"data"
);
String
sign
=
responseJson
.
getString
(
"sign"
);
boolean
f
=
SignUtil
.
veriSign
(
data
,
sign
,
AbcRsaUtil
.
getPublicKey
(
ypdPublicKey
));
if
(
f
)
{
String
dec
=
EncryptUtil
.
decrypt
(
data
,
AbcRsaUtil
.
getPrivateKey
(
privateKey
));
log
.
info
(
"请求浙农解密返回数据:{}"
,
JSON
.
toJSONString
(
dec
));
return
JSONObject
.
parseObject
(
dec
,
ZyHttpBaseResponse
.
class
);
}
else
{
throw
new
Exception
(
"请求
异常"
);
log
.
info
(
"验签
异常"
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"请求浙农异常:{}"
,
e
.
getMessage
(),
e
);
return
null
;
}
...
...
@@ -93,6 +94,7 @@ public class AbcHttpClient {
/*验签*/
boolean
f
=
SignUtil
.
veriSign
(
data
,
sign
,
AbcRsaUtil
.
getPublicKey
(
ypdPublicKey
));
if
(
f
)
{
data
=
"LbfVKZfHTWm0S6h81XLAgv8zRmUwljGCznpVln1be2oiuXH1vw00sPW2uA5iOJND0d+5KtCzT8O3xD4avg4qEHvwlUWDZ7nFCqs5y5X470MCSwyxrH1UbBGLNlrfiq8yWmz5eKcxlyjyhLy46IuVqpJlxZ8hP3yU2gObcACuT8YmiVgzPvzefomyF+YalaFf9l7kObTvmfayVfugC1vCvYDyIWlNs9BUeHpPboo8KUUMi7E7e/jIpunCSSd7fF7Sh3rziwa+170cZfE5wrkJ/m4cvHzK86kCzDrIOABbhuvTFIpaUs8SFNujV2E6YP6jxYJ2FR8IlgMS/W/B4fX7dQ=="
;
String
dec
=
EncryptUtil
.
decrypt
(
data
,
AbcRsaUtil
.
getPrivateKey
(
privateKey
));
System
.
out
.
println
(
"解密后返回数据:"
+
dec
);
}
else
{
...
...
@@ -121,10 +123,8 @@ public class AbcHttpClient {
// 请求认证头
System
.
out
.
println
(
"整理参数:"
+
JSON
.
toJSONString
(
zyHttpBaseRquest
));
System
.
out
.
println
(
"url:"
+
url
);
HashMap
<
String
,
String
>
headers
=
new
HashMap
<>();
//存放请求头,可以存放多个请求头
headers
.
put
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
HttpResponse
response
=
HttpRequest
.
post
(
url
)
.
header
(
"Content-Type"
,
"application/json;charset=UTF-8"
)
.
header
(
Header
.
CONTENT_TYPE
,
"application/json;charset=UTF-8"
)
.
body
(
JSON
.
toJSONString
(
zyHttpBaseRquest
))
.
setConnectionTimeout
(
5000
).
execute
();
System
.
out
.
println
(
"接口返回结果:"
+
response
);
...
...
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