source: TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/factory.py @ 7064

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

Incomplete - task 2: XACML-Security Integration

  • added and and function and placeholders fro xpath-node-* functions
  • Property svn:keywords set to Id
Line 
1"""NDG XACML ElementTree reader module containing reader base class
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "19/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$"
12import logging
13log = logging.getLogger(__name__)
14
15from ndg.xacml.parsers import AbstractReaderFactory
16from ndg.xacml.utils.factory import importModuleObject
17
18from ndg.xacml.core.policy import Policy
19from ndg.xacml.core.target import Target
20from ndg.xacml.core.rule import Rule
21
22# Target child elements
23from ndg.xacml.core.subject import Subject
24from ndg.xacml.core.action import Action
25from ndg.xacml.core.resource import Resource
26from ndg.xacml.core.environment import Environment
27
28
29class ReaderFactory(AbstractReaderFactory):
30    """Parser factory for ElementTree based parsers for XACML types"""
31   
32    @classmethod
33    def getReader(cls, xacmlType):
34        """Return ElementTree based Reader class for the given input
35       
36        @param xacmlType: XACML type to return a parser class for
37        @type xacmlType: type
38        @return: ElementTree based reader for the input XACML type.  The class
39        and module containing the class are infered from the XACML class name
40        input e.g.
41       
42        ndg.xacml.core.Subject => ndg.xacml.parsers.etree.subjectreader.SubjectReader
43       
44        @rtype: ndg.xacml.parsers.etree.reader.ETreeAbstractReader derived
45        type
46        @raise ImportError: if no reader class found for input type
47        """
48        xacmlTypeName = xacmlType.__name__
49        readerClassName = 'ndg.xacml.parsers.etree.%sreader.%sReader' % (
50                                                        xacmlTypeName.lower(),
51                                                        xacmlTypeName)
52        readerClass = importModuleObject(readerClassName)
53       
54        log.debug('Returning %r ElementTree based reader for %r type',
55                  readerClass, xacmlType)
56        return readerClass
57           
Note: See TracBrowser for help on using the repository browser.