Skip to content

Commit

Permalink
Merge pull request #297 from WeBankFinTech/release/1.8.1
Browse files Browse the repository at this point in the history
Release/1.8.1
  • Loading branch information
junqizhang-dev authored Apr 25, 2021
2 parents 012c95a + ddb71db commit b226bfe
Show file tree
Hide file tree
Showing 12 changed files with 469 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.0
1.8.1
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ dependencies {
localDeps 'org.projectlombok:lombok:1.18.10'
if (!gradle.startParameter.isOffline()) {
compile logger, lombok, apache_commons, json, mysql_driver, redisson, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.29") {
compile("com.webank:weid-contract-java:1.2.30") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
compile fileTree(dir: 'lib', include: '*.jar')
Expand Down
108 changes: 100 additions & 8 deletions docs/zh_CN/docs/weidentity-java-sdk-doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ WeIdentity Java SDK提供了一整套对WeIdentity进行管理操作的Java库
#. 查询授权机构:调用AuthorityIssuerService的queryAuthorityIssuerInfo()查阅生成的授权机构数据;
#. 注册CPT:通过CptService的registerCpt(),通过之前生成的WeIdentity DID身份创建一个你喜欢的CPT模板;
#. 查询CPT:调用CptService的queryCpt()查阅生成的CPT模板;
#. 生成凭证:通过CredentialPojoService的CreateCredential(),根据CPT模板,生成一份Credential;
#. 查询凭证:调用CredentialPojoService的Verify(),验证此Credential是否合法;
#. 凭证存证上链:调用EvidenceService的CreateEvidence(),将之前生成的Credential生成一份Hash存证上链;
#. 验证链上凭证存证:调用EvidenceService的VerifyEvidence(),和链上对比,验证Credential是否被篡改。
#. 生成凭证:通过CredentialPojoService的createCredential(),根据CPT模板,生成一份Credential;
#. 查询凭证:调用CredentialPojoService的verify(),验证此Credential是否合法;
#. 凭证存证上链:调用EvidenceService的createEvidence(),将之前生成的Credential生成一份Hash存证上链;
#. 验证链上凭证存证:调用EvidenceService的verifySigner(),和链上对比,验证Credential是否被篡改。

代码结构说明
------------
Expand Down Expand Up @@ -9356,11 +9356,57 @@ com.webank.weid.protocol.base.EvidenceSignInfo
.. code-block:: text
接口名称:com.webank.weid.rpc.EvidenceService.verifySigner
接口定义:ResponseData<Boolean> verify(EvidenceInfo evidenceInfo, String weId)
接口描述: 根据传入的存证信息和WeID,从链上根据WeID的公钥,判断此存证是否合法。
接口定义:ResponseData<Boolean> verify(CredentialPojo credentialPojo, EvidenceInfo evidenceInfo, String weId)
接口描述: 根据传入的凭证和存证信息和WeID,从链上根据WeID的公钥,判断此存证是否合法。
**接口入参**\ :

com.webank.weid.protocol.base.CredentialPojo

.. list-table::
:header-rows: 1

* - 名称
- 类型
- 说明
- 备注
* - context
- String
-
-
* - type
- List<String>
-
-
* - id
- String
- 证书ID
-
* - cptId
- Integer
- cptId
-
* - issuer
- String
- issuer 的 WeIdentity DID
-
* - issuanceDate
- Long
- 创建日期
-
* - expirationDate
- Long
- 到期日期
-
* - claim
- Map<String, Object>
- Claim数据
-
* - proof
- Map<String, Object>
- 签名数据结构体
-

com.webank.weid.protocol.base.EvidenceInfo

.. list-table::
Expand Down Expand Up @@ -9486,11 +9532,57 @@ java.lang.String
.. code-block:: text
接口名称:com.webank.weid.rpc.EvidenceService.verifySigner
接口定义:ResponseData<Boolean> verify(EvidenceInfo evidenceInfo, String weId, String publicKey)
接口描述: 根据传入的存证信息和WeID,及传入的公钥,判断此WeID是否为存证的合法创建者。不需要链上交互。
接口定义:ResponseData<Boolean> verify(CredentialPojo credentialPojo, EvidenceInfo evidenceInfo, String weId, String publicKey)
接口描述: 根据传入的凭证和存证信息和WeID,及传入的公钥,判断此WeID是否为存证的合法创建者。不需要链上交互。
**接口入参**\ :

com.webank.weid.protocol.base.CredentialPojo

.. list-table::
:header-rows: 1

* - 名称
- 类型
- 说明
- 备注
* - context
- String
-
-
* - type
- List<String>
-
-
* - id
- String
- 证书ID
-
* - cptId
- Integer
- cptId
-
* - issuer
- String
- issuer 的 WeIdentity DID
-
* - issuanceDate
- Long
- 创建日期
-
* - expirationDate
- Long
- 到期日期
-
* - claim
- Map<String, Object>
- Claim数据
-
* - proof
- Map<String, Object>
- 签名数据结构体
-

com.webank.weid.protocol.base.EvidenceInfo

.. list-table::
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/webank/weid/constant/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,22 @@ public enum ErrorCode {
"the specific issuer type or address does not exist."
),

/**
* The capacity has reached the upper limit.
*/
SPECIFIC_ISSUER_CONTRACT_ERROR_EXCEED_MAX(
500503,
"the capacity has reached the upper limit."
),

/**
* Has issuer in the specific issuer type.
*/
SPECIFIC_ISSUER_CONTRACT_ERROR_EXIST_ISSUER(
500504,
"has issuer in the specific issuer type."
),

/**
* The weid invalid.
*/
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/webank/weid/protocol/base/IssuerType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright© (2018-2021) 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.base;

import lombok.Data;

@Data
public class IssuerType {
/**
* Required: The Issuer Type Name.
*/
private String typeName;

/**
* Required: The The Issuer Type Owner..
*/
private String owner;

/**
* Required: The create date of the Authority Issuer, in timestamp (Long) format.
*/
private Long created;
}
36 changes: 36 additions & 0 deletions src/main/java/com/webank/weid/rpc/AuthorityIssuerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;

import com.webank.weid.protocol.base.AuthorityIssuer;
import com.webank.weid.protocol.base.IssuerType;
import com.webank.weid.protocol.base.WeIdAuthentication;
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.protocol.request.RegisterAuthorityIssuerArgs;
Expand Down Expand Up @@ -175,4 +176,39 @@ ResponseData<List<String>> getAllSpecificTypeIssuerList(
* @return the all issuer
*/
ResponseData<Integer> getIssuerCount();

/**
* get the issuer count with Recognized.
* @return the all issuer with Recognized
*/
ResponseData<Integer> getRecognizedIssuerCount();

/**
* get the issuer size in issuerType.
* @param issuerType the issuerType
* @return the all issuer in issuerType
*/
ResponseData<Integer> getSpecificTypeIssuerSize(String issuerType);

/**
* get the issuer type count.
* @return the all issuer type
*/
ResponseData<Integer> getIssuerTypeCount();

/**
* remove the issuerType.
* @param callerAuth the caller
* @param issuerType the issuerType name
* @return true is success, false is fail
*/
ResponseData<Boolean> removeIssuerType(WeIdAuthentication callerAuth, String issuerType);

/**
* get the issuerType list.
* @param index the start index
* @param num the page size
* @return the issuerType list
*/
ResponseData<List<IssuerType>> getIssuerTypeList(Integer index, Integer num);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.constant.WeIdConstant;
import com.webank.weid.protocol.base.AuthorityIssuer;
import com.webank.weid.protocol.base.IssuerType;
import com.webank.weid.protocol.base.WeIdAuthentication;
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.protocol.request.RegisterAuthorityIssuerArgs;
Expand Down Expand Up @@ -540,4 +541,41 @@ public ResponseData<String> getWeIdByOrgId(String orgId) {
public ResponseData<Integer> getIssuerCount() {
return authEngine.getIssuerCount();
}

@Override
public ResponseData<Integer> getRecognizedIssuerCount() {
return authEngine.getRecognizedIssuerCount();
}

@Override
public ResponseData<Integer> getSpecificTypeIssuerSize(String issuerType) {
return authEngine.getSpecificTypeIssuerSize(issuerType);
}

@Override
public ResponseData<Integer> getIssuerTypeCount() {
return authEngine.getIssuerTypeCount();
}

@Override
public ResponseData<Boolean> removeIssuerType(
WeIdAuthentication callerAuth,
String issuerType
) {
ErrorCode innerCode = isIssuerTypeValid(issuerType);
if (innerCode != ErrorCode.SUCCESS) {
return new ResponseData<>(false, innerCode);
}
innerCode = isCallerAuthValid(callerAuth);
if (innerCode != ErrorCode.SUCCESS) {
return new ResponseData<>(false, innerCode);
}
return authEngine.removeIssuerType(
issuerType, callerAuth.getWeIdPrivateKey().getPrivateKey());
}

@Override
public ResponseData<List<IssuerType>> getIssuerTypeList(Integer index, Integer num) {
return authEngine.getIssuerTypeList(index, num);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;

import com.webank.weid.protocol.base.AuthorityIssuer;
import com.webank.weid.protocol.base.IssuerType;
import com.webank.weid.protocol.request.RegisterAuthorityIssuerArgs;
import com.webank.weid.protocol.request.RemoveAuthorityIssuerArgs;
import com.webank.weid.protocol.response.ResponseData;
Expand Down Expand Up @@ -138,10 +139,45 @@ public ResponseData<Boolean> addIssuer(
public ResponseData<String> getWeIdFromOrgId(String orgId);

public ResponseData<Boolean> recognizeWeId(Boolean isRecognize, String addr, String privateKey);

/**
* get the issuer count.
* @return the all issuer
*/
public ResponseData<Integer> getIssuerCount();

/**
* get the issuer count with Recognized.
* @return the all issuer with Recognized
*/
public ResponseData<Integer> getRecognizedIssuerCount();

/**
* get the issuer size in issuerType.
* @param issuerType the issuerType
* @return the all issuer in issuerType
*/
public ResponseData<Integer> getSpecificTypeIssuerSize(String issuerType);

/**
* get the issuer type count.
* @return the all issuer type
*/
public ResponseData<Integer> getIssuerTypeCount();

/**
* remove the issuerType.
* @param issuerType the issuerType name
* @param privateKey the privateKey
* @return true is success, false is fail
*/
public ResponseData<Boolean> removeIssuerType(String issuerType, String privateKey);

/**
* get the issuerType list.
* @param index the start index
* @param num the page size
* @return the issuerType list
*/
public ResponseData<List<IssuerType>> getIssuerTypeList(Integer index, Integer num);
}
Loading

0 comments on commit b226bfe

Please sign in to comment.