1 | """NDG XACML ElementTree reader module containing reader base class |
---|
2 | |
---|
3 | NERC DataGrid |
---|
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$" |
---|
12 | import logging |
---|
13 | log = logging.getLogger(__name__) |
---|
14 | |
---|
15 | from ndg.xacml.parsers import AbstractReaderFactory |
---|
16 | from ndg.xacml.utils.factory import importModuleObject |
---|
17 | |
---|
18 | from ndg.xacml.core.policy import Policy |
---|
19 | from ndg.xacml.core.target import Target |
---|
20 | from ndg.xacml.core.rule import Rule |
---|
21 | |
---|
22 | # Target child elements |
---|
23 | from ndg.xacml.core.subject import Subject |
---|
24 | from ndg.xacml.core.action import Action |
---|
25 | from ndg.xacml.core.resource import Resource |
---|
26 | from ndg.xacml.core.environment import Environment |
---|
27 | |
---|
28 | |
---|
29 | class 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 | return readerClass |
---|
54 | |
---|