source: TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/attributedesignatorreader.py @ 6747

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/attributedesignatorreader.py@6747
Revision 6747, 1.5 KB checked in by pjkersha, 10 years ago (diff)

Adding parsing for Subject type and SubjectMatch? elements.

Line 
1"""NDG XACML ElementTree based reader for AttributeDesignator type
2
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.attributedesignator import AttributeDesignator
13from ndg.xacml.parsers import XMLParseError
14from ndg.xacml.parsers.etree import QName
15from ndg.xacml.parsers.etree.reader import ETreeAbstractReader
16
17
18class AttributeDesignatorReader(ETreeAbstractReader):
19    '''ElementTree based XACML Attribute Designator type parser
20    '''
21   
22    def __call__(self, obj):
23        """Parse AttributeDesignator object"""
24        elem = super(AttributeDesignatorReader, self)._parse(obj)
25       
26        cls = AttributeDesignator
27        attributeDesignator = cls()
28       
29        localName = QName.getLocalPart(elem.tag)
30        if localName != cls.ELEMENT_LOCAL_NAME:
31            raise XMLParseError("No \"%s\" element found" % 
32                                cls.ELEMENT_LOCAL_NAME)
33       
34        dataType = elem.attrib.get(cls.DATA_TYPE_ATTRIB_NAME)
35        if dataType is None:
36            raise XMLParseError('No "%s" attribute found in "%s" element' %
37                                (cls.DATA_TYPE_ATTRIB_NAME, 
38                                 cls.ELEMENT_LOCAL_NAME))
39               
40        attributeDesignator.dataType = dataType
41   
42        return attributeDesignator
43
44       
Note: See TracBrowser for help on using the repository browser.