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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/ndg_xacml/ndg/xacml/parsers/etree/policydefaultsreader.py@7087
Revision 7087, 2.0 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 PolicyDefaults type
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.policydefaults import PolicyDefaults
13from ndg.xacml.parsers import XMLParseError
14from ndg.xacml.parsers.etree import QName
15from ndg.xacml.parsers.etree.reader import ETreeAbstractReader
16
17
18class PolicyDefaultsReader(ETreeAbstractReader):
19    '''ElementTree based XACML PolicyDefaults type parser
20    '''
21    TYPE = PolicyDefaults
22   
23    def __call__(self, obj):
24        """Parse AttributeValue object"""
25        elem = super(PolicyDefaultsReader, self)._parse(obj)
26       
27        xacmlType = self.__class__.TYPE
28        policyDefaults = xacmlType()
29       
30        localName = QName.getLocalPart(elem.tag)
31        if localName != xacmlType.ELEMENT_LOCAL_NAME:
32            raise XMLParseError("No \"%s\" element found" % 
33                                xacmlType.ELEMENT_LOCAL_NAME)
34       
35        if len(elem) != 1:
36            raise XMLParseError('Expecting a single child element for '
37                                'PolicyDefaults element')
38           
39        if (QName.getLocalPart(elem[0].tag) != 
40            xacmlType.XPATH_VERSION_ELEMENT_NAME):
41            raise XMLParseError('Expecting a %r child element for '
42                                'PolicyDefaults element' % 
43                                xacmlType.XPATH_VERSION_ELEMENT_NAME)
44       
45        xpathVersion = elem[0].text
46        if xpathVersion is None:
47            raise XMLParseError('No %r child element value set for '
48                                'PolicyDefaults element' % 
49                                xacmlType.XPATH_VERSION_ELEMENT_NAME) 
50             
51        policyDefaults.xpathVersion = xpathVersion
52       
53        return policyDefaults
54
55
Note: See TracBrowser for help on using the repository browser.