列出业务网络中的所有身份

当向参与者发放新身份或者将现有身份绑定到参与者时,在已部署的业务网络中的身份库中一个身份与参与者之间的映射被创建。当该参与者使用该身份将事务提交到已部署的业务网络时,Composer运行时会在身份库中查找该身份的有效映射。这种查找是使用公钥签名或指纹完成的,指纹本质上是证书内容的散列(对证书和身份唯一的)。

为了在已部署的业务网络中执行身份管理操作,你需要列出和查看身份库中的一组身份。

在你开始之前

在执行这些步骤之前,你应该已经将参与者添加到参与者库,并向该参与者发放了新的身份或绑定了现有的身份。否则身份库将是空的,你不会看到任何结果。

过程

1.连接到业务网络并在身份库中列出身份

JavaScript API:

  1. const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
  2. let businessNetworkConnection = new BusinessNetworkConnection();
  3. return businessNetworkConnection.connect('admin@digitalPropertyNetwork')
  4. .then(() => {
  5. return businessNetworkConnection.getIdentityRegistry();
  6. })
  7. .then((identityRegistry) => {
  8. return identityRegistry.getAll();
  9. })
  10. .then((identities) => {
  11. identities.forEach((identity) => {
  12. console.log(`identityId = ${identity.identityId}, name = ${identity.name}, state = ${identity.state}`);
  13. });
  14. return businessNetworkConnection.disconnect();
  15. })
  16. .catch((error) => {
  17. console.error(error);
  18. process.exit(1);
  19. });

命令行:

  1. composer identity list -c admin@digitalPropertyNetwork