TBAC project development

Development of TBAC project.

Subject

Build a subject chain

1
2
3
rm -r ~/.shellchain/chainsub
./multichain-util create chainsub
./multichaind chainsub

Once start this chain, the ip address and port number of chainsub will be shown on the terminal. The default rpc receiving port is chainsub_port-1.

Now cancel multichaind process by Ctrl+D, then edit ~/.shellchain/subject/shellchain.conf. Here, chainsub=4361, so rpcport=4360.

chainsub-conf.png

Now restart chainsub.

Get subject chain address

1
./multichain-cli chainsub getaddresses

Create a new entity using JMeter

Params of rpc interface createentity:

params[0] is entitytype: 实体类型
    entitytype = 1, 拥有权限 connect, send, receive, create, issue, mine, activate, admin
    entitytype = 2, 拥有权限 connect, sned, receive, create, issue, mine, activate
    entitytype = 3 or others, 拥有权限 send, receive
params[1] is from-address: 创建实体的调用地址,这里是主体链的地址

create-entity-http-request.png

Enable create-entity and disable others and run and then get the result:

1
2
3
4
5
6
7
8
9
10
{
"result":{
"pubkey":"03479a7079bf4e22d3dcf087bcdfe2dc6b4124133fbaec5d14916e6f58fa941918",
"privkey":"VCEMsosr4HbwvnZ1NAJGtNWg6BuhN8tFeKpKiScQuiFGtu9q3XPf72Yp",
"address":"1WzU2fz7y78bivU36xBZsw1PCR6RUx99BNGFHt",
"grant_tx_id":"fb56c60a46b2dc10991f10ce1bb7ff05ae7ac342388f64f842023ee00c6d56fe"
},
"error":null,
"id":"1"
}

Issue an entity from subject chain

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"id": "1",
"chain_name": "subject",
"method": "issueentityfrom",
"params": [
"1XjRwWhr93s3ZwHHE7N8QrNFrZq5s62fSMueDX",
"1WzU2fz7y78bivU36xBZsw1PCR6RUx99BNGFHt",
"1",
"1231231312311313123111",
"VCEMsosr4HbwvnZ1NAJGtNWg6BuhN8tFeKpKiScQuiFGtu9q3XPf72Yp",
"******",
{
"ver": "SRT",
"attribute": {
"subject-id": "Shane Wang",
"age": 24,
"faculty": "master",
"security-level": 3
}
}
]
}

subject-issueentityfrom-input-description.png

Enable this and disable others and run

返回主体信息的交易ID

1
2
3
4
5
{
"result":"fc13ee161a90bb49e62fe416f2dbaad75e66d580d2a991fc01f5dd6f6d9ec820",
"error":null,
"id":"1"
}

register-subject-transaction-description.png

Error: null suggests a successful SRT registration on subject chain.

Regist an owner of object on subject chain

An example of transaction sent to the request chain:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"id": "1",
"chain_name": "chainrequest",
"method": "sendrequestfrom",
"params": [
"1YjuDfXfTqtUAW6N1cttSMLStLfhUKbC3sc3nU",
"1YjuDfXfTqtUAW6N1cttSMLStLfhUKbC3sc3nU",
{
"txid": "839a4ed408120fdd3d2f72a319823bf10ecf31663f21359fa4db5c881a37d9f5",
"scriptSig": "null"
},
"c3662ec6779160be959d119f453d74bd38ceb2305692a5076671f85d545d8d21",
"org. apache. pdfbox. pdfctrl# read"
]
}

Object

Create object chain

1
2
./multichain-util create object
./multichaind object

create object chain

Then edit shellchain.conf to add rpcallowip and rpcport:
object-chain-conf.png

1
./multichain-cli object getaddresses

object-chain-address.png

On object chain, no entity is needed so we directly send transaction to object chain for registering object.

Copy ip, port, rpcuser and rpcpassword into JMeter.

Send custom transaction and we will get TXID of object:
OET-txid.png

Policy chain

Create policy chain

1
./multichain-util create policy

Regist policy

We get an object txid in advance.
medica101/object.org: cbadd86ee7ace60491bb9207e28d3ac694fe36e6d656aab26d27483970970733
medica102/object.org: 12d77dc0297f570abef82bfcdb0f60aea25ef7ced8a348d33222319f3ed7edf4

Params: from-address to-address policyid rule-combining-method

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"id":"1",
"chain_name":"policy",
"method":"registpolicy",
"params":[
"1AWZxmCBG18MAaMcsz9PaQ7jeLkf9TDA7pCyvc",
"1AWZxmCBG18MAaMcsz9PaQ7jeLkf9TDA7pCyvc",
"policy1",
"deny_override",
[
{"attr":"resource-id#Obj","value":"medica101/object.org"}
],
[
{"id":"cond1","expr":["object-id","OP_OBJATTR","medical-record-001. pdf","OP_EQUAL"]},
{"id":"cond2","expr":["faculty","OP_SUBATTR","doctor","OP_EQUAL"]},
{"id":"cond3","expr":["action-id","OP_ACTATTR","org. apache. pdfbox. pdfctrl# read","OP_EQUAL"]}
],
[
{"id":"rule1","effect":"permit","expr":["cond1" ,"cond3", "OP_BOOLAND","cond2","OP_BOOLOR"]}
]
]
}

get return:

1
2
{"result":"a9f8dcd95c120956f52c99ed4ee4067dccb467d3e4cc765df17fa4ccafc99edb","error":null,"id":"1"}
{"result":"50420654e19db96ff8a6a62e7476d36bf48ebefa1e86589b59959790b97b21e1","error":null,"id":"1"}

Update policy chain

Params: from-address to-address 生成策略或上一次更新策略返回的txid policyid rule-combing-method target condition rule state

Request chain

Create request chain

The transaction got from the request chain will be like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
ART:
{
"hex" : "0100000001e8b60d8ea85703ffd1e8ba547856637b74fffb259282b42402030a10beaa1198000000006a47304402206669661d52e6616536ea38f86914c14321a9f4563609fff2050dc3bb0b3dd94702201642e30d94ea024abc204abe15cea99ce0db4fb4ddccb585f375d31d274a3175012103d2bf881784a2cf0bb2b56a7f4bd685900015ec742826adef3d6bb0cfc3c1447cffffffff0200000000000000001976a914ead6e273c04dd3952b003343712410ff5aca713788ac00000000000000001976a914ead6e273c04dd3952b003343712410ff5aca713788ac00000000f57b22766572223a22415254222c227375626a656374223a7b2274786964223a2238333961346564343038313230666464336432663732613331393832336266313065636633313636336632313335396661346462356338383161333764396635222c22736372697074536967223a226e756c6c227d2c226f626a6563742d74786964223a2263333636326563363737393136306265393539643131396634353364373462643338636562323330353639326135303736363731663835643534356438643231222c22616374696f6e223a226f72672e206170616368652e20706466626f782e207064666374726c232072656164227d04000000",
"txid" : "21c97d586f29267d5d7c701e639d0f89a2c568577fa8247bf8f24915e788ba25",
"version" : 1,
"locktime" : 0,
"ver" : "ART",
"subject" : {
"txid" : "839a4ed408120fdd3d2f72a319823bf10ecf31663f21359fa4db5c881a37d9f5",
"scriptSig" : "null"
},
"object-txid" : "c3662ec6779160be959d119f453d74bd38ceb2305692a5076671f85d545d8d21",
"action" : "org. apache. pdfbox. pdfctrl# read",
"vin" : [
{
"txid" : "9811aabe100a030224b4829225fbff747b63567854bae8d1ff0357a88e0db6e8",
"vout" : 0,
"scriptSig" : {
"asm" : "304402206669661d52e6616536ea38f86914c14321a9f4563609fff2050dc3bb0b3dd94702201642e30d94ea024abc204abe15cea99ce0db4fb4ddccb585f375d31d274a317501 03d2bf881784a2cf0bb2b56a7f4bd685900015ec742826adef3d6bb0cfc3c1447c",
"hex" : "47304402206669661d52e6616536ea38f86914c14321a9f4563609fff2050dc3bb0b3dd94702201642e30d94ea024abc204abe15cea99ce0db4fb4ddccb585f375d31d274a3175012103d2bf881784a2cf0bb2b56a7f4bd685900015ec742826adef3d6bb0cfc3c1447c"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 0.00000000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 ead6e273c04dd3952b003343712410ff5aca7137 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914ead6e273c04dd3952b003343712410ff5aca713788ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"1YjuDfXfTqtUAW6N1cttSMLStLfhUKbC3sc3nU"
]
},
"assets" : [
],
"permissions" : [
],
"items" : [
]
},
{
"value" : 0.00000000,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 ead6e273c04dd3952b003343712410ff5aca7137 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914ead6e273c04dd3952b003343712410ff5aca713788ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"1YjuDfXfTqtUAW6N1cttSMLStLfhUKbC3sc3nU"
]
},
"assets" : [
],
"permissions" : [
],
"items" : [
]
}
],
"data" : [
],
"nType" : 4,
"blockhash" : "0040dd89115fb5a7599f6b01a3c54131c19b0646c0b2c09de0e9607dee6621a1",
"confirmations" : 190,
"time" : 1575293978,
"blocktime" : 1575293978
}
学习非主流汉字输入法 Accumulation of English writing by examples

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×