1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 Contains classes for basic HTTP (authenticated) transport implementations.
19 """
20
21 import urllib2 as u2
22 from suds.transport import *
23 from suds.transport.http import HttpTransport
24 from logging import getLogger
25
26 log = getLogger(__name__)
27
28
30 """
31 Provides basic http authentication that follows the RFC-2617 specification.
32 As defined by specifications, credentials are provided to the server
33 upon request (HTTP/1.0 401 Authorization Required) by the server only.
34 @ivar pm: The password manager.
35 @ivar handler: The authentication handler.
36 """
37
39 """
40 @param kwargs: Keyword arguments.
41 - B{proxy} - An http proxy to be specified on requests.
42 The proxy is defined as {protocol:proxy,}
43 - type: I{dict}
44 - default: {}
45 - B{timeout} - Set the url open timeout (seconds).
46 - type: I{float}
47 - default: 90
48 - B{username} - The username used for http authentication.
49 - type: I{str}
50 - default: None
51 - B{password} - The password used for http authentication.
52 - type: I{str}
53 - default: None
54 """
55 HttpTransport.__init__(self, **kwargs)
56 self.pm = u2.HTTPPasswordMgrWithDefaultRealm()
57
58 - def open(self, request):
61
62 - def send(self, request):
65
72
75
80
81
83 """
84 Provides Windows (NTLM) http authentication.
85 @ivar pm: The password manager.
86 @ivar handler: The authentication handler.
87 @author: Christopher Bess
88 """
89
91
92 try:
93 from ntlm import HTTPNtlmAuthHandler
94 except ImportError:
95 raise Exception("Cannot import python-ntlm module")
96 handlers = HttpTransport.u2handlers(self)
97 handlers.append(HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.pm))
98 return handlers
99