source: TI12-security/trunk/ndg_xacml/ndg/xacml/parsers/etree/attributeselectorreader.py @ 7087

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/ndg_xacml/ndg/xacml/parsers/etree/attributeselectorreader.py@7087
Revision 7087, 1.9 KB checked in by pjkersha, 11 years ago (diff)

Incomplete - task 2: XACML-Security Integration

  • updating epydoc ready for release.
  • Property svn:keywords set to Id
Line 
1"""NDG XACML ElementTree Attribute Selector Reader 
2
3NERC DataGrid
4"""
5__author__ = "P J Kershaw"
6__date__ = "18/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.attributeselector import AttributeSelector
13from ndg.xacml.parsers import XMLParseError
14from ndg.xacml.parsers.etree import QName
15from ndg.xacml.parsers.etree.expressionreader import ExpressionReader
16
17
18class AttributeSelectorReader(ExpressionReader):
19    '''ElementTree based parser for XACML Attribute Selector type'''
20    TYPE = AttributeSelector
21   
22    def _parseExtension(self, elem, attributeSelector):
23       
24        xacmlType = self.__class__.TYPE
25       
26        localName = QName.getLocalPart(elem.tag)
27        if localName != xacmlType.ELEMENT_LOCAL_NAME:
28            raise XMLParseError("No \"%s\" element found" % 
29                                xacmlType.ELEMENT_LOCAL_NAME)
30           
31        # Unpack *required* attributes from top-level element
32        attributeValues = []
33        for attributeName in (xacmlType.REQUEST_CONTEXT_PATH_ATTRIB_NAME,):
34            attributeValue = elem.attrib.get(attributeName)
35            if attributeValue is None:
36                raise XMLParseError('No "%s" attribute found in "%s" element' %
37                                    (attributeName, 
38                                     xacmlType.ELEMENT_LOCAL_NAME))
39               
40            attributeValues.append(attributeValue)
41             
42        attributeSelector.requestContextPath, = attributeValues
43       
44        mustBePresent = elem.attrib.get(xacmlType.MUST_BE_PRESENT_ATTRIB_NAME)
45        if mustBePresent is not None:
46            attributeSelector.mustBePresent = str2Bool(mustBePresent)
47         
48        return attributeSelector
49
50               
Note: See TracBrowser for help on using the repository browser.