source: TI12-security/trunk/ndg_xacml/ndg/xacml/parsers/etree/attributedesignatorreader.py @ 7109

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/ndg_xacml/ndg/xacml/parsers/etree/attributedesignatorreader.py@7109
Revision 7109, 2.3 KB checked in by pjkersha, 10 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 based reader for AttributeDesignator type
2
3NERC DataGrid
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.utils import str2Bool
13from ndg.xacml.parsers import XMLParseError
14from ndg.xacml.parsers.etree import QName
15from ndg.xacml.parsers.etree.expressionreader import ExpressionReader
16
17
18class AttributeDesignatorReaderBase(ExpressionReader):
19    '''ElementTree based XACML Attribute Designator base class type parser
20    '''
21    def _parseExtension(self, elem, attributeDesignator):
22        """Parse Attribute Designator element
23       
24        @param elem: ElementTree XML element
25        @type elem: xml.etree.Element
26       
27        @param attributeDesignator: attribute designator
28        @type attributeDesignator: ndg.xacml.core.attributedesignator.AttributeDesignator
29       
30        @raise XMLParseError: error parsing attribute ID XML attribute
31       
32        @return: updated attribute designator
33        @rtype: ndg.xacml.core.attributedesignator.AttributeDesignator
34        """
35        xacmlType = self.__class__.TYPE
36       
37        # Unpack additional *required* attributes from top-level element
38        attributeValues = []
39        for attributeName in (xacmlType.ATTRIBUTE_ID_ATTRIB_NAME,):
40            attributeValue = elem.attrib.get(attributeName)
41            if attributeValue is None:
42                raise XMLParseError('No "%s" attribute found in "%s" element' %
43                                    (attributeName, 
44                                     xacmlType.ELEMENT_LOCAL_NAME))
45               
46            attributeValues.append(attributeValue)
47             
48        attributeDesignator.attributeId, = attributeValues
49             
50        # Optional attributes
51        issuer = elem.attrib.get(xacmlType.ISSUER_ATTRIB_NAME)
52        if issuer is not None:
53            attributeDesignator.issuer = issuer
54             
55        mustBePresent = elem.attrib.get(xacmlType.MUST_BE_PRESENT_ATTRIB_NAME)
56        if mustBePresent is not None:
57            attributeDesignator.mustBePresent = str2Bool(mustBePresent)
58   
59        return attributeDesignator
60
Note: See TracBrowser for help on using the repository browser.