Ignore:
Timestamp:
19/03/10 11:53:21 (10 years ago)
Author:
pjkersha
Message:

Started adding parsing for Condition and Apply types.

Location:
TI12-security/trunk/NDG_XACML/ndg/xacml
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/NDG_XACML/ndg/xacml/core/__init__.py

    r6747 r6753  
    2525        self.__reader = None 
    2626        self.__writer = None 
     27         
     28        if not isinstance(self.__class__.ELEMENT_LOCAL_NAME, basestring): 
     29            raise NotImplementedError('"ELEMENT_LOCAL_NAME" must be defined in ' 
     30                                      'a derived class') 
    2731         
    2832    def _getXmlns(self): 
  • TI12-security/trunk/NDG_XACML/ndg/xacml/core/attributedesignator.py

    r6752 r6753  
    7373    """XACML Resource Attribute Designator type""" 
    7474    ELEMENT_LOCAL_NAME = 'ResourceAttributeDesignator' 
     75     
     76         
     77class ActionAttributeDesignator(AttributeDesignator): 
     78    """XACML Action Attribute Designator type""" 
     79    ELEMENT_LOCAL_NAME = 'ActionAttributeDesignator' 
  • TI12-security/trunk/NDG_XACML/ndg/xacml/core/condition.py

    r6746 r6753  
    1515class Condition(PolicyComponent): 
    1616    """XACML Rule Condition""" 
     17    ELEMENT_LOCAL_NAME = 'Condition' 
     18    APPLY_ELEMENT_LOCAL_NAME = 'Apply' 
     19     
    1720    __slots__ = ('__expression', ) 
    1821     
    1922    def __init__(self): 
     23        super(Condition, self).__init__() 
    2024        self.__expression = None 
    2125         
     
    2630    @expression.setter 
    2731    def expression(self, value): 
     32        if not isinstance(value, Expression): 
     33            raise TypeError('Expecting Expression or Expression derived type ' 
     34                            'for "expression" attribute; got %r' % 
     35                            type(value)) 
    2836        self.__expression = value 
  • TI12-security/trunk/NDG_XACML/ndg/xacml/core/expression.py

    r6750 r6753  
    1 ''' 
    2 Created on 16 Mar 2010 
     1"""NDG Security Expression type definition 
    32 
    4 @author: pjkersha 
    5 ''' 
     3NERC DataGrid Project 
     4""" 
     5__author__ = "P J Kershaw" 
     6__date__ = "25/02/10" 
     7__copyright__ = "(C) 2010 Science and Technology Facilities Council" 
     8__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     9__license__ = "BSD - see LICENSE file in top-level directory" 
     10__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     11__revision__ = "$Id: $" 
    612from ndg.xacml.core import PolicyComponent 
    713 
  • TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/conditionreader.py

    r6752 r6753  
    1212from ndg.xacml.core.condition import Condition 
    1313from ndg.xacml.parsers import XMLParseError 
     14from ndg.xacml.parsers.etree import QName 
    1415from ndg.xacml.parsers.etree.reader import ETreeAbstractReader 
     16from ndg.xacml.parsers.etree.applyreader import ApplyReader 
    1517 
    1618 
    1719class ConditionReader(ETreeAbstractReader): 
    18     '''ElementTree based XACML Rule parser 
     20    '''ElementTree based XACML Condition parser 
     21     
     22    @cvar TYPE: XACML type to instantiate from parsed object 
     23    @type string: type 
    1924    ''' 
     25    TYPE = Condition 
     26     
    2027    def __call__(self, obj): 
    2128        """Parse policy object""" 
    22         elem = super(CondtionReader, self)._parse(obj) 
     29        elem = super(ConditionReader, self)._parse(obj) 
    2330         
    24         condition = Condition() 
    25         xacmlType = Condition 
     31        xacmlType = self.__class__.TYPE 
     32        condition = xacmlType() 
    2633         
    2734        localName = QName.getLocalPart(elem.tag) 
     
    3441            raise XMLParseError("No expression sub element found in " 
    3542                                "Condition element") 
     43         
     44        subElemlocalName = QName.getLocalPart(elem[0].tag) 
     45        if subElemlocalName == xacmlType.APPLY_ELEMENT_LOCAL_NAME: 
     46            condition.expression = ApplyReader.parse(elem[0]) 
     47        else: 
     48            raise XMLParseError('Expecting %r Condition sub-element not ' 
     49                                'recognised' % 
     50                                xacmlType.EXPRESSION_ELEMENT_LOCAL_NAME) 
    3651             
    37         condition = ExpressionReader.parse(elem[0]) 
     52         
    3853    
    3954        return condition 
  • TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/environmentreader.py

    r6747 r6753  
    1 ''' 
    2 Created on 16 Mar 2010 
     1"""NDG XACML ElementTree based Environment Element reader  
    32 
    4 @author: pjkersha 
    5 ''' 
     3NERC DataGrid Project 
     4""" 
     5__author__ = "P J Kershaw" 
     6__date__ = "16/03/10" 
     7__copyright__ = "(C) 2010 Science and Technology Facilities Council" 
     8__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     9__license__ = "BSD - see LICENSE file in top-level directory" 
     10__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     11__revision__ = "$Id: $" 
     12from ndg.xacml.core.environment import Environment 
     13from ndg.xacml.parsers.etree.targetchildreader import TargetChildReader 
     14     
    615 
    7 class EnvironmentReader(object): 
     16class EnvironmentReader(TargetChildReader): 
     17    '''ElementTree based XACML Rule parser 
     18    @cvar TYPE: XACML type to instantiate from parsed object 
     19    @type string: type 
    820    ''' 
    9     classdocs 
    10     ''' 
    11  
    12  
    13     def __init__(selfparams): 
    14         ''' 
    15         Constructor 
    16         ''' 
    17          
     21    TYPE = Environment         
  • TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/rulereader.py

    r6752 r6753  
    4141        # Unpack *required* attributes from top-level element 
    4242        attributeValues = [] 
    43         for attributeName in (xacmlType.RULE_ID_ATTRIB_NAME, xacmlType.EFFECT_ATTRIB_NAME): 
     43        for attributeName in (xacmlType.RULE_ID_ATTRIB_NAME,  
     44                              xacmlType.EFFECT_ATTRIB_NAME): 
    4445            attributeValue = elem.attrib.get(attributeName) 
    4546            if attributeValue is None: 
Note: See TracChangeset for help on using the changeset viewer.