Skip to content

Commit

Permalink
Merge pull request #207 from WeBankFinTech/feature/weid-delegate-with…
Browse files Browse the repository at this point in the history
…-rolecheck

- WeID Delegate call now requires admin/committee
  • Loading branch information
junqizhang-dev committed May 20, 2020
2 parents a2a48a6 + 9f074ea commit a7b6050
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ dependencies {
if (gradleVer.startsWith("4")) {
if (!gradle.startParameter.isOffline()) {
compile logger, lombok, apache_commons, json, mysql_driver, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.19") {
compile("com.webank:weid-contract-java:1.2.20") {
exclude group: "org.fisco-bcos", module: "web3sdk"
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
Expand All @@ -158,7 +158,7 @@ dependencies {
testAnnotationProcessor 'org.projectlombok:lombok:1.18.10'
testCompileOnly 'org.projectlombok:lombok:1.18.10'
compile logger, apache_commons, json, mysql_driver, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.19") {
compile("com.webank:weid-contract-java:1.2.20") {
exclude group: "org.fisco-bcos", module: "web3sdk"
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ protected static void initWeb3j() {
public static void deployContract(String privateKey) {
initWeb3j();
initCredentials(privateKey);
String weIdContractAddress = deployWeIdContract();
String roleControllerAddress = deployRoleControllerContracts();
String weIdContractAddress = deployWeIdContract(roleControllerAddress);
Map<String, String> addrList = deployIssuerContracts(roleControllerAddress);
if (addrList.containsKey("AuthorityIssuerData")) {
String authorityIssuerDataAddress = addrList.get("AuthorityIssuerData");
Expand All @@ -130,14 +130,14 @@ public static void deployContract(String privateKey) {
deployEvidenceContractsNew();
registerToCns();
}

private static void registerToCns() {
String privateKey = AddressProcess.getAddressFromFile("ecdsa_key");
WeIdPrivateKey weIdPrivate = new WeIdPrivateKey();
weIdPrivate.setPrivateKey(privateKey);
RegisterAddressV2.registerAddress(weIdPrivate);
}


private static String deployRoleControllerContracts() {
if (web3j == null) {
Expand All @@ -158,7 +158,7 @@ private static String deployRoleControllerContracts() {
}
}

private static String deployWeIdContract() {
private static String deployWeIdContract(String roleControllerAddress) {
if (web3j == null) {
initWeb3j();
}
Expand All @@ -168,7 +168,8 @@ private static String deployWeIdContract() {
weIdContract = WeIdContract.deploy(
web3j,
credentials,
new StaticGasProvider(WeIdConstant.GAS_PRICE, WeIdConstant.GAS_LIMIT))
new StaticGasProvider(WeIdConstant.GAS_PRICE, WeIdConstant.GAS_LIMIT),
roleControllerAddress)
.send();
} catch (Exception e) {
logger.error("WeIdContract deploy error.", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright© (2018) WeBank Co., Ltd.
* Copyright© (2018-2020) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
Expand Down Expand Up @@ -157,6 +157,13 @@ public void testDifferentPublicKeyType() {
.delegateSetPublicKey(publicKeyArgs, weIdAuthentication);
weIdDoc = weIdService.getWeIdDocument(createWeIdResult.getWeId());
Assert.assertEquals(weIdDoc.getResult().getPublicKey().size(), 3);
weIdAuthentication = new WeIdAuthentication();
weIdAuthentication.setWeId(createWeIdResult.getWeId());
weIdAuthentication.setWeIdPrivateKey(createWeIdResult.getUserWeIdPrivateKey());
ResponseData<Boolean> resp2 = weIdService
.delegateSetPublicKey(publicKeyArgs, weIdAuthentication);
weIdDoc = weIdService.getWeIdDocument(createWeIdResult.getWeId());
Assert.assertEquals(weIdDoc.getResult().getPublicKey().size(), 3);
}

/**
Expand Down

0 comments on commit a7b6050

Please sign in to comment.