Ignore:
Timestamp:
04/08/09 12:56:47 (11 years ago)
Author:
pjkersha
Message:
  • Started adding ElementTree based parsers for SAML classes in ndg.security.common.saml.xml.etree.
  • ndg.security.common.utils.prettyPrint needs a bug fix for namespace declarations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.common/ndg/security/common/saml/__init__.py

    r5538 r5554  
    4848    VERSION_11 = (1, 1) 
    4949    VERSION_20 = (2, 0) 
     50    KNOWN_VERSIONS = (VERSION_10, VERSION_11, VERSION_20) 
    5051     
    5152    def __init__(self, version): 
    52         self.__version = version 
     53        if isinstance(version, basestring): 
     54            self.__version = SAMLVersion.valueOf(version) 
     55        elif isinstance(version, (tuple, list)): 
     56            self.__version = tuple(version) 
     57        else: 
     58            raise TypeError("Expecting string, tuple or list type for SAML " 
     59                            "version initialiser; got %r" % version) 
    5360     
    5461    def __str__(self): 
    5562        return ".".join([str(i) for i in self.__version]) 
    5663     
     64    def __eq__(self, version): 
     65        """Test for equality against an input version string, tuple or list""" 
     66                 
     67        if isinstance(version, basestring): 
     68            return self.__version == SAMLVersion.valueOf(version) 
     69        elif isinstance(version, (tuple, list)): 
     70            return self.__version == tuple(version) 
     71        else: 
     72            raise TypeError("Expecting string, tuple or list type for SAML " 
     73                            "version comparison; got %r" % version) 
     74             
     75    def __ne__(self, version): 
     76        return self.__eq__(version) 
     77     
    5778    @staticmethod 
    5879    def valueOf(version): 
     80        """Parse input string into version tuple 
     81        @type version: version 
     82        @param version: SAML version 
     83        @rtype: tuple 
     84        @return: SAML version tuple""" 
    5985        return tuple(version.split(".")) 
    6086     
Note: See TracChangeset for help on using the changeset viewer.