1 """NDG XACML AttributeSelector type
2
3 NERC DataGrid
4 """
5 __author__ = "P J Kershaw"
6 __date__ = "16/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: attributeselector.py 8010 2012-01-30 16:24:06Z rwilkinson $"
12 import logging
13 log = logging.getLogger(__name__)
14
15 from ndg.xacml.core.attributevalue import AttributeValueClassFactory
16 from ndg.xacml.core.context.exceptions import MissingAttributeError
17 from ndg.xacml.core.context.request import Request
18 from ndg.xacml.core.expression import Expression
19 from ndg.xacml.parsers import XMLParseError
20 from ndg.xacml.utils import TypedList
24 '''XACML Attribute Selector type
25 @cvar ELEMENT_LOCAL_NAME: XML local name for this element
26 @type ELEMENT_LOCAL_NAME: string
27 @cvar REQUEST_CONTEXT_PATH_ATTRIB_NAME: request context XML attribute name
28 @type REQUEST_CONTEXT_PATH_ATTRIB_NAME: string
29 @cvar MUST_BE_PRESENT_ATTRIB_NAME: must be present XML attribute name
30 @type MUST_BE_PRESENT_ATTRIB_NAME: string
31
32 @ivar __attributeValueFactory: When evaluating matches, use an attribute
33 value class factory to create attribute values for match bag of the correct
34 DataType to respect type based rule functions
35 @type __attributeValueFactory: ndg.xacml.core.attributevalue.AttributeValueClassFactory
36 '''
37 ELEMENT_LOCAL_NAME = 'AttributeSelector'
38 MUST_BE_PRESENT_ATTRIB_NAME = 'MustBePresent'
39 REQUEST_CONTEXT_PATH_ATTRIB_NAME = 'RequestContextPath'
40
41 __slots__ = ('__mustBePresent',
42 '__requestContextPath',
43 '__attributeValueFactory'
44 )
45
57
58 @property
60 """Get request context path
61 @return: request context path
62 @rtype: basestring
63 """
64 return self.__requestContextPath
65
66 @requestContextPath.setter
67 - def requestContextPath(self, value):
68 """Set request context path
69 @param value: request context path
70 @type value: basestring
71 @raise TypeError: incorrect input type
72 """
73 if not isinstance(value, basestring):
74 raise TypeError('Expecting %r type for "requestContextPath" '
75 'attribute; got %r' % (basestring, type(value)))
76
77 self.__requestContextPath = value
78
79 @property
81 """Get Must Be Present flag
82 @return: must be present flag
83 @rtype: bool
84 """
85 return self.__mustBePresent
86
87 @mustBePresent.setter
89 """Set Must Be Present flag
90 @param value: must be present flag
91 @type value: bool
92 @raise TypeError: incorrect input type
93 """
94 if not isinstance(value, bool):
95 raise TypeError('Expecting %r type for "mustBePresent" '
96 'attribute; got %r' % (bool, type(value)))
97
98 self.__mustBePresent = value
99
100 @property
102 """Get Attribute Value factory function
103
104 @return: attribute value factory instance
105 @rtype: ndg.xacml.core.attributevalue.AttributeValueClassFactory
106 """
107 return self.__attributeValueFactory
108
149