70
70
return self.DEFAULT_SERVICE_URL
72
def get_proxy(self, authenticated):
73
73
"""Return the proxy for XMLRPC requests."""
74
# auth info must be in url
75
# TODO: if there's no registrant email perhaps we should just connect
77
scheme, hostinfo, path = urlsplit(self.service_url)[:3]
78
assert '@' not in hostinfo
79
assert self.registrant_email is not None
80
assert self.registrant_password is not None
81
# TODO: perhaps fully quote the password to make it very slightly
83
# TODO: can we perhaps add extra Authorization headers directly to the
84
# request, rather than putting this into the url? perhaps a bit more
85
# secure against accidentally revealing it. std66 s3.2.1 discourages putting
86
# the password in the url.
87
hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
88
urllib.quote(self.registrant_password),
90
url = urlunsplit((scheme, hostinfo, path, '', ''))
75
# auth info must be in url
76
# TODO: if there's no registrant email perhaps we should
77
# just connect anonymously?
78
scheme, hostinfo, path = urlsplit(self.service_url)[:3]
79
assert '@' not in hostinfo
80
assert self.registrant_email is not None
81
assert self.registrant_password is not None
82
# TODO: perhaps fully quote the password to make it very slightly
84
# TODO: can we perhaps add extra Authorization headers
85
# directly to the request, rather than putting this into
86
# the url? perhaps a bit more secure against accidentally
87
# revealing it. std66 s3.2.1 discourages putting the
88
# password in the url.
89
hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
90
urllib.quote(self.registrant_password),
92
url = urlunsplit((scheme, hostinfo, path, '', ''))
94
url = self.service_url
91
95
return xmlrpclib.ServerProxy(url, transport=self.transport)
93
97
def gather_user_credentials(self):
99
103
self.registrant_email
100
104
self.registrant_password = getpass(prompt)
102
def send_request(self, method_name, method_params):
103
proxy = self.get_proxy()
106
def send_request(self, method_name, method_params, authenticated):
107
proxy = self.get_proxy(authenticated)
104
108
assert method_name
105
109
method = getattr(proxy, method_name)
137
142
:param service: LaunchpadService indicating where to send
138
143
the request and the authentication credentials.
140
return service.send_request(self._methodname, self._request_params())
145
return service.send_request(self._methodname, self._request_params(),
143
149
class DryRunLaunchpadService(LaunchpadService):
146
152
The dummy service does not need authentication.
149
def send_request(self, method_name, method_params):
155
def send_request(self, method_name, method_params, authenticated):
152
158
def gather_user_credentials(self):