当前位置: 首页>>代码示例>>Python>>正文


Python PDP.fromPolicySource方法代码示例

本文整理汇总了Python中ndg.xacml.core.context.pdp.PDP.fromPolicySource方法的典型用法代码示例。如果您正苦于以下问题:Python PDP.fromPolicySource方法的具体用法?Python PDP.fromPolicySource怎么用?Python PDP.fromPolicySource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ndg.xacml.core.context.pdp.PDP的用法示例。


在下文中一共展示了PDP.fromPolicySource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def __init__(self, governance_controller):
        self.resource_policy_decision_point = dict()
        self.service_policy_decision_point = dict()

        self.empty_pdp = PDP.fromPolicySource(path.join(THIS_DIR, XACML_EMPTY_POLICY_FILENAME), ReaderFactory)
        self.load_common_service_policy_rules('')

        self.governance_controller = governance_controller


        #Create and register an Attribute Value derived class to handle a dict type used for the messages
        _className = 'Dict' + AttributeValue.CLASS_NAME_SUFFIX
        _classVars = {'TYPE': dict, 'IDENTIFIER': DICT_TYPE_URI}
        _attributeValueClass = type(_className, (AttributeValue, ), _classVars)
        AttributeValue.register(_attributeValueClass)
        attributeValueFactory.addClass(DICT_TYPE_URI, _attributeValueClass)

        self.DictAttributeValue = attributeValueFactory(DICT_TYPE_URI)


        #Create and register an Attribute Value derived class to handle any object
        _className = 'Object' + AttributeValue.CLASS_NAME_SUFFIX
        _classVars = {'TYPE': object, 'IDENTIFIER': OBJECT_TYPE_URI}
        _attributeValueClass = type(_className, (AttributeValue, ), _classVars)
        AttributeValue.register(_attributeValueClass)
        attributeValueFactory.addClass(OBJECT_TYPE_URI, _attributeValueClass)

        self.ObjectAttributeValue = attributeValueFactory(OBJECT_TYPE_URI)

        #Create and add new function for evaluating functions that take the message as a dict
        from pyon.core.governance.policy.evaluate import EvaluateCode, EvaluateFunction
        functionMap['urn:oasis:names:tc:xacml:1.0:function:evaluate-code'] = EvaluateCode
        functionMap['urn:oasis:names:tc:xacml:1.0:function:evaluate-function'] = EvaluateFunction
开发者ID:ooici,项目名称:pyon,代码行数:35,代码来源:policy_decision.py

示例2: load_policy_rules

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def load_policy_rules(self, resource_policy, rules_text):
        log.debug("Loading rules for service: %s" % resource_policy)

        #Simply create a new PDP object for the service
        #TODO - make sure this is thread safe with the evaluation that uses it.
        input_source = StringIO(rules_text)
        self.policy_decision_point[resource_policy] = PDP.fromPolicySource(input_source, ReaderFactory)
开发者ID:tgiguere,项目名称:pyon,代码行数:9,代码来源:policy_decision.py

示例3: initialise

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def initialise(self, prefix='', **kw):
        '''Initialise object from keyword settings
        
        :type prefix: basestring
        :param prefix: prefix for configuration items
        :type kw: dict        
        :param kw: configuration settings
        dictionary
        :raise SamlPepFilterConfigError: missing option setting(s)
        '''
        # Parse other options
        for name in SamlPepFilter.PARAM_NAMES:
            paramName = prefix + name
            value = kw.get(paramName)
            
            if value is not None:
                setattr(self, name, value)
                
            elif name != self.__class__.LOCAL_POLICY_FILEPATH_PARAM_NAME:
                # Policy file setting is optional
                raise SamlPepFilterConfigError('Missing option %r' % paramName)
            

        # Parse authorisation decision query options
        queryPrefix = prefix + self.__class__.AUTHZ_DECISION_QUERY_PARAMS_PREFIX
        self.client.parseKeywords(prefix=queryPrefix, **kw)

        # Initialise the local PDP  
        if self.localPolicyFilePath:
            self.__localPdp = PDP.fromPolicySource(self.localPolicyFilePath, 
                                                   XacmlPolicyReaderFactory)
开发者ID:philipkershaw,项目名称:ndg_security_server,代码行数:33,代码来源:pep.py

示例4: load_org_policy_rules

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def load_org_policy_rules(self, rules_text):
        log.debug("Loading policies for org")

        #Simply create a new PDP object for the service
        #TODO - make sure this is thread safe with the evaluation that uses it.
        input_source = StringIO(rules_text)
        self.org_pdp = PDP.fromPolicySource(input_source, ReaderFactory)
开发者ID:oldpatricka,项目名称:pyon,代码行数:9,代码来源:policy_decision.py

示例5: __init__

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def __init__(self, governance_controller):
        self.resource_policy_decision_point = dict()
        self.service_policy_decision_point = dict()

        self.empty_pdp = PDP.fromPolicySource(path.join(THIS_DIR, XACML_EMPTY_POLICY_FILENAME), ReaderFactory)
        self.load_common_service_policy_rules('')

        self.governance_controller = governance_controller
开发者ID:daf,项目名称:pyon,代码行数:10,代码来源:policy_decision.py

示例6: __init__

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def __init__(self, *args, **kwargs):
        self.policy_decision_point = dict()
        self.org_pdp = PDP.fromPolicySource(path.join(THIS_DIR, XACML_EMPTY_POLICY_FILENAME), ReaderFactory)

        #Adding an not function to XACML
        from pyon.core.governance.policy.xacml.not_function import Not
        from pyon.core.governance.policy.xacml.and_function import And
        functionMap['urn:oasis:names:tc:xacml:ooi:function:not'] = Not
        functionMap['urn:oasis:names:tc:xacml:ooi:function:and'] = And
开发者ID:oldpatricka,项目名称:pyon,代码行数:11,代码来源:policy_decision.py

示例7: test02_04And2ArgsTrue

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
 def test02_04And2ArgsTrue(self):
     self.pdp = PDP.fromPolicySource(XACML_ANDTEST_FILEPATH, ReaderFactory)
     request = self._createRequestCtx(
                         self.__class__.RESOURCE4_ID,
                         subjectRoles=('role1', 'role2'))
     response = self.pdp.evaluate(request)
     self.failIf(response is None, "Null response")
     for result in response.results:
         self.failIf(result.decision != Decision.PERMIT,
                     "Expecting Permit decision")
开发者ID:LiangLinCn,项目名称:ndg_xacml,代码行数:12,代码来源:test_logical_functions.py

示例8: test02_03And1ArgFalse

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
 def test02_03And1ArgFalse(self):
     self.pdp = PDP.fromPolicySource(XACML_ANDTEST_FILEPATH, ReaderFactory)
     request = self._createRequestCtx(
                         self.__class__.RESOURCE3_ID,
                         subjectRoles=('role1',))
     response = self.pdp.evaluate(request)
     self.failIf(response is None, "Null response")
     for result in response.results:
         self.failIf(result.decision != Decision.DENY,
                     "Expecting Deny decision")
开发者ID:LiangLinCn,项目名称:ndg_xacml,代码行数:12,代码来源:test_logical_functions.py

示例9: get_pdp

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def get_pdp(self, resource_id):

        if self.policy_decision_point.has_key(resource_id):
            return self.policy_decision_point[resource_id]

        # If a PDP does not exist for this resource - then return default.
        if self.default_pdp is None:
            # Loads a blank policy set as the default or an unknown resource_policy
            self.default_pdp = PDP.fromPolicySource(path.join(THIS_DIR, XACML_EMPTY_POLICY_FILENAME), ReaderFactory)

        return self.default_pdp
开发者ID:ooici-dm,项目名称:pyon,代码行数:13,代码来源:policy_decision.py

示例10: createPDP

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def createPDP(self):
        """Create PDP from ion agents policy file"""

        log.debug("Creating a new PDP")
        # TODO - May need to implement a not function here.
        #from pyon.core.governance.ndg_xacml.ooi_and import And
        #functionMap['urn:oasis:names:tc:xacml:ooi:function:and'] = And

        self.policy_decision_point = PDP.fromPolicySource(path.join(THIS_DIR, XACML_ION_POLICY_FILENAME), ReaderFactory)

        return self.policy_decision_point
开发者ID:dstuebe,项目名称:pyon,代码行数:13,代码来源:policy_decision.py

示例11: load_resource_policy_rules

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def load_resource_policy_rules(self, resource_key, rules_text):

        if not rules_text and not self.resource_policy_decision_point.has_key(resource_key):
            return

        log.info("Loading policies for resource: %s" % resource_key)

        self.clear_resource_policy(resource_key)

        #Simply create a new PDP object for the service
        input_source = StringIO(self.create_policy_from_rules(resource_key, rules_text))
        self.resource_policy_decision_point[resource_key] = PDP.fromPolicySource(input_source, ReaderFactory)
开发者ID:daf,项目名称:pyon,代码行数:14,代码来源:policy_decision.py

示例12: test01_04StringConcatenate4Values

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
 def test01_04StringConcatenate4Values(self):
     """Test concatenation of 4 string values resulting in deny decision.
     """
     self.pdp = PDP.fromPolicySource(XACML_CONCATENATE_TEST_FILEPATH,
                                     ReaderFactory)
     request = self._createRequestCtx(self.__class__.RESOURCE4_ID,
                                      subjectRoles=('role1',))
     response = self.pdp.evaluate(request)
     self.failIf(response is None, "Null response")
     for result in response.results:
         self.failIf(result.decision != Decision.DENY,
                     "Expecting Deny decision")
开发者ID:LiangLinCn,项目名称:ndg_xacml,代码行数:14,代码来源:test_string_functions.py

示例13: test02_02AnyUriUrlencode

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
 def test02_02AnyUriUrlencode(self):
     """Test URL encoding of a URI value resulting in a deny decision.
     """
     self.pdp = PDP.fromPolicySource(XACML_CUSTOM_FUNCTION_TEST_FILEPATH,
                                     ReaderFactory)
     request = self._createRequestCtx(self.__class__.RESOURCE4_ID,
                                      subjectRoles=('role1',))
     response = self.pdp.evaluate(request)
     self.failIf(response is None, "Null response")
     for result in response.results:
         self.failIf(result.decision != Decision.DENY,
                     "Expecting Deny decision")
开发者ID:LiangLinCn,项目名称:ndg_xacml,代码行数:14,代码来源:test_custom_function.py

示例14: test01_01StringUrlencode

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
 def test01_01StringUrlencode(self):
     """Test URL encoding of a string value resulting in a permit decision.
     """
     self.pdp = PDP.fromPolicySource(XACML_CUSTOM_FUNCTION_TEST_FILEPATH,
                                     ReaderFactory)
     request = self._createRequestCtx(self.__class__.RESOURCE1_ID,
                                      subjectRoles=('role1',))
     response = self.pdp.evaluate(request)
     self.failIf(response is None, "Null response")
     for result in response.results:
         self.failIf(result.decision != Decision.PERMIT,
                     "Expecting Permit decision")
开发者ID:LiangLinCn,项目名称:ndg_xacml,代码行数:14,代码来源:test_custom_function.py

示例15: set_service_policy_rules

# 需要导入模块: from ndg.xacml.core.context.pdp import PDP [as 别名]
# 或者: from ndg.xacml.core.context.pdp.PDP import fromPolicySource [as 别名]
    def set_service_policy_rules(self, service_name, policy_list):
        log.debug("Loading policies for service: %s" % service_name)

        self.clear_service_policy(service_name)

        if not policy_list:
            self.service_policy_decision_point[service_name] = None
            return

        # Create a new PDP object for the service
        rules_text = self._get_rules_text(policy_list)
        input_source = StringIO(self.create_policy_from_rules(service_name, rules_text))
        self.service_policy_decision_point[service_name] = PDP.fromPolicySource(input_source, ReaderFactory)
开发者ID:edwardhunter,项目名称:scioncc,代码行数:15,代码来源:policy_decision.py


注:本文中的ndg.xacml.core.context.pdp.PDP.fromPolicySource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。