Changeset 7101
- Timestamp:
- 25/06/10 17:13:06 (11 years ago)
- Location:
- TI12-security/trunk/ndg_xacml/ndg/xacml/core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/ndg_xacml/ndg/xacml/core/attribute.py
r7087 r7101 16 16 17 17 class Attribute(XacmlCoreBase): 18 """XACML Attribute type""" 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 """ 19 41 ELEMENT_LOCAL_NAME = 'Attribute' 20 42 ATTRIBUTE_VALUE_ELEMENT_LOCAL_NAME = 'AttributeValue' … … 33 55 @property 34 56 def attributeValues(self): 35 "attribute values" 57 """Get attribute values 58 59 @return: list of attribute values 60 @rtype: ndg.xacml.utils.TypedList 61 """ 36 62 return self.__attributeValues 37 63 38 64 @attributeValues.setter 39 65 def attributeValues(self, value): 40 "attribute values" 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 """ 41 72 if not isinstance(value, TypedList): 42 73 raise TypeError('Expecting %r type for "attributeValues" ' … … 46 77 47 78 def _get_dataType(self): 79 """Get data type 80 @return: attribute data type 81 @rtype: basestring / NoneType 82 """ 48 83 return self.__dataType 49 84 50 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 """ 51 91 if not isinstance(value, basestring): 52 92 raise TypeError('Expecting %r type for "dataType" ' … … 60 100 @property 61 101 def attributeId(self): 62 """Get Attribute Id""" 102 """Get Attribute Id 103 @return: attribute Id 104 @rtype: basestring / NoneType 105 """ 63 106 return self.__attributeId 64 107 65 108 @attributeId.setter 66 109 def attributeId(self, value): 67 """Set Attribute Id""" 110 """Set Attribute Id 111 @param value: attribute id 112 @type value: basestring 113 @raise TypeError: incorrect input type 114 """ 68 115 if not isinstance(value, basestring): 69 116 raise TypeError('Expecting %r type for "attributeId" ' … … 74 121 @property 75 122 def issuer(self): 76 """Get Issuer""" 123 """Get Issuer 124 @return: attribute issuer 125 @rtype: basestring / NoneType 126 """ 77 127 return self.__issuer 78 128 79 129 @issuer.setter 80 130 def issuer(self, value): 81 """Set Issuer""" 131 """Set Issuer 132 @param value: attribute issuer 133 @type value: basestring 134 @raise TypeError: incorrect input type 135 """ 82 136 if not isinstance(value, basestring): 83 137 raise TypeError('Expecting %r type for "issuer" ' -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/attributedesignator.py
r7087 r7101 20 20 21 21 class AttributeDesignator(Expression): 22 '''XACML Attribute Designator type 22 '''Base class for XACML Attribute Designator types 23 24 @cvar ATTRIBUTE_ID_ATTRIB_NAME: attribute ID XML attribute name 25 @type ATTRIBUTE_ID_ATTRIB_NAME: string 26 @cvar ISSUER_ATTRIB_NAME: issuer XML attribute name 27 @type ISSUER_ATTRIB_NAME: string 28 @cvar MUST_BE_PRESENT_ATTRIB_NAME: must be present XML attribute name 29 @type MUST_BE_PRESENT_ATTRIB_NAME: string 30 31 @ivar __attributeId: attribute ID for this designator 32 @type __attributeId: basestring / NoneType 33 @ivar __issuer: issuer if the designator 34 @type __issuer: basestring / NoneType 35 @ivar __mustBePresent: XML must be present flag 36 @type __mustBePresent: bool 37 @ivar __attributeValueFactory: When evaluating matches, use an attribute 38 value class factory to create attribute values for match bag of the correct 39 DataType to respect type based rule functions 40 @type __attributeValueFactory: ndg.xacml.core.attributevalue.AttributeValueClassFactory 23 41 ''' 24 42 ATTRIBUTE_ID_ATTRIB_NAME = 'AttributeId' … … 34 52 35 53 def __init__(self): 54 """Initialise attributes""" 36 55 super(AttributeDesignator, self).__init__() 37 56 self.__attributeId = None … … 46 65 @property 47 66 def attributeId(self): 48 """Get Attribute Id""" 67 """Get Attribute Id 68 @return: attribute ID 69 @rtype: basestring / NoneType 70 """ 49 71 return self.__attributeId 50 72 51 73 @attributeId.setter 52 74 def attributeId(self, value): 53 """Set Attribute Id""" 75 """Set Attribute Id 76 @param value: attribute ID 77 @type value: basestring 78 @raise TypeError: incorrect input type 79 """ 54 80 if not isinstance(value, basestring): 55 81 raise TypeError('Expecting %r type for "attributeId" ' … … 60 86 @property 61 87 def issuer(self): 62 """Get Issuer""" 88 """Get Issuer 89 @return: issuer 90 @rtype: basestring / NoneType 91 """ 63 92 return self.__issuer 64 93 65 94 @issuer.setter 66 95 def issuer(self, value): 67 """Set Issuer""" 96 """Set Issuer 97 @param value: issuer 98 @type value: basestring 99 @raise TypeError: incorrect input type 100 """ 68 101 if not isinstance(value, basestring): 69 102 raise TypeError('Expecting %r type for "issuer" ' … … 74 107 @property 75 108 def mustBePresent(self): 76 """Get Must Be Present flag""" 109 """Get Must Be Present flag 110 @return: must be present flag 111 @rtype: bool 112 """ 77 113 return self.__mustBePresent 78 114 79 115 @mustBePresent.setter 80 116 def mustBePresent(self, value): 81 """Set Must Be Present flag""" 117 """Set Must Be Present flag 118 @param value: must be present flag 119 @type value: bool 120 @raise TypeError: incorrect input type 121 """ 82 122 if not isinstance(value, bool): 83 123 raise TypeError('Expecting %r type for "mustBePresent" ' … … 88 128 @property 89 129 def attributeValueFactory(self): 90 """Get Attribute Value factory function""" 130 """Get Attribute Value factory function 131 132 @return: attribute value factory instance 133 @rtype: ndg.xacml.core.attributevalue.AttributeValueClassFactory 134 """ 91 135 return self.__attributeValueFactory 92 136 93 137 94 138 class SubjectAttributeDesignator(AttributeDesignator): 95 """XACML Subject Attribute Designator type""" 139 """XACML Subject Attribute Designator type 140 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 141 @type ELEMENT_LOCAL_NAME: string 142 """ 96 143 ELEMENT_LOCAL_NAME = 'SubjectAttributeDesignator' 97 144 __slots__ = () 145 98 146 def evaluate(self, context): 99 147 """Evaluate the result of the SubjectAttributeDesignator in a condition … … 152 200 153 201 class ResourceAttributeDesignator(AttributeDesignator): 154 """XACML Resource Attribute Designator type""" 202 """XACML Resource Attribute Designator type 203 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 204 @type ELEMENT_LOCAL_NAME: string 205 """ 155 206 ELEMENT_LOCAL_NAME = 'ResourceAttributeDesignator' 207 __slots__ = () 156 208 157 209 def evaluate(self, context): … … 201 253 202 254 class ActionAttributeDesignator(AttributeDesignator): 203 """XACML Action Attribute Designator type""" 255 """XACML Action Attribute Designator type 256 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 257 @type ELEMENT_LOCAL_NAME: string 258 """ 204 259 ELEMENT_LOCAL_NAME = 'ActionAttributeDesignator' 260 __slots__ = () 205 261 206 262 def evaluate(self, context): … … 250 306 251 307 class EnvironmentAttributeDesignator(AttributeDesignator): 252 """XACML Environment Attribute Designator type""" 308 """XACML Environment Attribute Designator type 309 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 310 @type ELEMENT_LOCAL_NAME: string 311 """ 253 312 ELEMENT_LOCAL_NAME = 'EnvironmentAttributeDesignator' 313 __slots__ = () 254 314 255 315 def evaluate(self, context): -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/attributeselector.py
r7087 r7101 18 18 class AttributeSelector(Expression): 19 19 '''XACML Attribute Selector type 20 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 21 @type ELEMENT_LOCAL_NAME: string 22 @cvar REQUEST_CONTEXT_PATH_ATTRIB_NAME: request context XML attribute name 23 @type REQUEST_CONTEXT_PATH_ATTRIB_NAME: string 24 @cvar MUST_BE_PRESENT_ATTRIB_NAME: must be present XML attribute name 25 @type MUST_BE_PRESENT_ATTRIB_NAME: string 26 20 27 ''' 21 28 ELEMENT_LOCAL_NAME = 'AttributeSelector' … … 34 41 @property 35 42 def requestContextPath(self): 36 """Get Issuer""" 43 """Get request context path 44 @return: request context path 45 @rtype: basestring 46 """ 37 47 return self.__requestContextPath 38 48 39 49 @requestContextPath.setter 40 50 def requestContextPath(self, value): 41 """Set Issuer""" 51 """Set request context path 52 @param value: request context path 53 @type value: basestring 54 @raise TypeError: incorrect input type 55 """ 42 56 if not isinstance(value, basestring): 43 57 raise TypeError('Expecting %r type for "requestContextPath" ' … … 48 62 @property 49 63 def mustBePresent(self): 50 """Get Must Be Present flag""" 64 """Get Must Be Present flag 65 @return: must be present flag 66 @rtype: bool 67 """ 51 68 return self.__mustBePresent 52 69 53 70 @mustBePresent.setter 54 71 def mustBePresent(self, value): 55 """Set Must Be Present flag""" 72 """Set Must Be Present flag 73 @param value: must be present flag 74 @type value: bool 75 @raise TypeError: incorrect input type 76 """ 56 77 if not isinstance(value, bool): 57 78 raise TypeError('Expecting %r type for "mustBePresent" ' -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/attributevalue.py
r7087 r7101 17 17 18 18 class AttributeValue(Expression): 19 """XACML Attribute Value type""" 19 """XACML Attribute Value type 20 21 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 22 @type ELEMENT_LOCAL_NAME: string 23 @cvar CLASS_NAME_SUFFIX: all attribute value classes end with this suffix 24 @type CLASS_NAME_SUFFIX: string 25 @cvar IDENTIFIER_PREFIX: geberic prefix for attribute value URNs 26 @type IDENTIFIER_PREFIX: string 27 @cvar IDENTIFIER: URN for attribute value in derived class 28 @type IDENTIFIER: NoneType - derived classes should set to appropriate 29 string 30 @cvar TYPE_URIS: URIs for all the different supported types 31 @type TYPE_URIS: tuple 32 @cvar TYPE_NAMES: corresponding short names for all the types 33 @type TYPE_NAMES: tuple 34 @cvar NATIVE_TYPES: equivalent python types as implemented 35 @cvar TYPE_MAP: mapping from type names to python types 36 @type TYPE_MAP: dict 37 @cvar TYPE_URI_MAP: mapping from type names to type URIs 38 @type TYPE_URI_MAP: dict 39 @cvar TYPE: type name for derived type - set to None in this parent class 40 @type TYPE: NoneType / string in derived type 41 42 @ivar __value: setting for this attribute value 43 @type __value: any - constrained in derived classes 44 """ 20 45 ELEMENT_LOCAL_NAME = 'AttributeValue' 21 46 CLASS_NAME_SUFFIX = 'AttributeValue' … … 84 109 85 110 def __init__(self): 111 """Derived classes must override setting TYPE class variable""" 112 86 113 super(AttributeValue, self).__init__() 87 114 if self.__class__.TYPE is None: 88 raise TypeError('TYPE class variable must be set to a valid type'89 'in a derived class')115 raise NotImplementedError('TYPE class variable must be set to a ' 116 'valid type in a derived class') 90 117 91 118 self.__value = None … … 99 126 100 127 def _get_value(self): 128 """Get value 129 @param: setting for this attribute value 130 @rtype: any - constrained in derived classes 131 """ 101 132 return self.__value 102 133 103 134 def _set_value(self, value): 135 """Set value 136 137 @param value: setting for this attribute value 138 @type value: any - constrained in derived classes 139 @raise TypeError: if type doesn't match TYPE class variable. Derived 140 classes should set this 141 """ 104 142 if not isinstance(value, self.__class__.TYPE): 105 143 raise TypeError('Expecting %r type for "value" ' … … 139 177 @staticmethod 140 178 def keyFilter(key): 141 """Enforce string type keys""" 179 """Enforce string type keys 180 181 @param key: URN for attribute 182 @type key: basestring 183 @return: boolean True indicating key is OK 184 @rtype: bool 185 @raise TypeError: incorrect input type 186 """ 142 187 if not isinstance(key, basestring): 143 188 raise TypeError('Expecting %r type for key; got %r' % … … 147 192 @staticmethod 148 193 def valueFilter(value): 149 """Enforce AttributeValue derived types for values""" 150 194 """Enforce AttributeValue derived types for values 195 @param value: attribute value 196 @type value: ndg.xacml.core.attributevalue.AttributeValue derived type 197 @return: boolean True indicating attribute value is correct type 198 @rtype: bool 199 @raise TypeError: incorrect input type 200 """ 151 201 if not issubclass(value, AttributeValue): 152 202 raise TypeError('Expecting %r derived type for value; got %r' % … … 175 225 Convenience wrapper for _IDENTIFIER2CLASS_MAP instance of 176 226 AttributeValueClassMap 227 228 @param __classMap: mapping object to map attribute value URIs to their 229 implementations as classes 230 @type __classMap: ndg.xacml.core.attributevalue.AttributeValueClassMap 177 231 """ 232 __slots__ = ('__classMap',) 233 178 234 def __init__(self, classMap=None): 235 """Set a mapping object to map attribute value URIs to their 236 implementations as classes 237 238 @param classMap: input an alternative to the default class mapping 239 object _IDENTIFIER2CLASS_MAP, if None, it will default to this setting 240 @type classMap: ndg.xacml.core.attributevalue.AttributeValueClassMap 241 """ 179 242 if classMap is None: 180 243 self.__classMap = _IDENTIFIER2CLASS_MAP … … 188 251 """Return <type>AttributeValue class for given identifier URI or None 189 252 if no match is found 253 254 @return: attribute value class 255 @rtype: NoneType / ndg.xacml.core.attributevalue.AttributeValue derived 256 type 190 257 """ 191 258 return self.__classMap.get(identifier) -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/combinerparameter.py
r7087 r7101 1 """ NDG SecurityCombinerParameter type definition1 """XACML CombinerParameter type definition 2 2 3 3 NERC DataGrid … … 12 12 13 13 class CombinerParameter(object): 14 ''' 15 classdocs 14 '''XACML Combiner parameter class - currently not implemented 15 16 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 17 @type ELEMENT_LOCAL_NAME: string 16 18 ''' 17 19 ELEMENT_LOCAL_NAME = "CombinerParameter" … … 19 21 20 22 def __init__(self): 23 '''@raise NotImplementedError: this class is a stub only 21 24 ''' 22 Constructor 23 ''' 24 25 raise NotImplementedError('Not currently implemented') -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/condition.py
r7087 r7101 18 18 element is its own type and not an Apply type. It expects a single 19 19 Expression derived type child element 20 21 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 22 @type ELEMENT_LOCAL_NAME: string 23 24 @cvar APPLY_ELEMENT_LOCAL_NAME: XML local name for the apply element 25 @type APPLY_ELEMENT_LOCAL_NAME: string 26 27 @ivar __expression: expression in this condition 28 @type __expression: ndg.xacml.core.expression.Expression 20 29 """ 21 30 ELEMENT_LOCAL_NAME = 'Condition' … … 30 39 @property 31 40 def expression(self): 41 """Get expression 42 43 @return: expression for this condition 44 @rtype: ndg.xacml.core.expression.Expression / NoneType 45 """ 32 46 return self.__expression 33 47 34 48 @expression.setter 35 49 def expression(self, value): 50 """Set expression 51 52 @param value: expression for this condition 53 @type value: ndg.xacml.core.expression.Expression 54 @raise TypeError: incorrect input type set 55 """ 36 56 if not isinstance(value, Expression): 37 57 raise TypeError('Expecting Expression or Expression derived type '
Note: See TracChangeset
for help on using the changeset viewer.