70
73
return self.DEFAULT_SERVICE_URL
75
def get_proxy(self, authenticated):
73
76
"""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, '', ''))
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
91
98
return xmlrpclib.ServerProxy(url, transport=self.transport)
93
100
def gather_user_credentials(self):
94
101
"""Get the password from the user."""
95
config = bzrlib.config.GlobalConfig()
96
self.registrant_email = config.user_email()
102
the_config = config.GlobalConfig()
103
self.registrant_email = the_config.user_email()
97
104
if self.registrant_password is None:
105
auth = config.AuthenticationConfig()
106
scheme, hostinfo = urlsplit(self.service_url)[:2]
98
107
prompt = 'launchpad.net password for %s: ' % \
99
108
self.registrant_email
100
self.registrant_password = getpass(prompt)
109
# We will reuse http[s] credentials if we can, prompt user
111
self.registrant_password = auth.get_password(scheme, hostinfo,
112
self.registrant_email,
102
def send_request(self, method_name, method_params):
103
proxy = self.get_proxy()
115
def send_request(self, method_name, method_params, authenticated):
116
proxy = self.get_proxy(authenticated)
104
117
assert method_name
105
118
method = getattr(proxy, method_name)