- Timestamp:
- 19/03/10 10:39:33 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/policyreader.py
r6751 r6752 17 17 from ndg.xacml.parsers.etree import QName 18 18 from ndg.xacml.parsers.etree.reader import ETreeAbstractReader 19 from ndg.xacml.parsers.etree.targetreader import TargetReader 20 from ndg.xacml.parsers.etree.rulereader import RuleReader 19 from ndg.xacml.parsers.etree.factory import ReaderFactory 21 20 22 21 … … 32 31 33 32 # XACML type to instantiate 34 cls= PolicyReader.TYPE35 policy = cls()33 xacmlType = PolicyReader.TYPE 34 policy = xacmlType() 36 35 37 36 localName = QName.getLocalPart(elem.tag) 38 if localName != cls.ELEMENT_LOCAL_NAME:37 if localName != xacmlType.ELEMENT_LOCAL_NAME: 39 38 raise XMLParseError("No \"%s\" element found" % 40 cls.ELEMENT_LOCAL_NAME)39 xacmlType.ELEMENT_LOCAL_NAME) 41 40 42 41 # Unpack *required* attributes from top-level element 43 42 attributeValues = [] 44 for attributeName in ( cls.POLICY_ID_ATTRIB_NAME,45 cls.RULE_COMBINING_ALG_ID_ATTRIB_NAME):43 for attributeName in (xacmlType.POLICY_ID_ATTRIB_NAME, 44 xacmlType.RULE_COMBINING_ALG_ID_ATTRIB_NAME): 46 45 attributeValue = elem.attrib.get(attributeName) 47 46 if attributeValue is None: … … 49 48 'element' % 50 49 (attributeName, 51 cls.ELEMENT_LOCAL_NAME))50 xacmlType.ELEMENT_LOCAL_NAME)) 52 51 53 52 attributeValues.append(attributeValue) … … 57 56 # Defaults to XACML version 1.0 58 57 # TODO: version check 59 policy.version = (elem.attrib.get( cls.VERSION_ATTRIB_NAME) or60 cls.DEFAULT_XACML_VERSION)58 policy.version = (elem.attrib.get(xacmlType.VERSION_ATTRIB_NAME) or 59 xacmlType.DEFAULT_XACML_VERSION) 61 60 62 61 # Parse sub-elements … … 64 63 localName = QName.getLocalPart(childElem.tag) 65 64 66 if localName == cls.DESCRIPTION_LOCAL_NAME:65 if localName == xacmlType.DESCRIPTION_LOCAL_NAME: 67 66 if childElem.text is not None: 68 67 policy.description = childElem.text.strip() 69 68 70 elif localName == cls.POLICY_DEFAULTS_LOCAL_NAME:69 elif localName == xacmlType.POLICY_DEFAULTS_LOCAL_NAME: 71 70 raise NotImplementedError() 72 71 73 72 elif localName == Target.ELEMENT_LOCAL_NAME: 73 TargetReader = ReaderFactory.getReader(Target) 74 74 policy.target = TargetReader.parse(childElem) 75 75 76 elif localName == cls.COMBINER_PARAMETERS_LOCAL_NAME:76 elif localName == xacmlType.COMBINER_PARAMETERS_LOCAL_NAME: 77 77 raise NotImplementedError() 78 78 79 elif localName == cls.RULE_COMBINER_PARAMETERS_LOCAL_NAME:79 elif localName == xacmlType.RULE_COMBINER_PARAMETERS_LOCAL_NAME: 80 80 raise NotImplementedError() 81 81 82 82 elif localName == VariableDefinition.ELEMENT_LOCAL_NAME: 83 VariableDefinitionReader = ReaderFactory.getReader( 84 VariableDefinition) 83 85 variableDefinition = VariableDefinitionReader.parse(childElem) 84 86 85 87 elif localName == Rule.ELEMENT_LOCAL_NAME: 88 RuleReader = ReaderFactory.getReader(Rule) 86 89 policy.rules.append(RuleReader.parse(childElem)) 87 90 88 elif localName == cls.OBLIGATIONS_LOCAL_NAME:91 elif localName == xacmlType.OBLIGATIONS_LOCAL_NAME: 89 92 raise NotImplementedError() 90 93
Note: See TracChangeset
for help on using the changeset viewer.