165
165
#really use bzrlib.auth get_password for this
166
166
#or possibly better gnome-keyring?
167
167
auth = config.AuthenticationConfig()
168
(scheme, urluser, urlpassword, host, port, urlpath) = \
169
urlutils.parse_url(self.url)
168
parsed_url = urlutils.URL.from_string(self.url)
171
170
if (flags & gio.ASK_PASSWORD_NEED_USERNAME and
172
171
flags & gio.ASK_PASSWORD_NEED_DOMAIN):
173
prompt = u'%s' % (scheme.upper(),) + u' %(host)s DOMAIN\\username'
174
user_and_domain = auth.get_user(scheme, host,
175
port=port, ask=True, prompt=prompt)
172
prompt = (u'%s' % (parsed_url.scheme.upper(),) +
173
u' %(host)s DOMAIN\\username')
174
user_and_domain = auth.get_user(parsed_url.scheme,
175
parsed_url.host, port=parsed_url.port, ask=True,
176
177
(domain, user) = user_and_domain.split('\\', 1)
177
178
op.set_username(user)
178
179
op.set_domain(domain)
179
180
elif flags & gio.ASK_PASSWORD_NEED_USERNAME:
180
user = auth.get_user(scheme, host,
181
user = auth.get_user(parsed_url.scheme, parsed_url.host,
182
port=parsed_url.port, ask=True)
182
183
op.set_username(user)
183
184
elif flags & gio.ASK_PASSWORD_NEED_DOMAIN:
184
185
#Don't know how common this case is, but anyway
185
186
#a DOMAIN and a username prompt should be the
186
187
#same so I will missuse the ui_factory get_username
187
188
#a little bit here.
188
prompt = u'%s' % (scheme.upper(),) + u' %(host)s DOMAIN'
189
prompt = (u'%s' % (parsed_url.scheme.upper(),) +
189
191
domain = ui.ui_factory.get_username(prompt=prompt)
190
192
op.set_domain(domain)
192
194
if flags & gio.ASK_PASSWORD_NEED_PASSWORD:
194
196
user = op.get_username()
195
password = auth.get_password(scheme, host,
197
password = auth.get_password(parsed_url.scheme, parsed_url.host,
198
user, port=parsed_url.port)
197
199
op.set_password(password)
198
200
op.reply(gio.MOUNT_OPERATION_HANDLED)
208
210
def _create_connection(self, credentials=None):
209
211
if credentials is None:
210
user, password = self._user, self._password
212
user, password = self._parsed_url.user, self._parsed_url.password
212
214
user, password = credentials