记得上下班打卡 | 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
cb347737
Commit
cb347737
authored
Nov 09, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交unionpay代码
parent
97b35e40
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
369 additions
and
826 deletions
+369
-826
ServiceDragonApplication.java
.../java/com/liquidnet/service/ServiceDragonApplication.java
+3
-0
Acp6Service.java
...dnet/service/dragon/channel/unionpay/sdk/Acp6Service.java
+56
-46
AcpService.java
...idnet/service/dragon/channel/unionpay/sdk/AcpService.java
+89
-82
CertUtil.java
...quidnet/service/dragon/channel/unionpay/sdk/CertUtil.java
+109
-106
QrcService.java
...idnet/service/dragon/channel/unionpay/sdk/QrcService.java
+32
-25
SDKConfig.java
...uidnet/service/dragon/channel/unionpay/sdk/SDKConfig.java
+9
-536
SDKUtil.java
...iquidnet/service/dragon/channel/unionpay/sdk/SDKUtil.java
+21
-17
SecureUtil.java
...idnet/service/dragon/channel/unionpay/sdk/SecureUtil.java
+14
-14
TestSdkConfig.java
...pl/src/test/java/com/liquidnet/service/TestSdkConfig.java
+36
-0
No files found.
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/ServiceDragonApplication.java
View file @
cb347737
...
@@ -4,7 +4,9 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -4,7 +4,9 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
...
@@ -12,6 +14,7 @@ import java.util.Arrays;
...
@@ -12,6 +14,7 @@ import java.util.Arrays;
@Slf4j
@Slf4j
@SpringBootApplication
(
scanBasePackages
=
{
"com.liquidnet"
})
@SpringBootApplication
(
scanBasePackages
=
{
"com.liquidnet"
})
@EnableConfigurationProperties
public
class
ServiceDragonApplication
implements
CommandLineRunner
{
public
class
ServiceDragonApplication
implements
CommandLineRunner
{
@Autowired
@Autowired
private
Environment
environment
;
private
Environment
environment
;
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/Acp6Service.java
View file @
cb347737
...
@@ -2,6 +2,7 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
...
@@ -2,6 +2,7 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
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
java.io.IOException
;
import
java.io.IOException
;
import
java.security.PublicKey
;
import
java.security.PublicKey
;
...
@@ -15,6 +16,15 @@ import java.util.Map;
...
@@ -15,6 +16,15 @@ import java.util.Map;
*/
*/
@Slf4j
@Slf4j
public
class
Acp6Service
{
public
class
Acp6Service
{
@Autowired
private
SDKConfig
sdkConfig
;
@Autowired
private
CertUtil
certUtil
;
@Autowired
private
SDKUtil
sdkUtil
;
/**
/**
* 请求报文签名(使用配置文件中配置的私钥证书或者对称密钥签名)<br>
* 请求报文签名(使用配置文件中配置的私钥证书或者对称密钥签名)<br>
* 功能:对请求报文进行签名,并计算赋值certid,signature字段并返回<br>
* 功能:对请求报文进行签名,并计算赋值certid,signature字段并返回<br>
...
@@ -22,8 +32,8 @@ public class Acp6Service {
...
@@ -22,8 +32,8 @@ public class Acp6Service {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return 签名后的map对象<br>
* @return 签名后的map对象<br>
*/
*/
public
static
Map
<
String
,
String
>
sign
(
Map
<
String
,
String
>
reqData
,
String
encoding
)
{
public
Map
<
String
,
String
>
sign
(
Map
<
String
,
String
>
reqData
,
String
encoding
)
{
return
signByCertInfo
(
reqData
,
SDKConfig
.
getConfig
().
getSignCertPath
(),
SDKConfig
.
getConfig
()
.
getSignCertPwd
(),
encoding
);
return
signByCertInfo
(
reqData
,
sdkConfig
.
getSignCertPath
(),
sdkConfig
.
getSignCertPwd
(),
encoding
);
}
}
/**
/**
...
@@ -35,7 +45,7 @@ public class Acp6Service {
...
@@ -35,7 +45,7 @@ public class Acp6Service {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return 签名后的map对象<br>
* @return 签名后的map对象<br>
*/
*/
public
static
Map
<
String
,
String
>
signByCertInfo
(
Map
<
String
,
String
>
reqData
,
String
certPath
,
public
Map
<
String
,
String
>
signByCertInfo
(
Map
<
String
,
String
>
reqData
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
String
certPwd
,
String
encoding
)
{
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
...
@@ -50,8 +60,8 @@ public class Acp6Service {
...
@@ -50,8 +60,8 @@ public class Acp6Service {
}
}
try
{
try
{
data
.
put
(
SDKConstants
.
param_certId
,
C
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_certId
,
c
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_signature
,
SDK
Util
.
signRsa2
(
data
,
certPath
,
certPwd
,
encoding
));
data
.
put
(
SDKConstants
.
param_signature
,
sdk
Util
.
signRsa2
(
data
,
certPath
,
certPwd
,
encoding
));
return
data
;
return
data
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Sign Error"
,
e
);
log
.
error
(
"Sign Error"
,
e
);
...
@@ -65,7 +75,7 @@ public class Acp6Service {
...
@@ -65,7 +75,7 @@ public class Acp6Service {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return true 通过 false 未通过<br>
* @return true 通过 false 未通过<br>
*/
*/
public
static
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"
;
...
@@ -73,7 +83,7 @@ public class Acp6Service {
...
@@ -73,7 +83,7 @@ public class Acp6Service {
String
certId
=
data
.
get
(
SDKConstants
.
param_certId
);
String
certId
=
data
.
get
(
SDKConstants
.
param_certId
);
log
.
info
(
"对返回报文串验签使用的验签公钥序列号:["
+
certId
+
"]"
);
log
.
info
(
"对返回报文串验签使用的验签公钥序列号:["
+
certId
+
"]"
);
PublicKey
verifyKey
=
C
ertUtil
.
getValidatePublicKey
(
certId
);
PublicKey
verifyKey
=
c
ertUtil
.
getValidatePublicKey
(
certId
);
if
(
verifyKey
==
null
)
{
if
(
verifyKey
==
null
)
{
log
.
error
(
"未找到此序列号证书。"
);
log
.
error
(
"未找到此序列号证书。"
);
return
false
;
return
false
;
...
@@ -94,8 +104,8 @@ public class Acp6Service {
...
@@ -94,8 +104,8 @@ public class Acp6Service {
* 更新成功则返回1,无更新返回0,失败异常返回-1<br>
* 更新成功则返回1,无更新返回0,失败异常返回-1<br>
* @return
* @return
*/
*/
public
static
int
updateEncryptCert
(
String
strCert
,
String
certType
)
{
public
int
updateEncryptCert
(
String
strCert
,
String
certType
)
{
return
SDK
Util
.
updateEncryptCert
(
strCert
,
certType
);
return
sdk
Util
.
updateEncryptCert
(
strCert
,
certType
);
}
}
/**
/**
...
@@ -105,9 +115,9 @@ public class Acp6Service {
...
@@ -105,9 +115,9 @@ public class Acp6Service {
* @param encoding<br>
* @param encoding<br>
* @return 加密的内容<br>
* @return 加密的内容<br>
*/
*/
public
static
String
encryptPin
(
String
accNo
,
String
pin
,
String
encoding
)
{
public
String
encryptPin
(
String
accNo
,
String
pin
,
String
encoding
)
{
byte
[]
pinblock
=
SecureUtil
.
pinblock
(
accNo
,
pin
);
byte
[]
pinblock
=
SecureUtil
.
pinblock
(
accNo
,
pin
);
return
Base64
.
encodeBase64String
(
SecureUtil
.
encrypt
(
C
ertUtil
.
getPinEncryptCert
().
pubKey
,
pinblock
));
return
Base64
.
encodeBase64String
(
SecureUtil
.
encrypt
(
c
ertUtil
.
getPinEncryptCert
().
pubKey
,
pinblock
));
}
}
// /**
// /**
...
@@ -117,7 +127,7 @@ public class Acp6Service {
...
@@ -117,7 +127,7 @@ public class Acp6Service {
// * @param encoding<br>
// * @param encoding<br>
// * @return 加密的内容<br>
// * @return 加密的内容<br>
// */
// */
// public
static
String encryptPin(String pin, String encoding) {
// public String encryptPin(String pin, String encoding) {
// byte[] pinblock = SecureUtil.pinblock(pin);
// byte[] pinblock = SecureUtil.pinblock(pin);
// return Base64.encodeBase64String(SecureUtil.encrypt(CertUtil.getPinEncryptCert().pubKey, pinblock));
// return Base64.encodeBase64String(SecureUtil.encrypt(CertUtil.getPinEncryptCert().pubKey, pinblock));
// }
// }
...
@@ -128,8 +138,8 @@ public class Acp6Service {
...
@@ -128,8 +138,8 @@ public class Acp6Service {
* @param encoding<br>
* @param encoding<br>
* @return 加密的密文<br>
* @return 加密的密文<br>
*/
*/
public
static
String
encryptData
(
String
data
,
String
encoding
)
{
public
String
encryptData
(
String
data
,
String
encoding
)
{
return
AcpService
.
encryptData
(
data
,
encoding
);
return
this
.
encryptData
(
data
,
encoding
);
}
}
...
@@ -137,9 +147,9 @@ public class Acp6Service {
...
@@ -137,9 +147,9 @@ public class Acp6Service {
* @param data 明文<br>
* @param data 明文<br>
* @return 加密的密文<br>
* @return 加密的密文<br>
*/
*/
public
static
String
encryptData
(
byte
[]
data
)
{
public
String
encryptData
(
byte
[]
data
)
{
try
{
try
{
return
Base64
.
encodeBase64String
(
SecureUtil
.
encrypt
(
C
ertUtil
.
getEncryptCert
().
pubKey
,
data
));
return
Base64
.
encodeBase64String
(
SecureUtil
.
encrypt
(
c
ertUtil
.
getEncryptCert
().
pubKey
,
data
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
return
null
;
...
@@ -151,7 +161,7 @@ public class Acp6Service {
...
@@ -151,7 +161,7 @@ public class Acp6Service {
* @param data 明文<br>
* @param data 明文<br>
* @return 加密的密文<br>
* @return 加密的密文<br>
*/
*/
public
static
String
tripleDesEncryptECBPKCS5Padding
(
byte
[]
key
,
byte
[]
data
)
{
public
String
tripleDesEncryptECBPKCS5Padding
(
byte
[]
key
,
byte
[]
data
)
{
try
{
try
{
return
Base64
.
encodeBase64String
(
SecureUtil
.
tripleDesEncryptECBPKCS5Padding
(
key
,
SecureUtil
.
rightPadZero
(
data
,
8
)));
return
Base64
.
encodeBase64String
(
SecureUtil
.
tripleDesEncryptECBPKCS5Padding
(
key
,
SecureUtil
.
rightPadZero
(
data
,
8
)));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -166,8 +176,8 @@ public class Acp6Service {
...
@@ -166,8 +176,8 @@ public class Acp6Service {
* @param encoding<br>
* @param encoding<br>
* @return 解密后的明文<br>
* @return 解密后的明文<br>
*/
*/
public
static
String
decryptData
(
String
base64EncryptedInfo
,
String
encoding
)
{
public
String
decryptData
(
String
base64EncryptedInfo
,
String
encoding
)
{
return
AcpService
.
decryptData
(
base64EncryptedInfo
,
encoding
);
return
this
.
decryptData
(
base64EncryptedInfo
,
encoding
);
}
}
/**
/**
...
@@ -178,25 +188,25 @@ public class Acp6Service {
...
@@ -178,25 +188,25 @@ public class Acp6Service {
* @param encoding<br>
* @param encoding<br>
* @return
* @return
*/
*/
public
static
String
decryptData
(
String
base64EncryptedInfo
,
String
certPath
,
public
String
decryptData
(
String
base64EncryptedInfo
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
String
certPwd
,
String
encoding
)
{
return
AcpService
.
decryptData
(
base64EncryptedInfo
,
certPath
,
certPwd
,
encoding
);
return
this
.
decryptData
(
base64EncryptedInfo
,
certPath
,
certPwd
,
encoding
);
}
}
/**
/**
* 获取敏感信息加密证书的物理序列号<br>
* 获取敏感信息加密证书的物理序列号<br>
* @return
* @return
*/
*/
public
static
String
getEncryptCertId
(){
public
String
getEncryptCertId
(){
return
C
ertUtil
.
getEncryptCert
().
certId
;
return
c
ertUtil
.
getEncryptCert
().
certId
;
}
}
/**
/**
* 获取敏感信息加密证书的物理序列号<br>
* 获取敏感信息加密证书的物理序列号<br>
* @return
* @return
*/
*/
public
static
String
getPinEncryptCertId
(){
public
String
getPinEncryptCertId
(){
return
C
ertUtil
.
getPinEncryptCert
().
certId
;
return
c
ertUtil
.
getPinEncryptCert
().
certId
;
}
}
...
@@ -207,13 +217,13 @@ public class Acp6Service {
...
@@ -207,13 +217,13 @@ public class Acp6Service {
* @param encoding<br>
* @param encoding<br>
* @return 应答http 200返回true ,其他false<br>
* @return 应答http 200返回true ,其他false<br>
*/
*/
public
static
Map
<
String
,
String
>
post
(
Map
<
String
,
String
>
reqData
,
String
reqUrl
,
String
encoding
)
{
public
Map
<
String
,
String
>
post
(
Map
<
String
,
String
>
reqData
,
String
reqUrl
,
String
encoding
)
{
if
(
reqData
==
null
||
reqUrl
==
null
)
{
if
(
reqData
==
null
||
reqUrl
==
null
)
{
log
.
error
(
"null input"
);
log
.
error
(
"null input"
);
return
null
;
return
null
;
}
}
log
.
info
(
"请求银联地址:"
+
reqUrl
+
",请求参数:"
+
reqData
.
toString
());
log
.
info
(
"请求银联地址:"
+
reqUrl
+
",请求参数:"
+
reqData
.
toString
());
if
(
reqUrl
.
startsWith
(
"https://"
)
&&
!
SDKConfig
.
getConfig
()
.
isIfValidateRemoteCert
())
{
if
(
reqUrl
.
startsWith
(
"https://"
)
&&
!
sdkConfig
.
isIfValidateRemoteCert
())
{
reqUrl
=
"u"
+
reqUrl
;
reqUrl
=
"u"
+
reqUrl
;
}
}
try
{
try
{
...
@@ -238,13 +248,13 @@ public class Acp6Service {
...
@@ -238,13 +248,13 @@ public class Acp6Service {
* @param encoding<br>
* @param encoding<br>
* @return 应答http 200返回true ,其他false<br>
* @return 应答http 200返回true ,其他false<br>
*/
*/
public
static
String
postNotice
(
Map
<
String
,
String
>
reqData
,
String
reqUrl
,
String
encoding
)
{
public
String
postNotice
(
Map
<
String
,
String
>
reqData
,
String
reqUrl
,
String
encoding
)
{
if
(
reqData
==
null
||
reqUrl
==
null
)
{
if
(
reqData
==
null
||
reqUrl
==
null
)
{
log
.
error
(
"null input"
);
log
.
error
(
"null input"
);
return
null
;
return
null
;
}
}
log
.
info
(
"请求银联地址:"
+
reqUrl
+
",请求参数:"
+
reqData
.
toString
());
log
.
info
(
"请求银联地址:"
+
reqUrl
+
",请求参数:"
+
reqData
.
toString
());
if
(
reqUrl
.
startsWith
(
"https://"
)
&&
!
SDKConfig
.
getConfig
()
.
isIfValidateRemoteCert
())
{
if
(
reqUrl
.
startsWith
(
"https://"
)
&&
!
sdkConfig
.
isIfValidateRemoteCert
())
{
reqUrl
=
"u"
+
reqUrl
;
reqUrl
=
"u"
+
reqUrl
;
}
}
try
{
try
{
...
@@ -269,7 +279,7 @@ public class Acp6Service {
...
@@ -269,7 +279,7 @@ public class Acp6Service {
* @return<br>
* @return<br>
* @throws IOException
* @throws IOException
*/
*/
public
static
String
base64Encode
(
String
rawStr
,
String
encoding
){
public
String
base64Encode
(
String
rawStr
,
String
encoding
){
return
AcpService
.
base64Encode
(
rawStr
,
encoding
);
return
AcpService
.
base64Encode
(
rawStr
,
encoding
);
}
}
...
@@ -280,7 +290,7 @@ public class Acp6Service {
...
@@ -280,7 +290,7 @@ public class Acp6Service {
* @return<br>
* @return<br>
* @throws IOException
* @throws IOException
*/
*/
public
static
String
base64Decode
(
String
base64Str
,
String
encoding
){
public
String
base64Decode
(
String
base64Str
,
String
encoding
){
return
AcpService
.
base64Decode
(
base64Str
,
encoding
);
return
AcpService
.
base64Decode
(
base64Str
,
encoding
);
}
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/AcpService.java
View file @
cb347737
...
@@ -2,6 +2,8 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
...
@@ -2,6 +2,8 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
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.stereotype.Component
;
import
java.io.*
;
import
java.io.*
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
...
@@ -18,11 +20,16 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants.*;
...
@@ -18,11 +20,16 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants.*;
/**
/**
* @ClassName AcpService
* @ClassName AcpService
* @Description acpsdk接口服务类,接入商户集成请可以直接参考使用本类中的方法
* @Description acpsdk接口服务类,接入商户集成请可以直接参考使用本类中的方法
* @date 20
16-7-22
下午2:44:37
* @date 20
21-11-09
下午2:44:37
*/
*/
@Slf4j
@Slf4j
@Component
public
class
AcpService
{
public
class
AcpService
{
@Autowired
private
SDKConfig
sdkConfig
;
@Autowired
private
CertUtil
certUtil
;
/**
/**
* 请求报文签名(使用配置文件中配置的私钥证书或者对称密钥签名)<br>
* 请求报文签名(使用配置文件中配置的私钥证书或者对称密钥签名)<br>
* 功能:对请求报文进行签名,并计算赋值certid,signature字段并返回<br>
* 功能:对请求报文进行签名,并计算赋值certid,signature字段并返回<br>
...
@@ -30,7 +37,7 @@ public class AcpService {
...
@@ -30,7 +37,7 @@ public class AcpService {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return 签名后的map对象<br>
* @return 签名后的map对象<br>
*/
*/
public
static
Map
<
String
,
String
>
sign
(
Map
<
String
,
String
>
reqData
,
String
encoding
)
{
public
Map
<
String
,
String
>
sign
(
Map
<
String
,
String
>
reqData
,
String
encoding
)
{
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
...
@@ -45,11 +52,11 @@ public class AcpService {
...
@@ -45,11 +52,11 @@ public class AcpService {
try
{
try
{
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
return
signByCertInfo
(
data
,
SDKConfig
.
getConfig
().
getSignCertPath
(),
SDKConfig
.
getConfig
()
.
getSignCertPwd
(),
encoding
);
return
signByCertInfo
(
data
,
sdkConfig
.
getSignCertPath
(),
sdkConfig
.
getSignCertPwd
(),
encoding
);
}
else
if
(
SIGNMETHOD_SHA256
.
equals
(
signMethod
))
{
}
else
if
(
SIGNMETHOD_SHA256
.
equals
(
signMethod
))
{
return
signBySecureKey
(
data
,
SDKConfig
.
getConfig
()
.
getSecureKey
(),
encoding
);
return
signBySecureKey
(
data
,
sdkConfig
.
getSecureKey
(),
encoding
);
}
else
if
(
SIGNMETHOD_SM3
.
equals
(
signMethod
))
{
}
else
if
(
SIGNMETHOD_SM3
.
equals
(
signMethod
))
{
return
signBySecureKey
(
data
,
SDKConfig
.
getConfig
()
.
getSecureKey
(),
encoding
);
return
signBySecureKey
(
data
,
sdkConfig
.
getSecureKey
(),
encoding
);
}
}
log
.
error
(
"未实现签名方法, version="
+
version
+
", signMethod="
+
signMethod
);
log
.
error
(
"未实现签名方法, version="
+
version
+
", signMethod="
+
signMethod
);
return
data
;
return
data
;
...
@@ -68,7 +75,7 @@ public class AcpService {
...
@@ -68,7 +75,7 @@ public class AcpService {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return 签名后的map对象<br>
* @return 签名后的map对象<br>
*/
*/
public
static
Map
<
String
,
String
>
signByCertInfo
(
Map
<
String
,
String
>
reqData
,
String
certPath
,
public
Map
<
String
,
String
>
signByCertInfo
(
Map
<
String
,
String
>
reqData
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
String
certPwd
,
String
encoding
)
{
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
...
@@ -88,13 +95,13 @@ public class AcpService {
...
@@ -88,13 +95,13 @@ public class AcpService {
try
{
try
{
if
(
VERSION_5_0_1
.
equals
(
version
)
||
VERSION_5_0_0
.
equals
(
version
)){
if
(
VERSION_5_0_1
.
equals
(
version
)
||
VERSION_5_0_0
.
equals
(
version
)){
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
data
.
put
(
SDKConstants
.
param_certId
,
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_certId
,
certUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa
(
data
,
certPath
,
certPwd
,
encoding
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa
(
data
,
certPath
,
certPwd
,
encoding
));
return
data
;
return
data
;
}
}
}
else
if
(
VERSION_5_1_0
.
equals
(
version
)){
}
else
if
(
VERSION_5_1_0
.
equals
(
version
)){
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
data
.
put
(
SDKConstants
.
param_certId
,
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_certId
,
certUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa2
(
data
,
certPath
,
certPwd
,
encoding
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa2
(
data
,
certPath
,
certPwd
,
encoding
));
return
data
;
return
data
;
}
}
...
@@ -151,7 +158,7 @@ public class AcpService {
...
@@ -151,7 +158,7 @@ public class AcpService {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return true 通过 false 未通过<br>
* @return true 通过 false 未通过<br>
*/
*/
public
static
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"
;
...
@@ -167,19 +174,19 @@ public class AcpService {
...
@@ -167,19 +174,19 @@ public class AcpService {
try
{
try
{
if
(
VERSION_5_1_0
.
equals
(
version
)){
if
(
VERSION_5_1_0
.
equals
(
version
)){
if
(
SIGNMETHOD_SHA256
.
equals
(
signMethod
))
if
(
SIGNMETHOD_SHA256
.
equals
(
signMethod
))
return
SDKUtil
.
verifySha256
(
data
,
SDKConfig
.
getConfig
()
.
getSecureKey
(),
encoding
);
return
SDKUtil
.
verifySha256
(
data
,
sdkConfig
.
getSecureKey
(),
encoding
);
else
if
(
SIGNMETHOD_SM3
.
equals
(
signMethod
))
else
if
(
SIGNMETHOD_SM3
.
equals
(
signMethod
))
return
SDKUtil
.
verifySm3
(
data
,
SDKConfig
.
getConfig
()
.
getSecureKey
(),
encoding
);
return
SDKUtil
.
verifySm3
(
data
,
sdkConfig
.
getSecureKey
(),
encoding
);
}
}
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
if
(
SIGNMETHOD_RSA
.
equals
(
signMethod
))
{
String
strCert
=
data
.
get
(
SDKConstants
.
param_signPubKeyCert
);
String
strCert
=
data
.
get
(
SDKConstants
.
param_signPubKeyCert
);
String
certId
=
data
.
get
(
SDKConstants
.
param_certId
);
String
certId
=
data
.
get
(
SDKConstants
.
param_certId
);
PublicKey
verifyKey
=
null
;
PublicKey
verifyKey
=
null
;
if
(!
SDKUtil
.
isEmpty
(
strCert
))
if
(!
SDKUtil
.
isEmpty
(
strCert
))
verifyKey
=
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
verifyAndGetVerifyPubKey
(
strCert
);
verifyKey
=
certUtil
.
verifyAndGetVerifyPubKey
(
strCert
);
else
if
(!
SDKUtil
.
isEmpty
(
certId
)){
else
if
(!
SDKUtil
.
isEmpty
(
certId
)){
log
.
info
(
"对返回报文串验签使用的验签公钥序列号:["
+
certId
+
"]"
);
log
.
info
(
"对返回报文串验签使用的验签公钥序列号:["
+
certId
+
"]"
);
verifyKey
=
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getValidatePublicKey
(
certId
);
verifyKey
=
certUtil
.
getValidatePublicKey
(
certId
);
}
}
if
(
verifyKey
==
null
)
{
if
(
verifyKey
==
null
)
{
log
.
error
(
"未成功获取验签公钥,验签失败。"
);
log
.
error
(
"未成功获取验签公钥,验签失败。"
);
...
@@ -248,7 +255,7 @@ public class AcpService {
...
@@ -248,7 +255,7 @@ public class AcpService {
* @param jsonData json格式数据,例如:{"sign" : "J6rPLClQ64szrdXCOtV1ccOMzUmpiOKllp9cseBuRqJ71pBKPPkZ1FallzW18gyP7CvKh1RxfNNJ66AyXNMFJi1OSOsteAAFjF5GZp0Xsfm3LeHaN3j/N7p86k3B1GrSPvSnSw1LqnYuIBmebBkC1OD0Qi7qaYUJosyA1E8Ld8oGRZT5RR2gLGBoiAVraDiz9sci5zwQcLtmfpT5KFk/eTy4+W9SsC0M/2sVj43R9ePENlEvF8UpmZBqakyg5FO8+JMBz3kZ4fwnutI5pWPdYIWdVrloBpOa+N4pzhVRKD4eWJ0CoiD+joMS7+C0aPIEymYFLBNYQCjM0KV7N726LA==", "data" : "pay_result=success&tn=201602141008032671528&cert_id=68759585097"}
* @param jsonData json格式数据,例如:{"sign" : "J6rPLClQ64szrdXCOtV1ccOMzUmpiOKllp9cseBuRqJ71pBKPPkZ1FallzW18gyP7CvKh1RxfNNJ66AyXNMFJi1OSOsteAAFjF5GZp0Xsfm3LeHaN3j/N7p86k3B1GrSPvSnSw1LqnYuIBmebBkC1OD0Qi7qaYUJosyA1E8Ld8oGRZT5RR2gLGBoiAVraDiz9sci5zwQcLtmfpT5KFk/eTy4+W9SsC0M/2sVj43R9ePENlEvF8UpmZBqakyg5FO8+JMBz3kZ4fwnutI5pWPdYIWdVrloBpOa+N4pzhVRKD4eWJ0CoiD+joMS7+C0aPIEymYFLBNYQCjM0KV7N726LA==", "data" : "pay_result=success&tn=201602141008032671528&cert_id=68759585097"}
* @return 是否成功
* @return 是否成功
*/
*/
public
static
boolean
validateAppResponse
(
String
jsonData
,
String
encoding
)
{
public
boolean
validateAppResponse
(
String
jsonData
,
String
encoding
)
{
log
.
info
(
"控件应答信息验签处理开始:["
+
jsonData
+
"]"
);
log
.
info
(
"控件应答信息验签处理开始:["
+
jsonData
+
"]"
);
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
encoding
=
"UTF-8"
;
encoding
=
"UTF-8"
;
...
@@ -271,7 +278,7 @@ public class AcpService {
...
@@ -271,7 +278,7 @@ public class AcpService {
try
{
try
{
// 验证签名需要用银联发给商户的公钥证书.
// 验证签名需要用银联发给商户的公钥证书.
return
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
verifySignature
(
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
return
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
verifySignature
(
certUtil
.
getValidatePublicKey
(
certId
),
Base64
.
decodeBase64
(
sign
),
.
getValidatePublicKey
(
certId
),
Base64
.
decodeBase64
(
sign
),
SDKUtil
.
byteArrayToHexString
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
sha1
(
data
.
getBytes
(
encoding
))).
getBytes
(
encoding
));
SDKUtil
.
byteArrayToHexString
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
sha1
(
data
.
getBytes
(
encoding
))).
getBytes
(
encoding
));
}
catch
(
UnsupportedEncodingException
e
)
{
}
catch
(
UnsupportedEncodingException
e
)
{
...
@@ -289,14 +296,14 @@ public class AcpService {
...
@@ -289,14 +296,14 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return 应答http 200返回true ,其他false<br>
* @return 应答http 200返回true ,其他false<br>
*/
*/
public
static
Map
<
String
,
String
>
post
(
public
Map
<
String
,
String
>
post
(
Map
<
String
,
String
>
reqData
,
String
reqUrl
,
String
encoding
)
{
Map
<
String
,
String
>
reqData
,
String
reqUrl
,
String
encoding
)
{
if
(
reqData
==
null
||
reqUrl
==
null
)
{
if
(
reqData
==
null
||
reqUrl
==
null
)
{
log
.
error
(
"post err: null input"
);
log
.
error
(
"post err: null input"
);
return
null
;
return
null
;
}
}
log
.
info
(
"请求银联地址:"
+
reqUrl
+
",请求参数:"
+
reqData
.
toString
());
log
.
info
(
"请求银联地址:"
+
reqUrl
+
",请求参数:"
+
reqData
.
toString
());
if
(
reqUrl
.
startsWith
(
"https://"
)
&&
!
SDKConfig
.
getConfig
()
.
isIfValidateRemoteCert
())
{
if
(
reqUrl
.
startsWith
(
"https://"
)
&&
!
sdkConfig
.
isIfValidateRemoteCert
())
{
reqUrl
=
"u"
+
reqUrl
;
reqUrl
=
"u"
+
reqUrl
;
}
}
try
{
try
{
...
@@ -320,13 +327,13 @@ public class AcpService {
...
@@ -320,13 +327,13 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return
* @return
*/
*/
public
static
String
get
(
String
reqUrl
,
String
encoding
)
{
public
String
get
(
String
reqUrl
,
String
encoding
)
{
if
(
reqUrl
==
null
)
{
if
(
reqUrl
==
null
)
{
log
.
error
(
"null input"
);
log
.
error
(
"null input"
);
return
null
;
return
null
;
}
}
log
.
info
(
"get请求银联地址:"
+
reqUrl
);
log
.
info
(
"get请求银联地址:"
+
reqUrl
);
if
(!
SDKConfig
.
getConfig
()
.
isIfValidateRemoteCert
())
{
if
(!
sdkConfig
.
isIfValidateRemoteCert
())
{
reqUrl
=
"u"
+
reqUrl
;
reqUrl
=
"u"
+
reqUrl
;
}
}
try
{
try
{
...
@@ -501,7 +508,7 @@ public class AcpService {
...
@@ -501,7 +508,7 @@ public class AcpService {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return base64后的持卡人信息域字段<br>
* @return base64后的持卡人信息域字段<br>
*/
*/
public
static
String
getCustomerInfo
(
Map
<
String
,
String
>
customerInfoMap
,
String
accNo
,
String
encoding
)
{
public
String
getCustomerInfo
(
Map
<
String
,
String
>
customerInfoMap
,
String
accNo
,
String
encoding
)
{
if
(
customerInfoMap
.
isEmpty
())
if
(
customerInfoMap
.
isEmpty
())
return
"{}"
;
return
"{}"
;
...
@@ -547,7 +554,7 @@ public class AcpService {
...
@@ -547,7 +554,7 @@ public class AcpService {
* @param encoding 上送请求报文域encoding字段的值
* @param encoding 上送请求报文域encoding字段的值
* @return base64后的持卡人信息域字段 <br>
* @return base64后的持卡人信息域字段 <br>
*/
*/
public
static
String
getCustomerInfoWithEncrypt
(
Map
<
String
,
String
>
customerInfoMap
,
String
accNo
,
String
encoding
)
{
public
String
getCustomerInfoWithEncrypt
(
Map
<
String
,
String
>
customerInfoMap
,
String
accNo
,
String
encoding
)
{
if
(
customerInfoMap
.
isEmpty
())
if
(
customerInfoMap
.
isEmpty
())
return
"{}"
;
return
"{}"
;
StringBuffer
sf
=
new
StringBuffer
(
"{"
);
StringBuffer
sf
=
new
StringBuffer
(
"{"
);
...
@@ -597,7 +604,7 @@ public class AcpService {
...
@@ -597,7 +604,7 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return
* @return
*/
*/
public
static
Map
<
String
,
String
>
parseCustomerInfo
(
String
customerInfo
,
String
encoding
)
{
public
Map
<
String
,
String
>
parseCustomerInfo
(
String
customerInfo
,
String
encoding
)
{
Map
<
String
,
String
>
customerInfoMap
=
null
;
Map
<
String
,
String
>
customerInfoMap
=
null
;
try
{
try
{
byte
[]
b
=
Base64
.
decodeBase64
(
customerInfo
);
byte
[]
b
=
Base64
.
decodeBase64
(
customerInfo
);
...
@@ -626,7 +633,7 @@ public class AcpService {
...
@@ -626,7 +633,7 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return
* @return
*/
*/
public
static
Map
<
String
,
String
>
parseCustomerInfo
(
String
customerInfo
,
String
certPath
,
public
Map
<
String
,
String
>
parseCustomerInfo
(
String
customerInfo
,
String
certPath
,
String
certPwd
,
String
encoding
){
String
certPwd
,
String
encoding
){
Map
<
String
,
String
>
customerInfoMap
=
null
;
Map
<
String
,
String
>
customerInfoMap
=
null
;
try
{
try
{
...
@@ -656,9 +663,9 @@ public class AcpService {
...
@@ -656,9 +663,9 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return 加密的内容<br>
* @return 加密的内容<br>
*/
*/
public
static
String
encryptPin
(
String
accNo
,
String
pin
,
String
encoding
)
{
public
String
encryptPin
(
String
accNo
,
String
pin
,
String
encoding
)
{
byte
[]
pinblock
=
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
pinblock
(
accNo
,
pin
);
byte
[]
pinblock
=
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
pinblock
(
accNo
,
pin
);
return
Base64
.
encodeBase64String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
encrypt
(
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getEncryptCert
().
pubKey
,
pinblock
));
return
Base64
.
encodeBase64String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
encrypt
(
certUtil
.
getEncryptCert
().
pubKey
,
pinblock
));
}
}
/**
/**
...
@@ -667,9 +674,9 @@ public class AcpService {
...
@@ -667,9 +674,9 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return 加密的密文<br>
* @return 加密的密文<br>
*/
*/
public
static
String
encryptData
(
String
data
,
String
encoding
)
{
public
String
encryptData
(
String
data
,
String
encoding
)
{
try
{
try
{
return
Base64
.
encodeBase64String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
encrypt
(
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getEncryptCert
().
pubKey
,
data
.
getBytes
(
encoding
)));
return
Base64
.
encodeBase64String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
encrypt
(
certUtil
.
getEncryptCert
().
pubKey
,
data
.
getBytes
(
encoding
)));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
return
null
;
...
@@ -682,8 +689,8 @@ public class AcpService {
...
@@ -682,8 +689,8 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return 解密后的明文<br>
* @return 解密后的明文<br>
*/
*/
public
static
String
decryptData
(
String
base64EncryptedInfo
,
String
encoding
)
{
public
String
decryptData
(
String
base64EncryptedInfo
,
String
encoding
)
{
return
new
String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
decrypt
(
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getSignCertPrivateKey
(),
Base64
.
decodeBase64
(
base64EncryptedInfo
)),
Charset
.
forName
(
encoding
));
return
new
String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
decrypt
(
certUtil
.
getSignCertPrivateKey
(),
Base64
.
decodeBase64
(
base64EncryptedInfo
)),
Charset
.
forName
(
encoding
));
}
}
/**
/**
...
@@ -694,9 +701,9 @@ public class AcpService {
...
@@ -694,9 +701,9 @@ public class AcpService {
* @param encoding<br>
* @param encoding<br>
* @return
* @return
*/
*/
public
static
String
decryptData
(
String
base64EncryptedInfo
,
String
certPath
,
public
String
decryptData
(
String
base64EncryptedInfo
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
String
certPwd
,
String
encoding
)
{
return
new
String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
decrypt
(
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
return
new
String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
decrypt
(
certUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
Base64
.
decodeBase64
(
base64EncryptedInfo
)),
Charset
.
forName
(
encoding
));
Base64
.
decodeBase64
(
base64EncryptedInfo
)),
Charset
.
forName
(
encoding
));
}
}
...
@@ -707,9 +714,9 @@ public class AcpService {
...
@@ -707,9 +714,9 @@ public class AcpService {
* @return 加密的密文<br>
* @return 加密的密文<br>
* @deprecated
* @deprecated
*/
*/
public
static
String
encryptTrack
(
String
trackData
,
String
encoding
)
{
public
String
encryptTrack
(
String
trackData
,
String
encoding
)
{
try
{
try
{
return
Base64
.
encodeBase64String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
encrypt
(
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getEncryptTrackPublicKey
(),
trackData
.
getBytes
(
encoding
)));
return
Base64
.
encodeBase64String
(
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
SecureUtil
.
encrypt
(
certUtil
.
getEncryptTrackPublicKey
(),
trackData
.
getBytes
(
encoding
)));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
return
null
;
...
@@ -720,8 +727,8 @@ public class AcpService {
...
@@ -720,8 +727,8 @@ public class AcpService {
* 获取敏感信息加密证书的物理序列号<br>
* 获取敏感信息加密证书的物理序列号<br>
* @return
* @return
*/
*/
public
static
String
getEncryptCertId
(){
public
String
getEncryptCertId
(){
return
c
om
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
.
C
ertUtil
.
getEncryptCert
().
certId
;
return
certUtil
.
getEncryptCert
().
certId
;
}
}
...
@@ -736,7 +743,7 @@ public class AcpService {
...
@@ -736,7 +743,7 @@ public class AcpService {
* @param encoding 编码<br>
* @param encoding 编码<br>
* @return
* @return
*/
*/
public
static
String
getCardTransData
(
Map
<
String
,
String
>
cardTransDataMap
,
public
String
getCardTransData
(
Map
<
String
,
String
>
cardTransDataMap
,
Map
<
String
,
String
>
requestData
,
Map
<
String
,
String
>
requestData
,
String
encoding
)
{
{
String
encoding
)
{
{
...
@@ -750,7 +757,7 @@ public class AcpService {
...
@@ -750,7 +757,7 @@ public class AcpService {
.
append
(
SDKConstants
.
COLON
).
append
(
requestData
.
get
(
"txnAmt"
)==
null
?
0
:
requestData
.
get
(
"txnAmt"
))
.
append
(
SDKConstants
.
COLON
).
append
(
requestData
.
get
(
"txnAmt"
)==
null
?
0
:
requestData
.
get
(
"txnAmt"
))
.
append
(
SDKConstants
.
COLON
).
append
(
cardTransDataMap
.
get
(
"track2Data"
));
.
append
(
SDKConstants
.
COLON
).
append
(
cardTransDataMap
.
get
(
"track2Data"
));
cardTransDataMap
.
put
(
"track2Data"
,
cardTransDataMap
.
put
(
"track2Data"
,
AcpService
.
encryptData
(
track2Buffer
.
toString
(),
encoding
));
this
.
encryptData
(
track2Buffer
.
toString
(),
encoding
));
}
}
if
(
cardTransDataMap
.
containsKey
(
"track3Data"
)){
if
(
cardTransDataMap
.
containsKey
(
"track3Data"
)){
...
@@ -761,7 +768,7 @@ public class AcpService {
...
@@ -761,7 +768,7 @@ public class AcpService {
.
append
(
SDKConstants
.
COLON
).
append
(
requestData
.
get
(
"txnAmt"
)==
null
?
0
:
requestData
.
get
(
"txnAmt"
))
.
append
(
SDKConstants
.
COLON
).
append
(
requestData
.
get
(
"txnAmt"
)==
null
?
0
:
requestData
.
get
(
"txnAmt"
))
.
append
(
SDKConstants
.
COLON
).
append
(
cardTransDataMap
.
get
(
"track3Data"
));
.
append
(
SDKConstants
.
COLON
).
append
(
cardTransDataMap
.
get
(
"track3Data"
));
cardTransDataMap
.
put
(
"track3Data"
,
cardTransDataMap
.
put
(
"track3Data"
,
AcpService
.
encryptData
(
track3Buffer
.
toString
(),
encoding
));
this
.
encryptData
(
track3Buffer
.
toString
(),
encoding
));
}
}
return
cardTransDataBuffer
.
append
(
SDKConstants
.
LEFT_BRACE
)
return
cardTransDataBuffer
.
append
(
SDKConstants
.
LEFT_BRACE
)
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/CertUtil.java
View file @
cb347737
...
@@ -18,7 +18,10 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
...
@@ -18,7 +18,10 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PostConstruct
;
import
java.io.*
;
import
java.io.*
;
import
java.math.BigInteger
;
import
java.math.BigInteger
;
import
java.security.*
;
import
java.security.*
;
...
@@ -33,10 +36,13 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKUtil.isEmpty;
...
@@ -33,10 +36,13 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKUtil.isEmpty;
/**
/**
* @ClassName: CertUtil
* @ClassName: CertUtil
* @Description: acpsdk证书工具类,主要用于对证书的加载和使用
* @Description: acpsdk证书工具类,主要用于对证书的加载和使用
* @date 20
16-7-22
下午2:46:20
* @date 20
21-11-09
下午2:46:20
*/
*/
@Slf4j
@Slf4j
@Configuration
public
class
CertUtil
{
public
class
CertUtil
{
@Autowired
private
SDKConfig
sdkConfig
;
/** 验签中级证书 */
/** 验签中级证书 */
private
static
X509Certificate
middleCert
=
null
;
private
static
X509Certificate
middleCert
=
null
;
...
@@ -61,16 +67,13 @@ public class CertUtil {
...
@@ -61,16 +67,13 @@ public class CertUtil {
protected
PrivateKey
priKey
;
protected
PrivateKey
priKey
;
}
}
static
{
addProvider
();
//向系统添加BC provider
init
();
}
/**
/**
* 初始化所有证书.
* 初始化所有证书.
*/
*/
public
static
void
init
()
{
@PostConstruct
public
void
init
()
{
try
{
try
{
addProvider
();
//向系统添加BC provider
initSignCert
();
//初始化签名私钥证书
initSignCert
();
//初始化签名私钥证书
initMiddleCert
();
//初始化验签证书的中级证书
initMiddleCert
();
//初始化验签证书的中级证书
initRootCert
();
//初始化验签证书的根证书
initRootCert
();
//初始化验签证书的根证书
...
@@ -86,7 +89,7 @@ public class CertUtil {
...
@@ -86,7 +89,7 @@ public class CertUtil {
/**
/**
* 添加签名,验签,加密算法提供者
* 添加签名,验签,加密算法提供者
*/
*/
private
static
void
addProvider
(){
private
void
addProvider
(){
if
(
Security
.
getProvider
(
"BC"
)
==
null
)
{
if
(
Security
.
getProvider
(
"BC"
)
==
null
)
{
log
.
debug
(
"add BC provider"
);
log
.
debug
(
"add BC provider"
);
Security
.
addProvider
(
new
org
.
bouncycastle
.
jce
.
provider
.
BouncyCastleProvider
());
Security
.
addProvider
(
new
org
.
bouncycastle
.
jce
.
provider
.
BouncyCastleProvider
());
...
@@ -104,7 +107,7 @@ public class CertUtil {
...
@@ -104,7 +107,7 @@ public class CertUtil {
* @param pwd
* @param pwd
* @return
* @return
*/
*/
private
static
Cert
addSignCert
(
String
path
,
String
pwd
)
{
private
Cert
addSignCert
(
String
path
,
String
pwd
)
{
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
log
.
warn
(
"签名证书路径或证书密码为空。 停止加载签名私钥证书。"
);
log
.
warn
(
"签名证书路径或证书密码为空。 停止加载签名私钥证书。"
);
...
@@ -158,7 +161,7 @@ public class CertUtil {
...
@@ -158,7 +161,7 @@ public class CertUtil {
* @param path
* @param path
* @return
* @return
*/
*/
public
static
X509Certificate
readX509Cert
(
String
path
)
{
public
X509Certificate
readX509Cert
(
String
path
)
{
X509Certificate
cert
=
null
;
X509Certificate
cert
=
null
;
CertificateFactory
cf
=
null
;
CertificateFactory
cf
=
null
;
FileInputStream
in
=
null
;
FileInputStream
in
=
null
;
...
@@ -183,10 +186,10 @@ public class CertUtil {
...
@@ -183,10 +186,10 @@ public class CertUtil {
/**
/**
* 用配置文件acp_sdk.properties中配置的私钥路径和密码 加载签名证书,会清空重新加载,一般仅第一次加载时调用即可
* 用配置文件acp_sdk.properties中配置的私钥路径和密码 加载签名证书,会清空重新加载,一般仅第一次加载时调用即可
*/
*/
private
static
void
initSignCert
()
{
private
void
initSignCert
()
{
signCerts
.
clear
();
signCerts
.
clear
();
String
path
=
SDKConfig
.
getConfig
()
.
getSignCertPath
();
String
path
=
sdkConfig
.
getSignCertPath
();
String
pwd
=
SDKConfig
.
getConfig
()
.
getSignCertPwd
();
String
pwd
=
sdkConfig
.
getSignCertPwd
();
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
log
.
warn
(
SDKConfig
.
SDK_SIGNCERT_PATH
+
" or "
+
SDKConfig
.
SDK_SIGNCERT_PWD
+
" is empty"
);
log
.
warn
(
SDKConfig
.
SDK_SIGNCERT_PATH
+
" or "
+
SDKConfig
.
SDK_SIGNCERT_PWD
+
" is empty"
);
return
;
return
;
...
@@ -198,8 +201,8 @@ public class CertUtil {
...
@@ -198,8 +201,8 @@ public class CertUtil {
/**
/**
* 用配置文件acp_sdk.properties配置路径 加载5.1验签证书中级证书
* 用配置文件acp_sdk.properties配置路径 加载5.1验签证书中级证书
*/
*/
private
static
void
initMiddleCert
()
{
private
void
initMiddleCert
()
{
String
path
=
SDKConfig
.
getConfig
()
.
getMiddleCertPath
();
String
path
=
sdkConfig
.
getMiddleCertPath
();
if
(
isEmpty
(
path
)){
if
(
isEmpty
(
path
)){
log
.
warn
(
SDKConfig
.
SDK_MIDDLECERT_PATH
+
" is empty"
);
log
.
warn
(
SDKConfig
.
SDK_MIDDLECERT_PATH
+
" is empty"
);
return
;
return
;
...
@@ -211,8 +214,8 @@ public class CertUtil {
...
@@ -211,8 +214,8 @@ public class CertUtil {
/**
/**
* 用配置文件acp_sdk.properties配置路径 加载5.1验签证书根证书
* 用配置文件acp_sdk.properties配置路径 加载5.1验签证书根证书
*/
*/
private
static
void
initRootCert
()
{
private
void
initRootCert
()
{
String
path
=
SDKConfig
.
getConfig
()
.
getRootCertPath
();
String
path
=
sdkConfig
.
getRootCertPath
();
if
(
isEmpty
(
path
)){
if
(
isEmpty
(
path
)){
log
.
warn
(
SDKConfig
.
SDK_ROOTCERT_PATH
+
" is empty"
);
log
.
warn
(
SDKConfig
.
SDK_ROOTCERT_PATH
+
" is empty"
);
return
;
return
;
...
@@ -224,10 +227,10 @@ public class CertUtil {
...
@@ -224,10 +227,10 @@ public class CertUtil {
/**
/**
* 用配置文件acp_sdk.properties配置路径 加载磁道公钥
* 用配置文件acp_sdk.properties配置路径 加载磁道公钥
*/
*/
private
static
void
initTrackKey
()
{
private
void
initTrackKey
()
{
String
modulus
=
SDKConfig
.
getConfig
()
.
getEncryptTrackKeyModulus
();
String
modulus
=
sdkConfig
.
getEncryptTrackKeyModulus
();
String
exponent
=
SDKConfig
.
getConfig
()
.
getEncryptTrackKeyExponent
();
String
exponent
=
sdkConfig
.
getEncryptTrackKeyExponent
();
if
(
isEmpty
(
modulus
)
||
isEmpty
(
exponent
)){
if
(
isEmpty
(
modulus
)
||
isEmpty
(
exponent
)){
log
.
warn
(
SDKConfig
.
SDK_ENCRYPTTRACKKEY_MODULUS
+
" or "
+
SDKConfig
.
SDK_ENCRYPTTRACKKEY_EXPONENT
+
" is empty"
);
log
.
warn
(
SDKConfig
.
SDK_ENCRYPTTRACKKEY_MODULUS
+
" or "
+
SDKConfig
.
SDK_ENCRYPTTRACKKEY_EXPONENT
+
" is empty"
);
return
;
return
;
...
@@ -239,11 +242,11 @@ public class CertUtil {
...
@@ -239,11 +242,11 @@ public class CertUtil {
/**
/**
* 用配置文件acp_sdk.properties配置路径 加载验签证书
* 用配置文件acp_sdk.properties配置路径 加载验签证书
*/
*/
private
static
void
initValidateCertFromDir
()
{
private
void
initValidateCertFromDir
()
{
verifyCerts
.
clear
();
verifyCerts
.
clear
();
String
dir
=
SDKConfig
.
getConfig
()
.
getValidateCertDir
();
String
dir
=
sdkConfig
.
getValidateCertDir
();
if
(
isEmpty
(
dir
))
{
if
(
isEmpty
(
dir
))
{
log
.
error
(
"WARN: acpsdk.validateCert.dir is empty"
);
log
.
error
(
"WARN: acpsdk.validateCert.dir is empty"
);
return
;
return
;
...
@@ -272,8 +275,8 @@ public class CertUtil {
...
@@ -272,8 +275,8 @@ public class CertUtil {
/**
/**
* 用配置文件acp_sdk.properties配置路径 加载敏感信息加密证书
* 用配置文件acp_sdk.properties配置路径 加载敏感信息加密证书
*/
*/
private
static
void
initEncryptCert
()
{
private
void
initEncryptCert
()
{
String
path
=
SDKConfig
.
getConfig
()
.
getEncryptCertPath
();
String
path
=
sdkConfig
.
getEncryptCertPath
();
if
(
isEmpty
(
path
)){
if
(
isEmpty
(
path
)){
log
.
warn
(
SDKConfig
.
SDK_ENCRYPTCERT_PATH
+
" is empty"
);
log
.
warn
(
SDKConfig
.
SDK_ENCRYPTCERT_PATH
+
" is empty"
);
return
;
return
;
...
@@ -291,8 +294,8 @@ public class CertUtil {
...
@@ -291,8 +294,8 @@ public class CertUtil {
/**
/**
* 用配置文件acp_sdk.properties配置路径 加载6.0统一支付产品pin加密证书
* 用配置文件acp_sdk.properties配置路径 加载6.0统一支付产品pin加密证书
*/
*/
private
static
void
initPinEncryptCert
()
{
private
void
initPinEncryptCert
()
{
String
path
=
SDKConfig
.
getConfig
()
.
getPinEncryptCertPath
();
String
path
=
sdkConfig
.
getPinEncryptCertPath
();
if
(
isEmpty
(
path
)){
if
(
isEmpty
(
path
)){
log
.
warn
(
SDKConfig
.
SDK_PINENCRYPTCERT_PATH
+
" is empty"
);
log
.
warn
(
SDKConfig
.
SDK_PINENCRYPTCERT_PATH
+
" is empty"
);
return
;
return
;
...
@@ -310,9 +313,9 @@ public class CertUtil {
...
@@ -310,9 +313,9 @@ public class CertUtil {
/**
/**
*
*
*/
*/
private
static
Cert
getSignCert
()
{
private
Cert
getSignCert
()
{
String
path
=
SDKConfig
.
getConfig
()
.
getSignCertPath
();
String
path
=
sdkConfig
.
getSignCertPath
();
String
pwd
=
SDKConfig
.
getConfig
()
.
getSignCertPwd
();
String
pwd
=
sdkConfig
.
getSignCertPwd
();
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
log
.
error
(
"未配置默认签名证书时无法调用此方法。"
);
log
.
error
(
"未配置默认签名证书时无法调用此方法。"
);
return
null
;
return
null
;
...
@@ -326,7 +329,7 @@ public class CertUtil {
...
@@ -326,7 +329,7 @@ public class CertUtil {
* @param pwd
* @param pwd
* @return
* @return
*/
*/
private
static
Cert
getSignCert
(
String
path
,
String
pwd
)
{
private
Cert
getSignCert
(
String
path
,
String
pwd
)
{
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
if
(
isEmpty
(
path
)
||
isEmpty
(
pwd
))
{
log
.
error
(
"传入的签名路径或密码为空。"
);
log
.
error
(
"传入的签名路径或密码为空。"
);
return
null
;
return
null
;
...
@@ -347,7 +350,7 @@ public class CertUtil {
...
@@ -347,7 +350,7 @@ public class CertUtil {
*
*
* @return
* @return
*/
*/
protected
static
Cert
getEncryptCert
()
{
protected
Cert
getEncryptCert
()
{
if
(
CertUtil
.
encryptCert
==
null
)
{
if
(
CertUtil
.
encryptCert
==
null
)
{
initEncryptCert
();
initEncryptCert
();
}
}
...
@@ -359,7 +362,7 @@ public class CertUtil {
...
@@ -359,7 +362,7 @@ public class CertUtil {
*
*
* @return
* @return
*/
*/
protected
static
Cert
getPinEncryptCert
()
{
protected
Cert
getPinEncryptCert
()
{
if
(
CertUtil
.
pinEncryptCert
==
null
)
{
if
(
CertUtil
.
pinEncryptCert
==
null
)
{
initPinEncryptCert
();
initPinEncryptCert
();
}
}
...
@@ -369,21 +372,21 @@ public class CertUtil {
...
@@ -369,21 +372,21 @@ public class CertUtil {
/**
/**
* 重置敏感信息加密证书公钥。
* 重置敏感信息加密证书公钥。
*/
*/
public
static
int
resetEncryptCertPublicKey
(
String
strCert
)
{
public
int
resetEncryptCertPublicKey
(
String
strCert
)
{
if
(
isEmpty
(
strCert
))
{
if
(
isEmpty
(
strCert
))
{
log
.
error
(
"传入证书信息为空。"
);
log
.
error
(
"传入证书信息为空。"
);
return
-
1
;
return
-
1
;
}
}
X509Certificate
x509Cert
=
CertUtil
.
genCertificateByStr
(
strCert
);
X509Certificate
x509Cert
=
this
.
genCertificateByStr
(
strCert
);
// 没换,不需要更新
// 没换,不需要更新
if
(
CertUtil
.
getEncryptCert
().
certId
.
equals
(
if
(
this
.
getEncryptCert
().
certId
.
equals
(
x509Cert
.
getSerialNumber
().
toString
(
10
)))
{
x509Cert
.
getSerialNumber
().
toString
(
10
)))
{
log
.
info
(
"返回证书和原证书一样,不用更新。"
);
log
.
info
(
"返回证书和原证书一样,不用更新。"
);
return
0
;
return
0
;
}
}
final
String
localCertPath
=
SDKConfig
.
getConfig
().
getEncryptCertPath
();
final
String
localCertPath
=
sdkConfig
.
getEncryptCertPath
();
if
(
isEmpty
(
localCertPath
)){
if
(
isEmpty
(
localCertPath
)){
log
.
error
(
"未配置加密证书路径,无法执行此方法。"
);
log
.
error
(
"未配置加密证书路径,无法执行此方法。"
);
return
-
1
;
return
-
1
;
...
@@ -420,21 +423,21 @@ public class CertUtil {
...
@@ -420,21 +423,21 @@ public class CertUtil {
/**
/**
* 重置pin敏感信息加密证书公钥。
* 重置pin敏感信息加密证书公钥。
*/
*/
public
static
int
resetPinEncryptCertPublicKey
(
String
strCert
)
{
public
int
resetPinEncryptCertPublicKey
(
String
strCert
)
{
if
(
isEmpty
(
strCert
))
{
if
(
isEmpty
(
strCert
))
{
log
.
error
(
"传入证书信息为空。"
);
log
.
error
(
"传入证书信息为空。"
);
return
-
1
;
return
-
1
;
}
}
X509Certificate
x509Cert
=
CertUtil
.
genCertificateByStr
(
strCert
);
X509Certificate
x509Cert
=
this
.
genCertificateByStr
(
strCert
);
// 没换,不需要更新
// 没换,不需要更新
if
(
CertUtil
.
getPinEncryptCert
().
certId
.
equals
(
if
(
this
.
getPinEncryptCert
().
certId
.
equals
(
x509Cert
.
getSerialNumber
().
toString
(
10
)))
{
x509Cert
.
getSerialNumber
().
toString
(
10
)))
{
log
.
info
(
"返回证书和原证书一样,不用更新。"
);
log
.
info
(
"返回证书和原证书一样,不用更新。"
);
return
0
;
return
0
;
}
}
final
String
localCertPath
=
SDKConfig
.
getConfig
()
.
getPinEncryptCertPath
();
final
String
localCertPath
=
sdkConfig
.
getPinEncryptCertPath
();
if
(
isEmpty
(
localCertPath
)){
if
(
isEmpty
(
localCertPath
)){
log
.
error
(
"未配置加密证书路径,无法执行此方法。"
);
log
.
error
(
"未配置加密证书路径,无法执行此方法。"
);
return
-
1
;
return
-
1
;
...
@@ -473,7 +476,7 @@ public class CertUtil {
...
@@ -473,7 +476,7 @@ public class CertUtil {
*
*
* @return
* @return
*/
*/
public
static
PublicKey
getEncryptTrackPublicKey
()
{
public
PublicKey
getEncryptTrackPublicKey
()
{
if
(
null
==
encryptTrackKey
)
{
if
(
null
==
encryptTrackKey
)
{
initTrackKey
();
initTrackKey
();
}
}
...
@@ -486,7 +489,7 @@ public class CertUtil {
...
@@ -486,7 +489,7 @@ public class CertUtil {
* @param certId 证书物理序号
* @param certId 证书物理序号
* @return 通过证书编号获取到的公钥
* @return 通过证书编号获取到的公钥
*/
*/
public
static
PublicKey
getValidatePublicKey
(
String
certId
)
{
public
PublicKey
getValidatePublicKey
(
String
certId
)
{
if
(
certId
==
null
)
{
if
(
certId
==
null
)
{
log
.
error
(
"没有传入certId."
);
log
.
error
(
"没有传入certId."
);
return
null
;
return
null
;
...
@@ -507,7 +510,7 @@ public class CertUtil {
...
@@ -507,7 +510,7 @@ public class CertUtil {
*
*
* @return 证书的物理编号
* @return 证书的物理编号
*/
*/
public
static
String
getSignCertId
()
{
public
String
getSignCertId
()
{
Cert
c
=
getSignCert
();
Cert
c
=
getSignCert
();
if
(
c
==
null
)
return
null
;
if
(
c
==
null
)
return
null
;
return
c
.
certId
;
return
c
.
certId
;
...
@@ -518,7 +521,7 @@ public class CertUtil {
...
@@ -518,7 +521,7 @@ public class CertUtil {
*
*
* @return 证书的物理编号
* @return 证书的物理编号
*/
*/
public
static
PrivateKey
getSignCertPrivateKey
()
{
public
PrivateKey
getSignCertPrivateKey
()
{
Cert
c
=
getSignCert
();
Cert
c
=
getSignCert
();
if
(
c
==
null
)
return
null
;
if
(
c
==
null
)
return
null
;
return
c
.
priKey
;
return
c
.
priKey
;
...
@@ -530,7 +533,7 @@ public class CertUtil {
...
@@ -530,7 +533,7 @@ public class CertUtil {
* @param pwd
* @param pwd
* @return
* @return
*/
*/
public
static
String
getCertIdByKeyStoreMap
(
String
path
,
String
pwd
)
{
public
String
getCertIdByKeyStoreMap
(
String
path
,
String
pwd
)
{
Cert
c
=
getSignCert
(
path
,
pwd
);
Cert
c
=
getSignCert
(
path
,
pwd
);
if
(
c
==
null
)
return
null
;
if
(
c
==
null
)
return
null
;
return
c
.
certId
;
return
c
.
certId
;
...
@@ -541,7 +544,7 @@ public class CertUtil {
...
@@ -541,7 +544,7 @@ public class CertUtil {
* @param pwd
* @param pwd
* @return
* @return
*/
*/
public
static
PrivateKey
getSignCertPrivateKeyByStoreMap
(
String
path
,
String
pwd
)
{
public
PrivateKey
getSignCertPrivateKeyByStoreMap
(
String
path
,
String
pwd
)
{
Cert
c
=
getSignCert
(
path
,
pwd
);
Cert
c
=
getSignCert
(
path
,
pwd
);
if
(
c
==
null
)
return
null
;
if
(
c
==
null
)
return
null
;
return
c
.
priKey
;
return
c
.
priKey
;
...
@@ -552,14 +555,14 @@ public class CertUtil {
...
@@ -552,14 +555,14 @@ public class CertUtil {
// *
// *
// * @return
// * @return
// */
// */
// public
static
String getEncryptCertId() {
// public String getEncryptCertId() {
// Cert c = getEncryptCert();
// Cert c = getEncryptCert();
// if(c == null) return null;
// if(c == null) return null;
// return c.certId;
// return c.certId;
// }
// }
//
//
//
//
// public
static
PublicKey getEncryptCertPublicKey(){
// public PublicKey getEncryptCertPublicKey(){
// Cert c = getEncryptCert();
// Cert c = getEncryptCert();
// if(c == null) return null;
// if(c == null) return null;
// return c.pubKey;
// return c.pubKey;
...
@@ -570,14 +573,14 @@ public class CertUtil {
...
@@ -570,14 +573,14 @@ public class CertUtil {
// *
// *
// * @return
// * @return
// */
// */
// public
static
String getPinEncryptCertId() {
// public String getPinEncryptCertId() {
// Cert c = getPinEncryptCert();
// Cert c = getPinEncryptCert();
// if(c == null) return null;
// if(c == null) return null;
// return c.certId;
// return c.certId;
// }
// }
//
//
//
//
// public
static
PublicKey getPinEncryptCertPublicKey(){
// public PublicKey getPinEncryptCertPublicKey(){
// Cert c = getEncryptCert();
// Cert c = getEncryptCert();
// if(c == null) return null;
// if(c == null) return null;
// return c.pubKey;
// return c.pubKey;
...
@@ -611,7 +614,7 @@ public class CertUtil {
...
@@ -611,7 +614,7 @@ public class CertUtil {
* @param x509CertString
* @param x509CertString
* @return
* @return
*/
*/
public
static
X509Certificate
genCertificateByStr
(
String
x509CertString
)
{
public
X509Certificate
genCertificateByStr
(
String
x509CertString
)
{
X509Certificate
x509Cert
=
null
;
X509Certificate
x509Cert
=
null
;
try
{
try
{
CertificateFactory
cf
=
CertificateFactory
.
getInstance
(
"X.509"
,
"BC"
);
CertificateFactory
cf
=
CertificateFactory
.
getInstance
(
"X.509"
,
"BC"
);
...
@@ -628,8 +631,8 @@ public class CertUtil {
...
@@ -628,8 +631,8 @@ public class CertUtil {
* 从配置文件acp_sdk.properties中获取验签公钥使用的中级证书
* 从配置文件acp_sdk.properties中获取验签公钥使用的中级证书
* @return
* @return
*/
*/
private
static
X509Certificate
getMiddleCert
()
{
private
X509Certificate
getMiddleCert
()
{
String
path
=
SDKConfig
.
getConfig
()
.
getMiddleCertPath
();
String
path
=
sdkConfig
.
getMiddleCertPath
();
if
(
isEmpty
(
path
))
{
if
(
isEmpty
(
path
))
{
log
.
error
(
"未配置中级证书时无法调用此方法。"
);
log
.
error
(
"未配置中级证书时无法调用此方法。"
);
return
null
;
return
null
;
...
@@ -644,8 +647,8 @@ public class CertUtil {
...
@@ -644,8 +647,8 @@ public class CertUtil {
* 从配置文件acp_sdk.properties中获取验签公钥使用的根证书
* 从配置文件acp_sdk.properties中获取验签公钥使用的根证书
* @return
* @return
*/
*/
private
static
X509Certificate
getRootCert
()
{
private
X509Certificate
getRootCert
()
{
String
path
=
SDKConfig
.
getConfig
()
.
getRootCertPath
();
String
path
=
sdkConfig
.
getRootCertPath
();
if
(
isEmpty
(
path
))
{
if
(
isEmpty
(
path
))
{
log
.
error
(
"未配置根证书时无法调用此方法。"
);
log
.
error
(
"未配置根证书时无法调用此方法。"
);
return
null
;
return
null
;
...
@@ -661,7 +664,7 @@ public class CertUtil {
...
@@ -661,7 +664,7 @@ public class CertUtil {
* @param aCert
* @param aCert
* @return
* @return
*/
*/
public
static
String
getIdentitiesFromCertficate
(
X509Certificate
aCert
)
{
public
String
getIdentitiesFromCertficate
(
X509Certificate
aCert
)
{
String
tDN
=
aCert
.
getSubjectDN
().
toString
();
String
tDN
=
aCert
.
getSubjectDN
().
toString
();
String
tPart
=
""
;
String
tPart
=
""
;
if
((
tDN
!=
null
))
{
if
((
tDN
!=
null
))
{
...
@@ -678,7 +681,7 @@ public class CertUtil {
...
@@ -678,7 +681,7 @@ public class CertUtil {
* @param cert
* @param cert
* @return
* @return
*/
*/
public
static
boolean
verifyCertificateChain
(
X509Certificate
cert
,
X509Certificate
middleCert
,
X509Certificate
rootCert
){
public
boolean
verifyCertificateChain
(
X509Certificate
cert
,
X509Certificate
middleCert
,
X509Certificate
rootCert
){
if
(
null
==
cert
)
{
if
(
null
==
cert
)
{
log
.
error
(
"cert must Not null"
);
log
.
error
(
"cert must Not null"
);
...
@@ -731,7 +734,7 @@ public class CertUtil {
...
@@ -731,7 +734,7 @@ public class CertUtil {
return
false
;
return
false
;
}
}
public
static
PublicKey
verifyAndGetVerifyPubKey
(
String
x509CertString
){
public
PublicKey
verifyAndGetVerifyPubKey
(
String
x509CertString
){
if
(
isEmpty
(
x509CertString
))
{
if
(
isEmpty
(
x509CertString
))
{
log
.
error
(
"验签公钥证书传了空。"
);
log
.
error
(
"验签公钥证书传了空。"
);
...
@@ -741,13 +744,13 @@ public class CertUtil {
...
@@ -741,13 +744,13 @@ public class CertUtil {
return
verifyCerts510
.
get
(
x509CertString
);
return
verifyCerts510
.
get
(
x509CertString
);
log
.
debug
(
"验签公钥证书:["
+
x509CertString
+
"]"
);
log
.
debug
(
"验签公钥证书:["
+
x509CertString
+
"]"
);
X509Certificate
x509Cert
=
CertUtil
.
genCertificateByStr
(
x509CertString
);
X509Certificate
x509Cert
=
this
.
genCertificateByStr
(
x509CertString
);
if
(
x509Cert
==
null
)
{
if
(
x509Cert
==
null
)
{
log
.
error
(
"convert signPubKeyCert failed"
);
log
.
error
(
"convert signPubKeyCert failed"
);
return
null
;
return
null
;
}
}
// 验证证书链
// 验证证书链
if
(!
CertUtil
.
verifyCertificate
(
x509Cert
))
{
if
(!
this
.
verifyCertificate
(
x509Cert
))
{
log
.
error
(
"验证公钥证书失败,证书信息:["
+
x509CertString
+
"]"
);
log
.
error
(
"验证公钥证书失败,证书信息:["
+
x509CertString
+
"]"
);
return
null
;
return
null
;
}
}
...
@@ -762,7 +765,7 @@ public class CertUtil {
...
@@ -762,7 +765,7 @@ public class CertUtil {
* @param cert
* @param cert
* @return
* @return
*/
*/
private
static
boolean
verifyCertificate
(
X509Certificate
cert
)
{
private
boolean
verifyCertificate
(
X509Certificate
cert
)
{
if
(
null
==
cert
)
{
if
(
null
==
cert
)
{
log
.
error
(
"cert must Not null"
);
log
.
error
(
"cert must Not null"
);
...
@@ -770,7 +773,7 @@ public class CertUtil {
...
@@ -770,7 +773,7 @@ public class CertUtil {
}
}
try
{
try
{
cert
.
checkValidity
();
//验证有效期
cert
.
checkValidity
();
//验证有效期
if
(!
verifyCertificateChain
(
cert
,
CertUtil
.
getMiddleCert
(),
CertUtil
.
getRootCert
())){
if
(!
verifyCertificateChain
(
cert
,
this
.
getMiddleCert
(),
this
.
getRootCert
())){
return
false
;
return
false
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -778,17 +781,17 @@ public class CertUtil {
...
@@ -778,17 +781,17 @@ public class CertUtil {
return
false
;
return
false
;
}
}
if
(
SDKConfig
.
getConfig
()
.
isIfValidateCNName
()){
if
(
sdkConfig
.
isIfValidateCNName
()){
// 验证公钥是否属于银联
// 验证公钥是否属于银联
if
(!
UNIONPAY_CNNAME
.
equals
(
CertUtil
.
getIdentitiesFromCertficate
(
cert
)))
{
if
(!
UNIONPAY_CNNAME
.
equals
(
this
.
getIdentitiesFromCertficate
(
cert
)))
{
log
.
error
(
"cer owner is not CUP:"
+
CertUtil
.
getIdentitiesFromCertficate
(
cert
));
log
.
error
(
"cer owner is not CUP:"
+
this
.
getIdentitiesFromCertficate
(
cert
));
return
false
;
return
false
;
}
}
}
else
{
}
else
{
// 验证公钥是否属于银联
// 验证公钥是否属于银联
if
(!
UNIONPAY_CNNAME
.
equals
(
CertUtil
.
getIdentitiesFromCertficate
(
cert
))
if
(!
UNIONPAY_CNNAME
.
equals
(
this
.
getIdentitiesFromCertficate
(
cert
))
&&
!
"00040000:SIGN"
.
equals
(
CertUtil
.
getIdentitiesFromCertficate
(
cert
)))
{
&&
!
"00040000:SIGN"
.
equals
(
this
.
getIdentitiesFromCertficate
(
cert
)))
{
log
.
error
(
"cer owner is not CUP:"
+
CertUtil
.
getIdentitiesFromCertficate
(
cert
));
log
.
error
(
"cer owner is not CUP:"
+
this
.
getIdentitiesFromCertficate
(
cert
));
return
false
;
return
false
;
}
}
}
}
...
@@ -843,7 +846,7 @@ public class CertUtil {
...
@@ -843,7 +846,7 @@ public class CertUtil {
}
}
}
}
public
static
Collection
<
PublicKey
>
getVerifySignPubKeys
(){
public
Collection
<
PublicKey
>
getVerifySignPubKeys
(){
return
verifyCerts
.
values
();
return
verifyCerts
.
values
();
}
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/QrcService.java
View file @
cb347737
...
@@ -2,6 +2,8 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
...
@@ -2,6 +2,8 @@ package com.liquidnet.service.dragon.channel.unionpay.sdk;
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.stereotype.Component
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
...
@@ -16,8 +18,13 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants.*;
...
@@ -16,8 +18,13 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants.*;
* @date 2018-12-10 下午2:44:37
* @date 2018-12-10 下午2:44:37
*/
*/
@Slf4j
@Slf4j
@Component
public
class
QrcService
{
public
class
QrcService
{
@Autowired
private
SDKConfig
sdkConfig
;
@Autowired
private
CertUtil
certUtil
;
/**
/**
* 请求报文签名(使用配置文件中配置的私钥证书或者对称密钥签名)<br>
* 请求报文签名(使用配置文件中配置的私钥证书或者对称密钥签名)<br>
* 功能:对请求报文进行签名,并计算赋值certid,signature字段并返回<br>
* 功能:对请求报文进行签名,并计算赋值certid,signature字段并返回<br>
...
@@ -25,8 +32,8 @@ public class QrcService {
...
@@ -25,8 +32,8 @@ public class QrcService {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return 签名后的map对象<br>
* @return 签名后的map对象<br>
*/
*/
public
static
Map
<
String
,
String
>
sign
(
Map
<
String
,
String
>
reqData
,
String
encoding
)
{
public
Map
<
String
,
String
>
sign
(
Map
<
String
,
String
>
reqData
,
String
encoding
)
{
return
signByCertInfo
(
reqData
,
SDKConfig
.
getConfig
().
getSignCertPath
(),
SDKConfig
.
getConfig
()
.
getSignCertPwd
(),
encoding
);
return
signByCertInfo
(
reqData
,
sdkConfig
.
getSignCertPath
(),
sdkConfig
.
getSignCertPwd
(),
encoding
);
}
}
/**
/**
...
@@ -38,7 +45,7 @@ public class QrcService {
...
@@ -38,7 +45,7 @@ public class QrcService {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return 签名后的map对象<br>
* @return 签名后的map对象<br>
*/
*/
public
static
Map
<
String
,
String
>
signByCertInfo
(
Map
<
String
,
String
>
reqData
,
String
certPath
,
public
Map
<
String
,
String
>
signByCertInfo
(
Map
<
String
,
String
>
reqData
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
String
certPwd
,
String
encoding
)
{
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
Map
<
String
,
String
>
data
=
SDKUtil
.
filterBlank
(
reqData
);
...
@@ -65,11 +72,11 @@ public class QrcService {
...
@@ -65,11 +72,11 @@ public class QrcService {
if
(
QRC_SIGNTYPE_SHA256WITHRSA
.
equals
(
signType
)
if
(
QRC_SIGNTYPE_SHA256WITHRSA
.
equals
(
signType
)
||
"0420000903"
.
equals
(
reqType
)
||
"0420000903"
.
equals
(
reqType
)
||
"0410000903"
.
equals
(
reqType
))
{
||
"0410000903"
.
equals
(
reqType
))
{
data
.
put
(
SDKConstants
.
param_certId
,
C
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_certId
,
c
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa2
(
data
,
certPath
,
certPwd
,
encoding
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa2
(
data
,
certPath
,
certPwd
,
encoding
));
return
data
;
return
data
;
}
else
if
(
QRC_SIGNTYPE_SHA1WITHRSA
.
equals
(
signType
))
{
}
else
if
(
QRC_SIGNTYPE_SHA1WITHRSA
.
equals
(
signType
))
{
data
.
put
(
SDKConstants
.
param_certId
,
C
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_certId
,
c
ertUtil
.
getCertIdByKeyStoreMap
(
certPath
,
certPwd
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa
(
data
,
certPath
,
certPwd
,
encoding
));
data
.
put
(
SDKConstants
.
param_signature
,
SDKUtil
.
signRsa
(
data
,
certPath
,
certPwd
,
encoding
));
return
data
;
return
data
;
}
else
if
(
QRC_SIGNTYPE_SM3WITHSM2
.
equals
(
signType
))
{
}
else
if
(
QRC_SIGNTYPE_SM3WITHSM2
.
equals
(
signType
))
{
...
@@ -91,14 +98,14 @@ public class QrcService {
...
@@ -91,14 +98,14 @@ public class QrcService {
* @param encoding 上送请求报文域encoding字段的值<br>
* @param encoding 上送请求报文域encoding字段的值<br>
* @return true 通过 false 未通过<br>
* @return true 通过 false 未通过<br>
*/
*/
public
static
boolean
validate
(
Map
<
String
,
String
>
resData
,
String
encoding
)
{
public
boolean
validate
(
Map
<
String
,
String
>
resData
,
String
encoding
)
{
log
.
info
(
"验签处理开始"
);
log
.
info
(
"验签处理开始"
);
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
if
(
SDKUtil
.
isEmpty
(
encoding
))
{
encoding
=
"UTF-8"
;
encoding
=
"UTF-8"
;
}
}
String
certId
=
resData
.
get
(
SDKConstants
.
param_certId
);
String
certId
=
resData
.
get
(
SDKConstants
.
param_certId
);
log
.
info
(
"对返回报文串验签使用的验签公钥序列号:["
+
certId
+
"]"
);
log
.
info
(
"对返回报文串验签使用的验签公钥序列号:["
+
certId
+
"]"
);
PublicKey
verifyKey
=
C
ertUtil
.
getValidatePublicKey
(
certId
);
PublicKey
verifyKey
=
c
ertUtil
.
getValidatePublicKey
(
certId
);
if
(
verifyKey
==
null
)
{
if
(
verifyKey
==
null
)
{
log
.
error
(
"未找到此序列号证书。"
);
log
.
error
(
"未找到此序列号证书。"
);
return
false
;
return
false
;
...
@@ -185,8 +192,8 @@ public class QrcService {
...
@@ -185,8 +192,8 @@ public class QrcService {
* 获取敏感信息加密证书的物理序列号<br>
* 获取敏感信息加密证书的物理序列号<br>
* @return
* @return
*/
*/
public
static
String
getEncryptCertId
(){
public
String
getEncryptCertId
(){
return
C
ertUtil
.
getEncryptCert
().
certId
;
return
c
ertUtil
.
getEncryptCert
().
certId
;
}
}
/**
/**
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/SDKConfig.java
View file @
cb347737
...
@@ -15,7 +15,11 @@
...
@@ -15,7 +15,11 @@
*/
*/
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
unionpay
.
sdk
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.autoconfigure.AutoConfigureOrder
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
java.io.*
;
import
java.io.*
;
import
java.util.Properties
;
import
java.util.Properties
;
...
@@ -27,13 +31,14 @@ import java.util.Properties;
...
@@ -27,13 +31,14 @@ import java.util.Properties;
* @date 2016-7-22 下午4:04:55
* @date 2016-7-22 下午4:04:55
*/
*/
@Slf4j
@Slf4j
@Component
@ConfigurationProperties
(
prefix
=
"acpsdk"
)
@Data
public
class
SDKConfig
{
public
class
SDKConfig
{
public
static
final
String
FILE_NAME
=
"acp_sdk.properties"
;
/** 前台请求URL. */
/** 前台请求URL. */
private
String
front
Request
Url
;
private
String
front
Trans
Url
;
/** 后台请求URL. */
/** 后台请求URL. */
private
String
back
Request
Url
;
private
String
back
Trans
Url
;
/** 二维码统一下单请求URL. */
/** 二维码统一下单请求URL. */
private
String
orderRequestUrl
;
private
String
orderRequestUrl
;
/** 单笔查询 */
/** 单笔查询 */
...
@@ -219,536 +224,4 @@ public class SDKConfig {
...
@@ -219,536 +224,4 @@ public class SDKConfig {
public
static
final
String
SDK_FRONTURL
=
"acpsdk.frontUrl"
;
public
static
final
String
SDK_FRONTURL
=
"acpsdk.frontUrl"
;
/** 前台失败通知地址 */
/** 前台失败通知地址 */
public
static
final
String
SDK_FRONT_FAIL_URL
=
"acpsdk.frontFailUrl"
;
public
static
final
String
SDK_FRONT_FAIL_URL
=
"acpsdk.frontFailUrl"
;
/** 操作对象. */
private
static
SDKConfig
config
=
null
;
/** 属性文件对象. */
protected
Properties
properties
;
protected
SDKConfig
()
{
super
();
}
/**
* 获取config对象.
* @return
*/
public
static
SDKConfig
getConfig
()
{
if
(
config
==
null
)
{
log
.
warn
(
"未主动调用loadPropertiesFromSrc或loadPropertiesFromPath方法,默认调loadPropertiesFromSrc初始化"
);
SDKConfig
.
loadPropertiesFromSrc
();
}
if
(
config
==
null
)
{
log
.
error
(
"初始化失败"
);
config
=
new
SDKConfig
();
}
return
config
;
}
/**
* 从properties文件加载
*
* @param rootPath
* 不包含文件名的目录.
*/
public
static
void
loadPropertiesFromPath
(
String
rootPath
)
{
Properties
properties
=
getPropertiesFromPath
(
rootPath
);
loadProperties
(
properties
);
}
protected
static
Properties
getPropertiesFromSrc
()
{
InputStream
in
=
null
;
try
{
log
.
info
(
"从classpath: "
+
SDKConfig
.
class
.
getClassLoader
().
getResource
(
""
).
getPath
()+
" 获取属性文件"
+
FILE_NAME
);
in
=
SDKConfig
.
class
.
getClassLoader
().
getResourceAsStream
(
FILE_NAME
);
if
(
in
==
null
)
{
log
.
error
(
FILE_NAME
+
"属性文件未能在classpath指定的目录下 "
+
SDKConfig
.
class
.
getClassLoader
().
getResource
(
""
).
getPath
()+
" 找到!"
);
return
null
;
}
Properties
properties
=
new
Properties
();
properties
.
load
(
in
);
return
properties
;
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
if
(
in
!=
null
)
{
try
{
in
.
close
();
}
catch
(
IOException
e
)
{
}
}
}
return
null
;
}
protected
static
Properties
getPropertiesFromPath
(
String
rootPath
)
{
if
(
rootPath
==
null
||
""
.
equals
(
rootPath
.
trim
()))
{
log
.
error
(
"rootPath为空"
);
return
null
;
}
String
path
=
rootPath
+
File
.
separator
+
FILE_NAME
;
log
.
info
(
"从路径读取配置文件: "
+
path
);
File
file
=
new
File
(
path
);
InputStream
in
=
null
;
if
(!
file
.
exists
())
{
log
.
error
(
rootPath
+
"不存在"
+
FILE_NAME
);
return
null
;
}
try
{
in
=
new
FileInputStream
(
file
);
Properties
properties
=
new
Properties
();
properties
.
load
(
in
);
return
properties
;
}
catch
(
FileNotFoundException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
if
(
in
!=
null
)
{
try
{
in
.
close
();
}
catch
(
IOException
e
)
{
}
}
}
return
null
;
}
/**
* 从classpath路径下加载配置参数
*/
public
static
void
loadPropertiesFromSrc
()
{
Properties
properties
=
getPropertiesFromSrc
();
loadProperties
(
properties
);
}
/**
* 根据传入的 {@link Properties}对象设置配置参数
*
* @param pro
*/
public
static
void
loadProperties
(
Properties
pro
)
{
config
=
new
SDKConfig
();
config
.
loadProperties1
(
pro
);
}
/**
* 根据传入的 {@link Properties}对象设置配置参数
*
* @param pro
*/
protected
void
loadProperties1
(
Properties
pro
)
{
if
(
pro
==
null
)
{
log
.
error
(
"loadProperties input is null"
);
return
;
}
if
(
this
.
properties
==
null
)
{
this
.
properties
=
pro
;
}
log
.
info
(
"开始从属性文件中加载配置项"
);
String
value
=
null
;
value
=
pro
.
getProperty
(
SDK_SIGNCERT_PATH
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
signCertPath
=
value
.
trim
();
log
.
info
(
"配置项:私钥签名证书路径==>"
+
SDK_SIGNCERT_PATH
+
"==>"
+
value
+
" 已加载"
);
}
value
=
pro
.
getProperty
(
SDK_SIGNCERT_PWD
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
signCertPwd
=
value
.
trim
();
log
.
info
(
"配置项:私钥签名证书密码==>"
+
SDK_SIGNCERT_PWD
+
" 已加载"
);
}
value
=
pro
.
getProperty
(
SDK_SIGNCERT_TYPE
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
signCertType
=
value
.
trim
();
log
.
info
(
"配置项:私钥签名证书类型==>"
+
SDK_SIGNCERT_TYPE
+
"==>"
+
value
+
" 已加载"
);
}
value
=
pro
.
getProperty
(
SDK_ENCRYPTCERT_PATH
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
encryptCertPath
=
value
.
trim
();
log
.
info
(
"配置项:敏感信息加密证书==>"
+
SDK_ENCRYPTCERT_PATH
+
"==>"
+
value
+
" 已加载"
);
}
value
=
pro
.
getProperty
(
SDK_VALIDATECERT_DIR
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
validateCertDir
=
value
.
trim
();
log
.
info
(
"配置项:验证签名证书路径(这里配置的是目录,不要指定到公钥文件)==>"
+
SDK_VALIDATECERT_DIR
+
"==>"
+
value
+
" 已加载"
);
}
value
=
pro
.
getProperty
(
SDK_PINENCRYPTCERT_PATH
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
pinEncryptCertPath
=
value
.
trim
();
log
.
info
(
"配置项:6.0.0统一支付产品加密pin证书路径(这里配置的是目录,不要指定到公钥文件)==>"
+
SDK_PINENCRYPTCERT_PATH
+
"==>"
+
value
+
" 已加载"
);
}
value
=
pro
.
getProperty
(
SDK_FRONT_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
frontRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_BACK_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
backRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_ORDER_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
orderRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_BATQ_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
batchQueryUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_BATTRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
batchTransUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_FILETRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
fileTransUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_SIGNQ_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
singleQueryUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_CARD_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
cardRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_APP_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
appRequestUrl
=
value
.
trim
();
}
// value = pro.getProperty(SDK_ENCRYPTTRACKCERT_PATH);
// if (!SDKUtil.isEmpty(value)) {
// this.encryptTrackCertPath = value.trim();
// }
value
=
pro
.
getProperty
(
SDK_SECURITYKEY
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
secureKey
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_ROOTCERT_PATH
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
rootCertPath
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_MIDDLECERT_PATH
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
middleCertPath
=
value
.
trim
();
}
/**缴费部分**/
value
=
pro
.
getProperty
(
JF_SDK_FRONT_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
jfFrontRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
JF_SDK_BACK_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
jfBackRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
JF_SDK_SINGLE_QUERY_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
jfSingleQueryUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
JF_SDK_CARD_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
jfCardRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
JF_SDK_APP_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
jfAppRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
QRC_BACK_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
qrcBackTransUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
QRC_B2C_ISS_BACK_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
qrcB2cIssBackTransUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
QRC_B2C_MER_BACK_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
qrcB2cMerBackTransUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
QRC_B2C_MER_BACK_SYN_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
qrcB2cMerBackSynTransUrl
=
value
.
trim
();
}
/**综合认证**/
value
=
pro
.
getProperty
(
ZHRZ_SDK_FRONT_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
zhrzFrontRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
ZHRZ_SDK_BACK_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
zhrzBackRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
ZHRZ_SDK_SINGLE_QUERY_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
zhrzSingleQueryUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
ZHRZ_SDK_CARD_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
zhrzCardRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
ZHRZ_SDK_APP_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
zhrzAppRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
ZHRZ_SDK_FACE_TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
zhrzFaceRequestUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
TRANS_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
transUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_ENCRYPTTRACKKEY_EXPONENT
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
encryptTrackKeyExponent
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_ENCRYPTTRACKKEY_MODULUS
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
encryptTrackKeyModulus
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_IF_VALIDATE_CN_NAME
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
if
(
SDKConstants
.
FALSE_STRING
.
equals
(
value
.
trim
()))
this
.
ifValidateCNName
=
false
;
}
value
=
pro
.
getProperty
(
SDK_IF_VALIDATE_REMOTE_CERT
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
if
(
SDKConstants
.
TRUE_STRING
.
equals
(
value
.
trim
()))
this
.
ifValidateRemoteCert
=
true
;
}
value
=
pro
.
getProperty
(
SDK_SIGN_METHOD
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
signMethod
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_SIGN_METHOD
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
signMethod
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_VERSION
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
version
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_FRONTURL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
frontUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_BACKURL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
backUrl
=
value
.
trim
();
}
value
=
pro
.
getProperty
(
SDK_FRONT_FAIL_URL
);
if
(!
SDKUtil
.
isEmpty
(
value
))
{
this
.
frontFailUrl
=
value
.
trim
();
}
}
public
String
getFrontRequestUrl
()
{
return
frontRequestUrl
;
}
public
String
getBackRequestUrl
()
{
return
backRequestUrl
;
}
public
String
getOrderRequestUrl
()
{
return
orderRequestUrl
;
}
public
String
getSignCertPath
()
{
return
signCertPath
;
}
public
String
getSignCertPwd
()
{
return
signCertPwd
;
}
public
String
getSignCertType
()
{
return
signCertType
;
}
public
String
getEncryptCertPath
()
{
return
encryptCertPath
;
}
public
String
getValidateCertDir
()
{
return
validateCertDir
;
}
public
String
getSingleQueryUrl
()
{
return
singleQueryUrl
;
}
public
String
getBatchQueryUrl
()
{
return
batchQueryUrl
;
}
public
String
getBatchTransUrl
()
{
return
batchTransUrl
;
}
public
String
getFileTransUrl
()
{
return
fileTransUrl
;
}
public
String
getSignCertDir
()
{
return
signCertDir
;
}
public
Properties
getProperties
()
{
return
properties
;
}
public
String
getCardRequestUrl
()
{
return
cardRequestUrl
;
}
public
String
getAppRequestUrl
()
{
return
appRequestUrl
;
}
// public String getEncryptTrackCertPath() {
// return encryptTrackCertPath;
// }
public
String
getPinEncryptCertPath
()
{
return
pinEncryptCertPath
;
}
public
String
getJfFrontRequestUrl
()
{
return
jfFrontRequestUrl
;
}
public
String
getJfBackRequestUrl
()
{
return
jfBackRequestUrl
;
}
public
String
getJfSingleQueryUrl
()
{
return
jfSingleQueryUrl
;
}
public
String
getJfCardRequestUrl
()
{
return
jfCardRequestUrl
;
}
public
String
getJfAppRequestUrl
()
{
return
jfAppRequestUrl
;
}
public
String
getSingleMode
()
{
return
singleMode
;
}
public
String
getEncryptTrackKeyExponent
()
{
return
encryptTrackKeyExponent
;
}
public
String
getEncryptTrackKeyModulus
()
{
return
encryptTrackKeyModulus
;
}
public
String
getSecureKey
()
{
return
secureKey
;
}
public
String
getMiddleCertPath
()
{
return
middleCertPath
;
}
public
boolean
isIfValidateCNName
()
{
return
ifValidateCNName
;
}
public
boolean
isIfValidateRemoteCert
()
{
return
ifValidateRemoteCert
;
}
public
String
getSignMethod
()
{
return
signMethod
;
}
public
String
getQrcBackTransUrl
()
{
return
qrcBackTransUrl
;
}
public
String
getQrcB2cIssBackTransUrl
()
{
return
qrcB2cIssBackTransUrl
;
}
public
String
getQrcB2cMerBackTransUrl
()
{
return
qrcB2cMerBackTransUrl
;
}
public
String
getQrcB2cMerBackSynTransUrl
()
{
return
qrcB2cMerBackSynTransUrl
;
}
public
String
getZhrzFrontRequestUrl
()
{
return
zhrzFrontRequestUrl
;
}
public
String
getZhrzBackRequestUrl
()
{
return
zhrzBackRequestUrl
;
}
public
String
getZhrzSingleQueryUrl
()
{
return
zhrzSingleQueryUrl
;
}
public
String
getZhrzCardRequestUrl
()
{
return
zhrzCardRequestUrl
;
}
public
String
getZhrzAppRequestUrl
()
{
return
zhrzAppRequestUrl
;
}
public
String
getZhrzFaceRequestUrl
()
{
return
zhrzFaceRequestUrl
;
}
public
String
getVersion
()
{
return
version
;
}
public
String
getFrontUrl
()
{
return
frontUrl
;
}
public
String
getBackUrl
()
{
return
backUrl
;
}
public
String
getFrontFailUrl
()
{
return
frontFailUrl
;
}
public
String
getRootCertPath
()
{
return
rootCertPath
;
}
public
String
getTransUrl
()
{
return
transUrl
;
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/SDKUtil.java
View file @
cb347737
...
@@ -19,6 +19,8 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -19,6 +19,8 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.codec.DecoderException
;
import
org.apache.commons.codec.DecoderException
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Hex
;
import
org.apache.commons.codec.binary.Hex
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -39,8 +41,10 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants.*;
...
@@ -39,8 +41,10 @@ import static com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants.*;
* @date 2016-7-22 下午4:06:18
* @date 2016-7-22 下午4:06:18
*/
*/
@Slf4j
@Slf4j
@Component
public
class
SDKUtil
{
public
class
SDKUtil
{
@Autowired
private
CertUtil
certUtil
;
/**
/**
* 全渠道5.0、二维码signType=01用。
* 全渠道5.0、二维码signType=01用。
* 1. 按ascii排序。【注意不是字母顺序】
* 1. 按ascii排序。【注意不是字母顺序】
...
@@ -55,14 +59,14 @@ public class SDKUtil {
...
@@ -55,14 +59,14 @@ public class SDKUtil {
* @param encoding
* @param encoding
* @return
* @return
*/
*/
public
static
String
signRsa
(
Map
<
String
,
String
>
data
,
String
certPath
,
String
certPwd
,
String
encoding
)
{
public
String
signRsa
(
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
[]
sha1
=
SecureUtil
.
sha1
(
stringData
.
getBytes
(
encoding
));
byte
[]
sha1
=
SecureUtil
.
sha1
(
stringData
.
getBytes
(
encoding
));
String
sha1Hex
=
byteArrayToHexString
(
sha1
).
toLowerCase
();
String
sha1Hex
=
byteArrayToHexString
(
sha1
).
toLowerCase
();
log
.
info
(
"sha1结果(交易返回11验证签名失败可以用来同正确的进行比对):["
+
sha1Hex
+
"]"
);
log
.
info
(
"sha1结果(交易返回11验证签名失败可以用来同正确的进行比对):["
+
sha1Hex
+
"]"
);
return
Base64
.
encodeBase64String
(
SecureUtil
.
getSignature
(
C
ertUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
sha1Hex
.
getBytes
()));
return
Base64
.
encodeBase64String
(
SecureUtil
.
getSignature
(
c
ertUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
sha1Hex
.
getBytes
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"calcSignRsa Error"
,
e
);
log
.
error
(
"calcSignRsa Error"
,
e
);
return
null
;
return
null
;
...
@@ -83,14 +87,14 @@ public class SDKUtil {
...
@@ -83,14 +87,14 @@ public class SDKUtil {
* @param encoding
* @param encoding
* @return
* @return
*/
*/
public
static
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
(
C
ertUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
sha256Hex
.
getBytes
()));
return
Base64
.
encodeBase64String
(
SecureUtil
.
getSignatureSHA256
(
c
ertUtil
.
getSignCertPrivateKeyByStoreMap
(
certPath
,
certPwd
),
sha256Hex
.
getBytes
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"calcSignRsa2 Error"
,
e
);
log
.
error
(
"calcSignRsa2 Error"
,
e
);
return
null
;
return
null
;
...
@@ -426,15 +430,15 @@ public class SDKUtil {
...
@@ -426,15 +430,15 @@ public class SDKUtil {
* @param certType
* @param certType
* @return
* @return
*/
*/
public
static
int
updateEncryptCert
(
String
strCert
,
String
certType
)
{
public
int
updateEncryptCert
(
String
strCert
,
String
certType
)
{
if
(
isEmpty
(
strCert
)
||
isEmpty
(
certType
))
if
(
isEmpty
(
strCert
)
||
isEmpty
(
certType
))
return
-
1
;
return
-
1
;
if
(
CERTTYPE_01
.
equals
(
certType
))
{
if
(
CERTTYPE_01
.
equals
(
certType
))
{
// 更新敏感信息加密公钥
// 更新敏感信息加密公钥
return
C
ertUtil
.
resetEncryptCertPublicKey
(
strCert
);
return
c
ertUtil
.
resetEncryptCertPublicKey
(
strCert
);
}
else
if
(
CERTTYPE_02
.
equals
(
certType
))
{
}
else
if
(
CERTTYPE_02
.
equals
(
certType
))
{
// 更新pin敏感信息加密公钥
// 更新pin敏感信息加密公钥
return
C
ertUtil
.
resetPinEncryptCertPublicKey
(
strCert
);
return
c
ertUtil
.
resetPinEncryptCertPublicKey
(
strCert
);
}
else
{
}
else
{
log
.
info
(
"unknown cerType:"
+
certType
);
log
.
info
(
"unknown cerType:"
+
certType
);
return
-
1
;
return
-
1
;
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/sdk/SecureUtil.java
View file @
cb347737
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/test/java/com/liquidnet/service/TestSdkConfig.java
0 → 100644
View file @
cb347737
package
com
.
liquidnet
.
service
;
import
com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: TestSdkConfig
* @Package com.liquidnet.service
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/11/9 10:57
*/
@Slf4j
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
TestSdkConfig
{
@Autowired
private
SDKConfig
sdkConfig
;
@Test
public
void
pringSdkConfigInfo
(){
System
.
out
.
println
(
sdkConfig
.
getFileTransUrl
());
System
.
out
.
println
(
sdkConfig
.
getSignCertPath
());
System
.
out
.
println
(
sdkConfig
.
getSignCertPwd
());
System
.
out
.
println
(
sdkConfig
.
getSignCertType
());
System
.
out
.
println
(
sdkConfig
.
getEncryptCertPath
());
System
.
out
.
println
(
sdkConfig
.
getMiddleCertPath
());
System
.
out
.
println
(
sdkConfig
.
getRootCertPath
());
}
}
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