Ignore:
Timestamp:
16/03/10 11:56:31 (10 years ago)
Author:
pjkersha
Message:

Added XACML Target ElementTree based parser.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/xacml/parsers/__init__.py

    r6731 r6734  
     1"""NDG Security XACML parsers package  
     2 
     3NERC DataGrid Project 
     4""" 
     5__author__ = "P J Kershaw" 
     6__date__ = "15/03/10" 
     7__copyright__ = "(C) 2010 Science and Technology Facilities Council" 
     8__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     9__license__ = "BSD - see LICENSE file in top-level directory" 
     10__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     11__revision__ = "$Id: $" 
     12import logging 
     13log = logging.getLogger(__name__) 
     14from abc import ABCMeta, abstractmethod 
     15 
     16from xml.etree import ElementTree 
     17 
     18 
     19class AbstractReader: 
     20    """Abstract base class for ElementTree implementation of XACML reader""" 
     21    __metaclass__ = ABCMeta 
     22     
     23    @classmethod 
     24    def __subclasshook__(cls, C): 
     25        """Derived class must implement __call__""" 
     26        if cls is AbstractReader: 
     27            if any("__call__" in B.__dict__ for B in C.__mro__): 
     28                return True 
     29             
     30        return NotImplemented 
     31         
     32    @abstractmethod 
     33    def __call__(self, obj): 
     34        """Abstract Parse XACML method 
     35        @raise NotImplementedError:  
     36        """ 
     37        raise NotImplementedError() 
     38     
     39    @classmethod 
     40    def parse(cls, obj): 
     41        """Parse from input object and return new XACML object 
     42        @param obj: input source - file name, stream object or other 
     43        @type obj: string, stream or other 
     44        @return: new XACML object 
     45        @rtype: PolicyComponent sub type 
     46        """ 
     47        reader = cls() 
     48        return reader(obj) 
Note: See TracChangeset for help on using the changeset viewer.