Esempio 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.'
Esempio 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."
Esempio 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.'
Esempio n. 4
0
 def check_challenge_single_www_authenticate_header(self):
     challenge='Basic realm="WallyWorld"'
     #print "=="*30
     #print challenge
     #print "=="*30
     cd = digest_auth.fetch_challenge(challenge)
     expect = {'challenge': 'Basic', 'realm': 'WallyWorld'}
     self.failUnless(cd == expect, 'Expected equivalent')
Esempio n. 5
0
 def check_challenge_single_www_authenticate_header(self):
     challenge = 'Basic realm="WallyWorld"'
     #print "=="*30
     #print challenge
     #print "=="*30
     cd = digest_auth.fetch_challenge(challenge)
     expect = {'challenge': 'Basic', 'realm': 'WallyWorld'}
     self.failUnless(cd == expect, 'Expected equivalent')
Esempio n. 6
0
 def check_challenge_single_www_authenticate_header(self):
     challenge = 'Basic realm="WallyWorld"'
     print("==" * 30)
     print(challenge)
     print("==" * 30)
     cd = digest_auth.fetch_challenge(challenge)
     expect = {'challenge': 'Basic', 'realm': 'WallyWorld'}
     self.assertTrue(cd == expect, 'Expected equivalent')
Esempio n. 7
0
 def check_challenge_single_www_authenticate_header3(self):
     challenge = '''Digest
              realm="*****@*****.**",
              qop="auth,auth-int",
              nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
              opaque="5ccc069c403ebaf9f0171e9517f40e41"'''
     cd = digest_auth.fetch_challenge(challenge)
     expect = {'nonce': 'dcd98b7102dd2f0e8b11d0f600bfb0c093', 'challenge': 'Digest', 'opaque': '5ccc069c403ebaf9f0171e9517f40e41', 'realm': '*****@*****.**', 'qop': 'auth,auth-int'}
     self.failUnless(cd == expect, 'Expected equivalent')
Esempio n. 8
0
 def check_challenge_single_www_authenticate_header3(self):
     challenge = '''Digest
              realm="*****@*****.**",
              qop="auth,auth-int",
              nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
              opaque="5ccc069c403ebaf9f0171e9517f40e41"'''
     cd = digest_auth.fetch_challenge(challenge)
     expect = {'nonce': 'dcd98b7102dd2f0e8b11d0f600bfb0c093', 'challenge': 'Digest', 'opaque': '5ccc069c403ebaf9f0171e9517f40e41', 'realm': '*****@*****.**', 'qop': 'auth,auth-int'}
     self.failUnless(cd == expect, 'Expected equivalent')