1 | """NDG XACML Attribute type |
---|
2 | |
---|
3 | NERC DataGrid |
---|
4 | """ |
---|
5 | __author__ = "P J Kershaw" |
---|
6 | __date__ = "24/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 | from ndg.xacml.utils import TypedList |
---|
13 | from ndg.xacml.core import XacmlCoreBase |
---|
14 | from ndg.xacml.core.attributevalue import AttributeValue |
---|
15 | |
---|
16 | |
---|
17 | class Attribute(XacmlCoreBase): |
---|
18 | """XACML Attribute type |
---|
19 | |
---|
20 | @cvar ELEMENT_LOCAL_NAME: XML local name for this element |
---|
21 | @type ELEMENT_LOCAL_NAME: string |
---|
22 | @cvar ATTRIBUTE_VALUE_ELEMENT_LOCAL_NAME: XML local name for attribute value |
---|
23 | child element |
---|
24 | @type ATTRIBUTE_VALUE_ELEMENT_LOCAL_NAME: string |
---|
25 | @cvar DATA_TYPE_ATTRIB_NAME: XML attribute name for data type |
---|
26 | @type DATA_TYPE_ATTRIB_NAME: string |
---|
27 | @cvar ATTRIBUTE_ID_ATTRIB_NAME: attribute ID XML attribute name |
---|
28 | @type ATTRIBUTE_ID_ATTRIB_NAME: string |
---|
29 | @cvar ISSUER_ATTRIB_NAME: issuer XML attribute name |
---|
30 | @type ISSUER_ATTRIB_NAME: string |
---|
31 | |
---|
32 | @ivar __attributeValues: list of attribute values |
---|
33 | @type __attributeValues: ndg.xacml.utils.TypedList |
---|
34 | @ivar __dataType: data type for this attribute |
---|
35 | @type __dataType: basestring / NoneType |
---|
36 | @ivar __attributeId: identifier for attribute |
---|
37 | @type __attributeId: basestring / NoneType |
---|
38 | @ivar __issuer: issuer id of this attribute |
---|
39 | @type __issuer: basestring / NoneType |
---|
40 | """ |
---|
41 | ELEMENT_LOCAL_NAME = 'Attribute' |
---|
42 | ATTRIBUTE_VALUE_ELEMENT_LOCAL_NAME = 'AttributeValue' |
---|
43 | DATA_TYPE_ATTRIB_NAME = 'DataType' |
---|
44 | ATTRIBUTE_ID_ATTRIB_NAME = 'AttributeId' |
---|
45 | ISSUER_ATTRIB_NAME = 'Issuer' |
---|
46 | |
---|
47 | __slots__ = ('__attributeValues', '__dataType', '__attributeId', '__issuer') |
---|
48 | |
---|
49 | def __init__(self): |
---|
50 | self.__attributeValues = TypedList(AttributeValue) |
---|
51 | self.__dataType = None |
---|
52 | self.__attributeId = None |
---|
53 | self.__issuer = None |
---|
54 | |
---|
55 | @property |
---|
56 | def attributeValues(self): |
---|
57 | """Get attribute values |
---|
58 | |
---|
59 | @return: list of attribute values |
---|
60 | @rtype: ndg.xacml.utils.TypedList |
---|
61 | """ |
---|
62 | return self.__attributeValues |
---|
63 | |
---|
64 | @attributeValues.setter |
---|
65 | def attributeValues(self, value): |
---|
66 | """Set attribute values |
---|
67 | |
---|
68 | @ivar value: list of attribute values |
---|
69 | @type value: ndg.xacml.utils.TypedList |
---|
70 | @raise TypeError: incorrect input type |
---|
71 | """ |
---|
72 | if not isinstance(value, TypedList): |
---|
73 | raise TypeError('Expecting %r type for "attributeValues" ' |
---|
74 | 'attribute; got %r' % (TypedList, type(value))) |
---|
75 | |
---|
76 | self.__attributeValues = value |
---|
77 | |
---|
78 | def _get_dataType(self): |
---|
79 | """Get data type |
---|
80 | @return: attribute data type |
---|
81 | @rtype: basestring / NoneType |
---|
82 | """ |
---|
83 | return self.__dataType |
---|
84 | |
---|
85 | def _set_dataType(self, value): |
---|
86 | """Set data type |
---|
87 | @param value: attribute data type |
---|
88 | @type value: basestring |
---|
89 | @raise TypeError: incorrect input type |
---|
90 | """ |
---|
91 | if not isinstance(value, basestring): |
---|
92 | raise TypeError('Expecting %r type for "dataType" ' |
---|
93 | 'attribute; got %r' % (basestring, type(value))) |
---|
94 | |
---|
95 | self.__dataType = value |
---|
96 | |
---|
97 | dataType = property(_get_dataType, _set_dataType, None, |
---|
98 | "Attribute data type") |
---|
99 | |
---|
100 | @property |
---|
101 | def attributeId(self): |
---|
102 | """Get Attribute Id |
---|
103 | @return: attribute Id |
---|
104 | @rtype: basestring / NoneType |
---|
105 | """ |
---|
106 | return self.__attributeId |
---|
107 | |
---|
108 | @attributeId.setter |
---|
109 | def attributeId(self, value): |
---|
110 | """Set Attribute Id |
---|
111 | @param value: attribute id |
---|
112 | @type value: basestring |
---|
113 | @raise TypeError: incorrect input type |
---|
114 | """ |
---|
115 | if not isinstance(value, basestring): |
---|
116 | raise TypeError('Expecting %r type for "attributeId" ' |
---|
117 | 'attribute; got %r' % (basestring, type(value))) |
---|
118 | |
---|
119 | self.__attributeId = value |
---|
120 | |
---|
121 | @property |
---|
122 | def issuer(self): |
---|
123 | """Get Issuer |
---|
124 | @return: attribute issuer |
---|
125 | @rtype: basestring / NoneType |
---|
126 | """ |
---|
127 | return self.__issuer |
---|
128 | |
---|
129 | @issuer.setter |
---|
130 | def issuer(self, value): |
---|
131 | """Set Issuer |
---|
132 | @param value: attribute issuer |
---|
133 | @type value: basestring |
---|
134 | @raise TypeError: incorrect input type |
---|
135 | """ |
---|
136 | if not isinstance(value, basestring): |
---|
137 | raise TypeError('Expecting %r type for "issuer" ' |
---|
138 | 'attribute; got %r' % (basestring, type(value))) |
---|
139 | |
---|
140 | self.__issuer = value |
---|