- Timestamp:
- 25/03/10 16:09:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDG_XACML/ndg/xacml/test/test_xacml.py
r6774 r6775 265 265 266 266 267 class MyPDP(PDPInterface): 268 269 def __init__(self): 270 self.policy = None 267 class PDP(PDPInterface): 268 """A XACML Policy Decision Point implementation. It supports the use of a 269 single policy but not policy sets""" 270 __slots__ = ('__policy',) 271 272 def __init__(self, policy=None): 273 """ 274 @param policy: policy object for PDP to use to apply access control 275 decisions, may be omitted. 276 @type policy: ndg.xacml.core.policy.Policy / None 277 """ 278 self.__policy = None 279 if policy is not None: 280 self.policy = policy 271 281 272 282 @classmethod 273 def fromPolicy(cls, source): 283 def fromPolicy(cls, source, reader): 284 """Create a new PDP instance with a given policy 285 @param source: source for policy 286 @type source: type (dependent on the reader set, it could be for example 287 a file path string, file object, XML element instance) 288 @param reader: the reader instance to use to read this policy 289 @type reader: ndg.xacml.parsers.AbstractReader derived type 290 """ 291 if not isinstance(reader, AbstractReader): 292 raise TypeError('Expecting %r derived type for "reader" input; got ' 293 '%r instead' % (AbstractReader, type(reader))) 294 274 295 pdp = cls() 275 self.policy = ReaderFactory.getReader(Policy).parse(source) 276 296 pdp.policy = reader.parse(source) 297 return policy 298 299 @property 300 def policy(self): 301 """policy object for PDP to use to apply access control decisions""" 302 return self.__policy 303 304 @policy.setter 305 def policy(self, value): 306 '''policy object for PDP to use to apply access control decisions''' 307 if not isinstance(value, Policy): 308 raise TypeError('Expecting %r derived type for "policy" input; got ' 309 '%r instead' % (Policy, type(value))) 310 self.__policy = value 311 277 312 def evaluate(self, request): 278 313 """Make an access control decision for the given request based on the … … 288 323 response.results.append(result) 289 324 result.decision = Decision.NOT_APPLICABLE 325 326 if not isinstance(request, Request): 327 log.error('Expecting %r derived type for "reader" input; got ' 328 '%r instead' % Request, type(request)) 329 result.decision = Decision.INDETERMINATE 330 return response 290 331 291 332 # Exception block around all rule processing in order to set 292 333 # INDETERMINATE response from any exceptions raised 293 try: 334 try: 335 294 336 # Check policy target for match 295 337 log.debug('Checking policy target for match...')
Note: See TracChangeset
for help on using the changeset viewer.