Skip to content

Commit

Permalink
Merge pull request #235 from youwenbusi/develop
Browse files Browse the repository at this point in the history
develop
  • Loading branch information
youwenbusi authored Apr 28, 2023
2 parents f170b16 + 56544fe commit e4d0499
Show file tree
Hide file tree
Showing 23 changed files with 97 additions and 42 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### V3.1.0 (2023-4-28)
* 优化功能:
1. 修复创建并启用新的应用后配置文件没有更新chain.id导致registerAuthorityIssuer失败
2. 生成的WeIdentity配置文件支持本地数据库部署
3. 集成weid-java-sdk 3.1.0和weid-kit 3.1.0
4. 更新多个已知漏洞的组件

### V3.0.0 (2022-12-15)
* 优化功能:
1. 修复registerPolicy失败和部署Evidence合约失败
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ WeIdentity JAVA SDK安装部署工具

| weid-build-tools 版本 | weid-java-sdk 版本 | weid-contract-java 版本 | 备注 |
| :---- | :---- | :---- | :---- |
| v3.1.0 | v3.1.0 | v1.3.2 | 适配weid-java-sdk数据库部署方式 |
| v3.0.0 | v3.0.0 | v1.3.1 | 适配重构weid-java-sdk |
| v1.3.1 | v1.8.6 | v1.3.1 | 替换合约,改变获取所有weid的方式 |
| v1.3.0 | v1.8.5 | v1.3.0 | 替换web3sdk、支持国密和FISCO BCOS 3.0 |
| v1.0.28 | v1.8.3 | v1.2.30 | 升级log4j |
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0-rc.1
3.1.0-rc.1
37 changes: 27 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ List jcommander = [
"com.beust:jcommander:1.72"
]

def log4j_version="2.18.0"
def log4j_version="2.20.0"
List log4j = [
"org.apache.logging.log4j:log4j-api:$log4j_version",
"org.apache.logging.log4j:log4j-web:$log4j_version",
Expand All @@ -77,7 +77,7 @@ List log4j = [
"org.slf4j:slf4j-api:1.7.30"
]

def jackson_version="2.13.3"
def jackson_version="2.14.2"
List json = [
"com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jackson_version",
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
Expand All @@ -97,10 +97,10 @@ List http_proxy = [
]

List redis_driver = [
"org.redisson:redisson:3.15.6"
"org.redisson:redisson:3.20.0"
]

def spring_version = "5.3.18"
def spring_version = "5.3.25"
List spring = [
"org.springframework:spring-aop:$spring_version",
"org.springframework:spring-beans:$spring_version",
Expand All @@ -115,16 +115,33 @@ List spring = [
"org.springframework:spring-web:$spring_version"
]

def gson_version = "2.8.9"
def gson_version = "2.10.1"
List gson = [
"com.google.code.gson:gson:$gson_version"
]

def netty_version = "4.1.89.Final";
List netty = [
"io.netty:netty-common:$netty_version",
"io.netty:netty-codec:$netty_version",
"io.netty:netty-buffer:$netty_version",
"io.netty:netty-transport:$netty_version",
"io.netty:netty-resolver:$netty_version",
"io.netty:netty-resolver-dns:$netty_version",
"io.netty:netty-handler:$netty_version",
"io.netty:netty-handler-proxy:$netty_version",
"io.netty:netty-all:$netty_version",
"io.netty:netty-codec-dns:$netty_version",
"io.netty:netty-resolver-dns-native-macos:$netty_version",
"io.netty:netty-transport-native-kqueue:$netty_version",
]

configurations {
localDeps
all*.exclude group: "org.slf4j", module: "slf4j-log4j12"
all*.exclude group: "ch.qos.logback"
all*.exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j"
all*.exclude group: "io.netty", module: "netty-tcnative"
}

configurations.all {
Expand All @@ -137,29 +154,29 @@ dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-websocket")
// cover old version
compile 'io.netty:netty-all:4.1.68.Final'
//compile 'io.netty:netty-all:4.1.86.Final'
if (gradleVer.startsWith("4")) {
if (!gradle.startParameter.isOffline()) {
compile lombok, jcommander, log4j, spring, gson, json, mysql_driver, redis_driver, http_proxy
compile lombok, jcommander, log4j, spring, gson, json, mysql_driver, redis_driver, http_proxy, netty
compile("com.webank:weid-java-sdk:${weidSdkVersion}") {
exclude group: "org.springframework", module: "*"
exclude group: "javax.validation", module: "validation-api"
exclude group: "org.codehaus.jackson", module: "jackson-mapper-asl"
}
compile("com.webank:weid-kit:3.0.0-rc.1")
compile("com.webank:weid-kit:3.1.0-rc.1")
}
}
if (gradleVer.startsWith("5")) {
if (!gradle.startParameter.isOffline()) {
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
compile lombok, jcommander, log4j, spring, gson, json, mysql_driver, redis_driver, http_proxy
compile lombok, jcommander, log4j, spring, gson, json, mysql_driver, redis_driver, http_proxy, netty
compile("com.webank:weid-java-sdk:${weidSdkVersion}") {
exclude group: "org.springframework", module: "*"
exclude group: "javax.validation", module: "validation-api"
exclude group: "org.codehaus.jackson", module: "jackson-mapper-asl"
}
compile("com.webank:weid-kit:3.0.0-rc.1")
compile("com.webank:weid-kit:3.1.0-rc.1")
} else {
compileOnly files('dist/lib/lombok-1.18.12.jar')
annotationProcessor files('dist/lib/lombok-1.18.12.jar')
Expand Down
20 changes: 19 additions & 1 deletion common/script/tpl/weidentity.properties.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
# application config #
# #
#######################################################################################################
# Deploy WeIdentity with blockchain or only database
deploy.style=${DEPLOY_STYLE}
# Crypto type, only use for deploy with database, 0 for ECDSA, 1 for SM
crypto.type=${CRYPTO_TYPE}

# The organization ID for AMOP communication.
blockchain.orgid=${ORG_ID}

# The Blockchain Type
blockchain.type=${CHAIN_TYPE}

# The Chain Id
chain.id=${CHAIN_ID}

Expand Down Expand Up @@ -65,7 +73,7 @@ redis_cluster.master_connection_pool_size=64
# persistence domain config #
# #
#######################################################################################################
# Domain configuration, which divides colons into two segments, the first segment is the name of the data source,
# Domain configuration, which divides colons into two segments, the first segment is the name of the data source,
# the second segment is the name of the table, and if not, the default is the first data source and the default table `sdk_all_data`,
# Multiple domains can be configured at the same time.
# example:
Expand Down Expand Up @@ -99,6 +107,16 @@ domain.weIdAuth=datasource1:weid_auth
domain.resourceInfo=datasource1:resource_info
domain.resourceInfo.timeout=31556908799941

# tables for running locally
local.weIdDocument=datasource1:table_weid_document
local.cpt=datasource1:table_cpt
local.policy=datasource1:table_policy
local.presentation=datasource1:table_presentation
local.role=datasource1:table_role
local.authorityIssuer=datasource1:table_authority_issuer
local.specificIssuer=datasource1:table_specific_issuer
local.evidence=datasource1:table_evidence


#######################################################################################################
# #
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
weidSdkVersion=3.0.0-rc.1
weidSdkVersion=3.1.0-rc.1
repoType=zn
jdkTlsNamedGroups=secp256r1,secp256k1
signing.keyId=
Expand Down
6 changes: 3 additions & 3 deletions run.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#fill with your node ip and channel_listen_port, example: 0.0.0.0:20200
#if you have more than one node ,you can put them with separator","
#for example: 0.0.0.0:20200,0:0:0:1:20200
blockchain_address=10.107.120.121:25200
blockchain_address=10.107.120.121:29200

#this build tool supports FISCO BCOS 2.0 and FISCO BCOS 3.0
#if you want to build on FISCO BCOS 2.0, please fill with "2".
Expand All @@ -20,7 +20,7 @@ org_id=webank
amop_id=11

#chain id
chain_id=1
chain_id=112

#group id
group_id=group0
Expand All @@ -41,4 +41,4 @@ redis_password=
#"stg" to set the test environment, "prd" to set the production environment.
#If you do not set it, the system will use allOrg as the environment by default.
#It is not recommended. Production use default configuration
cns_profile_active=prdabf
cns_profile_active=prdabd
4 changes: 2 additions & 2 deletions src/main/java/com/webank/weid/command/CreateWeId.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import com.webank.weid.config.StaticConfig;
import com.webank.weid.constant.DataFrom;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.WeIdSdkService;
import com.webank.weid.util.FileUtils;
import com.webank.weid.util.WeIdUtils;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/webank/weid/command/EnableShareCns.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import com.beust.jcommander.JCommander;
import com.webank.weid.config.StaticConfig;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.ContractService;

public class EnableShareCns extends StaticConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import com.beust.jcommander.JCommander;
import com.webank.weid.config.StaticConfig;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.WeIdSdkService;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/webank/weid/command/RegistCpt.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import com.beust.jcommander.JCommander;
import com.webank.weid.config.StaticConfig;
import com.webank.weid.constant.DataFrom;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.dto.CptFile;
import com.webank.weid.protocol.base.WeIdAuthentication;
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.WeIdSdkService;
import com.webank.weid.service.impl.WeIdServiceImpl;
import com.webank.weid.service.rpc.WeIdService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.webank.weid.contract.deploy.AddressProcess;
import com.webank.weid.contract.v2.DataBucket;
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.util.DataToolUtils;
import com.webank.weid.blockchain.util.DataToolUtils;
import com.webank.weid.util.WeIdSdkUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import com.beust.jcommander.JCommander;
import com.webank.weid.config.StaticConfig;
import com.webank.weid.constant.DataFrom;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.WeIdSdkService;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/webank/weid/command/ToPojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

import com.beust.jcommander.JCommander;
import com.webank.weid.constant.DataFrom;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.constant.FileOperator;
import com.webank.weid.dto.CptFile;
import com.webank.weid.protocol.base.PresentationPolicyE;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.WeIdSdkService;
import com.webank.weid.util.DataToolUtils;
import com.webank.weid.util.FileUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.webank.weid.constant.ErrorCode;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.WeIdSdkService;
import com.webank.weid.util.FileUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import com.webank.weid.blockchain.deploy.v3.DeployContractV3;
import com.webank.weid.constant.BuildToolsConstant;
import com.webank.weid.constant.DataFrom;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.constant.WeIdConstant;
import com.webank.weid.dto.CnsInfo;
import com.webank.weid.dto.DeployInfo;
import com.webank.weid.dto.ShareInfo;
import com.webank.weid.exception.WeIdBaseException;
import com.webank.weid.protocol.base.AuthorityIssuer;
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.ConfigService;
import com.webank.weid.service.ContractService;
import com.webank.weid.util.WeIdSdkUtils;
Expand Down Expand Up @@ -183,6 +183,7 @@ public ResponseData<Boolean> enableHash(@PathVariable("hash") String hash) {
contract.setCptAddress(deployInfo.getCptAddress());
if (StringUtils.isNotBlank(deployInfo.getChainId())) {
fiscoConfig.setChainId(deployInfo.getChainId());
configService.updateChainId(deployInfo.getChainId());
} else {
//兼容历史数据
fiscoConfig.setChainId(configService.loadConfig().get("chain_id"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.webank.weid.dto.*;
import com.webank.weid.protocol.base.AuthorityIssuer;
import com.webank.weid.protocol.base.IssuerType;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.ContractService;
import com.webank.weid.service.WeIdSdkService;
import com.webank.weid.util.DataToolUtils;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/webank/weid/service/ConfigService.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public void updateChainId(String chainId) {
}
FileUtils.writeToFile(buffer.toString(), "run.config", FileOperator.OVERWRITE);
backRunConfig();
generateProperties();
}


Expand Down Expand Up @@ -382,6 +383,13 @@ private void generateWeidentityProperties(Map<String, String> loadConfig) {
fileStr = fileStr.replace("${ORG_ID}", loadConfig.get("org_id"));
fileStr = fileStr.replace("${AMOP_ID}", loadConfig.get("amop_id"));
fileStr = fileStr.replace("${CHAIN_ID}", loadConfig.get("chain_id"));

//暂时默认blockchain部署方式
fileStr = fileStr.replace("${DEPLOY_STYLE}", "blockchain");
fileStr = fileStr.replace("${CRYPTO_TYPE}", loadConfig.get("sm_crypto"));
//暂时默认使用FISCO BCOS区块链底层
fileStr = fileStr.replace("${CHAIN_TYPE}", "FISCO_BCOS");

fileStr = fileStr.replace("${BLOCKCHIAN_NODE_INFO}", loadConfig.get("blockchain_address"));
fileStr = fileStr.replace("${PERSISTENCE_TYPE}", loadConfig.get("persistence_type"));
fileStr = fileStr.replace("${MYSQL_ADDRESS}", loadConfig.get("mysql_address"));
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/webank/weid/service/ContractService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.protocol.request.CptStringArgs;
import com.webank.weid.protocol.request.CreateWeIdArgs;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.impl.CptServiceImpl;
import com.webank.weid.service.impl.WeIdServiceImpl;
import com.webank.weid.util.*;
Expand Down Expand Up @@ -62,7 +63,7 @@ public ResponseData<String> deploy(String chainId, String applyName) {
FiscoConfig fiscoConfig = WeIdSdkUtils.loadNewFiscoConfig();
fiscoConfig.setChainId(chainId);
String hash = deployContract(fiscoConfig, DataFrom.WEB);
//configService.updateChainId(chainId);
configService.updateChainId(chainId);
log.info("[deploy] the hash: {}", hash);
//将应用名写入配置中
applyName = StringEscapeUtils.unescapeHtml(applyName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.webank.weid.service;

import com.webank.weid.constant.ErrorCode;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.suite.persistence.Persistence;
import com.webank.weid.suite.persistence.PersistenceFactory;
import com.webank.weid.suite.persistence.PersistenceType;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/webank/weid/service/WeIdSdkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
import com.webank.weid.protocol.request.RegisterAuthorityIssuerArgs;
import com.webank.weid.protocol.request.RemoveAuthorityIssuerArgs;
import com.webank.weid.protocol.response.CreateWeIdDataResult;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.blockchain.protocol.response.ResponseData;
import com.webank.weid.service.rpc.AuthorityIssuerService;
import com.webank.weid.service.rpc.CptService;
import com.webank.weid.service.rpc.PolicyService;
import com.webank.weid.service.rpc.WeIdService;
import com.webank.weid.blockchain.service.fisco.server.WeServerUtils;
import com.webank.weid.blockchain.constant.CnsType;
import com.webank.weid.blockchain.protocol.base.HashContract;
import com.webank.weid.blockchain.constant.ErrorCode;
import com.webank.weid.service.impl.AuthorityIssuerServiceImpl;
import com.webank.weid.service.impl.CptServiceImpl;
import com.webank.weid.service.impl.PolicyServiceImpl;
Expand Down
Loading

0 comments on commit e4d0499

Please sign in to comment.