github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/aclmgmt/aclmgmtimpl.go (about) 1 /* 2 Copyright hechain. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package aclmgmt 8 9 import "github.com/hechain20/hechain/core/policy" 10 11 // implementation of aclMgmt. CheckACL calls in fabric result in the following flow 12 // if resourceProvider[resourceName] 13 // return resourceProvider[resourceName].CheckACL(...) 14 // else 15 // return defaultProvider[resourceName].CheckACL(...) 16 // with rescfgProvider encapsulating resourceProvider and defaultProvider 17 type aclMgmtImpl struct { 18 // resource provider gets resource information from config 19 rescfgProvider ACLProvider 20 } 21 22 // CheckACL checks the ACL for the resource for the channel using the 23 // idinfo. idinfo is an object such as SignedProposal from which an 24 // id can be extracted for testing against a policy 25 func (am *aclMgmtImpl) CheckACL(resName string, channelID string, idinfo interface{}) error { 26 // use the resource based config provider (which will in turn default to 1.0 provider) 27 return am.rescfgProvider.CheckACL(resName, channelID, idinfo) 28 } 29 30 // CheckACLNoChannel checks the ACL for the resource for the local MSP 31 // using the idinfo. idinfo is an object such as SignedProposal 32 // from which an id can be extracted for testing against a policy. 33 func (am *aclMgmtImpl) CheckACLNoChannel(resName string, idinfo interface{}) error { 34 // use the resource based config provider (which will in turn default to 1.0 provider) 35 return am.rescfgProvider.CheckACLNoChannel(resName, idinfo) 36 } 37 38 // ACLProvider consists of two providers, supplied one and a default one (1.0 ACL management 39 // using ChannelReaders and ChannelWriters). If supplied provider is nil, a resource based 40 // ACL provider is created. 41 func NewACLProvider(rg ResourceGetter, policyChecker policy.PolicyChecker) ACLProvider { 42 return &aclMgmtImpl{ 43 rescfgProvider: newResourceProvider(rg, newDefaultACLProvider(policyChecker)), 44 } 45 }