def __init__(self, username, password, url): try: from urllib2_kerberos import HTTPKerberosAuthHandler except ImportError: raise ImportError( 'You need urllib2_kerberos, try: pip install urllib2_kerberos') super(KerberosAuthenticator, self).__init__(username, password, url, HTTPKerberosAuthHandler())
def urlopen_with_timeout(url, data=None, timeout=None, secure_http_service_name=None, username=None, password=None, cafile=None, capath=None, max_cert_depth=9): openers = [] openers.append(_make_https_handler(cafile, capath, max_cert_depth)) openers.append(HTTPKerberosAuthHandler(secure_http_service_name)) full_url = url if isinstance(url, urllib2.Request): full_url = url.get_full_url() openers.append(_make_http_digest_auth_handler(full_url, username, password)) LOG.info("url_util: urlopen_with_timeout: full_url: %s" % full_url) if sys.version_info < (2, 6): # The timeout parameter to urlopen was introduced in Python 2.6. # To workaround it in older versions of python, we copy, with # minor modification, httplib.HTTPConnection, and hook it all # up. openers.append(_make_timeout_handler(timeout)) opener = urllib2.build_opener(*openers) LOG.info( "url_util: urlopen_with_timeout: sys.version_inf < (2, 6): opener: %s" % opener) return opener.open(url, data) else: openers.append(_make_timeout_handler(timeout)) opener = urllib2.build_opener(*openers) LOG.info( "url_util: urlopen_with_timeout: sys.version_inf > (2, 6): opener: %s" % opener) return opener.open(url, data, timeout)
def set_kerberos_auth(self): """Set up kerberos auth for the client, based on the current ticket.""" authhandler = HTTPKerberosAuthHandler() self._opener.add_handler(authhandler) return self
def u2handlers(self): handlers = suds.transport.http.HttpTransport.u2handlers(self) handlers.append(HTTPKerberosAuthHandler(self.as_user, self.spn)) return handlers