Changeset 7088 for TI12-security/trunk/ndg_xacml
- Timestamp:
- 25/06/10 13:14:03 (9 years ago)
- Location:
- TI12-security/trunk/ndg_xacml/ndg/xacml/core/functions
- Files:
-
- 4 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) -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/functions/v1/regexp_match.py
r7087 r7088 19 19 class RegexpMatchBase(AbstractFunction): 20 20 """XACML 2.0 Regular Expression matching base class function 21 22 @cvar TYPE: attribute type for the given implementation. Derived classes 23 should set appropriately 24 @type TYPE: NoneType 25 26 @cvar FUNCTION_SUFFIX: suffix for all regular expression type function class 27 names 28 @type FUNCTION_SUFFIX: string 29 30 @cvar FUNCTION_NS_SUFFIX: generic suffix for regular expression type 31 function URNs 32 @type FUNCTION_NS_SUFFIX: string 33 34 @cvar CLASS_NAME_SUFFIX: suffix for all regular expression class names 35 @type CLASS_NAME_SUFFIX: string 21 36 """ 22 37 FUNCTION_NS = None … … 51 66 class StringRegexMatch(RegexpMatchBase): 52 67 """String regular expression match function class representation 68 69 @cvar FUNCTION_NS: String regular expression match function URN 70 @type FUNCTION_NS: string 71 72 @cvar TYPE: string attribute value type 73 @type TYPE: dynamically generated string type derived from 74 ndg.xacml.core.attributevalue.AttributeValue 53 75 """ 54 76 FUNCTION_NS = 'urn:oasis:names:tc:xacml:1.0:function:string-regexp-match' -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/functions/v1/round.py
r7087 r7088 15 15 16 16 class Round(AbstractFunction): 17 """Base class for XACML <type>-round functions""" 17 """Base class for XACML <type>-round functions 18 19 @cvar FUNCTION_NS: namespace for this function 20 @type FUNCTION_NS: string 21 """ 18 22 FUNCTION_NS = AbstractFunction.V1_0_FUNCTION_NS + 'round' 19 23 … … 21 25 """Check a bag has one element only and return it 22 26 23 @param bag: bag containing one element 24 @rtype: bool 27 @param num: number to round up 28 @type num: int / long / float 29 @rtype: float 30 @raise TypeError: incorrect type for input 25 31 """ 26 32 try: -
TI12-security/trunk/ndg_xacml/ndg/xacml/core/functions/v2/regexp_match.py
r7087 r7088 17 17 class FunctionClassFactory(FunctionClassFactoryBase): 18 18 """Class Factory for *-regexp-match XACML function classes 19 20 @cvar FUNCTION_NAMES: regular expression match function URNs 21 @type FUNCTION_NAMES: tuple 22 23 @cvar FUNCTION_NS_SUFFIX: generic suffix for one and only function URNs 24 @type FUNCTION_NS_SUFFIX: string 25 26 @cvar FUNCTION_BASE_CLASS: base class for regular expression match function 27 classes 28 @type FUNCTION_BASE_CLASS: ndg.xacml.core.functions.v1.RegexMatchBase 19 29 """ 20 30 FUNCTION_NS_SUFFIX = RegexpMatchBase.FUNCTION_NS_SUFFIX
Note: See TracChangeset
for help on using the changeset viewer.