Skip to content

Commit 53307ab

Browse files
authored
Merge pull request #3 from BSNDA/hotfix2022_4_29
Hotfix2022 4 29
2 parents b1bf3f2 + d0a60fb commit 53307ab

15 files changed

+249
-217
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Decentralized Identifiers refers to a decentralized on-chain mapping of the identity of the real entity, where any individual/organization/entity can create and manage their own digital identities on the blockchain. The traditional identity authentication system has problems such as centralized authentication, identity data security, duplicate authentication, multi-location authentication, etc. With the promotion and application of blockchain technology in various industries, DID will be used more and more widely.
44

55
## BSN DID Overview
6-
BSN DID takes blockchain technology as the cornerstone and W3C DID as the specification to provide digital identity and digital credential interaction for individuals/organizations, and the BSN opens DID services to the public through BSN gateway. It consists of three main parts: SDK, Service and Smart Contract. The SDK can be integrated into developers' projects; the Service handles the business logic and connects the Identity Hub and the chain nodes; the smart contract is deployed on the blockchain, and the Service makes contract method calls.
6+
BSN DID takes blockchain technology as the cornerstone and W3C DID as the specification to provide digital identity and digital credential interaction for individuals/organizations, and the BSN opens DID services to the public through BSN gateway. It consists of three main parts: SDK, Service and Smart Contract. The SDK can be integrated into developers' projects; the Service handles the business logic and connects the Identity Hub and the chain nodes; the smart contract is deployed on the blockchain, and the Service makes contract method calls.
77

88

99
![BSN DID data flow structure](bsn-did.png)
@@ -16,16 +16,16 @@ BSN currently provides a Java-based SDK, developers can quickly and easily acces
1616
### Access Parameters
1717
- Gateway address
1818

19-
BSN China: `https://didservice.bsngate.com:18602`
19+
BSN China: `https://didservice.bsngate.com:18602`
2020

21-
BSN International: `https://did.bsngate.com:18602`
21+
BSN International: `https://did.bsngate.com:18602`
2222

2323
- Public Test Parameters
2424

25-
`PROJECTID:8320935187`
26-
27-
`TOKEN:3wxYHXwAm57grc9JUr2zrPHt9HC`
28-
25+
`PROJECTID:8320935187`
26+
27+
`TOKEN:3wxYHXwAm57grc9JUr2zrPHt9HC`
28+
2929
### Steps to Use
3030

3131
1. Compile and package the source code into a jar file named did-sdk-1.0.jar.
@@ -34,11 +34,11 @@ BSN currently provides a Java-based SDK, developers can quickly and easily acces
3434

3535
3. Create an instance of DidClient, e.g.:
3636

37-
`DidClient didClient = new DidClient(URL, PROJECTID, TOKEN);`
38-
37+
`DidClient didClient = new DidClient(URL, PROJECTID, TOKEN);`
38+
3939
4. Call the methods within the SDK, such as:
4040

41-
`DidDataWrapper didData = didClient.createDid(true);`
41+
`DidDataWrapper didData = didClient.createDid(true);`
4242

4343
### FAQ
4444

@@ -63,8 +63,8 @@ The credential template belongs to the issuer and needs to be public and transpa
6363

6464
1) After issuing the credential, the issuer directly returns the digital credential to the user and the user keeps it by himself.
6565

66-
2) The credential is stored in the Identity Hub provided by the BSN. Each credential of each user can be stored in the Identity Hub (hereinafter referred to as Hub) with full access control by the user, and the content of the credential is encrypted so that only the user can parse the plaintext with his private key.
67-
There are two ways to store credentials in the Hub: the user gets the credentials and registers on the Hub, and then calls the saveResource method to complete the storage; the issuer stores the credentials on behalf of the user, which requires the user to authorize access permissions to the issuer first, and the issuer can register on the Hub in advance to get its own ID in the Hub and present it to the user in the client. In this way, the user can create access permissions for the issuer, and the client provides markers to identify that the user needs to store the credentials in the Hub after the issuer has issued them, then the issuer can directly call the saveResource method after issuing the credentials to complete the storage action on behalf of the user.
66+
2) The credential is stored in the Identity Hub provided by the BSN. Each credential of each user can be stored in the Identity Hub (hereinafter referred to as Hub) with full access control by the user, and the content of the credential is encrypted so that only the user can parse the plaintext with his private key.
67+
There are two ways to store credentials in the Hub: the user gets the credentials and registers on the Hub, and then calls the saveResource method to complete the storage; the issuer stores the credentials on behalf of the user, which requires the user to authorize access permissions to the issuer first, and the issuer can register on the Hub in advance to get its own ID in the Hub and present it to the user in the client. In this way, the user can create access permissions for the issuer, and the client provides markers to identify that the user needs to store the credentials in the Hub after the issuer has issued them, then the issuer can directly call the saveResource method after issuing the credentials to complete the storage action on behalf of the user.
6868

6969

7070

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<dependency>
3030
<groupId>com.alibaba</groupId>
3131
<artifactId>fastjson</artifactId>
32-
<version>1.2.47</version>
32+
<version>1.2.83</version>
3333
</dependency>
3434
<dependency>
3535
<groupId>org.bouncycastle</groupId>
@@ -88,6 +88,7 @@
8888
<version>4.13.2</version>
8989
<scope>test</scope>
9090
</dependency>
91+
9192
</dependencies>
9293

9394
<build>

src/main/java/com/reddate/did/sdk/constant/ErrorMessage.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,63 @@
22

33
public enum ErrorMessage {
44

5-
UNKNOWN_ERROR(9999, "service error: "),
5+
UNKNOWN_ERROR(9999, "Unknown exception "),
66

7-
PARAMETER_IS_EMPTY(1001, " is empty"),
7+
PARAMETER_IS_EMPTY(1001, "is null"),
88

9-
PUBLIC_AND_PRIVATE_KEY_MISMATCH(1021, "public key and private key do not match"),
9+
PUBLIC_AND_PRIVATE_KEY_MISMATCH(1021, "Public and private keys do not match"),
1010

11-
GENERATE_DID_FAIL(1044, "generate DID failed"),
11+
GENERATE_DID_FAIL(1044, "Failed to generate the DID"),
1212

13-
ENCRYPT_KEY_FAILED(1337, "encrypt key failed"),
13+
ENCRYPT_KEY_FAILED(1337, "Failed to encrypt the key"),
1414

15-
SIGNATURE_FAILED(1338, "signature failed"),
15+
SIGNATURE_FAILED(1029, "Failed to sign the data"),
1616

17-
PRIVATE_KEY_ILLEGAL_FORMAT(1025, "private key is illegal format"),
17+
PRIVATE_KEY_ILLEGAL_FORMAT(1304, "Private key format is invalid"),
1818

19-
CPT_NOT_EXIST(1060, "CPT is not exist"),
19+
CPT_NOT_EXIST(1060, "CPT does not exist"),
2020

21-
DID_NOT_EXIST(1041, "DID not exist"),
21+
DID_NOT_EXIST(1041, "DID does not exist"),
2222

23-
CPT_AND_ISSUER_CANNOT_MATCH(1062, "issuer and CPT's publisherDid are not equals"),
23+
CPT_AND_ISSUER_CANNOT_MATCH(1062, "privateKey does not match issuerDid"),
2424

25-
QUERY_GRANT_ENCPY_KEY_FAILED(1501, "query grant resource's encryption key failed"),
25+
QUERY_GRANT_ENCPY_KEY_FAILED(1501, "Failed to query the encryption key of the granted resource"),
2626

27-
DECRPTY_GRANT_KEY_FAILED(1502, "decrypt resource's encryption key failed"),
27+
// DECRPTY_GRANT_KEY_FAILED(1502, "Failed to decrypt the key of the granted resource"),
2828

29-
RESOURCE_NOT_EISTS(1503, "resource is not exist"),
29+
RESOURCE_NOT_EISTS(1418, "Resource does not exist"),
3030

31-
RECOVERY_KEY_INCORRECT(1504, "recovery key pair is incorrect, can not reset DID auth"),
31+
RECOVERY_KEY_INCORRECT(1504, " mismatch"),
3232

33-
PRK_PUK_NOT_MATCH(1505, "primary private key and public key do not match"),
33+
PRK_PUK_NOT_MATCH(1306, " format is invalid"),
3434

35-
INVALID_DID(1043, "DID is illegal format"),
35+
INVALID_DID(1043, "Invalid DID"),
3636

3737
DECRYPT_KEY_FAILED(1455, "decrypt encptyKey failed"),
3838

3939
DECRYPT_CONTENT_FAILED(1456, "decrypt content failed"),
4040

41-
CREAT_KEY_FAIL(1085, "create key failed"),
41+
CREAT_KEY_FAIL(1085, "Failed to create the key pair"),
4242

43-
HASH_DID_FAIL(1086, "calculate did identifier failed"),
43+
HASH_DID_FAIL(1086, "Failed to calculate the DID"),
4444

45-
SIGN_DID_FAIL(1087, "calculate did document sign failed"),
45+
// SIGN_DID_FAIL(1087, "Failed to calculate the DID Document signature"),
4646

47-
CREATE_DID_DOC_FAIL(1088, "create document failed"),
47+
CREATE_DID_DOC_FAIL(1088, "Failed to create the DID Document"),
4848

49-
MNEM_IS_EMPTY(1090, "mnemonic is empty"),
49+
MNEM_IS_EMPTY(1090, "The mnemonic is empty"),
5050

51-
VALIDATE_SIGN_ERROR(1422, "verify signature failed"),
51+
VALIDATE_SIGN_ERROR(1422, "Signature verification failed"),
5252

53-
DECRYPT_FAILED(1365, "decrypt failed"),
53+
DECRYPT_FAILED(1365, "Failed to decrypt the data"),
5454

55-
ENCRYPT_FAILED(1366, "encrypt failed"),
55+
ENCRYPT_FAILED(1366, "Failed to encrypt the data"),
5656

57-
SAVE_RESOURCE_ERROR(1408, "save resource failed"),
57+
SAVE_RESOURCE_ERROR(1408, "Failed to save the resource"),
5858

59-
USER_NOT_EXISTS(1423, "user is not registered"),
59+
USER_NOT_EXISTS(1423, "The user is not registered"),
6060

61-
CRYPTO_TYPE_INCORRECT(1466, "crypto type is illegal format"),
61+
CRYPTO_TYPE_INCORRECT(1466, "Crypto type format is invalid"),
6262
;
6363

6464
private Integer code;

src/main/java/com/reddate/did/sdk/param/req/Operation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ public enum Operation {
2121
/**
2222
* Delete permission
2323
*/
24-
DELETE
24+
DELETE,
25+
/**
26+
* Transfer permission
27+
*/
28+
TRANSFER
2529
}

src/main/java/com/reddate/did/sdk/protocol/response/ResultData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void setData(T data) {
6060
public static <T> ResultData<T> success(T data) {
6161
ResultData<T> result = new ResultData<>();
6262
result.setCode(0);
63-
result.setMsg("success");
63+
result.setMsg("Success");
6464
result.setData(data);
6565
return result;
6666
}

src/main/java/com/reddate/did/sdk/service/AuthIssuerService.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ public AuthIssuerService(String url, String projectId, String token, CryptoType
5353
public boolean registerAuthIssuer(RegisterAuthorityIssuer register) {
5454

5555
if (ObjectUtil.isEmpty(register)) {
56-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register is empty");
56+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register is null");
5757
}
5858
if (StringUtils.isBlank(register.getName())) {
59-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register.name is empty");
59+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register.name is null");
6060
}
6161
if (StringUtils.isBlank(register.getDid())) {
62-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register.did is empty");
62+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register.did is null");
6363
}
6464
if (StringUtils.isBlank(register.getPrivateKey())) {
65-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register.privateKey is empty");
65+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "register.privateKey is null");
6666
}
6767
RegisterAuthorityIssuerWrapper req = new RegisterAuthorityIssuerWrapper();
6868
req.setDid(register.getDid());
@@ -101,13 +101,13 @@ public boolean registerAuthIssuer(RegisterAuthorityIssuer register) {
101101
public Pages<AuthorityIssuer> queryAuthIssuerList(AuthIssuer query) {
102102

103103
if (ObjectUtil.isEmpty(query)) {
104-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "query is empty");
104+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "query is null");
105105
}
106106
if (query.getPage() == null) {
107-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "page is empty");
107+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "page is null");
108108
}
109109
if (query.getSize() == null) {
110-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "size is empty");
110+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "size is null");
111111
}
112112

113113
AuthIssuerListWrapper authIssuerListWrapper = new AuthIssuerListWrapper();
@@ -136,22 +136,22 @@ public Pages<AuthorityIssuer> queryAuthIssuerList(AuthIssuer query) {
136136
*/
137137
public CptBaseInfo registerCpt(RegisterCpt registerCpt) {
138138
if (ObjectUtil.isEmpty(registerCpt)) {
139-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "registerCpt is empty");
139+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "registerCpt is null");
140140
}
141141
if (StringUtils.isBlank(registerCpt.getDescription())) {
142-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "description is empty");
142+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "description is null");
143143
}
144144
if (StringUtils.isBlank(registerCpt.getTitle())) {
145-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "title is empty");
145+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "title is null");
146146
}
147147
if (StringUtils.isBlank(registerCpt.getPrivateKey())) {
148-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "privateKey is empty");
148+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "privateKey is null");
149149
}
150150
if (StringUtils.isBlank(registerCpt.getType())) {
151-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "type is empty");
151+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "type is null");
152152
}
153153
if (StringUtils.isBlank(registerCpt.getDid())) {
154-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "did is empty");
154+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "did is null");
155155
}
156156
CptJsonSchemaUtils.validateJsonSchema(registerCpt.getCptJsonSchema());
157157

@@ -207,21 +207,21 @@ public CptBaseInfo registerCpt(RegisterCpt registerCpt) {
207207
* Query all registered CPT templates under the issuer according to the DID
208208
* identifier of the issuer.
209209
*
210-
* @param query Page information and authority issuer
210+
* @param queryCpt Page information and authority issuer
211211
* @return Return the CPT template list
212212
*/
213213
public Pages<CptInfo> queryCptListByDid(QueryCpt queryCpt) {
214214
if (ObjectUtil.isEmpty(queryCpt)) {
215-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "queryCpt is empty");
215+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "queryCpt is null");
216216
}
217217
if (StringUtils.isBlank(queryCpt.getDid())) {
218-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "did is empty");
218+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "did is null");
219219
}
220220
if (ObjectUtil.isEmpty(queryCpt.getPage())) {
221-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "page is empty");
221+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "page is null");
222222
}
223223
if (ObjectUtil.isEmpty(queryCpt.getSize())) {
224-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "size is empty");
224+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "size is null");
225225
}
226226
RequestParam<QueryCptListWrapper> reqParam = new RequestParam<>(this.getProjectId(), queryCpt.getDid());
227227
QueryCptListWrapper queryCptListWrapper = new QueryCptListWrapper();
@@ -245,7 +245,7 @@ public Pages<CptInfo> queryCptListByDid(QueryCpt queryCpt) {
245245
*/
246246
public CptInfo queryCptById(Long cptId) {
247247
if (cptId == null) {
248-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "cptId is empty");
248+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "cptId is null");
249249
}
250250
RequestParam<QueryCptByIdWrapper> reqParam = new RequestParam<>(this.getProjectId(), null);
251251
QueryCptByIdWrapper query = new QueryCptByIdWrapper();
@@ -267,25 +267,25 @@ public CptInfo queryCptById(Long cptId) {
267267
*/
268268
public CptBaseInfo updateCpt(RegisterCpt registerCpt) {
269269
if (ObjectUtil.isEmpty(registerCpt)) {
270-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "registerCpt is empty");
270+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "registerCpt is null");
271271
}
272272
if (ObjectUtil.isEmpty(registerCpt.getCptId())) {
273-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "cptId is empty");
273+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "cptId is null");
274274
}
275275
if (StringUtils.isBlank(registerCpt.getDescription())) {
276-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "description is empty");
276+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "description is null");
277277
}
278278
if (StringUtils.isBlank(registerCpt.getTitle())) {
279-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "title is empty");
279+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "title is null");
280280
}
281281
if (StringUtils.isBlank(registerCpt.getPrivateKey())) {
282-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "privateKey is empty");
282+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "privateKey is null");
283283
}
284284
if (StringUtils.isBlank(registerCpt.getType())) {
285-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "type is empty");
285+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "type is null");
286286
}
287287
if (StringUtils.isBlank(registerCpt.getDid())) {
288-
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "did is empty");
288+
throw new DidException(ErrorMessage.PARAMETER_IS_EMPTY.getCode(), "did is null");
289289
}
290290
CptJsonSchemaUtils.validateJsonSchema(registerCpt.getCptJsonSchema());
291291

0 commit comments

Comments
 (0)