Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
Project
Project
Details
Activity
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
曲欣亮
common
Commits
ef03daf5
Commit
ef03daf5
authored
Feb 13, 2020
by
Quxl
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://key@gitlab.linkfern.com/key/common.git
parents
6d0b78f0
296878ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
HttpsUtil.java
src/main/java/com/egolm/common/HttpsUtil.java
+8
-2
MD5Util.java
src/main/java/com/egolm/common/MD5Util.java
+7
-8
No files found.
src/main/java/com/egolm/common/HttpsUtil.java
View file @
ef03daf5
...
...
@@ -123,7 +123,9 @@ public class HttpsUtil {
requestUrl
=
requestUrl
+
(
requestUrl
.
contains
(
"?"
)
?
(
requestUrl
.
endsWith
(
"&"
)
?
""
:
"&"
)
:
"?"
)
+
requestBody
;
URL
GET_URL
=
new
URL
(
requestUrl
);
connection
=
(
HttpsURLConnection
)
(
proxy
==
null
?
GET_URL
.
openConnection
()
:
GET_URL
.
openConnection
(
proxy
));
connection
.
setSSLSocketFactory
(
sslSocketFactory
);
if
(
sslSocketFactory
!=
null
)
{
connection
.
setSSLSocketFactory
(
sslSocketFactory
);
}
connection
.
setRequestMethod
(
"GET"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"utf-8"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
...
...
@@ -142,6 +144,7 @@ public class HttpsUtil {
}
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
Object
>
parameters
,
Map
<
String
,
String
>
headers
,
SSLSocketFactory
sslSocketFactory
,
Proxy
proxy
)
throws
HttpRequestException
{
System
.
out
.
println
(
"----"
+
HttpUtil
.
toQueryString
(
parameters
));
return
HttpsUtil
.
post
(
requestUrl
,
HttpUtil
.
toQueryString
(
parameters
),
headers
,
sslSocketFactory
,
proxy
);
}
...
...
@@ -151,7 +154,10 @@ public class HttpsUtil {
byte
[]
bytes
=
text
==
null
?
new
byte
[
0
]
:
text
.
getBytes
();
URL
POST_URL
=
new
URL
(
requestUrl
);
connection
=
(
HttpsURLConnection
)
(
proxy
==
null
?
POST_URL
.
openConnection
()
:
POST_URL
.
openConnection
(
proxy
));
connection
.
setSSLSocketFactory
(
sslSocketFactory
);
if
(
sslSocketFactory
!=
null
)
{
connection
.
setSSLSocketFactory
(
sslSocketFactory
);
}
connection
.
setDoOutput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setRequestMethod
(
"POST"
);
...
...
src/main/java/com/egolm/common/MD5Util.java
View file @
ef03daf5
...
...
@@ -25,8 +25,7 @@ public class MD5Util {
Entry
<?,
?>
entry
=
(
Entry
<?,
?>)
it
.
next
();
String
k
=
(
String
)
entry
.
getKey
();
Object
v
=
entry
.
getValue
();
if
(
null
!=
v
&&
!
""
.
equals
(
v
)&&
!
"sign"
.
equals
(
k
)
)
{
System
.
out
.
println
(
k
+
"---"
+
v
);
if
(
null
!=
v
&&
!
""
.
equals
(
v
)&&
!
"sign"
.
equals
(
k
)
)
{
sb
.
append
(
k
+
"="
+
v
+
"&"
);
}
}
...
...
@@ -78,12 +77,12 @@ public class MD5Util {
SortedMap
<
Object
,
Object
>
parameters
=
new
TreeMap
<
Object
,
Object
>
();
parameters
.
put
(
"AppID"
,
"
E34EAAAFCC714ABA
"
);
parameters
.
put
(
"AppKey"
,
"
F7FC3382E34EAAAFCC714ABA172FD00C
"
);
parameters
.
put
(
"
LangID"
,
"936"
);
parameters
.
put
(
"Server
ID"
,
"Scan_CheckMemPointCoupon"
);
parameters
.
put
(
"
ServerTypeID"
,
1
);
parameters
.
put
(
"
timestamp"
,
"1560474936524
"
);
parameters
.
put
(
"AppID"
,
"
201909230001
"
);
parameters
.
put
(
"AppKey"
,
"
d0dd209596922ae29630ded8ba46f15f
"
);
parameters
.
put
(
"
ServerID"
,
"ThirdAgentOnStockAdd"
);
parameters
.
put
(
"Server
TypeID"
,
3
);
parameters
.
put
(
"
timestamp"
,
"1569310600084"
);
parameters
.
put
(
"
data"
,
"{\"dataList_0\": [{\"AgentContractNO\": \"600022001\",\"AgentID\": 22,\"WarehouseNO\": \"002\"}],\"dataList_1\": [{\"AgentContractNO\": \"600022001\",\"GoodsID\": 22,\"StockQty\": \"002\",\"CostPrice\":0 },{\"AgentContractNO\": \"600022001\",\"GoodsID\": 22,\"StockQty\": \"002\",\"CostPrice\":0}]}
"
);
System
.
out
.
println
(
parameters
);
String
createSign
=
MD5Util
.
createSign
(
"UTF-8"
,
parameters
);
System
.
out
.
println
(
createSign
);
...
...
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