Changeset 7108 for TI12-security
- Timestamp:
- 28/06/10 10:19:26 (11 years ago)
- Location:
- TI12-security/trunk/ndg_xacml/ndg/xacml/core
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/ndg_xacml/ndg/xacml/core/context/result.py
r7087 r7108 258 258 @type TYPES: tuple 259 259 260 @ivar value: decision value261 @type value: string260 @ivar __value: decision value 261 @type __value: string 262 262 """ 263 263 … … 357 357 """ 358 358 @param decision: decision value to compare with self's 359 @type param: string or ndg.xacml.core.context.result.Decision359 @type decision: string or ndg.xacml.core.context.result.Decision 360 360 @return: True if the decision values match, False otherwise 361 361 @rtype: bool -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/policy.py
r7103 r7108 76 76 @type __description: NoneType / basestring 77 77 @ivar __target: target element 78 @type __target: NoneType / basestring79 @ivar __attr: attribute80 @type __attr: NoneType / basestring78 @type __target: NoneType / ndg.xacml.core.target.Target 79 @ivar __attr: list of rules 80 @type __attr: ndg.xacml.utils.TypedList 81 81 @ivar __obligations: obligations 82 @type __obligations: NoneType / basestring82 @type __obligations: ndg.xacml.utils.TypedList 83 83 @ivar __ruleCombiningAlgFactory: rule combining algorithm factory 84 @type __ruleCombiningAlgFactory: NoneType / basestring84 @type __ruleCombiningAlgFactory: ndg.xacml.core.rule_combining_alg.RuleCombiningAlgClassFactory 85 85 @ivar __ruleCombiningAlg: rule combining algorithm 86 @type __ruleCombiningAlg: NoneType / basestring86 @type __ruleCombiningAlg: NoneType / ndg.xacml.core.rule_combining_alg.RuleCombiningAlgInterface 87 87 88 88 """ … … 129 129 self.__description = None 130 130 self.__target = None 131 self.__policyDefaults = None 131 132 132 133 # Attr should eventually allow a choice of Rule, CombinerParameter, … … 146 147 147 148 def _getRuleCombiningAlgFactory(self): 149 """ 150 @return: rule combining algorithm factory 151 @rtype: NoneType / ndg.xacml.core.rule_combining_alg.RuleCombiningAlgClassFactory 152 """ 148 153 return self.__ruleCombiningAlgFactory 149 154 150 155 def _setRuleCombiningAlgFactory(self, value): 156 """ 157 @param value: rule combining algorithm factory 158 @type value: ndg.xacml.core.rule_combining_alg.RuleCombiningAlgClassFactory 159 @raise TypeError: incorrect input type 160 """ 151 161 if not isinstance(value, RuleCombiningAlgClassFactory): 152 162 raise TypeError('Expecting %r derived type for ' … … 162 172 @property 163 173 def ruleCombiningAlg(self): 164 "Rule Combining algorithm" 174 """Rule Combining algorithm 175 @return: rule combining algorithm class instance 176 @rtype: ndg.xacml.core.rule_combining_alg.RuleCombiningAlgInterface 177 derived type 178 """ 165 179 return self.__ruleCombiningAlg 166 180 … … 193 207 194 208 def _getPolicyId(self): 209 ''' 210 @return: policy id 211 @type basestring: NoneType / basestring 212 ''' 195 213 return self.__policyId 196 214 197 215 def _setPolicyId(self, value): 216 '''@param value: policy id 217 @type value: basestring 218 @raise TypeError: incorrect input type 219 ''' 198 220 if not isinstance(value, basestring): 199 221 raise TypeError('Expecting string type for "policyId" ' … … 205 227 206 228 def _getVersion(self): 229 '''@return: policy version 230 @rtype: NoneType / basestring 231 ''' 207 232 return self.__version 208 233 209 234 def _setVersion(self, value): 235 '''@param value: policy version 236 @type value: basestring 237 @raise TypeError: incorrect input type 238 ''' 210 239 if not isinstance(value, basestring): 211 240 raise TypeError('Expecting string type for "version" ' … … 217 246 218 247 def _getRuleCombiningAlgId(self): 248 '''@return: rule combining algorithm ID 249 @rtype: NoneType / basestring 250 ''' 219 251 return self.__ruleCombiningAlgId 220 252 221 253 def _setRuleCombiningAlgId(self, value): 254 '''@param value: rule combining algorithm ID 255 @type value: NoneType / basestring 256 @raise TypeError: incorrect input type 257 ''' 222 258 if not isinstance(value, basestring): 223 259 raise TypeError('Expecting string type for "ruleCombiningAlgId" ' … … 228 264 229 265 def _setRuleCombiningAlgFromId(self): 230 """Set the rule combining algorithm implementation from the Id set 266 """Set the rule combining algorithm implementation from the Id set in 267 __ruleCombiningAlgId the attribute 268 269 @raise TypeError: incorrect input type 270 @raise UnsupportedStdFunctionError: no implementation is avaliable for 271 this XACML rule combining algorithm 272 @raise UnsupportedFunctionError: the rule combining algorithm is not 273 recognised as a standard XACML one 231 274 """ 232 275 # Look-up rule combining algorithm … … 256 299 @property 257 300 def combinerParameters(self): 301 """@raise NotImplementedError: combiner parameters property is not 302 currently implemented 303 """ 258 304 raise NotImplementedError() 259 305 260 306 @property 261 307 def ruleCombinerParameters(self): 308 """@raise NotImplementedError: rule combiner parameters property is not 309 currently implemented 310 """ 262 311 raise NotImplementedError() 263 312 264 313 @property 265 314 def variableDefinitions(self): 315 """@raise NotImplementedError: variable definitions parameters property 316 is not currently implemented 317 """ 266 318 raise NotImplementedError() 267 319 268 320 @property 269 321 def rules(self): 322 """Return the list of rules 323 @return: list of rules 324 @rtype: ndg.xacml.utils.TypedList 325 """ 270 326 return self.__attr 271 327 272 328 @property 273 329 def obligations(self): 330 """@ivar __obligations: obligations 331 @type __obligations: ndg.xacml.utils.TypedList 332 """ 274 333 return self.__obligations 275 334 276 335 def _getTarget(self): 336 """@return: target element 337 @rtype: NoneType / ndg.xacml.core.target.Target 338 """ 277 339 return self.__target 278 340 279 341 def _setTarget(self, value): 342 """@param value: target element 343 @type value: ndg.xacml.core.target.Target 344 @raise TypeError: incorrect input type 345 """ 280 346 if not isinstance(value, Target): 281 347 raise TypeError('Expecting Target for "target" ' … … 286 352 287 353 def _getDescription(self): 354 '''@return: policy description text 355 @rtype: NoneType / basestring 356 ''' 288 357 return self.__description 289 358 290 359 def _setDescription(self, value): 360 '''@param value: policy description text 361 @type value: basestring 362 @raise TypeError: incorrect input type 363 ''' 291 364 if not isinstance(value, basestring): 292 365 raise TypeError('Expecting string type for "description" ' … … 298 371 299 372 def _getPolicyDefaults(self): 373 '''@return: policy defaults 374 @rtype: NoneType / ndg.xacml.core.policydefaults.PolicyDefaults 375 ''' 300 376 return self.__policyDefaults 301 377 302 378 def _setPolicyDefaults(self, value): 379 '''@param value: policy defaults 380 @type value: ndg.xacml.core.policydefaults.PolicyDefaults 381 @raise TypeError: incorrect input type 382 ''' 303 383 if not isinstance(value, PolicyDefaults): 304 384 raise TypeError('Expecting string type for "policyDefaults" ' … … 320 400 @return: XACML response instance 321 401 @rtype: ndg.xacml.core.context.response.Response 402 @raise XacmlContextError: error evaluating input request context 322 403 """ 323 404 response = Response() -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/policydefaults.py
r7087 r7108 14 14 15 15 class PolicyDefaults(XacmlCoreBase): 16 """XACML PolicyDefaults type""" 16 """XACML PolicyDefaults type 17 18 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 19 @type ELEMENT_LOCAL_NAME: string 20 @cvar XPATH_VERSION_ELEMENT_NAME: XML local name for XPath version element 21 @type XPATH_VERSION_ELEMENT_NAME: string 22 23 @ivar __xpathVersion: XPath version 24 @type __xpathVersion: basestring / NoneType 25 """ 17 26 ELEMENT_LOCAL_NAME = 'PolicyDefaults' 18 27 XPATH_VERSION_ELEMENT_NAME = 'XPathVersion' … … 21 30 22 31 def __init__(self): 32 """Initialise attributes""" 23 33 super(PolicyDefaults, self).__init__() 24 34 self.__xpathVersion = None 25 35 26 36 def _get_xpathVersion(self): 37 """@return: XPath version 38 @rtype: basestring / NoneType 39 """ 27 40 return self.__xpathVersion 28 41 29 42 def _set_xpathVersion(self, value): 43 """@param value: XPath version 44 @type value: basestring / NoneType 45 @raise TypeError: incorrect input type 46 """ 30 47 if not isinstance(value, basestring): 31 48 raise TypeError('Expecting %r type for "xpathVersion" ' -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/rule.py
r7087 r7108 21 21 22 22 class Effect(object): 23 """Rule Effect""" 23 """Rule Effect 24 25 @cvar PERMIT_STR: permit decision string 26 @type PERMIT_STR: string 27 28 @cvar DENY_STR: deny decision string 29 @type DENY_STR: string 30 31 @cvar TYPES: list of valid effect strings 32 @type TYPES: tuple 33 34 @ivar value: effect value 35 @type value: string 36 """ 24 37 DENY_STR = 'Deny' 25 38 PERMIT_STR = 'Permit' … … 28 41 29 42 def __init__(self, effect=DENY_STR): 43 """@param effect: initialise effect value, defaults to deny 44 @type effect: basestring / ndg.xacml.core.rule.Effect 45 """ 30 46 self.__value = None 31 47 self.value = effect 32 48 33 49 def __getstate__(self): 34 '''Enable pickling''' 50 '''Enable pickling 51 52 @return: class instance attributes dictionary 53 @rtype: dict 54 ''' 35 55 _dict = {} 36 56 for attrName in Effect.__slots__: … … 45 65 46 66 def __setstate__(self, attrDict): 47 '''Enable pickling''' 67 '''Enable pickling 68 69 @param attrDict: class instance attributes dictionary 70 @type attrDict: dict 71 ''' 48 72 for attrName, val in attrDict.items(): 49 73 setattr(self, attrName, val) 50 74 51 75 def _setValue(self, value): 76 """Set effect value 77 78 @param value: effect value - constrained vocabulary to Effect.TYPES 79 @type value: string or ndg.xacml.core.rule.Effect 80 @raise AttributeError: invalid decision string value input 81 @raise TypeError: invalid type for input decision value 82 """ 52 83 if isinstance(value, Effect): 53 84 # Cast to string … … 64 95 65 96 def _getValue(self): 97 """Get effect value 98 99 @return: effect value 100 @rtype: string 101 """ 66 102 return self.__value 67 103 … … 69 105 70 106 def __str__(self): 107 """represent decision as a string 108 109 @return: decision value 110 @rtype: string 111 """ 71 112 return self.__value 72 113 73 114 def __eq__(self, effect): 115 """ 116 @param effect: effect value to compare with self's 117 @type effect: string or ndg.xacml.core.rule.Effect 118 @return: True if the decision values match, False otherwise 119 @rtype: bool 120 @raise AttributeError: invalid decision string value input 121 @raise TypeError: invalid type for input decision value 122 """ 74 123 if isinstance(effect, Effect): 75 124 # Cast to string … … 91 140 def __nonzero__(self): 92 141 """Boolean evaluation of a rule effect - True = Allow; False = Deny 142 143 @return: True if the effect value is permit, False otherwise 144 @rtype: bool 93 145 """ 94 146 return self.__value == Effect.PERMIT_STR … … 100 152 101 153 def __init__(self): 154 """Initialise set with Permit value""" 102 155 super(PermitEffect, self).__init__(Effect.PERMIT_STR) 103 156 104 def _setValue(self): 157 def _setValue(self, value): 158 """Make value read-only 159 @raise AttributeError: value can't be set 160 """ 105 161 raise AttributeError("can't set attribute") 106 162 … … 111 167 112 168 def __init__(self): 169 """Initialise set with Permit value""" 113 170 super(DenyEffect, self).__init__(Effect.DENY_STR) 114 171 115 172 def _setValue(self, value): 173 """Make value read-only 174 @raise AttributeError: value can't be set 175 """ 116 176 raise AttributeError("can't set attribute") 117 177 … … 122 182 123 183 class Rule(XacmlCoreBase): 124 """XACML Policy Rule""" 184 """XACML Policy Rule 185 186 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 187 @type ELEMENT_LOCAL_NAME: string 188 @cvar DESCRIPTION_LOCAL_NAME: XML local name for the description element 189 @type DESCRIPTION_LOCAL_NAME: string 190 @cvar RULE_ID_ATTRIB_NAME: rule id XML attribute name 191 @type RULE_ID_ATTRIB_NAME: string 192 @cvar EFFECT_ATTRIB_NAME: effect XML attribute name 193 @type EFFECT_ATTRIB_NAME: string 194 195 @ivar __target: rule target 196 @type __target: ndg.xacml.core.target.Target / NoneType 197 @ivar __condition: rule condition 198 @type __condition: ndg.xacml.core.condition.Condition / NoneType 199 @ivar __description: rule description text 200 @type __description: basestring / NoneType 201 @ivar __id: rule ID 202 @type __id: basestring / NoneType 203 @ivar __effect: rule effect 204 @type __effect: ndg.xacml.core.rule.Effect / NoneType 205 """ 125 206 ELEMENT_LOCAL_NAME = 'Rule' 126 207 RULE_ID_ATTRIB_NAME = 'RuleId' … … 138 219 139 220 def __init__(self): 221 """Initialise attributes""" 222 super(Rule, self).__init__() 223 140 224 self.__id = None 141 225 self.__effect = None … … 145 229 @property 146 230 def target(self): 147 "Rule target" 231 """Get Rule target 232 @return: rule target 233 @rtype: ndg.xacml.core.target import Target / NoneType 234 """ 148 235 return self.__target 149 236 150 237 @target.setter 151 238 def target(self, value): 239 """Set rule target 240 @param value: rule target 241 @type value: ndg.xacml.core.target import Target 242 @raise TypeError: incorrect type set 243 """ 152 244 if not isinstance(value, Target): 153 245 raise TypeError('Expecting %r type for "id" ' … … 157 249 @property 158 250 def condition(self): 159 "rule condition" 251 """Get rule condition 252 253 @return: rule condition 254 @rtype: ndg.xacml.core.condition.Condition / NoneType 255 """ 160 256 return self.__condition 161 257 162 258 @condition.setter 163 259 def condition(self, value): 260 """Set rule condition 261 262 @param value: rule condition 263 @type value: ndg.xacml.core.condition.Condition 264 @raise TypeError: incorrect type set 265 """ 164 266 if not isinstance(value, Condition): 165 raise TypeError('Expecting %r type for "id" '166 'attribute; got %r' %(Condition, type(value)))267 raise TypeError('Expecting %r type for "id" attribute; got %r' % 268 (Condition, type(value))) 167 269 168 270 self.__condition = value 169 271 170 272 def _get_id(self): 273 """Get rule ID 274 275 @return: rule ID 276 @rtype: ndg.xacml.core.condition.Condition / NoneType 277 """ 171 278 return self.__id 172 279 173 280 def _set_id(self, value): 281 """Set rule ID 282 283 @param value: rule ID 284 @type value: basestring 285 @raise TypeError: incorrect type set 286 """ 174 287 if not isinstance(value, basestring): 175 raise TypeError('Expecting %r type for "id" '176 'attribute; got %r' %(basestring, type(value)))288 raise TypeError('Expecting %r type for "id" attribute; got %r' % 289 (basestring, type(value))) 177 290 178 291 self.__id = value … … 181 294 182 295 def _get_effect(self): 296 """Get rule effect 297 298 @return: rule effect 299 @rtype: ndg.xacml.core.rule.Effect / NoneType 300 """ 183 301 return self.__effect 184 302 185 303 def _set_effect(self, value): 304 """Set rule effect 305 306 @param value: rule effect 307 @type value: ndg.xacml.core.rule.Effect 308 @raise TypeError: incorrect type set 309 """ 186 310 if not isinstance(value, Effect): 187 311 raise TypeError('Expecting %r type for "effect" ' … … 194 318 195 319 def _getDescription(self): 320 """Get rule description 321 322 @return: rule description 323 @rtype: basestring / NoneType 324 """ 196 325 return self.__description 197 326 198 327 def _setDescription(self, value): 328 """Set rule description 329 330 @param value: rule description 331 @type value: basestring 332 @raise TypeError: incorrect type set 333 """ 199 334 if not isinstance(value, basestring): 200 335 raise TypeError('Expecting string type for "description" ' -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/rule_combining_alg.py
r7087 r7108 15 15 16 16 17 # Rule Combining algorithms from the XACML spec. 17 18 ALGORITHMS = ( 18 19 'urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:deny-overrides', … … 48 49 """ 49 50 return Decision.INDETERMINATE 51 50 52 51 53 class DenyOverridesRuleCombiningAlg(RuleCombiningAlgInterface): … … 167 169 PermitOverridesRuleCombiningAlg 168 170 }) 171 __slots__ = ('__map',) 169 172 170 173 def __init__(self, map=DEFAULT_MAP): 171 """Initialise mapping of identifiers to class implementations""" 174 """Initialise mapping of identifiers to class implementations 175 176 @param map: mapping of rule combining algorithms IDs to classes. Set 177 this to override the default taken from the DEFAULT_MAP class variable 178 """ 172 179 self.__map = map 173 180 -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/subject.py
r7100 r7108 12 12 from ndg.xacml.core import TargetChildBase 13 13 from ndg.xacml.core.match import SubjectMatch 14 14 15 15 16 class Subject(TargetChildBase): -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/target.py
r7087 r7108 27 27 28 28 class Target(XacmlCoreBase): 29 """XACML Target element""" 29 """XACML Target element 30 31 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 32 @type ELEMENT_LOCAL_NAME: string 33 @cvar SUBJECTS_ELEMENT_LOCAL_NAME: XML local name for the subjects element 34 @type SUBJECTS_ELEMENT_LOCAL_NAME: string 35 @cvar ACTIONS_ELEMENT_LOCAL_NAME: XML local name for the actions element 36 @type ACTIONS_ELEMENT_LOCAL_NAME: string 37 @cvar RESOURCES_ELEMENT_LOCAL_NAME: XML local name for the resources element 38 @type RESOURCES_ELEMENT_LOCAL_NAME: string 39 @cvar ENVIRONMENTS_ELEMENT_LOCAL_NAME: XML local name for the environments 40 element 41 @type ENVIRONMENTS_ELEMENT_LOCAL_NAME: string 42 @cvar CHILD_ATTRS: list of the XML child element names for <Target/> 43 @type CHILD_ATTRS: tuple 44 45 @ivar __subjects: list of subjects for this target 46 @type __subjects: ndg.xacml.utils.TypedList 47 @ivar __resources: list of resources for this target 48 @type __resources: ndg.xacml.utils.TypedList 49 @ivar __actions: list of actions for this target 50 @type __actions: ndg.xacml.utils.TypedList 51 @ivar __environments: list of environment settings for this target 52 @type __environments: ndg.xacml.utils.TypedList 53 """ 30 54 ELEMENT_LOCAL_NAME = "Target" 31 55 SUBJECTS_ELEMENT_LOCAL_NAME = "Subjects" … … 46 70 @property 47 71 def subjects(self): 72 """Get subjects 73 @return: list of subjects for this target 74 @rtype: ndg.xacml.utils.TypedList 75 """ 48 76 return self.__subjects 49 77 50 78 @property 51 79 def resources(self): 80 """Get resources 81 @return: list of resources for this target 82 @rtype: ndg.xacml.utils.TypedList 83 """ 52 84 return self.__resources 53 85 54 86 @property 55 87 def actions(self): 88 """Get actions 89 @return: list of actions for this target 90 @rtype: ndg.xacml.utils.TypedList 91 """ 56 92 return self.__actions 57 93 58 94 @property 59 95 def environments(self): 96 """Get environments 97 @return: list of environments for this target 98 @rtype: ndg.xacml.utils.TypedList 99 """ 60 100 return self.__environments 61 101 … … 63 103 """Generic method to match a <Target> element to the request context 64 104 65 @param target: XACML target element66 @type target: ndg.xacml.core.target.Target67 105 @param request: XACML request context 68 106 @type request: ndg.xacml.core.context.request.Request … … 136 174 object 137 175 @type targetChild: ndg.xacml.core.TargetChildBase 138 @param requestChild: Request Subject, Resource, Action or Environment 139 object 140 @type requestChild: ndg.xacml.core.context.RequestChildBase 176 @param request: Request context object 177 @type request: ndg.xacml.core.context.request.Request 141 178 @return: True if request context matches something in the target 142 179 @rtype: bool -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/variabledefinition.py
r7087 r7108 14 14 15 15 class VariableDefinition(XacmlPolicyBase): 16 '''XACML Variable Definition Type 16 '''XACML Variable Definition Type - this class is a placeholder, it's not 17 currently implemented 18 19 @cvar ELEMENT_LOCAL_NAME: XML element local name 20 @type ELEMENT_LOCAL_NAME: string 17 21 ''' 18 22 ELEMENT_LOCAL_NAME = "VariableDefinition" -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/variablereference.py
r7087 r7108 14 14 15 15 class VariableReference(XacmlPolicyBase): 16 '''XACML Variable Reference Type 16 '''XACML Variable Reference Type - this class is a placeholder, it's not 17 currently implemented 18 19 @cvar ELEMENT_LOCAL_NAME: XML element local name 20 @type ELEMENT_LOCAL_NAME: string 17 21 ''' 18 22 ELEMENT_LOCAL_NAME = "VariableReference"
Note: See TracChangeset
for help on using the changeset viewer.