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

Started adding parsing for Condition and Apply types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.