6. registerIssuerType

基本信息

  1. 接口名称: com.webank.weid.rpc.AuthorityIssuerService.registerIssuerType
  2. 接口定义: ResponseData<Boolean> registerIssuerType(WeIdAuthentication callerAuth, String issuerType)
  3. 接口描述: 指定并注册不同issuer的类型,如学校、政府机构等。
  4. 权限说明:本方法对传入的WeIdAuthentication没有特定权限要求。

接口入参:

名称类型非空说明备注
callerAuthWeIdAuthenticationYweId身份信息
issuerTypeStringY机构类型

com.webank.weid.protocol.base.WeIdAuthentication

名称类型非空说明备注
weIdStringYWeIdentity DIDWeIdentity DID的格式传入
weIdPublicKeyIdStringN公钥Id
weIdPrivateKeyWeIdPrivateKeyY 交易私钥,见下

接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;

名称类型说明备注
errorCodeInteger返回结果码
errorMessageString返回结果描述
resultBoolean是否注册成功
transactionInfoTransactionInfo交易信息

com.webank.weid.protocol.response.TransactionInfo

名称类型说明备注
blockNumberBigInteger交易块高
transactionHashString交易hash
transactionIndexBigInteger交易索引

此方法返回code

enumcodedesc
SUCCESS0成功
AUTHORITY_ISSUER_ERROR100200授权标准异常
SPECIFIC_ISSUER_TYPE_ILLEGAL100208机构类型非法
TRANSACTION_TIMEOUT160001超时
TRANSACTION_EXECUTE_ERROR160002交易错误
UNKNOW_ERROR160003未知异常
ILLEGAL_INPUT160004参数为空

调用示例

  1. WeIdAuthentication weIdAuthentication = new WeIdAuthentication();
  2. weIdAuthentication.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
  3.  
  4. WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
  5. weIdPrivateKey.setPrivateKey("60866441986950167911324536025850958917764441489874006048340539971987791929772");
  6. weIdAuthentication.setWeIdPrivateKey(weIdPrivateKey);
  7.  
  8. weIdAuthentication.setWeIdPublicKeyId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0");
  9. AuthorityIssuerService authorityIssuerService = new AuthorityIssuerServiceImpl();
  10. ResponseData<List<AuthorityIssuer>> response = authorityIssuerService.registerIssuerType(weIdAuthentication, "College");
  1. 返回数据如:
  2. result: true
  3. errorCode: 0
  4. errorMessage: success
  5. transactionInfo: (com.webank.weid.protocol.response.TransactionInfo)
  6. blockNumber: 29950
  7. transactionHash: 0xe3f48648beee61d17de609d32af36ac0bf4d68a9352890b04d53841c4949bd13
  8. transactionIndex: 0

时序图

sequenceDiagramparticipant 调用者participant AuthorityIssuerServiceparticipant 区块链节点调用者->>AuthorityIssuerService: registerIssuerType()AuthorityIssuerService->>AuthorityIssuerService: 入参非空、格式及合法性检查opt 入参校验失败AuthorityIssuerService—>>调用者: 报错,提示参数不合法并退出endAuthorityIssuerService->>区块链节点: 调用注册授权机构类型合约区块链节点->>区块链节点: 执行合约注册授权机构类型区块链节点—>>AuthorityIssuerService: 返回执行结果AuthorityIssuerService—>>调用者: 返回执行结果