记得上下班打卡 | 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
9df3d29d
Commit
9df3d29d
authored
Feb 24, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调试素材上传接口
parent
54e2b094
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
274 additions
and
69 deletions
+274
-69
ZxlnftBiz.java
...java/com/liquidnet/common/third/zxlnft/biz/ZxlnftBiz.java
+21
-0
ZxlnftConfig.java
...om/liquidnet/common/third/zxlnft/config/ZxlnftConfig.java
+12
-4
Nft022UploadSecretReq.java
...et/common/third/zxlnft/dto/nft/Nft022UploadSecretReq.java
+1
-1
WalletSdkServiceImpl.java
...ommon/third/zxlnft/service/impl/WalletSdkServiceImpl.java
+50
-3
ZxlnftSdkServiceImpl.java
...ommon/third/zxlnft/service/impl/ZxlnftSdkServiceImpl.java
+22
-14
ZxlWalletSdkUtil.java
.../liquidnet/common/third/zxlnft/util/ZxlWalletSdkUtil.java
+86
-0
ZxlnftSdkUtil.java
...com/liquidnet/common/third/zxlnft/util/ZxlnftSdkUtil.java
+4
-31
TestZxlWalletSdkUtil.java
...m/liquidnet/service/zxlnft/test/TestZxlWalletSdkUtil.java
+48
-12
TestZxlnftSdkUtil.java
.../com/liquidnet/service/zxlnft/test/TestZxlnftSdkUtil.java
+30
-4
No files found.
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/biz/ZxlnftBiz.java
View file @
9df3d29d
...
...
@@ -9,6 +9,7 @@ import com.liquidnet.common.third.zxlnft.dto.wallet.SignByPriKeyResp;
import
com.liquidnet.common.third.zxlnft.exception.ZxlNftException
;
import
com.liquidnet.common.third.zxlnft.service.WalletSdkService
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.MultiValueMap
;
...
...
@@ -22,6 +23,7 @@ import org.springframework.util.MultiValueMap;
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/21 11:19
*/
@Slf4j
@Component
public
class
ZxlnftBiz
{
@Autowired
...
...
@@ -29,6 +31,10 @@ public class ZxlnftBiz {
@Autowired
private
WalletSdkService
walletSdkService
;
/**
* 构造鉴权方案二
* @param commonHeader
*/
public
void
buildHeader
(
MultiValueMap
<
String
,
String
>
commonHeader
){
GenerateApiSignReq
req
=
GenerateApiSignReq
.
getNew
();
req
.
setAppId
(
""
);
...
...
@@ -40,8 +46,14 @@ public class ZxlnftBiz {
commonHeader
.
add
(
"Signature-Time"
,
resp
.
getSignData
().
getSignatureTime
());
commonHeader
.
add
(
"Nonce"
,
resp
.
getSignData
().
getNonce
());
commonHeader
.
add
(
"Content-Type"
,
"application/json;charset=utf-8"
);
log
.
info
(
"buildHeader ---> {}"
,
JsonUtils
.
toJson
(
commonHeader
));
}
/**
* 构造鉴权方案一
* @param commonHeader
*/
public
void
buildPlatFormHeader
(
MultiValueMap
<
String
,
String
>
commonHeader
){
GenerateApiSignReq
req
=
GenerateApiSignReq
.
getNew
();
req
.
setAppId
(
zxlnftConfig
.
getAppId
());
...
...
@@ -49,10 +61,13 @@ public class ZxlnftBiz {
GenerateApiSignResp
resp
=
walletSdkService
.
generateApiSign
(
req
);
commonHeader
.
clear
();
commonHeader
.
add
(
"App-Id"
,
req
.
getAppId
());
commonHeader
.
add
(
"Signature"
,
resp
.
getSignData
().
getSignature
());
commonHeader
.
add
(
"Signature-Time"
,
resp
.
getSignData
().
getSignatureTime
());
commonHeader
.
add
(
"Nonce"
,
resp
.
getSignData
().
getNonce
());
commonHeader
.
add
(
"Content-Type"
,
"application/json;charset=utf-8"
);
log
.
info
(
"buildPlatFormHeader ---> {}"
,
JsonUtils
.
toJson
(
commonHeader
));
}
public
static
<
T
>
T
buildNftRespObj
(
String
response
,
Class
<
T
>
tClass
){
...
...
@@ -77,6 +92,12 @@ public class ZxlnftBiz {
return
resp
;
}
/**
* 接口内签名
* @param key
* @param data
* @return
*/
public
String
createSign
(
String
key
,
String
data
){
SignByPriKeyReq
req
=
SignByPriKeyReq
.
getNew
();
req
.
setPriKey
(
key
);
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/config/ZxlnftConfig.java
View file @
9df3d29d
...
...
@@ -17,9 +17,9 @@ import java.io.UnsupportedEncodingException;
*/
@Configuration
public
class
ZxlnftConfig
{
@Value
(
"${liquidnet.zxlnft.appId:
'220214000100001'
}"
)
@Value
(
"${liquidnet.zxlnft.appId:
220214000100001
}"
)
private
String
appId
;
@Value
(
"${liquidnet.zxlnft.appKey:
'82b561110c4b4f4d91ad2a2b0d5b7908'
}"
)
@Value
(
"${liquidnet.zxlnft.appKey:
82b561110c4b4f4d91ad2a2b0d5b7908
}"
)
private
String
appKey
;
@Value
(
"${liquidnet.zxlnft.nftPlatformAddress:ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4}"
)
private
String
nftPlatformAddress
;
...
...
@@ -27,9 +27,9 @@ public class ZxlnftConfig {
private
String
nftPlatformPubKey
;
@Value
(
"${liquidnet.zxlnft.nftPlatformPriKey:LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR1RBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUJITTlWQVlJdEJIa3dkd0lCQVFRZ1VhbTVWM2V6ZFZJTmNoZ28KVDRKL28zMHArMGJCd3hQWUZFL01FdEU3MTZhZ0NnWUlLb0VjejFVQmdpMmhSQU5DQUFTVkpJRXpqU3NkOUVTUQpKeGd0NFdaQ0RYZ2ZJZW5JVTZja3F5ZENPWFFIOXRiMzRSbTg2Yy83bWIvUVowLzViZWl2R2NuRFBMeXlGcjgxCnNQd0E5L25JCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K}"
)
private
String
nftPlatformPriKey
;
@Value
(
"${liquidnet.zxlnft.walletSdkUrl:
'http://127.0.0.1:30505'
}"
)
@Value
(
"${liquidnet.zxlnft.walletSdkUrl:
http://127.0.0.1:30505
}"
)
private
String
walletSdkUrl
;
@Value
(
"${liquidnet.zxlnft.nftApiUrl:
'https://nfttest2.zxinchain.com'
}"
)
@Value
(
"${liquidnet.zxlnft.nftApiUrl:
https://nfttest2.zxinchain.com
}"
)
private
String
nftApiUrl
;
public
String
getAppId
(){
...
...
@@ -44,6 +44,14 @@ public class ZxlnftConfig {
return
nftPlatformAddress
;
}
// public String getNftPlatformPubKey(){
// return nftPlatformPubKey;
// }
//
// public String getNftPlatformPriKey(){
// return nftPlatformPriKey;
// }
public
String
getNftPlatformPubKey
(){
String
pubKey
=
null
;
try
{
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/dto/nft/Nft022UploadSecretReq.java
View file @
9df3d29d
...
...
@@ -22,7 +22,7 @@ public class Nft022UploadSecretReq implements Serializable {
/**
* 10位时间戳,秒为单位,5分钟内有效
*/
private
String
ti
em
stamp
;
private
String
ti
me
stamp
;
/**
* 平台公钥
*/
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/service/impl/WalletSdkServiceImpl.java
View file @
9df3d29d
...
...
@@ -58,7 +58,7 @@ public class WalletSdkServiceImpl implements WalletSdkService {
public
GenerateApiSignResp
generateApiSign
(
GenerateApiSignReq
req
)
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"appId"
,
req
.
getAppId
());
json
.
put
(
"apKey"
,
req
.
getAppKey
());
json
.
put
(
"ap
p
Key"
,
req
.
getAppKey
());
String
requestUrl
=
zxlnftConfig
.
getWalletSdkUrl
()
+
ZxlnftConstant
.
WALLET_SDK_02_GENERATE_API_SIGN
;
log
.
info
(
"generateApiSign--->>> request url : {} body : {} "
,
requestUrl
,
json
.
toString
());
...
...
@@ -83,7 +83,32 @@ public class WalletSdkServiceImpl implements WalletSdkService {
@Override
public
UploadToCosResp
uploadToCos
(
UploadToCosReq
req
)
{
return
null
;
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"cosPath"
,
req
.
getCosPath
());
json
.
put
(
"tempSecretId"
,
req
.
getTempSecretId
());
json
.
put
(
"tempSecretKey"
,
req
.
getTempSecretKey
());
json
.
put
(
"sessionToken"
,
req
.
getSessionToken
());
json
.
put
(
"filePath"
,
req
.
getFilePath
());
String
requestUrl
=
zxlnftConfig
.
getWalletSdkUrl
()
+
ZxlnftConstant
.
WALLET_SDK_03_UPLOAD_TO_COS
;
log
.
info
(
"uploadToCos--->>> request url : {} body : {} "
,
requestUrl
,
json
.
toString
());
String
response
=
null
;
// ObjectNode objectNode = JsonUtils.OM().createObjectNode();
try
{
response
=
HttpUtil
.
postJson
(
requestUrl
,
json
.
toString
(),
commonHeader
);
}
catch
(
HttpClientErrorException
e
)
{
log
.
error
(
"uploadToCos error"
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"uploadToCos error"
,
e
);
}
log
.
info
(
"uploadToCos--->>> response : {} "
,
response
);
if
(
StringUtils
.
isEmpty
(
response
))
{
return
null
;
}
UploadToCosResp
resp
=
JsonUtils
.
fromJson
(
response
,
UploadToCosResp
.
class
);
return
resp
;
}
@Override
...
...
@@ -93,7 +118,29 @@ public class WalletSdkServiceImpl implements WalletSdkService {
@Override
public
DeriveKeyPairResp
deriveKeyPair
(
DeriveKeyPairReq
req
)
{
return
null
;
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"mnemonic"
,
req
.
getMnemonic
());
json
.
put
(
"index"
,
req
.
getIndex
());
String
requestUrl
=
zxlnftConfig
.
getWalletSdkUrl
()
+
ZxlnftConstant
.
WALLET_SDK_05_DERIVE_KEY_PAIR
;
log
.
info
(
"deriveKeyPair--->>> request url : {} body : {} "
,
requestUrl
,
json
.
toString
());
String
response
=
null
;
// ObjectNode objectNode = JsonUtils.OM().createObjectNode();
try
{
response
=
HttpUtil
.
postJson
(
requestUrl
,
json
.
toString
(),
commonHeader
);
}
catch
(
HttpClientErrorException
e
)
{
log
.
error
(
"deriveKeyPair error"
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"deriveKeyPair error"
,
e
);
}
log
.
info
(
"deriveKeyPair--->>> response : {} "
,
response
);
if
(
StringUtils
.
isEmpty
(
response
))
{
return
null
;
}
DeriveKeyPairResp
resp
=
JsonUtils
.
fromJson
(
response
,
DeriveKeyPairResp
.
class
);
return
resp
;
}
@Override
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/service/impl/ZxlnftSdkServiceImpl.java
View file @
9df3d29d
package
com
.
liquidnet
.
common
.
third
.
zxlnft
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftConstant
;
import
com.liquidnet.common.third.zxlnft.dto.nft.*
;
import
com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService
;
import
com.liquidnet.commons.lang.util.HttpUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -222,27 +222,35 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService
@Override
public
Nft022UploadSecretResp
nft022UploadSecret
(
Nft022UploadSecretReq
req
)
{
zxlnftBiz
.
buildHeader
(
commonHeader
);
zxlnftBiz
.
build
PlatForm
Header
(
commonHeader
);
MultiValueMap
<
String
,
Object
>
params
=
new
LinkedMultiValueMap
();
List
<
String
>
addressList
=
new
ArrayList
();
// MultiValueMap<String, Object> params = new LinkedMultiValueMap();
// List<String> addressList = new ArrayList();
// if(StringUtil.isNotEmpty(req.getSeriesName())){
// params.add("seriesName", req.getSeriesName());
// }
// params.add("tiemstamp", req.getTiemstamp());
// params.add("pubKey", req.getPubKey());
// params.add("pubSignedData", req.getPubSignedData());
// params.add("userPubKey", req.getUserPubKey());
// params.add("userSignedData", req.getUserSignedData());
JSONObject
json
=
new
JSONObject
();
if
(
StringUtil
.
isNotEmpty
(
req
.
getSeriesName
())){
params
.
add
(
"seriesName"
,
req
.
getSeriesName
());
json
.
put
(
"seriesName"
,
req
.
getSeriesName
());
}
params
.
add
(
"tiemstamp"
,
req
.
getTiemstamp
());
params
.
add
(
"pubKey"
,
req
.
getPubKey
());
params
.
add
(
"pubSignedData"
,
req
.
getPubSignedData
());
params
.
add
(
"userPubKey"
,
req
.
getUserPubKey
());
params
.
add
(
"userSignedData"
,
req
.
getUserSignedData
());
json
.
put
(
"timestamp"
,
req
.
getTimestamp
());
json
.
put
(
"pubKey"
,
req
.
getPubKey
());
json
.
put
(
"pubSignedData"
,
req
.
getPubSignedData
());
json
.
put
(
"userPubKey"
,
req
.
getUserPubKey
());
json
.
put
(
"userSignedData"
,
req
.
getUserSignedData
());
String
requestUrl
=
zxlnftConfig
.
getNftApiUrl
()
+
ZxlnftConstant
.
ZXL_NFT_022_UPLOAD_SECRET_URL
;
log
.
info
(
"nft022UploadSecret--->>> request url : {} body : {} "
,
requestUrl
,
JsonUtils
.
toJson
(
params
));
log
.
info
(
"nft022UploadSecret--->>> request url : {} body : {} "
,
requestUrl
,
json
.
toString
(
));
String
response
=
null
;
try
{
response
=
HttpUtil
.
postJson
(
requestUrl
,
JsonUtils
.
toJson
(
params
),
commonHeader
);
response
=
HttpUtil
.
postJson
(
requestUrl
,
json
.
toString
(
),
commonHeader
);
}
catch
(
HttpClientErrorException
e
)
{
log
.
error
(
"nft022UploadSecret error"
,
e
);
}
catch
(
Exception
e
)
{
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/util/ZxlWalletSdkUtil.java
0 → 100644
View file @
9df3d29d
package
com
.
liquidnet
.
common
.
third
.
zxlnft
.
util
;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.*
;
import
com.liquidnet.common.third.zxlnft.service.WalletSdkService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxlWalletSdkUtil
* @Package com.liquidnet.common.third.zxlnft.util
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/2/24 16:08
*/
@Slf4j
@Component
public
class
ZxlWalletSdkUtil
{
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
@Autowired
private
WalletSdkService
walletSdkService
;
/**
* 1、生成助记词
* @param req
* @return
*/
public
CreateMnemonicResp
createMnemonic
(
CreateMnemonicReq
req
){
CreateMnemonicResp
resp
=
walletSdkService
.
createMnemonic
(
req
);
return
resp
;
}
/**
* 2、API签名
* @param req
* @return
*/
public
GenerateApiSignResp
generateApiSign
(
GenerateApiSignReq
req
){
GenerateApiSignResp
resp
=
walletSdkService
.
generateApiSign
(
req
);
return
resp
;
}
/**
* 3、文件上传至COS
* @param req
* @return
*/
public
UploadToCosResp
uploadToCos
(
UploadToCosReq
req
){
UploadToCosResp
resp
=
walletSdkService
.
uploadToCos
(
req
);
return
resp
;
}
/**
* 5、派生生成子公私钥对
* @param req
* @return
*/
public
DeriveKeyPairResp
deriveKeyPair
(
DeriveKeyPairReq
req
){
DeriveKeyPairResp
resp
=
walletSdkService
.
deriveKeyPair
(
req
);
return
resp
;
}
/**
* 6、SDK签名
* @param req
* @return
*/
public
SignByPriKeyResp
signByPriKey
(
SignByPriKeyReq
req
){
SignByPriKeyResp
resp
=
walletSdkService
.
signByPriKey
(
req
);
return
resp
;
}
/**
* 10、SDK验签
* @param req
* @return
*/
public
VerifyByPubKeyResp
verifyByPubKey
(
VerifyByPubKeyReq
req
){
VerifyByPubKeyResp
resp
=
walletSdkService
.
verifyByPubKey
(
req
);
return
resp
;
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-zxlnft/src/main/java/com/liquidnet/common/third/zxlnft/util/ZxlnftSdkUtil.java
View file @
9df3d29d
...
...
@@ -2,8 +2,6 @@ package com.liquidnet.common.third.zxlnft.util;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.dto.nft.*
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.*
;
import
com.liquidnet.common.third.zxlnft.service.WalletSdkService
;
import
com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -13,45 +11,20 @@ import org.springframework.stereotype.Component;
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class:
Easemob
Util
* @Package com.liquidnet.common.third.
easemob
.util
* @Copyright: LightNet @ Copyright (c) 202
1
* @date 202
1/9/6
16:08
* @class:
ZxlnftSdk
Util
* @Package com.liquidnet.common.third.
zxlnft
.util
* @Copyright: LightNet @ Copyright (c) 202
2
* @date 202
2/2/24
16:08
*/
@Slf4j
@Component
public
class
ZxlnftSdkUtil
{
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
@Autowired
private
WalletSdkService
walletSdkService
;
@Autowired
private
ZxlnftSdkService
zxlnftSdkService
;
public
CreateMnemonicResp
createMnemonic
(
CreateMnemonicReq
req
){
CreateMnemonicResp
resp
=
walletSdkService
.
createMnemonic
(
req
);
return
resp
;
}
public
GenerateApiSignResp
generateApiSign
(
GenerateApiSignReq
req
){
GenerateApiSignResp
resp
=
walletSdkService
.
generateApiSign
(
req
);
return
resp
;
}
public
SignByPriKeyResp
signByPriKey
(
SignByPriKeyReq
req
){
SignByPriKeyResp
resp
=
walletSdkService
.
signByPriKey
(
req
);
return
resp
;
}
public
VerifyByPubKeyResp
verifyByPubKey
(
VerifyByPubKeyReq
req
){
VerifyByPubKeyResp
resp
=
walletSdkService
.
verifyByPubKey
(
req
);
return
resp
;
}
public
Nft016IdentityBindQueryResp
nft016IdentityBindQuery
(
Nft016IdentityBindQueryReq
req
){
req
.
setAddressList
(
zxlnftConfig
.
getNftPlatformAddress
());
Nft016IdentityBindQueryResp
resp
=
zxlnftSdkService
.
nft016IdentityBindQuery
(
req
);
...
...
liquidnet-bus-service/liquidnet-service-zxlnft/liquidnet-service-zxlnft-impl/src/test/java/com/liquidnet/service/zxlnft/test/TestZxlWalletSdkUtil.java
View file @
9df3d29d
package
com
.
liquidnet
.
service
.
zxlnft
.
test
;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicReq
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.GenerateApiSignReq
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.SignByPriKeyReq
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.VerifyByPubKeyReq
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.*
;
import
com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -27,25 +24,61 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@SpringBootTest
public
class
TestZxlWalletSdkUtil
{
@Autowired
private
Zxl
nftSdkUtil
zxlnf
tSdkUtil
;
private
Zxl
WalletSdkUtil
zxlWalle
tSdkUtil
;
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
/**
* 1、生成助记词
*/
@Test
public
void
createMnemonic
(){
CreateMnemonicReq
req
=
CreateMnemonicReq
.
getNew
();
zxl
nf
tSdkUtil
.
createMnemonic
(
req
);
zxl
Walle
tSdkUtil
.
createMnemonic
(
req
);
}
/**
* 2、API签名
*/
@Test
public
void
generateApiSign
(){
GenerateApiSignReq
req
=
GenerateApiSignReq
.
getNew
();
req
.
setAppId
(
""
);
req
.
setAppKey
(
""
);
zxl
nf
tSdkUtil
.
generateApiSign
(
req
);
zxl
Walle
tSdkUtil
.
generateApiSign
(
req
);
}
/**
* 2、API签名
*/
@Test
public
void
uploadToCos
(){
UploadToCosReq
req
=
UploadToCosReq
.
getNew
();
req
.
setCosPath
(
"https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/zxl_image_test_001.jpg"
);
req
.
setTempSecretId
(
"AKIDhVGgR7gKaVE5qUIpSPD9k6pcmUj7fobmEspHDlCjC27Te6Dmputh-fI87qvL2EDT"
);
req
.
setTempSecretKey
(
"xuNqn+FfVjm0Ug0je9k1Mn5MQHKlWKs18uU03KIMAH0="
);
req
.
setSessionToken
(
"fwJfhxx5ILXFYNItgiQid1bBiTrofX5af128eb2fa96eef4d9841c98756853142d0X-nPNtZgA0AEIwJ-MAJigzB3IZOgDjLorykjfoxAHusyQ_HeAhvHSlORtPol_iqqJVolGP78H5byiZKhKxATIZiJzrTCQysR02tR1vJPkJp03VH70sSzTJ3WcyTPpBs_NCuXkYvLZaDbRKmE8Xln4uqDJDSthNNaQKBJBYJNnxmVpCRCIeIyqOvQrSKXRGkvkjQ79Enlq7iUeKSqXrpKEBliAq9hgMrXPRHapqihseRl-WerjB4BgQ261mmOuZD6oHg37EPy_JrHAJxHh9dJlFlqz3CxUL-We36RcQeDpLvL1KuzZUBBmjSb0SYMvnun7SOEDdDMF0-1ApATsyQ-bTgDiCHAoo5Xqf9CcFKop-rUeQEDKSV17raeRRcN6ZcBQ-BJ5s4R4bqRm3y1nUwePNKD1Hi2__-nPUKuI5o535wkQcqMeDhQ40Fg3jCcPPRJ-9_Egp3yTEraTkfihKDAXTZnhiQdxaDInlP1JFJKZwY5b0hinlW6yaxnaUzYyXqTVY2tEufNOu5Sn4fGOTZmyqJJ0oDsCJiby-92vKqIS9fHIzemEXfuCULNdonmEThspBA7tUAUr-fY1KCjTMolhG0XvsJ-hNVzwNbpLMLd87TwajlyqJisnn5-sR-wuj9Hx9Inoe5kTRX-0F0NeP9vcfpYZns5No5jrBM74HMgOOSplXZ3yuML42LxTtw9SWcsxqFQJpohTyijpbrwdkKlwc0qGyUIPy7WQ7Jltb7iE"
);
req
.
setFilePath
(
"/Users/anjiabin/Downloads/zxl_image_test_001.jpg"
);
zxlWalletSdkUtil
.
uploadToCos
(
req
);
}
/**
* 5、派生生成子公私钥对
*/
@Test
public
void
deriveKeyPair
(){
DeriveKeyPairReq
req
=
DeriveKeyPairReq
.
getNew
();
// req.setPriKey(zxlnftConfig.getNftPlatformPriKey());
req
.
setMnemonic
(
"stuff"
);
req
.
setIndex
(
0
l
);
//3045022072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54
zxlWalletSdkUtil
.
deriveKeyPair
(
req
);
}
/**
* 6、SDK签名
*/
@Test
public
void
signByPriKey
(){
SignByPriKeyReq
req
=
SignByPriKeyReq
.
getNew
();
...
...
@@ -53,16 +86,19 @@ public class TestZxlWalletSdkUtil {
req
.
setPriKey
(
zxlnftConfig
.
getNftPlatformPriKey
());
req
.
setData
(
"ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4"
);
//3045022072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54
zxl
nf
tSdkUtil
.
signByPriKey
(
req
);
zxl
Walle
tSdkUtil
.
signByPriKey
(
req
);
}
/**
* 10、SDK验签
*/
@Test
public
void
verifyByPubKey
(){
VerifyByPubKeyReq
req
=
VerifyByPubKeyReq
.
getNew
();
req
.
setPubKey
(
zxlnftConfig
.
getNftPlatformPubKey
());
req
.
setData
(
"ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4
-
"
);
req
.
setSignedData
(
"3045022
072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54
"
);
req
.
setData
(
"ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4"
);
req
.
setSignedData
(
"3045022
100f062e29953951317c6577ba5d7641d3f19c38930dbb8a93e7b9be699f3f208450220723b87ec6c1f4efd3f70b39b586b74bf52576c6ca8a8bb3d9ddd21255651dff8
"
);
//3045022072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54
zxl
nf
tSdkUtil
.
verifyByPubKey
(
req
);
zxl
Walle
tSdkUtil
.
verifyByPubKey
(
req
);
}
}
liquidnet-bus-service/liquidnet-service-zxlnft/liquidnet-service-zxlnft-impl/src/test/java/com/liquidnet/service/zxlnft/test/TestZxlnftS
erver
Util.java
→
liquidnet-bus-service/liquidnet-service-zxlnft/liquidnet-service-zxlnft-impl/src/test/java/com/liquidnet/service/zxlnft/test/TestZxlnftS
dk
Util.java
View file @
9df3d29d
...
...
@@ -6,6 +6,7 @@ import com.liquidnet.common.third.zxlnft.dto.nft.Nft016IdentityBindQueryReq;
import
com.liquidnet.common.third.zxlnft.dto.nft.Nft016IdentityBindQueryResp
;
import
com.liquidnet.common.third.zxlnft.dto.nft.Nft022UploadSecretReq
;
import
com.liquidnet.common.third.zxlnft.dto.nft.Nft022UploadSecretResp
;
import
com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -27,7 +28,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@Slf4j
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
TestZxlnftServerUtil
{
public
class
TestZxlnftSdkUtil
{
@Autowired
private
ZxlWalletSdkUtil
zxlWalletSdkUtil
;
@Autowired
private
ZxlnftSdkUtil
zxlnftSdkUtil
;
...
...
@@ -46,13 +50,35 @@ public class TestZxlnftServerUtil {
@Test
public
void
nft022UploadSecret
(){
/**
* 生成公私钥
*/
// DeriveKeyPairReq wReq = DeriveKeyPairReq.getNew();
// wReq.setMnemonic("stuff");
// wReq.setIndex(0l);
// DeriveKeyPairResp wResp = zxlWalletSdkUtil.deriveKeyPair(wReq);
// Nft022UploadSecretReq req = Nft022UploadSecretReq.getNew();
//// req.setSeriesName("");
// req.setTiemstamp(DateUtil.getNowSeconds().toString());
// req.setPubKey(wResp.getPubKey());
// req.setUserPubKey(wResp.getPubKey());
// String pubData = req.getTiemstamp() + "_" + req.getUserPubKey();
// String userData = req.getTiemstamp();
// req.setPubSignedData(zxlnftBiz.createSign(wResp.getPriKey(),pubData));
// req.setUserSignedData(zxlnftBiz.createSign(wResp.getPriKey(),userData));
//系列不为空
// req.setPubSignedData(req.getTiemstamp() + "_" + req.getSeriesName() + "_" + req.getUserPubKey());
// req.setUserSignedData(req.getTiemstamp() + "_" + req.getSeriesName() );
Nft022UploadSecretReq
req
=
Nft022UploadSecretReq
.
getNew
();
// req.setSeriesName("");
req
.
setTi
em
stamp
(
DateUtil
.
getNowSeconds
().
toString
());
req
.
setTi
me
stamp
(
DateUtil
.
getNowSeconds
().
toString
());
req
.
setPubKey
(
zxlnftConfig
.
getNftPlatformPubKey
());
req
.
setUserPubKey
(
zxlnftConfig
.
getNftPlatformPubKey
());
String
pubData
=
req
.
getTi
em
stamp
()
+
"_"
+
req
.
getUserPubKey
();
String
userData
=
req
.
getTi
em
stamp
();
String
pubData
=
req
.
getTi
me
stamp
()
+
"_"
+
req
.
getUserPubKey
();
String
userData
=
req
.
getTi
me
stamp
();
req
.
setPubSignedData
(
zxlnftBiz
.
createSign
(
zxlnftConfig
.
getNftPlatformPriKey
(),
pubData
));
req
.
setUserSignedData
(
zxlnftBiz
.
createSign
(
zxlnftConfig
.
getNftPlatformPriKey
(),
userData
));
//系列不为空
...
...
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