73
73
return self.DEFAULT_SERVICE_URL
75
def get_proxy(self, authenticated):
76
76
"""Return the proxy for XMLRPC requests."""
77
# auth info must be in url
78
# TODO: if there's no registrant email perhaps we should just connect
80
scheme, hostinfo, path = urlsplit(self.service_url)[:3]
81
assert '@' not in hostinfo
82
assert self.registrant_email is not None
83
assert self.registrant_password is not None
84
# TODO: perhaps fully quote the password to make it very slightly
86
# TODO: can we perhaps add extra Authorization headers directly to the
87
# request, rather than putting this into the url? perhaps a bit more
88
# secure against accidentally revealing it. std66 s3.2.1 discourages putting
89
# the password in the url.
90
hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
91
urllib.quote(self.registrant_password),
93
url = urlunsplit((scheme, hostinfo, path, '', ''))
78
# auth info must be in url
79
# TODO: if there's no registrant email perhaps we should
80
# just connect anonymously?
81
scheme, hostinfo, path = urlsplit(self.service_url)[:3]
82
assert '@' not in hostinfo
83
assert self.registrant_email is not None
84
assert self.registrant_password is not None
85
# TODO: perhaps fully quote the password to make it very slightly
87
# TODO: can we perhaps add extra Authorization headers
88
# directly to the request, rather than putting this into
89
# the url? perhaps a bit more secure against accidentally
90
# revealing it. std66 s3.2.1 discourages putting the
91
# password in the url.
92
hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
93
urllib.quote(self.registrant_password),
95
url = urlunsplit((scheme, hostinfo, path, '', ''))
97
url = self.service_url
94
98
return xmlrpclib.ServerProxy(url, transport=self.transport)
96
100
def gather_user_credentials(self):
97
101
"""Get the password from the user."""
98
config = config.GlobalConfig()
99
self.registrant_email = config.user_email()
102
the_config = config.GlobalConfig()
103
self.registrant_email = the_config.user_email()
100
104
if self.registrant_password is None:
101
105
auth = config.AuthenticationConfig()
102
106
scheme, hostinfo = urlsplit(self.service_url)[:2]
105
109
# We will reuse http[s] credentials if we can, prompt user
107
111
self.registrant_password = auth.get_password(scheme, hostinfo,
112
self.registrant_email,
110
def send_request(self, method_name, method_params):
111
proxy = self.get_proxy()
115
def send_request(self, method_name, method_params, authenticated):
116
proxy = self.get_proxy(authenticated)
112
117
assert method_name
113
118
method = getattr(proxy, method_name)
216
223
# This must match the parameter tuple expected by Launchpad for this
218
225
return (self.branch_url, self.bug_id, '')
228
class ResolveLaunchpadPathRequest(BaseRequest):
229
"""Request to resolve the path component of an lp: URL."""
231
_methodname = 'resolve_lp_path'
232
_authenticated = False
234
def __init__(self, path):
238
def _request_params(self):
239
"""Return xmlrpc request parameters"""