Merge lp:~nataliabidart/ubuntuone-client/revert-provide_credentials_management into lp:ubuntuone-client
- revert-provide_credentials_management
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged |
---|---|
Approved by: | Alejandro J. Cura |
Approved revision: | 994 |
Merged at revision: | 994 |
Proposed branch: | lp:~nataliabidart/ubuntuone-client/revert-provide_credentials_management |
Merge into: | lp:ubuntuone-client |
Diff against target: |
1062 lines (+230/-745) 8 files modified
po/POTFILES.in (+0/-1) tests/platform/linux/test_credentials.py (+5/-4) tests/platform/windows/test_credentials.py (+0/-151) tests/test_credentials.py (+0/-99) ubuntuone/credentials.py (+0/-255) ubuntuone/platform/linux/__init__.py (+1/-1) ubuntuone/platform/linux/credentials.py (+224/-56) ubuntuone/platform/windows/credentials.py (+0/-178) |
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-client/revert-provide_credentials_management |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alejandro J. Cura (community) | Approve | ||
dobey (community) | Approve | ||
Review via email: mp+62181@code.launchpad.net |
Commit message
- Reverting changes applied from https:/
Description of the change
To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote : | # |
Revision history for this message
dobey (dobey) : | # |
review:
Approve
Revision history for this message
Alejandro J. Cura (alecu) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'po/POTFILES.in' |
2 | --- po/POTFILES.in 2011-04-01 20:31:53 +0000 |
3 | +++ po/POTFILES.in 2011-05-24 18:23:27 +0000 |
4 | @@ -1,7 +1,6 @@ |
5 | ubuntuone/clientdefs.py.in |
6 | ubuntuone/status/aggregator.py |
7 | ubuntuone/platform/linux/credentials.py |
8 | -ubuntuone/platform/windows/credentials.py |
9 | data/emblem-ubuntuone-downloading.icon.in |
10 | data/emblem-ubuntuone-unsynchronized.icon.in |
11 | data/emblem-ubuntuone-uploading.icon.in |
12 | |
13 | === modified file 'tests/platform/linux/test_credentials.py' |
14 | --- tests/platform/linux/test_credentials.py 2011-04-01 20:00:42 +0000 |
15 | +++ tests/platform/linux/test_credentials.py 2011-05-24 18:23:27 +0000 |
16 | @@ -25,11 +25,12 @@ |
17 | from ubuntuone.devtools.handlers import MementoHandler |
18 | |
19 | from ubuntuone.platform.linux.credentials import (dbus, logger, logging, |
20 | - CredentialsManagement, ubuntu_sso, DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH, |
21 | - DBUS_CREDENTIALS_IFACE, APP_NAME, HELP_TEXT_KEY, DESCRIPTION, |
22 | - TC_URL_KEY, TC_URL, PING_URL_KEY, PING_URL, TIMEOUT_INTERVAL, |
23 | + CredentialsManagement, CredentialsManagementTool, CredentialsError, |
24 | + ubuntu_sso, |
25 | + DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH, DBUS_CREDENTIALS_IFACE, |
26 | + APP_NAME, HELP_TEXT_KEY, DESCRIPTION, TC_URL_KEY, TC_URL, |
27 | + PING_URL_KEY, PING_URL, TIMEOUT_INTERVAL, |
28 | ) |
29 | -from ubuntuone.credentials import CredentialsManagementTool, CredentialsError |
30 | |
31 | FAKED_CREDENTIALS = { |
32 | 'consumer_key': 'faked_consumer_key', |
33 | |
34 | === removed file 'tests/platform/windows/test_credentials.py' |
35 | --- tests/platform/windows/test_credentials.py 2011-05-04 11:21:02 +0000 |
36 | +++ tests/platform/windows/test_credentials.py 1970-01-01 00:00:00 +0000 |
37 | @@ -1,151 +0,0 @@ |
38 | -#!/usr/bin/env python |
39 | -# -*- coding: utf-8 -*- |
40 | -# Author: Manuel de la Pena <manuel@canonical.com> |
41 | -# |
42 | -# Copyright 2011 Canonical Ltd. |
43 | -# |
44 | -# This program is free software: you can redistribute it and/or modify it |
45 | -# under the terms of the GNU General Public License version 3, as published |
46 | -# by the Free Software Foundation. |
47 | -# |
48 | -# This program is distributed in the hope that it will be useful, but |
49 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
50 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
51 | -# PURPOSE. See the GNU General Public License for more details. |
52 | -# |
53 | -# You should have received a copy of the GNU General Public License along |
54 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
55 | -"""Tests for the credentials management on Windows.""" |
56 | - |
57 | -from mocker import MockerTestCase |
58 | - |
59 | -from ubuntu_sso.credentials import HELP_TEXT_KEY, PING_URL_KEY, TC_URL_KEY |
60 | -from ubuntuone.platform.windows.credentials import ( |
61 | - CredentialsManagement, |
62 | - APP_NAME, |
63 | - DESCRIPTION, |
64 | - PING_URL, |
65 | - TC_URL) |
66 | - |
67 | - |
68 | -class TestCredentialsManagement(MockerTestCase): |
69 | - """Test that the credentials management is correctly used.""" |
70 | - |
71 | - def setUp(self): |
72 | - """Set the different tests.""" |
73 | - super(TestCredentialsManagement, self).setUp() |
74 | - self.proxy = self.mocker.mock() |
75 | - self.management = CredentialsManagement() |
76 | - self.management._get_sso_proxy = lambda *args: self.proxy |
77 | - |
78 | - def test_find_credentials(self): |
79 | - """Ensure we do ask corectly for the credentials.""" |
80 | - reply_handler = lambda: None |
81 | - error_handler = lambda: None |
82 | - self.proxy.find_credentials(APP_NAME, {}) |
83 | - self.mocker.replay() |
84 | - self.management.find_credentials(reply_handler=reply_handler, |
85 | - error_handler=error_handler) |
86 | - |
87 | - def test_clear_credentials(self): |
88 | - """Ensure we do clear the credentials.""" |
89 | - reply_handler = lambda: None |
90 | - error_handler = lambda: None |
91 | - self.proxy.clear_credentials(APP_NAME, {}) |
92 | - self.mocker.replay() |
93 | - self.management.clear_credentials(reply_handler=reply_handler, |
94 | - error_handler=error_handler) |
95 | - |
96 | - def test_store_credentials(self): |
97 | - """Store the token for Ubuntu One application.""" |
98 | - credentials = 'creds' |
99 | - reply_handler = lambda: None |
100 | - error_handler = lambda: None |
101 | - self.proxy.store_credentials(APP_NAME, credentials) |
102 | - self.mocker.replay() |
103 | - self.management.store_credentials(credentials, |
104 | - reply_handler=reply_handler, error_handler=error_handler) |
105 | - |
106 | - def test_register(self): |
107 | - """Get credentials if found else prompt to register to Ubuntu One.""" |
108 | - reply_handler = lambda: None |
109 | - error_handler = lambda: None |
110 | - args = dict(test='test', args='args') |
111 | - extra_params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL, |
112 | - PING_URL_KEY: PING_URL} |
113 | - extra_params.update(args) |
114 | - self.proxy.register(APP_NAME, extra_params) |
115 | - self.mocker.replay() |
116 | - self.management.register(args, reply_handler, error_handler) |
117 | - |
118 | - def test_login(self): |
119 | - """Get credentials if found else prompt to login to Ubuntu One.""" |
120 | - reply_handler = lambda: None |
121 | - error_handler = lambda: None |
122 | - args = dict(test='test', args='args') |
123 | - extra_params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL, |
124 | - PING_URL_KEY: PING_URL} |
125 | - extra_params.update(args) |
126 | - self.proxy.login(APP_NAME, extra_params) |
127 | - self.mocker.replay() |
128 | - self.management.login(args, reply_handler, error_handler) |
129 | - |
130 | - def test_register_to_credentials_stored(self): |
131 | - """Register to the CredentialsStored dbus signal.""" |
132 | - callback = lambda: None |
133 | - self.proxy.register_to_signals() |
134 | - self.proxy.on_credentials_stored_cb = callback |
135 | - self.proxy.on_credentials_stored_cb |
136 | - self.mocker.result(callback) |
137 | - self.mocker.replay() |
138 | - self.management.register_to_credentials_stored(callback) |
139 | - |
140 | - def test_register_to_credentials_cleared(self): |
141 | - """Register to the CredentialsCleared dbus signal.""" |
142 | - callback = lambda: None |
143 | - self.proxy.register_to_signals() |
144 | - self.proxy.on_credentials_cleared_cb = callback |
145 | - self.proxy.on_credentials_cleared_cb |
146 | - self.mocker.result(callback) |
147 | - self.mocker.replay() |
148 | - self.management.register_to_credentials_cleared(callback) |
149 | - |
150 | - def test_register_to_credentials_found(self): |
151 | - """Register to the CredentialsFound dbus signal.""" |
152 | - callback = lambda: None |
153 | - self.proxy.register_to_signals() |
154 | - self.proxy.on_credentials_found_cb = callback |
155 | - self.proxy.on_credentials_found_cb |
156 | - self.mocker.result(callback) |
157 | - self.mocker.replay() |
158 | - self.management.register_to_credentials_found(callback) |
159 | - |
160 | - def test_register_to_credentials_not_found(self): |
161 | - """Register to the CredentialsFound dbus signal.""" |
162 | - callback = lambda: None |
163 | - self.proxy.register_to_signals() |
164 | - self.proxy.on_credentials_not_found_cb = callback |
165 | - self.proxy.on_credentials_not_found_cb |
166 | - self.mocker.result(callback) |
167 | - self.mocker.replay() |
168 | - self.management.register_to_credentials_not_found(callback) |
169 | - |
170 | - def test_register_to_authorization_denied(self): |
171 | - """Register to the AuthorizationDenied dbus signal.""" |
172 | - callback = lambda: None |
173 | - self.proxy.register_to_signals() |
174 | - self.proxy.on_authorization_denied_cb = callback |
175 | - self.proxy.on_authorization_denied_cb |
176 | - self.mocker.result(callback) |
177 | - self.mocker.replay() |
178 | - self.management.register_to_authorization_denied(callback) |
179 | - |
180 | - def test_register_to_credentials_error(self): |
181 | - """Register to the CredentialsError dbus signal.""" |
182 | - callback = lambda: None |
183 | - self.proxy.register_to_signals() |
184 | - self.proxy.on_credentials_error_cb = callback |
185 | - self.proxy.on_credentials_error_cb |
186 | - self.mocker.result(callback) |
187 | - self.mocker.replay() |
188 | - self.management.register_to_credentials_error(callback) |
189 | |
190 | === removed file 'tests/test_credentials.py' |
191 | --- tests/test_credentials.py 2011-04-01 20:31:53 +0000 |
192 | +++ tests/test_credentials.py 1970-01-01 00:00:00 +0000 |
193 | @@ -1,99 +0,0 @@ |
194 | -#!/usr/bin/env python |
195 | -# -*- coding: utf-8 -*- |
196 | -# |
197 | -# Author: Manuel de la Pena<manuel@canonical.com> |
198 | -# |
199 | -# Copyright 2011 Canonical Ltd. |
200 | -# |
201 | -# This program is free software: you can redistribute it and/or modify it |
202 | -# under the terms of the GNU General Public License version 3, as published |
203 | -# by the Free Software Foundation. |
204 | -# |
205 | -# This program is distributed in the hope that it will be useful, but |
206 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
207 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
208 | -# PURPOSE. See the GNU General Public License for more details. |
209 | -# |
210 | -# You should have received a copy of the GNU General Public License along |
211 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
212 | -"""Platform independent tests for the credentials management.""" |
213 | - |
214 | -from mocker import MockerTestCase, MATCH |
215 | - |
216 | -from ubuntuone.credentials import CredentialsManagementTool |
217 | - |
218 | - |
219 | -class TestCredentialsManagementTool(MockerTestCase): |
220 | - """Test the crendentials management tool mocking the proxy.""" |
221 | - |
222 | - def setUp(self): |
223 | - """Set the diff tests.""" |
224 | - super(TestCredentialsManagementTool, self).setUp() |
225 | - self.get_cred_proxy = self.mocker.replace( |
226 | - 'ubuntuone.platform.get_creds_proxy') |
227 | - self.proxy = self.mocker.mock() |
228 | - self.management_tool = CredentialsManagementTool() |
229 | - |
230 | - def test_find_credentials(self): |
231 | - """Test that we do ask for the credentials correctly.""" |
232 | - signals = ['creds_found', 'creds_not_found', 'creds_erro'] |
233 | - self.get_cred_proxy() |
234 | - self.mocker.result(self.proxy) |
235 | - self.proxy.register_to_credentials_found(MATCH(callable)) |
236 | - self.mocker.result(signals[0]) |
237 | - self.proxy.register_to_credentials_not_found(MATCH(callable)) |
238 | - self.mocker.result(signals[1]) |
239 | - self.proxy.register_to_credentials_error(MATCH(callable)) |
240 | - self.mocker.result(signals[2]) |
241 | - self.proxy.find_credentials(reply_handler=MATCH(callable), |
242 | - error_handler=MATCH(callable)) |
243 | - self.mocker.replay() |
244 | - return self.management_tool.find_credentials() |
245 | - |
246 | - def test_clear_credentials(self): |
247 | - """Test that we clear the credentials correctly.""" |
248 | - signals = ['creds_cleared', 'creds_error'] |
249 | - self.get_cred_proxy() |
250 | - self.mocker.result(self.proxy) |
251 | - self.proxy.register_to_credentials_cleared(MATCH(callable)) |
252 | - self.mocker.result(signals[0]) |
253 | - self.proxy.register_to_credentials_error(MATCH(callable)) |
254 | - self.mocker.result(signals[1]) |
255 | - self.proxy.clear_credentials(reply_handler=MATCH(callable), |
256 | - error_handler=MATCH(callable)) |
257 | - self.mocker.replay() |
258 | - return self.management_tool.clear_credentials() |
259 | - |
260 | - def test_store_credentials(self): |
261 | - """Test that we store the credentials correctly.""" |
262 | - token = 'token' |
263 | - signals = ['creds_stored','creds_error'] |
264 | - self.get_cred_proxy() |
265 | - self.mocker.result(self.proxy) |
266 | - self.proxy.register_to_credentials_stored(MATCH(callable)) |
267 | - self.mocker.result(signals[0]) |
268 | - self.proxy.register_to_credentials_error(MATCH(callable)) |
269 | - self.mocker.result(signals[1]) |
270 | - self.proxy.store_credentials(token, reply_handler=MATCH(callable), |
271 | - error_handler=MATCH(callable)) |
272 | - self.mocker.replay() |
273 | - return self.management_tool.store_credentials(token) |
274 | - |
275 | - def test_register(self): |
276 | - """Test that we correctly register.""" |
277 | - window_id = 10 |
278 | - window_id_dict = dict(window_id=str(window_id)) |
279 | - signals = ['creds_found', 'creds_denied', 'creds_error'] |
280 | - self.get_cred_proxy() |
281 | - self.mocker.result(self.proxy) |
282 | - self.proxy.register_to_credentials_found(MATCH(callable)) |
283 | - self.mocker.result(signals[0]) |
284 | - self.proxy.register_to_authorization_denied(MATCH(callable)) |
285 | - self.mocker.result(signals[1]) |
286 | - self.proxy.register_to_credentials_error(MATCH(callable)) |
287 | - self.mocker.result(signals[2]) |
288 | - self.proxy.register(window_id_dict, reply_handler=MATCH(callable), |
289 | - error_handler=MATCH(callable)) |
290 | - self.mocker.replay() |
291 | - return self.management_tool.register(window_id=window_id) |
292 | - |
293 | |
294 | === removed file 'ubuntuone/credentials.py' |
295 | --- ubuntuone/credentials.py 2011-05-03 07:58:57 +0000 |
296 | +++ ubuntuone/credentials.py 1970-01-01 00:00:00 +0000 |
297 | @@ -1,255 +0,0 @@ |
298 | -#!/usr/bin/env python |
299 | -# -*- coding: utf-8 -*- |
300 | -# |
301 | -# Author: Natalia B. Bidart <natalia.bidart@canonical.com> |
302 | -# Author: Manuel de la Pena<manuel@canonical.com> |
303 | -# |
304 | -# Copyright 2011 Canonical Ltd. |
305 | -# |
306 | -# This program is free software: you can redistribute it and/or modify it |
307 | -# under the terms of the GNU General Public License version 3, as published |
308 | -# by the Free Software Foundation. |
309 | -# |
310 | -# This program is distributed in the hope that it will be useful, but |
311 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
312 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
313 | -# PURPOSE. See the GNU General Public License for more details. |
314 | -# |
315 | -# You should have received a copy of the GNU General Public License along |
316 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
317 | -"""Common code for the credentials management.""" |
318 | - |
319 | -import os |
320 | - |
321 | -from twisted.internet import defer |
322 | - |
323 | -from ubuntuone.logger import (basic_formatter, logging, |
324 | - CustomRotatingFileHandler, LOGFOLDER) |
325 | -from ubuntuone.platform import get_creds_proxy |
326 | - |
327 | -LOG_LEVEL = logging.DEBUG |
328 | -path = os.path.join(LOGFOLDER, 'credentials.log') |
329 | -MAIN_HANDLER = CustomRotatingFileHandler(path) |
330 | -MAIN_HANDLER.setFormatter(basic_formatter) |
331 | -MAIN_HANDLER.setLevel(LOG_LEVEL) |
332 | - |
333 | -logger = logging.getLogger("ubuntuone.credentials") |
334 | -logger.setLevel(LOG_LEVEL) |
335 | -logger.addHandler(MAIN_HANDLER) |
336 | - |
337 | - |
338 | -class CredentialsError(Exception): |
339 | - """A general exception when hadling credentilas.""" |
340 | - |
341 | - |
342 | -class CredentialsManagementTool(object): |
343 | - """Wrapper to CredentialsManagement. |
344 | - |
345 | - The goal of this class is to abstract the caller from calling the DBus |
346 | - service implemented in the class CredentialsManagement. |
347 | - |
348 | - """ |
349 | - |
350 | - def __init__(self): |
351 | - self._cleanup_signals = [] |
352 | - |
353 | - def cleanup(self, _): |
354 | - """Disconnect all the DBus signals.""" |
355 | - for sig in self._cleanup_signals: |
356 | - logger.debug('cleanup: removing signal match %r', sig) |
357 | - sig.remove() |
358 | - |
359 | - return _ |
360 | - |
361 | - @defer.inlineCallbacks |
362 | - def find_credentials(self): |
363 | - """Find credentials for Ubuntu One. |
364 | - |
365 | - Return a deferred that, when fired, will return the credentials for |
366 | - Ubuntu One for the current logged in user. |
367 | - |
368 | - The credentials is a dictionary with both string keys and values. The |
369 | - dictionary may be either empty if there are no credentials for the |
370 | - user, or will hold five items as follow: |
371 | - |
372 | - - "name" |
373 | - - "token" |
374 | - - "token_secret" |
375 | - - "consumer_key" |
376 | - - "consumer_secret" |
377 | - |
378 | - """ |
379 | - d = defer.Deferred() |
380 | - d.addBoth(self.cleanup) |
381 | - |
382 | - proxy = get_creds_proxy() |
383 | - |
384 | - sig = proxy.register_to_credentials_found(d.callback) |
385 | - self._cleanup_signals.append(sig) |
386 | - |
387 | - sig = proxy.register_to_credentials_not_found(lambda: d.callback({})) |
388 | - self._cleanup_signals.append(sig) |
389 | - |
390 | - sig = proxy.register_to_credentials_error( |
391 | - lambda error_dict: d.errback(CredentialsError(error_dict))) |
392 | - self._cleanup_signals.append(sig) |
393 | - |
394 | - done = defer.Deferred() |
395 | - proxy.find_credentials(reply_handler=lambda: done.callback(None), |
396 | - error_handler=lambda *a: done.errback(a)) |
397 | - |
398 | - yield done |
399 | - |
400 | - result = yield d |
401 | - defer.returnValue(result) |
402 | - |
403 | - @defer.inlineCallbacks |
404 | - def clear_credentials(self): |
405 | - """Clear credentials for Ubuntu One. |
406 | - |
407 | - Return a deferred that, when fired, will return no result but will |
408 | - indicate that the Ubuntu One credentials for the current user were |
409 | - removed from the local keyring. |
410 | - |
411 | - """ |
412 | - d = defer.Deferred() |
413 | - d.addBoth(self.cleanup) |
414 | - |
415 | - proxy = get_creds_proxy() |
416 | - sig = proxy.register_to_credentials_cleared(lambda: d.callback(None)) |
417 | - self._cleanup_signals.append(sig) |
418 | - |
419 | - sig = proxy.register_to_credentials_error( |
420 | - lambda error_dict: d.errback(CredentialsError(error_dict))) |
421 | - self._cleanup_signals.append(sig) |
422 | - |
423 | - done = defer.Deferred() |
424 | - proxy.clear_credentials(reply_handler=lambda: done.callback(None), |
425 | - error_handler=lambda *a: done.errback(a)) |
426 | - |
427 | - yield done |
428 | - |
429 | - yield d |
430 | - |
431 | - @defer.inlineCallbacks |
432 | - def store_credentials(self, token): |
433 | - """Store credentials for Ubuntu One. |
434 | - |
435 | - The parameter 'token' should be a dictionary that matches the |
436 | - description of the result of 'find_credentials'. |
437 | - |
438 | - Return a deferred that, when fired, will return no result but will |
439 | - indicate that 'token' was stored in the local keyring as the new Ubuntu |
440 | - One credentials for the current user. |
441 | - |
442 | - """ |
443 | - d = defer.Deferred() |
444 | - d.addBoth(self.cleanup) |
445 | - |
446 | - proxy = get_creds_proxy() |
447 | - sig = proxy.register_to_credentials_stored(lambda: d.callback(None)) |
448 | - self._cleanup_signals.append(sig) |
449 | - |
450 | - sig = proxy.register_to_credentials_error( |
451 | - lambda error_dict: d.errback(CredentialsError(error_dict))) |
452 | - self._cleanup_signals.append(sig) |
453 | - |
454 | - done = defer.Deferred() |
455 | - proxy.store_credentials(token, |
456 | - reply_handler=lambda: done.callback(None), |
457 | - error_handler=lambda *a: done.errback(a)) |
458 | - |
459 | - yield done |
460 | - |
461 | - yield d |
462 | - |
463 | - @defer.inlineCallbacks |
464 | - def register(self, window_id=0): |
465 | - """Register to Ubuntu One. |
466 | - |
467 | - Return a deferred that, when fired, will return the credentials for |
468 | - Ubuntu One for the current logged in user. |
469 | - |
470 | - If there are no credentials for the current user, a GTK UI will be |
471 | - opened to invite the user to register to Ubuntu One. This UI provides |
472 | - options to either register (main screen) or login (secondary screen). |
473 | - |
474 | - You can pass an optional 'window_id' parameter that will be used by the |
475 | - GTK UI to be set transient for it. |
476 | - |
477 | - The returned credentials will be either a non-empty dictionary like the |
478 | - one described in 'find_credentials', or None. The latter indicates that |
479 | - there were no credentials for the user in the local keyring and that |
480 | - the user refused to register to Ubuntu One. |
481 | - |
482 | - """ |
483 | - d = defer.Deferred() |
484 | - d.addBoth(self.cleanup) |
485 | - |
486 | - proxy = get_creds_proxy() |
487 | - |
488 | - sig = proxy.register_to_credentials_found(d.callback) |
489 | - self._cleanup_signals.append(sig) |
490 | - |
491 | - sig = proxy.register_to_authorization_denied(lambda: d.callback(None)) |
492 | - self._cleanup_signals.append(sig) |
493 | - |
494 | - sig = proxy.register_to_credentials_error( |
495 | - lambda error_dict: d.errback(CredentialsError(error_dict))) |
496 | - self._cleanup_signals.append(sig) |
497 | - |
498 | - done = defer.Deferred() |
499 | - proxy.register({'window_id': str(window_id)}, |
500 | - reply_handler=lambda: done.callback(None), |
501 | - error_handler=lambda *a: done.errback(a)) |
502 | - |
503 | - yield done |
504 | - |
505 | - result = yield d |
506 | - defer.returnValue(result) |
507 | - |
508 | - @defer.inlineCallbacks |
509 | - def login(self, window_id=0): |
510 | - """Login to Ubuntu One. |
511 | - |
512 | - Return a deferred that, when fired, will return the credentials for |
513 | - Ubuntu One for the current logged in user. |
514 | - |
515 | - If there are no credentials for the current user, a GTK UI will be |
516 | - opened to invite the user to login to Ubuntu One. This UI provides |
517 | - options to either login (main screen) or retrieve password (secondary |
518 | - screen). |
519 | - |
520 | - You can pass an optional 'window_id' parameter that will be used by the |
521 | - GTK UI to be set transient for it. |
522 | - |
523 | - The returned credentials will be either a non-empty dictionary like the |
524 | - one described in 'find_credentials', or None. The latter indicates that |
525 | - there were no credentials for the user in the local keyring and that |
526 | - the user refused to login to Ubuntu One. |
527 | - |
528 | - """ |
529 | - d = defer.Deferred() |
530 | - d.addBoth(self.cleanup) |
531 | - |
532 | - proxy = get_creds_proxy() |
533 | - |
534 | - sig = proxy.register_to_credentials_found(d.callback) |
535 | - self._cleanup_signals.append(sig) |
536 | - |
537 | - sig = proxy.register_to_authorization_denied(lambda: d.callback(None)) |
538 | - self._cleanup_signals.append(sig) |
539 | - |
540 | - sig = proxy.register_to_credentials_error( |
541 | - lambda error_dict: d.errback(CredentialsError(error_dict))) |
542 | - self._cleanup_signals.append(sig) |
543 | - |
544 | - done = defer.Deferred() |
545 | - proxy.login({'window_id': str(window_id)}, |
546 | - reply_handler=lambda: done.callback(None), |
547 | - error_handler=lambda *a: done.errback(a)) |
548 | - |
549 | - yield done |
550 | - |
551 | - result = yield d |
552 | - defer.returnValue(result) |
553 | |
554 | === modified file 'ubuntuone/platform/linux/__init__.py' |
555 | --- ubuntuone/platform/linux/__init__.py 2011-05-03 15:22:19 +0000 |
556 | +++ ubuntuone/platform/linux/__init__.py 2011-05-24 18:23:27 +0000 |
557 | @@ -55,7 +55,7 @@ |
558 | get_udf_path, |
559 | VMMetadataUpgraderMixIn |
560 | ) |
561 | -from ubuntuone.platform.linux.credentials import get_creds_proxy |
562 | +from ubuntuone.platform.linux.credentials import CredentialsManagement |
563 | from ubuntuone.platform.linux.logger import setup_filesystem_logging, get_filesystem_logger |
564 | from ubuntuone.platform.linux.filesystem_notifications import FilesystemMonitor |
565 | from ubuntuone.platform.linux.notification import Notification |
566 | |
567 | === modified file 'ubuntuone/platform/linux/credentials.py' |
568 | --- ubuntuone/platform/linux/credentials.py 2011-05-03 07:58:57 +0000 |
569 | +++ ubuntuone/platform/linux/credentials.py 2011-05-24 18:23:27 +0000 |
570 | @@ -15,6 +15,7 @@ |
571 | # |
572 | # You should have received a copy of the GNU General Public License along |
573 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
574 | + |
575 | """Ubuntu One credentials management dbus service.""" |
576 | |
577 | import os |
578 | @@ -23,6 +24,7 @@ |
579 | import gettext |
580 | import ubuntu_sso |
581 | |
582 | +from twisted.internet import defer |
583 | from ubuntu_sso.credentials import HELP_TEXT_KEY, PING_URL_KEY, TC_URL_KEY |
584 | |
585 | from ubuntuone.logger import (basic_formatter, logging, |
586 | @@ -236,71 +238,237 @@ |
587 | reply_handler=reply_handler, error_handler=error_handler) |
588 | |
589 | |
590 | -class CredentialsManagementProxy(object): |
591 | - """Proxy that allows to work with the dbus api. |
592 | - |
593 | - This proxy has been added to hide the exact details of |
594 | - how the signals are connected. This allows the reuse of |
595 | - the CredentialsManagementTool in diff platforms. |
596 | +class CredentialsError(Exception): |
597 | + """A general exception when hadling credentilas.""" |
598 | + |
599 | + |
600 | +class CredentialsManagementTool(object): |
601 | + """Wrapper to CredentialsManagement. |
602 | + |
603 | + The goal of this class is to abstract the caller from calling the DBus |
604 | + service implemented in the class CredentialsManagement. |
605 | + |
606 | """ |
607 | |
608 | def __init__(self): |
609 | - """Create a new instance.""" |
610 | + self._cleanup_signals = [] |
611 | + |
612 | + def _get_creds_proxy(self): |
613 | + """Get the CredentialsManagement dbus proxy.""" |
614 | bus = dbus.SessionBus() |
615 | try: |
616 | obj = bus.get_object(DBUS_BUS_NAME, |
617 | DBUS_CREDENTIALS_PATH, |
618 | follow_name_owner_changes=True) |
619 | - self.proxy = dbus.Interface(obj, DBUS_CREDENTIALS_IFACE) |
620 | + proxy = dbus.Interface(obj, DBUS_CREDENTIALS_IFACE) |
621 | except: |
622 | logger.exception('get_creds_proxy:') |
623 | raise |
624 | |
625 | - def find_credentials(self, *args, **kwargs): |
626 | - """Relay the find_credentials method.""" |
627 | - return self.proxy.find_credentials(*args, **kwargs) |
628 | - |
629 | - def clear_credentials(self, *args, **kwargs): |
630 | - """Relay the clear_credentials method.""" |
631 | - return self.proxy.clear_credentials(*args, **kwargs) |
632 | - |
633 | - def store_credentials(self, *args, **kwargs): |
634 | - """Relay the store_credentials method.""" |
635 | - return self.proxy.store_credentials(*args, **kwargs) |
636 | - |
637 | - def register(self, *args, **kwargs): |
638 | - """Relay the register method.""" |
639 | - return self.proxy.register(*args, **kwargs) |
640 | - |
641 | - def login(self, *args, **kwargs): |
642 | - """Relay the login method.""" |
643 | - return self.proxy.login(*args, **kwargs) |
644 | - |
645 | - def register_to_credentials_stored(self, callback): |
646 | - """Register to the CredentialsStored dbus signal.""" |
647 | - return self.proxy.connect_to_signal('CredentialsStored', callback) |
648 | - |
649 | - def register_to_credentials_cleared(self, callback): |
650 | - """Register to the CredentialsCleared dbus signal.""" |
651 | - return self.proxy.connect_to_signal('CredentialsCleared', callback) |
652 | - |
653 | - def register_to_credentials_found(self, callback): |
654 | - """Register to the CredentialsFound dbus signal.""" |
655 | - return self.proxy.connect_to_signal('CredentialsFound', callback) |
656 | - |
657 | - def register_to_credentials_not_found(self, callback): |
658 | - """Register to the CredentialsFound dbus signal.""" |
659 | - return self.proxy.connect_to_signal('CredentialsNotFound', callback) |
660 | - |
661 | - def register_to_authorization_denied(self, callback): |
662 | - """Register to the AuthorizationDenied dbus signal.""" |
663 | - return self.proxy.connect_to_signal('AuthorizationDenied', callback) |
664 | - |
665 | - def register_to_credentials_error(self, callback): |
666 | - """Register to the CredentialsError dbus signal.""" |
667 | - return self.proxy.connect_to_signal('CredentialsError', callback) |
668 | - |
669 | - |
670 | -def get_creds_proxy(): |
671 | - """Get the CredentialsManagement dbus proxy.""" |
672 | - return CredentialsManagementProxy() |
673 | + return proxy |
674 | + |
675 | + def cleanup(self, _): |
676 | + """Disconnect all the DBus signals.""" |
677 | + for sig in self._cleanup_signals: |
678 | + logger.debug('cleanup: removing signal match %r', sig) |
679 | + sig.remove() |
680 | + |
681 | + return _ |
682 | + |
683 | + @defer.inlineCallbacks |
684 | + def find_credentials(self): |
685 | + """Find credentials for Ubuntu One. |
686 | + |
687 | + Return a deferred that, when fired, will return the credentials for |
688 | + Ubuntu One for the current logged in user. |
689 | + |
690 | + The credentials is a dictionary with both string keys and values. The |
691 | + dictionary may be either empty if there are no credentials for the |
692 | + user, or will hold five items as follow: |
693 | + |
694 | + - "name" |
695 | + - "token" |
696 | + - "token_secret" |
697 | + - "consumer_key" |
698 | + - "consumer_secret" |
699 | + |
700 | + """ |
701 | + d = defer.Deferred() |
702 | + d.addBoth(self.cleanup) |
703 | + |
704 | + proxy = self._get_creds_proxy() |
705 | + |
706 | + sig = proxy.connect_to_signal('CredentialsFound', d.callback) |
707 | + self._cleanup_signals.append(sig) |
708 | + |
709 | + sig = proxy.connect_to_signal('CredentialsNotFound', |
710 | + lambda: d.callback({})) |
711 | + self._cleanup_signals.append(sig) |
712 | + |
713 | + sig = proxy.connect_to_signal('CredentialsError', |
714 | + lambda error_dict: d.errback(CredentialsError(error_dict))) |
715 | + self._cleanup_signals.append(sig) |
716 | + |
717 | + done = defer.Deferred() |
718 | + proxy.find_credentials(reply_handler=lambda: done.callback(None), |
719 | + error_handler=lambda *a: done.errback(a)) |
720 | + |
721 | + yield done |
722 | + |
723 | + result = yield d |
724 | + defer.returnValue(result) |
725 | + |
726 | + @defer.inlineCallbacks |
727 | + def clear_credentials(self): |
728 | + """Clear credentials for Ubuntu One. |
729 | + |
730 | + Return a deferred that, when fired, will return no result but will |
731 | + indicate that the Ubuntu One credentials for the current user were |
732 | + removed from the local keyring. |
733 | + |
734 | + """ |
735 | + d = defer.Deferred() |
736 | + d.addBoth(self.cleanup) |
737 | + |
738 | + proxy = self._get_creds_proxy() |
739 | + sig = proxy.connect_to_signal('CredentialsCleared', |
740 | + lambda: d.callback(None)) |
741 | + self._cleanup_signals.append(sig) |
742 | + |
743 | + sig = proxy.connect_to_signal('CredentialsError', |
744 | + lambda error_dict: d.errback(CredentialsError(error_dict))) |
745 | + self._cleanup_signals.append(sig) |
746 | + |
747 | + done = defer.Deferred() |
748 | + proxy.clear_credentials(reply_handler=lambda: done.callback(None), |
749 | + error_handler=lambda *a: done.errback(a)) |
750 | + |
751 | + yield done |
752 | + |
753 | + yield d |
754 | + |
755 | + @defer.inlineCallbacks |
756 | + def store_credentials(self, token): |
757 | + """Store credentials for Ubuntu One. |
758 | + |
759 | + The parameter 'token' should be a dictionary that matches the |
760 | + description of the result of 'find_credentials'. |
761 | + |
762 | + Return a deferred that, when fired, will return no result but will |
763 | + indicate that 'token' was stored in the local keyring as the new Ubuntu |
764 | + One credentials for the current user. |
765 | + |
766 | + """ |
767 | + d = defer.Deferred() |
768 | + d.addBoth(self.cleanup) |
769 | + |
770 | + proxy = self._get_creds_proxy() |
771 | + sig = proxy.connect_to_signal('CredentialsStored', |
772 | + lambda: d.callback(None)) |
773 | + self._cleanup_signals.append(sig) |
774 | + |
775 | + sig = proxy.connect_to_signal('CredentialsError', |
776 | + lambda error_dict: d.errback(CredentialsError(error_dict))) |
777 | + self._cleanup_signals.append(sig) |
778 | + |
779 | + done = defer.Deferred() |
780 | + proxy.store_credentials(token, |
781 | + reply_handler=lambda: done.callback(None), |
782 | + error_handler=lambda *a: done.errback(a)) |
783 | + |
784 | + yield done |
785 | + |
786 | + yield d |
787 | + |
788 | + @defer.inlineCallbacks |
789 | + def register(self, window_id=0): |
790 | + """Register to Ubuntu One. |
791 | + |
792 | + Return a deferred that, when fired, will return the credentials for |
793 | + Ubuntu One for the current logged in user. |
794 | + |
795 | + If there are no credentials for the current user, a GTK UI will be |
796 | + opened to invite the user to register to Ubuntu One. This UI provides |
797 | + options to either register (main screen) or login (secondary screen). |
798 | + |
799 | + You can pass an optional 'window_id' parameter that will be used by the |
800 | + GTK UI to be set transient for it. |
801 | + |
802 | + The returned credentials will be either a non-empty dictionary like the |
803 | + one described in 'find_credentials', or None. The latter indicates that |
804 | + there were no credentials for the user in the local keyring and that |
805 | + the user refused to register to Ubuntu One. |
806 | + |
807 | + """ |
808 | + d = defer.Deferred() |
809 | + d.addBoth(self.cleanup) |
810 | + |
811 | + proxy = self._get_creds_proxy() |
812 | + |
813 | + sig = proxy.connect_to_signal('CredentialsFound', d.callback) |
814 | + self._cleanup_signals.append(sig) |
815 | + |
816 | + sig = proxy.connect_to_signal('AuthorizationDenied', |
817 | + lambda: d.callback(None)) |
818 | + self._cleanup_signals.append(sig) |
819 | + |
820 | + sig = proxy.connect_to_signal('CredentialsError', |
821 | + lambda error_dict: d.errback(CredentialsError(error_dict))) |
822 | + self._cleanup_signals.append(sig) |
823 | + |
824 | + done = defer.Deferred() |
825 | + proxy.register({'window_id': str(window_id)}, |
826 | + reply_handler=lambda: done.callback(None), |
827 | + error_handler=lambda *a: done.errback(a)) |
828 | + |
829 | + yield done |
830 | + |
831 | + result = yield d |
832 | + defer.returnValue(result) |
833 | + |
834 | + @defer.inlineCallbacks |
835 | + def login(self, window_id=0): |
836 | + """Login to Ubuntu One. |
837 | + |
838 | + Return a deferred that, when fired, will return the credentials for |
839 | + Ubuntu One for the current logged in user. |
840 | + |
841 | + If there are no credentials for the current user, a GTK UI will be |
842 | + opened to invite the user to login to Ubuntu One. This UI provides |
843 | + options to either login (main screen) or retrieve password (secondary |
844 | + screen). |
845 | + |
846 | + You can pass an optional 'window_id' parameter that will be used by the |
847 | + GTK UI to be set transient for it. |
848 | + |
849 | + The returned credentials will be either a non-empty dictionary like the |
850 | + one described in 'find_credentials', or None. The latter indicates that |
851 | + there were no credentials for the user in the local keyring and that |
852 | + the user refused to login to Ubuntu One. |
853 | + |
854 | + """ |
855 | + d = defer.Deferred() |
856 | + d.addBoth(self.cleanup) |
857 | + |
858 | + proxy = self._get_creds_proxy() |
859 | + |
860 | + sig = proxy.connect_to_signal('CredentialsFound', d.callback) |
861 | + self._cleanup_signals.append(sig) |
862 | + |
863 | + sig = proxy.connect_to_signal('AuthorizationDenied', |
864 | + lambda: d.callback(None)) |
865 | + self._cleanup_signals.append(sig) |
866 | + |
867 | + sig = proxy.connect_to_signal('CredentialsError', |
868 | + lambda error_dict: d.errback(CredentialsError(error_dict))) |
869 | + self._cleanup_signals.append(sig) |
870 | + |
871 | + done = defer.Deferred() |
872 | + proxy.login({'window_id': str(window_id)}, |
873 | + reply_handler=lambda: done.callback(None), |
874 | + error_handler=lambda *a: done.errback(a)) |
875 | + |
876 | + yield done |
877 | + |
878 | + result = yield d |
879 | + defer.returnValue(result) |
880 | |
881 | === removed file 'ubuntuone/platform/windows/credentials.py' |
882 | --- ubuntuone/platform/windows/credentials.py 2011-05-04 11:21:02 +0000 |
883 | +++ ubuntuone/platform/windows/credentials.py 1970-01-01 00:00:00 +0000 |
884 | @@ -1,178 +0,0 @@ |
885 | -#!/usr/bin/env python |
886 | -# -*- coding: utf-8 -*- |
887 | -# |
888 | -# Author: Manuel de la Pena<manuel@canonical.com> |
889 | -# |
890 | -# Copyright 2011 Canonical Ltd. |
891 | -# |
892 | -# This program is free software: you can redistribute it and/or modify it |
893 | -# under the terms of the GNU General Public License version 3, as published |
894 | -# by the Free Software Foundation. |
895 | -# |
896 | -# This program is distributed in the hope that it will be useful, but |
897 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
898 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
899 | -# PURPOSE. See the GNU General Public License for more details. |
900 | -# |
901 | -# You should have received a copy of the GNU General Public License along |
902 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
903 | -"""Ubuntu One credentials management IPC service.""" |
904 | - |
905 | -import os |
906 | - |
907 | -import gettext |
908 | - |
909 | -from ubuntu_sso.main.windows import UbuntuSSOClient |
910 | -from ubuntu_sso.credentials import HELP_TEXT_KEY, PING_URL_KEY, TC_URL_KEY |
911 | -from twisted.internet import defer |
912 | - |
913 | -from ubuntuone.logger import (basic_formatter, logging, |
914 | - CustomRotatingFileHandler, LOGFOLDER) |
915 | -from ubuntuone.clientdefs import GETTEXT_PACKAGE |
916 | - |
917 | - |
918 | -Q_ = lambda string: gettext.dgettext(GETTEXT_PACKAGE, string) |
919 | -NO_OP = lambda *args, **kwargs: None |
920 | - |
921 | -LOG_LEVEL = logging.DEBUG |
922 | -path = os.path.join(LOGFOLDER, 'credentials.log') |
923 | -MAIN_HANDLER = CustomRotatingFileHandler(path) |
924 | -MAIN_HANDLER.setFormatter(basic_formatter) |
925 | -MAIN_HANDLER.setLevel(LOG_LEVEL) |
926 | - |
927 | -logger = logging.getLogger("ubuntuone.credentials") |
928 | -logger.setLevel(LOG_LEVEL) |
929 | -logger.addHandler(MAIN_HANDLER) |
930 | - |
931 | -APP_NAME = "Ubuntu One" |
932 | -TC_URL = "https://one.ubuntu.com/terms/" |
933 | -PING_URL = "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/" |
934 | -DESCRIPTION = Q_('Ubuntu One requires an Ubuntu Single Sign On (SSO) account. ' |
935 | - 'This process will allow you to create a new account, ' |
936 | - 'if you do not yet have one.') |
937 | - |
938 | - |
939 | -class CredentialsManagement(object): |
940 | - """Object that manages Ubuntu One credentials.""" |
941 | - |
942 | - def __init__(self): |
943 | - super(CredentialsManagement, self).__init__() |
944 | - self._sso_proxy = None |
945 | - self._registered_to_signals = False |
946 | - |
947 | - @defer.inlineCallbacks |
948 | - def _get_sso_proxy(self): |
949 | - if not self._sso_proxy: |
950 | - client = UbuntuSSOClient() |
951 | - client = yield client.connect() |
952 | - self._sso_proxy = client |
953 | - defer.returnValue(self._sso_proxy.cred_management) |
954 | - |
955 | - @defer.inlineCallbacks |
956 | - def _register_to_signals(self): |
957 | - if not self._registered_to_signals: |
958 | - self._registered_to_signals = True |
959 | - proxy = yield self._get_sso_proxy() |
960 | - yield proxy.register_to_signals() |
961 | - |
962 | - @defer.inlineCallbacks |
963 | - def find_credentials(self, reply_handler=NO_OP, error_handler=NO_OP): |
964 | - """Ask the Ubuntu One credentials.""" |
965 | - sso_proxy = yield self._get_sso_proxy() |
966 | - sso_proxy.find_credentials(APP_NAME, {}) |
967 | - |
968 | - @defer.inlineCallbacks |
969 | - def clear_credentials(self, reply_handler=NO_OP, error_handler=NO_OP): |
970 | - """Clear the Ubuntu One credentials.""" |
971 | - sso_proxy = yield self._get_sso_proxy() |
972 | - sso_proxy.clear_credentials(APP_NAME, {}) |
973 | - |
974 | - @defer.inlineCallbacks |
975 | - def store_credentials(self, credentials, |
976 | - reply_handler=NO_OP, error_handler=NO_OP): |
977 | - """Store the token for Ubuntu One application.""" |
978 | - sso_proxy = yield self._get_sso_proxy() |
979 | - sso_proxy.store_credentials(APP_NAME, credentials) |
980 | - |
981 | - @defer.inlineCallbacks |
982 | - def register(self, args, reply_handler=NO_OP, error_handler=NO_OP): |
983 | - """Get credentials if found else prompt to register to Ubuntu One.""" |
984 | - sso_proxy = yield self._get_sso_proxy() |
985 | - params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL, |
986 | - PING_URL_KEY: PING_URL} |
987 | - params.update(args) |
988 | - sso_proxy.register(APP_NAME, params) |
989 | - |
990 | - @defer.inlineCallbacks |
991 | - def login(self, args, reply_handler=NO_OP, error_handler=NO_OP): |
992 | - """Get credentials if found else prompt to login to Ubuntu One.""" |
993 | - sso_proxy = yield self._get_sso_proxy() |
994 | - params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL, |
995 | - PING_URL_KEY: PING_URL} |
996 | - params.update(args) |
997 | - sso_proxy.login(APP_NAME, params) |
998 | - |
999 | - @defer.inlineCallbacks |
1000 | - def register_to_credentials_stored(self, callback): |
1001 | - """Register to the CredentialsStored dbus signal.""" |
1002 | - logger.info('%s: Registering to credentials stored "%s".', |
1003 | - self.__class__.__name__, callback) |
1004 | - sso_proxy = yield self._get_sso_proxy() |
1005 | - yield self._register_to_signals() |
1006 | - sso_proxy.on_credentials_stored_cb = callback |
1007 | - defer.returnValue(sso_proxy.on_credentials_stored_cb) |
1008 | - |
1009 | - @defer.inlineCallbacks |
1010 | - def register_to_credentials_cleared(self, callback): |
1011 | - """Register to the CredentialsCleared dbus signal.""" |
1012 | - logger.info('%s: Registering to credentials stored "%s".', |
1013 | - self.__class__.__name__, callback) |
1014 | - sso_proxy = yield self._get_sso_proxy() |
1015 | - yield self._register_to_signals() |
1016 | - sso_proxy.on_credentials_cleared_cb = callback |
1017 | - defer.returnValue(sso_proxy.on_credentials_cleared_cb) |
1018 | - |
1019 | - @defer.inlineCallbacks |
1020 | - def register_to_credentials_found(self, callback): |
1021 | - """Register to the CredentialsFound dbus signal.""" |
1022 | - logger.info('%s: Registering to credentials found"%s".', |
1023 | - self.__class__.__name__, callback) |
1024 | - sso_proxy = yield self._get_sso_proxy() |
1025 | - yield self._register_to_signals() |
1026 | - sso_proxy.on_credentials_found_cb = callback |
1027 | - defer.returnValue(sso_proxy.on_credentials_found_cb) |
1028 | - |
1029 | - @defer.inlineCallbacks |
1030 | - def register_to_credentials_not_found(self, callback): |
1031 | - """Register to the CredentialsFound dbus signal.""" |
1032 | - logger.info('%s: Registering to credentials NOT found"%s".', |
1033 | - self.__class__.__name__, callback) |
1034 | - sso_proxy = yield self._get_sso_proxy() |
1035 | - yield self._register_to_signals() |
1036 | - sso_proxy.on_credentials_not_found_cb = callback |
1037 | - defer.returnValue(sso_proxy.on_credentials_not_found_cb) |
1038 | - |
1039 | - @defer.inlineCallbacks |
1040 | - def register_to_authorization_denied(self, callback): |
1041 | - """Register to the AuthorizationDenied dbus signal.""" |
1042 | - logger.info('%s: Registering to credentials denied"%s".', |
1043 | - self.__class__.__name__, callback) |
1044 | - sso_proxy = yield self._get_sso_proxy() |
1045 | - yield self._register_to_signals() |
1046 | - sso_proxy.on_authorization_denied_cb = callback |
1047 | - defer.returnValue(sso_proxy.on_authorization_denied_cb) |
1048 | - |
1049 | - @defer.inlineCallbacks |
1050 | - def register_to_credentials_error(self, callback): |
1051 | - """Register to the CredentialsError dbus signal.""" |
1052 | - logger.info('%s: Registering to credentials error"%s".', |
1053 | - self.__class__.__name__, callback) |
1054 | - sso_proxy = yield self._get_sso_proxy() |
1055 | - yield self._register_to_signals() |
1056 | - sso_proxy.on_credentials_error_cb = callback |
1057 | - defer.returnValue(sso_proxy.on_credentials_error_cb) |
1058 | - |
1059 | - |
1060 | -def get_creds_proxy(): |
1061 | - """Get the CredentialsManagement dbus proxy.""" |
1062 | - return CredentialsManagement() |
To test, run the suite and also confirm that ubuntuone-launch works:
PYTHONPATH=. ./bin/ubuntuone -launch
(on trunk the above fails with ImportError on CredentialsMana gementTool) .