1. registerAuthorityIssuer
基本信息
- 接口名称:com.webank.weid.rpc.AuthorityIssuerService.registerAuthorityIssuer
- 接口定义:ResponseData<Boolean> registerAuthorityIssuer(RegisterAuthorityIssuerArgs args)
- 接口描述: 注册成为权威机构。
- 注意:这是一个需要权限的操作,目前只有合约的部署者(一般为SDK)才能正确执行。
接口入参: com.webank.weid.protocol.request.RegisterAuthorityIssuerArgs
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
authorityIssuer | AuthorityIssuer | Y | AuthorityIssuer信息,见下 | |
weIdPrivateKey | WeIdPrivateKey | Y | 交易私钥,见下 |
com.webank.weid.protocol.base.AuthorityIssuer
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | 授权机构WeIdentity DID | |
name | String | Y | 授权机构名称 | 机构名称必须小于32个字节,非空,且仅包含ASCII码可打印字符(ASCII值位于32~126) |
created | Long | N | 创建日期 | 注册时不需要传入,SDK内置默认为当前时间 |
accValue | String | Y | 授权方累积判定值 |
com.webank.weid.protocol.base.WeIdPrivateKey
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
privateKey | String | Y | 私钥值 | 使用十进制数字表示 |
接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | Boolean | 返回结果值 | |
transactionInfo | TransactionInfo | 交易信息 |
com.webank.weid.protocol.response.TransactionInfo
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
blockNumber | BigInteger | 交易块高 | |
transactionHash | String | 交易hash | |
transactionIndex | BigInteger | 交易索引 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
AUTHORITY_ISSUER_ERROR | 100200 | 授权标准异常 |
AUTHORITY_ISSUER_PRIVATE_KEY_ILLEGAL | 100202 | 私钥格式非法 |
AUTHORITY_ISSUER_OPCODE_MISMATCH | 100205 | 操作码不匹配 |
AUTHORITY_ISSUER_NAME_ILLEGAL | 100206 | 名称格式非法 |
AUTHORITY_ISSUER_ACCVALUE_ILLEAGAL | 100207 | 累计值格式非法 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
ILLEGAL_INPUT | 160004 | 参数为空 |
调用示例
- AuthorityIssuerService authorityIssuerService = new AuthorityIssuerServiceImpl();
- AuthorityIssuer authorityIssuer = new AuthorityIssuer();
- authorityIssuer.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
- authorityIssuer.setName("webank1");
- authorityIssuer.setAccValue("0");
- WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
- weIdPrivateKey.setPrivateKey("36162289879206412028682370838615850457668262092955617990245744195910144330785");
- RegisterAuthorityIssuerArgs registerAuthorityIssuerArgs = new RegisterAuthorityIssuerArgs();
- registerAuthorityIssuerArgs.setAuthorityIssuer(authorityIssuer);
- registerAuthorityIssuerArgs.setWeIdPrivateKey(weIdPrivateKey);
- ResponseData<Boolean> response = authorityIssuerService.registerAuthorityIssuer(registerAuthorityIssuerArgs);
- 返回结果如:
- result: true
- errorCode: 0
- errorMessage: success
- transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
- blockNumber: 29963
- transactionHash: 0x97a5cc2f4f7888e788a22e7c9bef1a293614bceec4721810511d07fc5b748f33
- transactionIndex: 0
时序图
sequenceDiagramparticipant 调用者participant AuthorityIssuerServiceparticipant WeIdServiceparticipant 区块链节点调用者->>AuthorityIssuerService: 调用RegisterAuthorityIssuer()AuthorityIssuerService->>AuthorityIssuerService: 入参非空、格式及合法性检查opt 入参校验失败AuthorityIssuerService—>>调用者: 报错,提示参数不合法并退出endAuthorityIssuerService->>WeIdService: 查询WeIdentity DID存在性WeIdService->>区块链节点: 链上查询WeIdentity DID属性区块链节点—>>WeIdService: 返回查询结果WeIdService—>>AuthorityIssuerService: 返回查询结果opt 在链上不存在AuthorityIssuerService—>>调用者: 报错并退出endAuthorityIssuerService->>区块链节点: 加载私钥,调用注册合约opt 身份校验Note over 区块链节点: 如果传入WeIdentity DID在链上不存在区块链节点->>区块链节点: 报错并退出end区块链节点->>区块链节点: 权限检查,执行合约写入AuthorityIssuer信息区块链节点—>>AuthorityIssuerService: 返回合约执行结果AuthorityIssuerService->>AuthorityIssuerService: 解析合约事件opt 失败,地址无效或无权限AuthorityIssuerService—>>调用者: 报错并退出endAuthorityIssuerService—>>调用者: 返回成功