- Timestamp:
- 25/06/10 13:14:03 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/ndg_xacml/ndg/xacml/core/functions/__init__.py
r7087 r7088 23 23 24 24 class AbstractFunction(object): 25 """Base class for all XACML matching functions""" 26 25 """Abstract Base class for all XACML matching functions 26 @cvar FUNCTION_NS: namespace for the given function 27 @type FUNCTION_NS: NoneType (must be string in derived type) 28 29 @cvar V1_0_FUNCTION_NS: XACML 1.0 function namespace prefix 30 @type V1_0_FUNCTION_NS: string 31 32 @cvar V2_0_FUNCTION_NS: XACML 2.0 function namespace prefix 33 @type V2_0_FUNCTION_NS: string 34 """ 27 35 __metaclass__ = ABCMeta 36 28 37 FUNCTION_NS = None 29 38 V1_0_FUNCTION_NS = "urn:oasis:names:tc:xacml:1.0:function:" … … 31 40 32 41 def __init__(self): 42 """ 43 @raise TypeError: if FUNCTION_NS not set correctly 44 """ 33 45 if self.__class__.FUNCTION_NS is None: 34 46 raise TypeError('"FUNCTION_NS" class variable must be defined in ' … … 38 50 def evaluate(self, *inputs): 39 51 """Evaluate the function from the given input arguments and context 52 40 53 @param inputs: input arguments need to evaluate the function 41 54 @type inputs: tuple 42 @return: True for match, False otherwise43 @rtype: bool 55 @return: derived type should return True for match, False otherwise 56 @rtype: bool (derived type), NoneType for THIS implementation 44 57 """ 45 58 46 59 class XacmlFunctionNames(object): 47 """XACML standard match function names""" 60 """XACML standard match function names 61 62 @cvar FUNCTION_NAMES: list of all the XACML function URNs 63 @type FUNCTION_NAMES: tuple 64 """ 48 65 FUNCTION_NAMES = ( 49 66 'urn:oasis:names:tc:xacml:1.0:function:string-equal', … … 275 292 @return: at least one member of class corresponding to the given input 276 293 identifier 277 @rtype: AbstractFunction derived type or None if no match is 278 found 294 @rtype: AbstractFunction derived type or NoneType if no match is found 279 295 ''' 280 296 return None … … 462 478 FunctionClassFactoryInterface implementations so that a function class can 463 479 be obtained directly from a given XACML function URN. 480 481 @cvar FUNCTION_PKG_PREFIX: python package path for functions package 482 @type FUNCTION_PKG_PREFIX: string 483 484 @cvar V1_0_PKG_PREFIX: python package path for XACML 1.0 functions package 485 @type V1_0_PKG_PREFIX: string 486 487 @cvar V2_0_PKG_PREFIX: python package path for XACML 2.0 functions package 488 @type V2_0_PKG_PREFIX: string 489 490 @cvar SUPPORTED_NSS: mapping of function URN prefix to Python package 491 @type SUPPORTED_NSS: dict 492 493 @cvar FUNCTION_CLASS_FACTORY_CLASSNAME: standard name for class factory 494 which should be present in each generic function module. This factory is 495 invoked to create the function class for any given function URN related to 496 that module 497 @type FUNCTION_CLASS_FACTORY_CLASSNAME: string 464 498 """ 465 499 FUNCTION_PKG_PREFIX = 'ndg.xacml.core.functions.' … … 496 530 @staticmethod 497 531 def keyFilter(key): 498 """Enforce string type keys""" 532 """Enforce string type keys 533 534 @param key: function URN 535 @type key: basestring 536 @return: True for valid key type 537 @rtype: bool 538 @raise TypeError: invalid key type 539 """ 499 540 if not isinstance(key, basestring): 500 541 raise TypeError('Expecting %r type for key; got %r' % … … 505 546 @staticmethod 506 547 def valueFilter(value): 507 """Enforce AbstractFunction derived types for match functions""" 548 """Enforce AbstractFunction derived types for match functions 549 550 @param value: function URN 551 @type value: ndg.xacml.core.functions.AbstractFunction / NotImplemented 552 @return: True for valid function type 553 @rtype: bool 554 @raise TypeError: invlaid key type 555 """ 508 556 if value is NotImplemented: 509 557 return True … … 580 628 """Override base class implementation to load and cache function classes 581 629 if they don't otherwise exist 630 631 @param key: function URN 632 @type key: basestring 633 @return: function class 634 @rtype: ndg.xacml.core.functions.AbstractFunction / NotImplemented 582 635 """ 583 636 functionClass = VettedDict.get(self, key) … … 590 643 """Likewise to __getitem__, enable loading and caching of function 591 644 classes if they don't otherwise exist 645 646 @param key: XACML function URN 647 @type key: basestring 648 @param *arg: set a single additional argument if required which is 649 used as the default value should the key not be found in the map 650 @type *arg: tuple 651 @return: function class 652 @rtype: ndg.xacml.core.functions.AbstractFunction / NotImplemented 592 653 """ 593 654 functionClass = VettedDict.get(self, key, *arg)
Note: See TracChangeset
for help on using the changeset viewer.