Exemplo n.º 1
0
    def SendSOAPDataHTTPDigestAuth(self, response, soapdata, url, request_uri, soapaction, **kw):
        """Resend the initial request w/http digest authorization headers.
        The SOAP server has requested authorization.  Fetch the challenge, 
        generate the authdict for building a response.
        """
        if self.trace:
            print >> self.trace, "------ Digest Auth Header"
        url = url or self.url
        if response.status != 401:
            raise RuntimeError, "Expecting HTTP 401 response."
        if self.auth_style != AUTH.httpdigest:
            raise RuntimeError, "Auth style(%d) does not support requested digest authorization." % self.auth_style

        from ZSI.digest_auth import fetch_challenge, generate_response, build_authorization_arg, dict_fetch

        chaldict = fetch_challenge(response.getheader("www-authenticate"))
        if (
            dict_fetch(chaldict, "challenge", "").lower() == "digest"
            and dict_fetch(chaldict, "nonce", None)
            and dict_fetch(chaldict, "realm", None)
            and dict_fetch(chaldict, "qop", None)
        ):
            authdict = generate_response(chaldict, request_uri, self.auth_user, self.auth_pass, method="POST")
            headers = {"Authorization": build_authorization_arg(authdict), "Expect": "100-continue"}
            self.SendSOAPData(soapdata, url, soapaction, headers, **kw)
            return

        raise RuntimeError, "Client expecting digest authorization challenge."
Exemplo n.º 2
0
	def SendSOAPDataHTTPDigestAuth(self, response, soapdata, url, request_uri, soapaction, **kw):
		'''Resend the initial request w/http digest authorization headers.
		The SOAP server has requested authorization.  Fetch the challenge, 
		generate the authdict for building a response.
		'''
		if self.trace:
			print >>self.trace, "------ Digest Auth Header"
		url = url or self.url
		if response.status != 401:
			raise RuntimeError, 'Expecting HTTP 401 response.'
		if self.auth_style != AUTH.httpdigest:
			raise RuntimeError,\
				'Auth style(%d) does not support requested digest authorization.' %self.auth_style

		from ZSI.digest_auth import fetch_challenge,\
			generate_response,\
			build_authorization_arg,\
			dict_fetch

		chaldict = fetch_challenge( response.getheader('www-authenticate') )
		if dict_fetch(chaldict,'challenge','').lower() == 'digest' and \
			dict_fetch(chaldict,'nonce',None) and \
			dict_fetch(chaldict,'realm',None) and \
			dict_fetch(chaldict,'qop',None):
			authdict = generate_response(chaldict,
				request_uri, self.auth_user, self.auth_pass, method='POST')
			headers = {\
				'Authorization':build_authorization_arg(authdict),
				'Expect':'100-continue',
			}
			self.SendSOAPData(soapdata, url, soapaction, headers, **kw)
			return

		raise RuntimeError,\
			'Client expecting digest authorization challenge.'
Exemplo n.º 3
0
    def SendSOAPDataHTTPDigestAuth(self, response, soapdata, url, soapaction, **kw):
        '''Resend the initial request w/http digest authorization headers.
        The SOAP server has requested authorization.  Fetch the challenge, 
        generate the authdict for building a response.
        '''
        if self.trace:
            print >>self.trace, "------ Digest Auth Header"
        url = url or self.url
        if response.status != 401:
            raise RuntimeError, 'Expecting HTTP 401 response.'
        if self.auth_style != AUTH.httpdigest:
            raise RuntimeError,\
                'Auth style(%d) does not support requested digest authorization.' %self.auth_style

        from ZSI.digest_auth import fetch_challenge,\
            generate_response,\
            build_authorization_arg,\
            dict_fetch

        chaldict = fetch_challenge( response.getheader('www-authenticate') )
        if dict_fetch(chaldict,'challenge','').lower() == 'digest' and \
            dict_fetch(chaldict,'nonce',None) and \
            dict_fetch(chaldict,'realm',None) and \
            dict_fetch(chaldict,'qop',None):
            authdict = generate_response(chaldict,
                url, self.auth_user, self.auth_pass, method='POST')
            headers = {\
                'Authorization':build_authorization_arg(authdict),
                'Expect':'100-continue',
            }
            self.SendSOAPData(soapdata, url, soapaction, headers, **kw)
            return

        raise RuntimeError,\
            'Client expecting digest authorization challenge.'