【发布时间】:2017-06-26 22:26:10
【问题描述】:
我正在使用超级账本作曲家制作商业模型,其中我有银行作为参与者,客户作为资产。银行定义如下:
participant Bank identified by bankId {
o String bankId
o String name
o String code
}
客户看起来像这样:
asset Customer identified by aadhaarId {
o String aadhaarId
o String panId
o String firstName
o String lastName
o String contactNo
o String residence
o String accountNumber
o AccountType accountType
o String creationDate
--> Bank bank
}
我希望参与者(银行)只能更新属于它的那些客户,并且我想创建一个交易来执行此操作。所以我创建了以下事务:
transaction updateCustomer identified by transactionId {
o String transactionId
--> Customer customer
o Customer newDetails
}
并在.acl文件中定义如下规则:
rule bankCanUpdateItsCutomersViaTransaction {
description: "Allow a participant to update it's own resources"
participant(p): "org.acme.sample.Bank"
operation: UPDATE
resource(r): "org.acme.sample.updateCustomer"
condition: (p.getIdentifier() == r.customer.bank.getIdentifier())
action: ALLOW
}
为了测试这一点,我创建了一个参与者(除了已经提供的管理员)并创建了一个与该参与者链接的客户。我在这背后有一个事务处理器功能,它只是更新客户资产注册表。 但是当我尝试执行 updateCustomer 事务时,我收到一条错误消息,指出参与者没有对资源的 CREATE 访问权限。即使我在 .acl 文件中将操作更改为 CREATE,问题仍然存在。我认为问题出在条件部分,但我无法纠正。
我有一个类似的创建客户的交易如下:
transaction createCustomer identified by transactionId {
o String transactionId
o Customer newCustomer
}
规则如下:
rule bankCanCreateItsCutomersViaTransaction {
description: "Allow a participant to create it's own resources"
participant(p): "org.acme.sample.Bank"
operation: CREATE
resource(r): "org.acme.sample.createCustomer"
condition: (p.getIdentifier() == r.newCustomer.bank.getIdentifier())
action: ALLOW
}
这个 createCustomer 事务背后有一个简单的事务处理器函数,它只是将 newCustomer 添加到客户资产注册表中。这工作得很好,但 updateCustomer 事务不工作。 任何帮助将非常感激。谢谢:)
【问题讨论】:
标签: access-control hyperledger hyperledger-composer