def get_proxy_ticket_for(self, service):
        """
        Verifies CAS 2.0+ XML-based authentication ticket.

        :param: service

        Returns username on success and None on failure.
        """

        if not settings.CAS_PROXY_CALLBACK:
            raise CasConfigException("No proxy callback set in settings")

        params = {'pgt': self.tgt, 'targetService': service}

        url = (urljoin(settings.CAS_SERVER_URL, 'proxy') + '?' +
               urlencode(params))

        page = urlopen(url)

        try:
            response = page.read()
            tree = ElementTree.fromstring(response)
            if tree[0].tag.endswith('proxySuccess'):
                return tree[0][0].text
            else:
                logger.warning('Failed to get proxy ticket')
                raise CasTicketException('Failed to get proxy ticket: %s' % \
                                         tree[0].text.strip())
        finally:
            page.close()
def get_proxy_ticket_for ( self , service ) : if not settings . CAS_PROXY_CALLBACK : raise CasConfigException ( "No proxy callback set in settings" ) params = { 'pgt' : self . tgt , 'targetService' : service } url = ( urljoin ( settings . CAS_SERVER_URL , 'proxy' ) + '?' + urlencode ( params ) ) page = urlopen ( url ) try : response = page . read ( ) tree = ElementTree . fromstring ( response ) if tree [ 0 ] . tag . endswith ( 'proxySuccess' ) : return tree [ 0 ] [ 0 ] . text else : logger . warning ( 'Failed to get proxy ticket' ) raise CasTicketException ( 'Failed to get proxy ticket: %s' % tree [ 0 ] . text . strip ( ) ) finally : page . close ( )
Verifies CAS 2.0+ XML-based authentication ticket.

        :param: service

        Returns username on success and None on failure.