I am creating an asset in Hyperledger composer as shown below. I want to add participants in Bank[] array (these banks will only have read only access). In Permission.acl file how can I write condition for checking into the array(Bank[]) if the participant exist for this asset(Read only).
ASSET DEFINITION:
asset Details identified by detailsId {
o String detailsId
o String description optional
--> Bank owner
--> Bank[] access optional
o String document
}
something like below - a) if its not empty and b) if the participant from the bank is authorised (by checking the array) - if so, allow READ access (if I read you correctly).
rule checkParticipant {
description: "check Participant is from allowed Bank"
participant(p): "org.acme.account.BankTeller"
operation: READ
resource(v): "org.acme.account.Details"
condition: ( v.access && v.access.indexOf(p.getIdentifier()) > -1 )
action: ALLOW
}
or a condition (something like below) if case is an issue:
condition: ( v.access && v.access.toLowerCase().indexOf(p.getIdentifier().toLowerCase()) > -1 )
This rule should do the trick, though your namespace is likely different. Assumes that you have other rules in place to allow access to the Bank participant registry.
rule AllowAccessToBankInArray {
description: "Allow access "
participant(p): "com.example.Bank"
operation: ALL
resource(r): "com.example.Details"
condition: (
r.access.some(function (bank) {
return bank.getIdentifier() === p.getIdentifier();
} )
)