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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/ndg_xacml/ndg/xacml/parsers/etree/attributedesignatorreader.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 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 AttributeDesignator object"""
23        xacmlType = self.__class__.TYPE
24       
25        # Unpack additional *required* attributes from top-level element
26        attributeValues = []
27        for attributeName in (xacmlType.ATTRIBUTE_ID_ATTRIB_NAME,):
28            attributeValue = elem.attrib.get(attributeName)
29            if attributeValue is None:
30                raise XMLParseError('No "%s" attribute found in "%s" element' %
31                                    (attributeName, 
32                                     xacmlType.ELEMENT_LOCAL_NAME))
33               
34            attributeValues.append(attributeValue)
35             
36        attributeDesignator.attributeId, = attributeValues
37             
38        # Optional attributes
39        issuer = elem.attrib.get(xacmlType.ISSUER_ATTRIB_NAME)
40        if issuer is not None:
41            attributeDesignator.issuer = issuer
42             
43        mustBePresent = elem.attrib.get(xacmlType.MUST_BE_PRESENT_ATTRIB_NAME)
44        if mustBePresent is not None:
45            attributeDesignator.mustBePresent = str2Bool(mustBePresent)
46   
47        return attributeDesignator
48
Note: See TracBrowser for help on using the repository browser.