记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
d4c7551f
Commit
d4c7551f
authored
Nov 23, 2021
by
zhengfuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改一些没有必要的log
parent
5a7178e2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
14 deletions
+15
-14
UnionpayBiz.java
...dnet/service/dragon/channel/unionpay/biz/UnionpayBiz.java
+2
-2
AcpService.java
...idnet/service/dragon/channel/unionpay/sdk/AcpService.java
+4
-3
CertUtil.java
...quidnet/service/dragon/channel/unionpay/sdk/CertUtil.java
+2
-2
HttpsUtil.java
...uidnet/service/dragon/channel/unionpay/sdk/HttpsUtil.java
+1
-1
SDKUtil.java
...iquidnet/service/dragon/channel/unionpay/sdk/SDKUtil.java
+6
-6
No files found.
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/biz/UnionpayBiz.java
View file @
d4c7551f
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
biz
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
biz
;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
...
@@ -155,12 +156,11 @@ public class UnionpayBiz {
...
@@ -155,12 +156,11 @@ public class UnionpayBiz {
Map
<
String
,
String
>
reqData
=
acpService
.
sign
(
contentData
,
UnionpayConstant
.
encoding
);
//报文中certId,signature的值是在signData方法中获取并自动赋值的,只要证书配置正确即可。
Map
<
String
,
String
>
reqData
=
acpService
.
sign
(
contentData
,
UnionpayConstant
.
encoding
);
//报文中certId,signature的值是在signData方法中获取并自动赋值的,只要证书配置正确即可。
String
requestAppUrl
=
sdkConfig
.
getAppTransUrl
();
//交易请求url从配置文件读取对应属性文件acp_sdk.properties中的 acpsdk.backTransUrl
String
requestAppUrl
=
sdkConfig
.
getAppTransUrl
();
//交易请求url从配置文件读取对应属性文件acp_sdk.properties中的 acpsdk.backTransUrl
Map
<
String
,
String
>
rspData
=
acpService
.
post
(
reqData
,
requestAppUrl
,
UnionpayConstant
.
encoding
);
//发送请求报文并接受同步应答(默认连接超时时间30秒,读取返回结果超时时间30秒);这里调用signData之后,调用submitUrl之前不能对submitFromData中的键值对做任何修改,如果修改会导致验签不通过
Map
<
String
,
String
>
rspData
=
acpService
.
post
(
reqData
,
requestAppUrl
,
UnionpayConstant
.
encoding
);
//发送请求报文并接受同步应答(默认连接超时时间30秒,读取返回结果超时时间30秒);这里调用signData之后,调用submitUrl之前不能对submitFromData中的键值对做任何修改,如果修改会导致验签不通过
log
.
info
(
"银联App支付返参{}"
,
rspData
);
//log.info("银联App支付返参{}", JSON.toJSON(rspData)
);
/**对应答码的处理,请根据您的业务逻辑来编写程序,以下应答码处理逻辑仅供参考------------->**/
/**对应答码的处理,请根据您的业务逻辑来编写程序,以下应答码处理逻辑仅供参考------------->**/
//应答码规范参考open.unionpay.com帮助中心 下载 产品接口规范 《平台接入接口规范-第5部分-附录》
//应答码规范参考open.unionpay.com帮助中心 下载 产品接口规范 《平台接入接口规范-第5部分-附录》
if
(!
rspData
.
isEmpty
()){
if
(!
rspData
.
isEmpty
()){
if
(
acpService
.
validate
(
rspData
,
UnionpayConstant
.
encoding
)){
if
(
acpService
.
validate
(
rspData
,
UnionpayConstant
.
encoding
)){
log
.
info
(
"验证签名成功"
);
String
respCode
=
rspData
.
get
(
"respCode"
)
;
String
respCode
=
rspData
.
get
(
"respCode"
)
;
if
((
"00"
).
equals
(
respCode
)){
if
((
"00"
).
equals
(
respCode
)){
//成功,获取tn号
//成功,获取tn号
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/AcpService.java
View file @
d4c7551f
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
;
import
com.alibaba.fastjson.JSON
;
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.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -162,7 +163,7 @@ public class AcpService {
...
@@ -162,7 +163,7 @@ public class AcpService {
* @return true 通过 false 未通过<br>
* @return true 通过 false 未通过<br>
*/
*/
public
boolean
validate
(
Map
<
String
,
String
>
data
,
String
encoding
)
{
public
boolean
validate
(
Map
<
String
,
String
>
data
,
String
encoding
)
{
log
.
info
(
"验签处理开始"
);
//
log.info("验签处理开始");
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
encoding
=
"UTF-8"
;
encoding
=
"UTF-8"
;
}
}
...
@@ -201,7 +202,7 @@ public class AcpService {
...
@@ -201,7 +202,7 @@ public class AcpService {
return
result
;
return
result
;
}
else
if
(
VERSION_5_1_0
.
equals
(
version
))
{
}
else
if
(
VERSION_5_1_0
.
equals
(
version
))
{
boolean
result
=
SDKUtil
.
verifyRsa2
(
data
,
verifyKey
,
encoding
);
boolean
result
=
SDKUtil
.
verifyRsa2
(
data
,
verifyKey
,
encoding
);
log
.
info
(
"验签"
+
(
result
?
"成功"
:
"失败"
)
+
"。"
);
//
log.info("验签" + (result? "成功":"失败") + "。");
return
result
;
return
result
;
}
}
}
}
...
@@ -316,7 +317,7 @@ public class AcpService {
...
@@ -316,7 +317,7 @@ public class AcpService {
return
null
;
return
null
;
}
}
Map
<
String
,
String
>
result
=
SDKUtil
.
parseRespString
(
new
String
(
respBytes
,
encoding
));
Map
<
String
,
String
>
result
=
SDKUtil
.
parseRespString
(
new
String
(
respBytes
,
encoding
));
log
.
info
(
"银联应答参数:
"
+
result
);
log
.
info
(
"银联应答参数:
{}"
,
JSON
.
toJSONString
(
result
)
);
return
result
;
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"post失败:"
+
e
.
getMessage
(),
e
);
log
.
error
(
"post失败:"
+
e
.
getMessage
(),
e
);
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/CertUtil.java
View file @
d4c7551f
...
@@ -724,7 +724,7 @@ public class CertUtil {
...
@@ -724,7 +724,7 @@ public class CertUtil {
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
PKIXCertPathBuilderResult
result
=
(
PKIXCertPathBuilderResult
)
builder
PKIXCertPathBuilderResult
result
=
(
PKIXCertPathBuilderResult
)
builder
.
build
(
pkixParams
);
.
build
(
pkixParams
);
log
.
info
(
"verify certificate chain succeed."
);
//
log.info("verify certificate chain succeed.");
return
true
;
return
true
;
}
catch
(
java
.
security
.
cert
.
CertPathBuilderException
e
){
}
catch
(
java
.
security
.
cert
.
CertPathBuilderException
e
){
log
.
error
(
"verify certificate chain fail."
,
e
);
log
.
error
(
"verify certificate chain fail."
,
e
);
...
@@ -754,7 +754,7 @@ public class CertUtil {
...
@@ -754,7 +754,7 @@ public class CertUtil {
log
.
error
(
"验证公钥证书失败,证书信息:["
+
x509CertString
+
"]"
);
log
.
error
(
"验证公钥证书失败,证书信息:["
+
x509CertString
+
"]"
);
return
null
;
return
null
;
}
}
log
.
info
(
"验证公钥验证成功:["
+
x509Cert
.
getSerialNumber
().
toString
(
10
)
+
"]"
);
//
log.info("验证公钥验证成功:[" + x509Cert.getSerialNumber().toString(10) + "]");
PublicKey
publicKey
=
x509Cert
.
getPublicKey
();
PublicKey
publicKey
=
x509Cert
.
getPublicKey
();
verifyCerts510
.
put
(
x509CertString
,
publicKey
);
verifyCerts510
.
put
(
x509CertString
,
publicKey
);
return
publicKey
;
return
publicKey
;
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/HttpsUtil.java
View file @
d4c7551f
...
@@ -215,7 +215,7 @@ public class HttpsUtil {
...
@@ -215,7 +215,7 @@ public class HttpsUtil {
sslContext
.
init
(
keyManagers
,
trustManagers
,
SecureRandom
.
getInstance
(
"SHA1PRNG"
));
sslContext
.
init
(
keyManagers
,
trustManagers
,
SecureRandom
.
getInstance
(
"SHA1PRNG"
));
ssLSocketFactoryMap
.
put
(
tag
,
sslContext
.
getSocketFactory
());
ssLSocketFactoryMap
.
put
(
tag
,
sslContext
.
getSocketFactory
());
ifVerifyHostnameMap
.
put
(
tag
,
verifyHostname
);
ifVerifyHostnameMap
.
put
(
tag
,
verifyHostname
);
log
.
info
(
"addSslConf succeed: ["
+
tag
+
"]"
+
(
tmf
==
null
?
",但没验服务器证书哦"
:
""
)
+
"。"
);
//
log.info("addSslConf succeed: [" + tag + "]" + (tmf == null ? ",但没验服务器证书哦" : "") + "。");
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"addSslConf fail. "
,
e
);
log
.
error
(
"addSslConf fail. "
,
e
);
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/SDKUtil.java
View file @
d4c7551f
...
@@ -90,10 +90,10 @@ public class SDKUtil {
...
@@ -90,10 +90,10 @@ public class SDKUtil {
public
String
signRsa2
(
Map
<
String
,
String
>
data
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
public
String
signRsa2
(
Map
<
String
,
String
>
data
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
try
{
try
{
String
stringData
=
createLinkString
(
data
,
true
,
false
,
encoding
);
String
stringData
=
createLinkString
(
data
,
true
,
false
,
encoding
);
log
.
info
(
"打印排序后待签名请求报文串(交易返回11验证签名失败时可以用来同正确的进行比对):["
+
stringData
+
"]"
);
//
log.info("打印排序后待签名请求报文串(交易返回11验证签名失败时可以用来同正确的进行比对):[" + stringData + "]");
byte
[]
sha256
=
SecureUtil
.
sha256
(
stringData
.
getBytes
(
encoding
));
byte
[]
sha256
=
SecureUtil
.
sha256
(
stringData
.
getBytes
(
encoding
));
String
sha256Hex
=
byteArrayToHexString
(
sha256
).
toLowerCase
();
String
sha256Hex
=
byteArrayToHexString
(
sha256
).
toLowerCase
();
log
.
info
(
"sha256(交易返回11验证签名失败可以用来同正确的进行比对):["
+
sha256Hex
+
"]"
);
//
log.info("sha256(交易返回11验证签名失败可以用来同正确的进行比对):[" + sha256Hex + "]");
return
Base64
.
encodeBase64String
(
SecureUtil
.
getSignatureSHA256
(
certUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
sha256Hex
.
getBytes
()));
return
Base64
.
encodeBase64String
(
SecureUtil
.
getSignatureSHA256
(
certUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
sha256Hex
.
getBytes
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"calcSignRsa2 Error"
,
e
);
log
.
error
(
"calcSignRsa2 Error"
,
e
);
...
@@ -190,16 +190,16 @@ public class SDKUtil {
...
@@ -190,16 +190,16 @@ public class SDKUtil {
log
.
error
(
"signature is null. verifyRsa2 fail."
);
log
.
error
(
"signature is null. verifyRsa2 fail."
);
return
false
;
return
false
;
}
}
log
.
info
(
"签名原文:["
+
stringSign
+
"]"
);
//
log.info("签名原文:[" + stringSign + "]");
String
stringData
=
createLinkString
(
resData
,
true
,
false
,
encoding
);
String
stringData
=
createLinkString
(
resData
,
true
,
false
,
encoding
);
log
.
info
(
"待验签排序串:["
+
stringData
+
"]"
);
//
log.info("待验签排序串:[" + stringData + "]");
byte
[]
sha256
=
SecureUtil
.
sha256
(
stringData
.
getBytes
(
encoding
));
byte
[]
sha256
=
SecureUtil
.
sha256
(
stringData
.
getBytes
(
encoding
));
String
sha256Hex
=
byteArrayToHexString
(
sha256
).
toLowerCase
();
String
sha256Hex
=
byteArrayToHexString
(
sha256
).
toLowerCase
();
log
.
info
(
"sha256结果:["
+
sha256Hex
+
"]"
);
//
log.info("sha256结果:[" + sha256Hex + "]");
boolean
result
=
SecureUtil
.
verifySignatureSHA256
(
publicKey
,
boolean
result
=
SecureUtil
.
verifySignatureSHA256
(
publicKey
,
sha256Hex
.
getBytes
(
encoding
),
sha256Hex
.
getBytes
(
encoding
),
Base64
.
decodeBase64
(
stringSign
));
Base64
.
decodeBase64
(
stringSign
));
log
.
info
(
"验证签名"
+
(
result
?
"成功"
:
"失败"
));
//
log.info("验证签名" + (result ? "成功" : "失败"));
return
result
;
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"verifyRsa2 fail."
+
e
.
getMessage
(),
e
);
log
.
error
(
"verifyRsa2 fail."
+
e
.
getMessage
(),
e
);
...
...
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