Skip to content

Commit

Permalink
Merge pull request #67 from WeBankFinTech/dev
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
CodingCattwo committed Apr 29, 2020
2 parents 12684a3 + 3f53fac commit d78b032
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 32 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Created by .ignore support plugin (hsz.mobi)
### Java template
*.class


# Package Files #
*.war
*.ear

### Gradle template
.gradle
/build
gradle.properties
.project

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

.idea
*.iml

# OS X
.DS_Store

/target
/out
/log
/dist
*.crt
*.key



15 changes: 11 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ List spring_boot =[
"org.springframework.boot:spring-boot-starter-web:$spring_boot_version",
"org.springframework.boot:spring-boot-autoconfigure:$spring_boot_version",
"org.springframework.boot:spring-boot-configuration-processor:$spring_boot_version",
"org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version"
// "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version"
]

List mysql = [
Expand All @@ -38,7 +38,7 @@ List swagger = [
'io.springfox:springfox-swagger-ui:2.8.0'
]

def log4j_version="2.9.0"
def log4j_version="2.13.1"
List logger = [
"org.apache.logging.log4j:log4j-api:$log4j_version",
"org.apache.logging.log4j:log4j-core:$log4j_version",
Expand Down Expand Up @@ -79,8 +79,15 @@ List jaxb = [
"javax.activation:activation:1.1.1"
]

List jackson = [
"com.fasterxml.jackson.core:jackson-databind:2.10.0",
"com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.0",
"com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.0",
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.0"
]

dependencies {
compile spring_boot,mysql,swagger,web3sdk,logger,netty,dangdang,zookeeper,jaxb
compile spring_boot,mysql,swagger,web3sdk,logger,netty,dangdang,zookeeper,jaxb,jackson
// guomi contract compile: USE 'socJ-all-0.4.25-gm' to REPLACE 'ethereum:solcJ-all'
compile ("org.fisco-bcos:web3sdk:2.2.0")
// {
Expand All @@ -89,7 +96,7 @@ dependencies {
// compile fileTree(dir:'lib',includes:['solcJ-all-0.4.25-gm.jar'])
compile "org.apache.commons:commons-lang3:3.6"
compile "commons-io:commons-io:2.4"
compile "com.alibaba:fastjson:1.2.60"
compile "com.alibaba:fastjson:1.2.67"
compile "io.shardingsphere:sharding-jdbc-spring-boot-starter:3.1.0"
compile 'org.projectlombok:lombok:1.18.2'
annotationProcessor 'org.projectlombok:lombok:1.18.2'
Expand Down
6 changes: 6 additions & 0 deletions sider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ linter:
dir: src
encoding: Shift_JIS
min_priority: 2
checkstyle:
config: google
dir: src
ignore:
- warning
- info
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public interface ConstantCode {
RetCode GROUPID_NOT_CONFIGURED =
RetCode.mark(303019, "request group id has not been configured");
RetCode SIGN_USERID_EMPTY =
RetCode.mark(303020, "sign user id cannot be empty while sign type is 2");
RetCode SIGN_USERID_ERROR = RetCode.mark(303021, "sign user id check failed");
RetCode.mark(303020, "signUserId cannot be empty while sign type is 2");
RetCode SIGN_USERID_ERROR = RetCode.mark(303021, "signUserId check failed");
RetCode FUNCTION_NOT_EXISTS = RetCode.mark(303022, "function is not exists");
RetCode DATA_NOT_EXISTS = RetCode.mark(303023, "data is not exists");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@ public ResponseEntity deploy(ReqDeployInfo req) throws BaseException {
}
// check sign user id
if (SignType.CLOUDCALL.getValue() == req.getSignType()) {
if (req.getSignUserId() == null) {
String signUserId = req.getSignUserId();
if (StringUtils.isBlank(signUserId)) {
log.warn("deploy fail. sign user id is empty");
throw new BaseException(ConstantCode.SIGN_USERID_EMPTY);
} else {
boolean result = keyStoreService.checkSignUserId(req.getSignUserId());
boolean result = keyStoreService.checkSignUserId(signUserId);
if (!result) {
throw new BaseException(ConstantCode.SIGN_USERID_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class DeployInfoDto {
private String contractAddress;
private String funcParam;
private int signType;
private int signUserId;
private String signUserId;
private int requestCount;
private int handleStatus = 0;
private String transHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ReqDeployInfo {
private String uuidDeploy;
@NotNull(message = ConstantCode.SIGN_TYPE_IS_EMPTY)
private Integer signType;
private Integer signUserId = 0;
private String signUserId;
@NotBlank(message = ConstantCode.CONTRACT_BIN_IS_EMPTY)
private String contractBin;
@NotEmpty(message = ConstantCode.CONTRACT_ABI_IS_EMPTY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,28 @@ public String getRandomAddress() throws BaseException {
}

/**
* getSignDate from sign service.
* getSignDatd from webase-sign service.
*
* @param params params
* @return
*/
public String getSignDate(EncodeInfo params) {
public String getSignData(EncodeInfo params) {
try {
SignInfo signInfo = new SignInfo();
String url = String.format(SIGN_ADDSIGN_URL, properties.getSignServer());
log.info("getSignDate url:{}", url);
log.info("getSignData url:{}", url);
HttpHeaders headers = CommonUtils.buildHeaders();
HttpEntity<String> formEntity =
new HttpEntity<String>(JSON.toJSONString(params), headers);
ResponseEntity response =
restTemplate.postForObject(url, formEntity, ResponseEntity.class);
log.info("getSignDate response:{}", JSON.toJSONString(response));
log.info("getSignData response:{}", JSON.toJSONString(response));
if (response.getCode() == 0) {
signInfo = CommonUtils.object2JavaBean(response.getData(), SignInfo.class);
}
return signInfo.getSignDataStr();
} catch (Exception e) {
log.error("getSignDate exception", e);
log.error("getSignData exception", e);
LogUtils.monitorAbnormalLogger().error(ConstantProperties.CODE_ABNORMAL_S0005,
ConstantProperties.MSG_ABNORMAL_S0005);
}
Expand All @@ -140,12 +140,12 @@ public String getSignDate(EncodeInfo params) {
/**
* checkSignUserId.
*
* @param userId userId
* @param signUserId business id of user in sign
* @return
*/
public boolean checkSignUserId(int userId) {
public boolean checkSignUserId(String signUserId) {
try {
String url = String.format(SIGN_USERINFO_URL, properties.getSignServer(), userId);
String url = String.format(SIGN_USERINFO_URL, properties.getSignServer(), signUserId);
log.info("checkSignUserId url:{}", url);
ResponseEntity response = restTemplate.getForObject(url, ResponseEntity.class);
log.info("checkSignUserId response:{}", JSON.toJSONString(response));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
*/
@Data
public class EncodeInfo {
private Integer userId;
private String signUserId;
private String encodedDataStr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@
import org.fisco.bcos.web3j.abi.datatypes.Function;
import org.fisco.bcos.web3j.abi.datatypes.Type;
import org.fisco.bcos.web3j.crypto.Credentials;
import org.fisco.bcos.web3j.crypto.RawTransaction;
import org.fisco.bcos.web3j.crypto.ExtendedRawTransaction;
import org.fisco.bcos.web3j.crypto.EncryptType;
import org.fisco.bcos.web3j.crypto.TransactionEncoder;
import org.fisco.bcos.web3j.crypto.ExtendedTransactionEncoder;
import org.fisco.bcos.web3j.crypto.RawTransaction;
import org.fisco.bcos.web3j.crypto.Sign.SignatureData;
import org.fisco.bcos.web3j.crypto.TransactionEncoder;
import org.fisco.bcos.web3j.crypto.gm.GenCredential;
import org.fisco.bcos.web3j.protocol.Web3j;
import org.fisco.bcos.web3j.protocol.core.DefaultBlockParameterName;
Expand Down Expand Up @@ -123,11 +124,12 @@ public ResponseEntity save(ReqTransSendInfo req) throws BaseException {
}
// check sign user id
if (SignType.CLOUDCALL.getValue() == req.getSignType()) {
if (req.getSignUserId() == null) {
String signUserId = req.getSignUserId();
if (StringUtils.isBlank(signUserId)) {
log.warn("deploy fail. sign user id is empty");
throw new BaseException(ConstantCode.SIGN_USERID_EMPTY);
} else {
boolean result = keyStoreService.checkSignUserId(req.getSignUserId());
boolean result = keyStoreService.checkSignUserId(signUserId);
if (!result) {
throw new BaseException(ConstantCode.SIGN_USERID_ERROR);
}
Expand Down Expand Up @@ -501,7 +503,7 @@ public void transSend(TransInfoDto transInfoDto) {
* @param data info
* @return
*/
public String signMessage(int groupId, int signType, int signUserId, String contractAddress,
public String signMessage(int groupId, int signType, String signUserId, String contractAddress,
String data) throws IOException, BaseException {
Random r = new Random();
BigInteger randomid = new BigInteger(250, r);
Expand All @@ -527,8 +529,8 @@ public String signMessage(int groupId, int signType, int signUserId, String cont

EncodeInfo encodeInfo = new EncodeInfo();
encodeInfo.setEncodedDataStr(encodedDataStr);
encodeInfo.setUserId(signUserId);
String signDataStr = keyStoreService.getSignDate(encodeInfo);
encodeInfo.setSignUserId(signUserId);
String signDataStr = keyStoreService.getSignData(encodeInfo);
if (StringUtils.isBlank(signDataStr)) {
log.warn("deploySend get sign data error.");
return null;
Expand Down Expand Up @@ -563,8 +565,8 @@ BigInteger.ZERO, data, new BigInteger(chainId),

EncodeInfo encodeInfo = new EncodeInfo();
encodeInfo.setEncodedDataStr(encodedDataStr);
encodeInfo.setUserId(signUserId);
String signDataStr = keyStoreService.getSignDate(encodeInfo);
encodeInfo.setSignUserId(signUserId);
String signDataStr = keyStoreService.getSignData(encodeInfo);
if (StringUtils.isBlank(signDataStr)) {
log.warn("deploySend get sign data error.");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ReqTransSendInfo {
private String uuidDeploy;
@NotNull(message = ConstantCode.SIGN_TYPE_IS_EMPTY)
private Integer signType;
private Integer signUserId = 0;
private String signUserId;
private List<Object> contractAbi = new ArrayList<>();
private String contractAddress;
@NotBlank(message = ConstantCode.FUNCTION_NAME_IS_EMPTY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class TransInfoDto {
private String funcName;
private String funcParam;
private int signType;
private int signUserId;
private String signUserId;
private int requestCount;
private int handleStatus = 0;
private String transHash;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mapper/ContractMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
contract_address varchar(64) COMMENT '合约地址',
func_param text COMMENT '构造方法的入参json',
sign_type tinyint(4) DEFAULT '0' COMMENT '签名 类型(0-本地配置私钥,1-本地随机私钥,2-调用签名服务)',
sign_user_id int(11) COMMENT '调用签名服务的用户编号',
sign_user_id varchar(64) COMMENT '调用签名服务的用户uuid编号',
request_count tinyint(4) DEFAULT '0' COMMENT '请求次数',
handle_status tinyint(4) DEFAULT '0' COMMENT '处理状态(0-待处理,1-处理成功)',
trans_hash varchar(128) COMMENT '交易hash值',
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mapper/StatelessTransMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
func_name varchar(32) NOT NULL COMMENT '调用的合约方法名',
func_param text COMMENT '合约方法的入参json',
sign_type tinyint(4) DEFAULT '0' COMMENT '签名 类型(0-本地配置私钥,1-本地随机私钥,2-调用签名服务)',
sign_user_id int(11) COMMENT '调用签名服务的用户编号',
sign_user_id varchar(64) COMMENT '调用签名服务的用户编号',
request_count tinyint(4) DEFAULT '0' COMMENT '请求次数',
handle_status tinyint(4) DEFAULT '0' COMMENT '处理状态(0-待处理,1-处理成功)',
trans_hash varchar(128) COMMENT '交易hash值',
Expand Down

0 comments on commit d78b032

Please sign in to comment.