summaryrefslogtreecommitdiffstats
path: root/install/share/preferences.html.template
blob: 48bcc42bca592ddeae64f8971e5ff9954aac2725 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>Automatically set browser preferences</title>
  <style type="text/css">
  body {
    font-family:"Liberation Sans",Arial,Sans;
    font-size:11px;
  }
  .textblock {
    text-align: left;
    margin-top: 1.0em;
    font-size: 1.1em;
  }
  a {
    color: #1D85D5;
    font-weight: normal;
    text-decoration: none;
    text-transform: none;
  }
  </style>
</head>
<body>
<form action="undefined" method="get">
<input id="button" type=button onclick="setPreferences()" name="prefs" value="Configure Firefox">
<div id="success" class="textblock" style="display: none;">
  <p>Browser configured.</p>
  <p>
    <a href="/ipa/ui" id="redirect_link" target="_top">Click here to return to the Web UI.</a>
  </p>
</div>
</form>

<script type="text/javascript">
  function setPreferences() {
    var privilege, setIntPref, setCharPref, setBoolPref;

    if (typeof navigator.preference == 'undefined') {
      // From Firefox 4 and SeaMonkey 2.1, navigator.preference intefrace is dropped
      // Use new Gecko2 Services.jsm JavaScript code module instead.
      privilege = 'UniversalXPConnect';
      netscape.security.PrivilegeManager.enablePrivilege(privilege);
      Components.utils.import("resource://gre/modules/Services.jsm");

      setIntPref = function(par, val) {Services.prefs.setIntPref(par, val)};
      setCharPref = function(par, val) {Services.prefs.setCharPref(par, val)};
      setBoolPref = function(par, val) {Services.prefs.setBoolPref(par, val)};
    } else {
      privilege = 'UniversalPreferencesWrite';
      netscape.security.PrivilegeManager.enablePrivilege(privilege);
      setCharPref = function(par, val) {navigator.preference(par, val)};
      setBoolPref = setCharPref;  // same function for bool and char and int
      setIntPref = setCharPref;
    }

    try {

      try {
        setIntPref('network.http.sendRefererHeader', 2);
        setBoolPref('network.negotiate-auth.using-native-gsslib', true);
        setCharPref('network.negotiate-auth.trusted-uris', '.$DOMAIN');
        setBoolPref('network.negotiate-auth.allow-proxies', true);
      } catch (e) {
        alert("Unable to store preferences: " + e);
        return;
      }

      netscape.security.PrivilegeManager.disablePrivilege(privilege);

      alert("Successfully configured Firefox for single sign-on.");

      var redirect_link = document.getElementById('redirect_link');
      redirect_link.href = "https://" + location.hostname + location.port + "/ipa/ui";

      var button = document.getElementById('button');
      button.style['display'] = "none";

      var successDiv = document.getElementById('success');
      successDiv.style['display'] = "block";
    } catch (e) {
      alert("Unable to apply recommended settings.\n\n" +
            "Click on the Certificate Authority link and select trust for all, " +
            "then reload this page and try again.\n\nThe error returned was: " + e);
      return;
    }
  }
</script>

</body>
</html>