~ralsina/ubuntu-sso-client/cross-platform

« back to all changes in this revision

Viewing changes to ubuntu_sso/utils/webclient/gsettings.py

  • Committer: Tarmac
  • Author(s): Manuel de la Pena
  • Date: 2012-03-09 14:33:28 UTC
  • mfrom: (846.10.21 qt-ssl-dialog)
  • Revision ID: tarmac-20120309143328-5uih024zxk5sh3js
- Added a translatable string to give more context of the ssl cert info to the user
  (LP: #948119).
- Provided the logic required for the Qt webclient implementation to detect ssl errors
  and spawn the ssl dialog to allow the user accept the ssl cert exceptions
  (LP: #948134).
- Changed the qt webclient implementation to use a proxy factory so that the correct
  proxy is chosen according to the request (LP: #950088).

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    return hostname, username, password
32
32
 
33
33
 
 
34
def parse_manual_proxy_settings(scheme, gsettings):
 
35
    """Parse the settings for a given scheme."""
 
36
    host, username, pwd = parse_proxy_host(gsettings[scheme + ".host"])
 
37
    settings = {
 
38
        "host": host,
 
39
        "port": gsettings[scheme + ".port"],
 
40
    }
 
41
    if scheme == "http" and gsettings["http.use-authentication"]:
 
42
        username = gsettings["http.authentication-user"]
 
43
        pwd = gsettings["http.authentication-password"]
 
44
    if username is not None and pwd is not None:
 
45
        settings.update({
 
46
            "username": username,
 
47
            "password": pwd,
 
48
        })
 
49
    return settings
 
50
 
 
51
 
34
52
def get_proxy_settings():
35
53
    """Parse the proxy settings as returned by the gsettings executable."""
36
54
    output = subprocess.check_output(GSETTINGS_CMDLINE.split())
56
74
    if mode == "none":
57
75
        settings = {}
58
76
    elif mode == "manual":
59
 
        # attempt to parse the host
60
 
        host, username, pwd = parse_proxy_host(gsettings["http.host"])
61
 
        settings = {
62
 
            "host": host,
63
 
            "port": gsettings["http.port"],
64
 
        }
65
 
        if gsettings["http.use-authentication"]:
66
 
            username = gsettings["http.authentication-user"]
67
 
            pwd = gsettings["http.authentication-password"]
68
 
        if username is not None and pwd is not None:
69
 
            settings.update({
70
 
                "username": username,
71
 
                "password": pwd,
72
 
            })
 
77
        settings = {}
 
78
        for scheme in ["http", "https"]:
 
79
            settings[scheme] = parse_manual_proxy_settings(scheme, gsettings)
73
80
    else:
74
81
        # If mode is automatic the PAC javascript should be interpreted
75
82
        # on each request. That is out of scope so it's ignored for now