Changeset 6802 for TI12-security/trunk/NDG_XACML
- Timestamp:
- 12/04/10 16:40:24 (10 years ago)
- Location:
- TI12-security/trunk/NDG_XACML/ndg/xacml
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDG_XACML/ndg/xacml/core/attributevalue.py
r6797 r6802 44 44 def __init__(self): 45 45 super(AttributeValue, self).__init__() 46 if self.__class__.TYPE is None: 47 raise TypeError('TYPE class variable must be set to a valid type ' 48 'in a derived class') 49 46 50 self.__value = None 47 51 … … 119 123 120 124 121 class AttributeValue Factory(object):125 class AttributeValueClassFactory(object): 122 126 """Create AttributeValue types based on the XML namespace identifier 123 127 -
TI12-security/trunk/NDG_XACML/ndg/xacml/core/functions/__init__.py
r6797 r6802 331 331 cls = FunctionMap 332 332 classPath = None 333 334 if functionNs == "urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of": 335 pass 336 333 337 for namespacePrefix, pkgNamePrefix in cls.SUPPORTED_NSS.items(): 334 338 if functionNs.startswith(namespacePrefix): -
TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/attributevaluereader.py
r6754 r6802 10 10 __contact__ = "Philip.Kershaw@stfc.ac.uk" 11 11 __revision__ = "$Id: $" 12 from ndg.xacml.core.attributevalue import AttributeValue 12 from ndg.xacml.core.attributevalue import (AttributeValue, 13 AttributeValueClassFactory) 13 14 from ndg.xacml.parsers import XMLParseError 15 from ndg.xacml.parsers.etree import QName 14 16 from ndg.xacml.parsers.etree.expressionreader import ExpressionReader 15 17 … … 19 21 ''' 20 22 TYPE = AttributeValue 23 FACTORY = AttributeValueClassFactory() 24 25 def __call__(self, obj): 26 """Parse *AttributeValue type element - override this method instead of 27 _parseExtension since AttributeValue class is virtual. A sub-type can 28 be instantiated only once the data type attribute is parsed 29 """ 30 elem = super(AttributeValueReader, self)._parse(obj) 31 32 xacmlType = self.__class__.TYPE 33 localName = QName.getLocalPart(elem.tag) 34 if localName != xacmlType.ELEMENT_LOCAL_NAME: 35 raise XMLParseError("No \"%s\" element found" % 36 xacmlType.ELEMENT_LOCAL_NAME) 37 38 # Unpack *required* attributes from top-level element 39 elemAttributeValues = [] 40 for attributeName in (xacmlType.DATA_TYPE_ATTRIB_NAME,): 41 attributeValue = elem.attrib.get(attributeName) 42 if attributeValue is None: 43 raise XMLParseError('No "%s" attribute found in "%s" element' % 44 (attributeName, 45 xacmlType.ELEMENT_LOCAL_NAME)) 46 47 elemAttributeValues.append(attributeValue) 48 49 attributeValueClass = self.__class__.FACTORY(elemAttributeValues[0]) 50 attributeValue = attributeValueClass() 51 attributeValue.dataType = elemAttributeValues[0] 52 self._parseExtension(elem, attributeValue) 53 54 return attributeValue 21 55 22 56 def _parseExtension(self, elem, attributeValue): 23 """Implement abstract method to complete parsing of attribute value"""24 25 57 if elem.text is None: 26 58 raise XMLParseError('No attribute value element found parsing %r' % 27 59 AttributeValueReader.TYPE.ELEMENT_LOCAL_NAME) 28 29 attributeValue.value = elem.text .strip()60 61 attributeValue.value = elem.text 30 62 -
TI12-security/trunk/NDG_XACML/ndg/xacml/test/test_context.py
r6798 r6802 22 22 from ndg.xacml.core.context.handler import AbstractContextHandler 23 23 from ndg.xacml.core.attribute import Attribute 24 from ndg.xacml.core.attributevalue import AttributeValueFactory, AttributeValue 24 from ndg.xacml.core.attributevalue import (AttributeValueClassFactory, 25 AttributeValue) 25 26 from ndg.xacml.core.context.request import Request 26 27 from ndg.xacml.core.context.response import Response … … 61 62 subject = Subject() 62 63 63 attributeValueFactory = AttributeValue Factory()64 attributeValueFactory = AttributeValueClassFactory() 64 65 65 66 openidSubjectAttribute = Attribute() … … 100 101 101 102 resourceAttribute.dataType = "http://www.w3.org/2001/XMLSchema#anyURI" 102 resourceAttribute.attributeValues.append( AttributeValue())103 resourceAttribute.attributeValues.append(StringAttributeValue()) 103 104 resourceAttribute.attributeValues[-1].value = \ 104 105 'http://www.localhost/test_securedURI' … … 113 114 "urn:oasis:names:tc:xacml:1.0:action:action-id" 114 115 actionAttribute.dataType = "http://www.w3.org/2001/XMLSchema#string" 115 actionAttribute.attributeValues.append( AttributeValue())116 actionAttribute.attributeValues.append(StringAttributeValue()) 116 117 actionAttribute.attributeValues[-1].value = 'read' 117 118
Note: See TracChangeset
for help on using the changeset viewer.