每个用户或者participant都有一个X509证书。
MSP很麻烦,但是composer简化了它的生成步骤。

business network card 包含颁发给用户的加密相关的证书以及composer链接档案(记录来了链接fabric机构里不同组件的urls)。

因此在以composer为基础构建的network application中,participant需要一个card和network application交互。

composer有角色:这些角色用于管理participants的权限。

角色

peer administrator是fabric建立时就有的一部分
network administrator是 network app建立时的一部分
其他participant其他participant是由network administrator建立或者是由一个有权限的participant建立的。

composer CLI tool

使用这个工具的用户必须有权限去管理identities。
在使用cli tool的时候,一定要提供合适的card。
使用命令

-c option

命令

composer participant add --help
composer identity --help

第一条命令用于添加participant到app中;
第二条命令用于执行围绕identities的多个操作(app中)。

命令一
[email protected]-ThinkPad-E550:~/cprogrames$ composer identity --help
composer identity <subcommand>

Composer identity command

Commands:
  composer identity bind [options]     Bind an existing identity to a participant in a participant registry
  composer identity issue [options]    Issue a new identity to a participant in a participant registry
  composer identity list [options]     List all identities in a business network
  composer identity request [options]  Request an identity's certificate and key
  composer identity revoke [options]   Revoke an identity that was issued or bound to a participant

Options:
  --help         Show help  [boolean]

bind用于链接现有的identity(或证书)和participant;
issue用于向participant发布新identity或card;
list列出现有的identity;
request得到存在的一个identity的card;
revoke是撤销一个app中的identity。

SDK、API

为business network application创建新的identity的步骤

Step1: 生成一个participant实例;

participant有三种生成的方式。
(1)playground或rest server
(2)composer CLI tool
(3)SDK或API

Step2: 为participant创建一个identity或者将一个identity与这个participant结合forBNA【有权限生成一个participant实例的用户执行此操作】

[email protected]-ThinkPad-E550:~/cprogrames$ composer identity issue --help
composer identity issue [options]

Issue a new identity to a participant in a participant registry

Options:
  --help               Show help  [boolean]
  -v, --version        Show version number  [boolean]
  --newUserId, -u      The user ID for the new identity  [string]
  --participantId, -a  The participant to issue the new identity to  [string] [required]
  --issuer, -x         If the new identity should be able to issue other new identities  [boolean]
  --option, -o         Options that are specific to connection. Multiple options are specified by repeating this option  [string]
  --optionsFile, -O    A file containing options that are specific to connection  [string]
  --card, -c           Name of the network card to use for issuing  [string]
  --file, -f           The card file name for the new identity  [string]

这一步会生成一个card,这个card和identity绑定,是这个participant的card。

Step3: import 在第二步生成的card

演示

playground

生成一个participant后,点击右上角的 ID registry进去。
【composer开发】身份管理简介
在ID Registry页面进行给card的操作。
【composer开发】身份管理简介
如果选了这个allow,他就可以生成新的Participant了。

【composer开发】身份管理简介
生成之后wallet会出现这人的card。

ERROR

但我又出现了不明错误,说是这个card没有读权限。那它能干嘛,在哪授权???找了一圈没找到授权的地方啊。懵。
【composer开发】身份管理简介

cli tool

Step1

composer participant add -d {json格式的participant数据} -c【card name】

[email protected]-ThinkPad-E550:~/cprogrames$ composer participant add -d '{"$class":"org.acme.airline.participant.ACMENetworkAdmin","participantKey":"alice","contact":{"$class":"org.acme.airline.participant.Contact","fName":"Alice","lname":"Wang","email":"[email protected]"}}' -c [email protected]
Participant was added to participant registry.

Command succeeded

Step2
composer identity issue -u

composer identity issue -u alice -a org.acme.airline.participant.ACMENetworkAdmin#alice -c [email protected] -x

-u 这个identity的名字
-a 这个identity会和谁(participant)结合
-c cardname
-x 设置这个用户是否可以新建其他用户。

Step3: import 在第二步生成的card

[email protected]-ThinkPad-E550:~/cprogrames/airlinev1/dist$ composer card import -f [email protected].card

Successfully imported business network card
        Card file: [email protected].card
        Card name: [email protected]

Command succeeded

[email protected]-ThinkPad-E550:~/cprogrames/airlinev1/dist$ composer card list
The following Business Network Cards are available:

Connection Profile: hlfv1
┌─────────────────┬───────────┬──────────────────┐
│ Card Name       │ UserId    │ Business Network │
├─────────────────┼───────────┼──────────────────┤
│ [email protected] │ admin     │ airlinev8        │
├─────────────────┼───────────┼──────────────────┤
│ [email protected]-bna  │ admin     │ test-bna         │
├─────────────────┼───────────┼──────────────────┤
│ [email protected] │ alice     │ airlinev8        │
├─────────────────┼───────────┼──────────────────┤
│ [email protected] │ PeerAdmin │                  │
└─────────────────┴───────────┴──────────────────┘


Issue composer card list --card <Card Name> to get details a specific card

Command succeeded

相关文章: