Skip to content

Commit

Permalink
Merge pull request #184 from WeBankFinTech/feature/support-lite-crede…
Browse files Browse the repository at this point in the history
…ntial

Feature/support delegate setAttribute method
  • Loading branch information
junqizhang-dev committed Apr 26, 2020
2 parents 076cbc9 + 16c0870 commit 26169de
Show file tree
Hide file tree
Showing 9 changed files with 544 additions and 115 deletions.
14 changes: 2 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,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.18") {
exclude group: "org.fisco-bcos", module: "web3sdk"
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
compile("org.fisco-bcos:web3sdk:2.1.3"){
exclude group:"io.netty"
compile("com.webank:weid-contract-java:1.2.19") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
compile files("lib/WeDPR-Java-SDK.jar")
Expand All @@ -159,12 +154,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.18") {
exclude group: "org.fisco-bcos", module: "web3sdk"
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
compile("org.fisco-bcos:web3sdk:2.3.0"){
// exclude group: "io.netty"
compile("com.webank:weid-contract-java:1.2.19") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
compile files("lib/WeDPR-Java-SDK.jar")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright© (2018-2020) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
* weid-java-sdk is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* weid-java-sdk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with weid-java-sdk. If not, see <https://www.gnu.org/licenses/>.
*/

package com.webank.weid.protocol.request;

import lombok.Data;

/**
* The Arguments when setting Authentication for WeIdentity DID.
*
* @author tonychen 2020.4.24
*/
@Data
public class AuthenticationArgs {

/**
* Required: The WeIdentity DID.
*/
private String weId;

/**
* Required: The owner.
*/
private String owner;

/**
* Required: The public key.
*/
private String publicKey;

}
60 changes: 60 additions & 0 deletions src/main/java/com/webank/weid/protocol/request/PublicKeyArgs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright© (2018-2020) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
* weid-java-sdk is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* weid-java-sdk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with weid-java-sdk. If not, see <https://www.gnu.org/licenses/>.
*/

package com.webank.weid.protocol.request;

import lombok.Data;

/**
* The Arguments when setting Public Key for WeIdentity DID.
*
* @author tonychen 2020.4.24
*/
@Data
public class PublicKeyArgs {

/**
* Required: The WeIdentity DID.
*/
private String weId;

/**
* Required: The type.
*/
private String type = "Secp256k1";

/**
* Required: The owner.
*/
private String owner;

/**
* Required: The public key.
*/
private String publicKey;

/**
* nothing to do.
*
* @param type the public key type
*/
public void setType(String type) {
this.type = "Secp256k1";
}
}
47 changes: 47 additions & 0 deletions src/main/java/com/webank/weid/protocol/request/ServiceArgs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright© (2018-2020) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
* weid-java-sdk is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* weid-java-sdk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with weid-java-sdk. If not, see <https://www.gnu.org/licenses/>.
*/

package com.webank.weid.protocol.request;

import lombok.Data;

/**
* The Arguments when setting services.
*
* @author tonychen 2020.4.24
*/
@Data
public class ServiceArgs {

/**
* Required: user's WeIdentity DID.
*/
private String weId;

/**
* Required: service type.
*/
private String type;

/**
* Required: service endpoint.
*/
private String serviceEndpoint;

}
39 changes: 39 additions & 0 deletions src/main/java/com/webank/weid/rpc/WeIdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import com.webank.weid.protocol.base.WeIdAuthentication;
import com.webank.weid.protocol.base.WeIdDocument;
import com.webank.weid.protocol.base.WeIdPublicKey;
import com.webank.weid.protocol.request.AuthenticationArgs;
import com.webank.weid.protocol.request.CreateWeIdArgs;
import com.webank.weid.protocol.request.PublicKeyArgs;
import com.webank.weid.protocol.request.ServiceArgs;
import com.webank.weid.protocol.request.SetAuthenticationArgs;
import com.webank.weid.protocol.request.SetPublicKeyArgs;
import com.webank.weid.protocol.request.SetServiceArgs;
Expand Down Expand Up @@ -88,6 +91,18 @@ ResponseData<String> delegateCreateWeId(
*/
ResponseData<Boolean> setPublicKey(SetPublicKeyArgs setPublicKeyArgs);

/**
* Set public key in the WeIdentity DID Document.
*
* @param publicKeyArgs the set public key args
* @param delegateAuth the delegate's auth
* @return true if the "set" operation succeeds, false otherwise.
*/
ResponseData<Boolean> delegateSetPublicKey(
PublicKeyArgs publicKeyArgs,
WeIdAuthentication delegateAuth
);

/**
* Set service properties.
*
Expand All @@ -96,6 +111,18 @@ ResponseData<String> delegateCreateWeId(
*/
ResponseData<Boolean> setService(SetServiceArgs setServiceArgs);

/**
* Set service properties.
*
* @param serviceArgs your service name and endpoint
* @param delegateAuth the delegate's auth
* @return true if the "set" operation succeeds, false otherwise.
*/
ResponseData<Boolean> delegateSetService(
ServiceArgs serviceArgs,
WeIdAuthentication delegateAuth
);

/**
* Set authentications in WeIdentity DID.
*
Expand All @@ -104,6 +131,18 @@ ResponseData<String> delegateCreateWeId(
*/
ResponseData<Boolean> setAuthentication(SetAuthenticationArgs setAuthenticationArgs);

/**
* Set authentications in WeIdentity DID.
*
* @param authenticationArgs A public key is needed.
* @param delegateAuth the delegate's auth
* @return true if the "set" operation succeeds, false otherwise.
*/
ResponseData<Boolean> delegateSetAuthentication(
AuthenticationArgs authenticationArgs,
WeIdAuthentication delegateAuth
);

/**
* Check if the WeIdentity DID exists on chain.
*
Expand Down

0 comments on commit 26169de

Please sign in to comment.