1 # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is the Firefox Preferences System.
17 # The Initial Developer of the Original Code is
19 # Portions created by the Initial Developer are Copyright (C) 2005
20 # the Initial Developer. All Rights Reserved.
23 # Ben Goodger <ben@mozilla.org>
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
42 _OCSPResponders : null,
47 this._certDB = Components.classes["@mozilla.org/security/x509certdb;1"]
48 .getService(Components.interfaces.nsIX509CertDB);
49 this._OCSPResponders = this._certDB.getOCSPResponders();
51 var signingCA = document.getElementById("signingCA");
52 const nsIOCSPResponder = Components.interfaces.nsIOCSPResponder;
53 for (var i = 0; i < this._OCSPResponders.length; ++i) {
54 var ocspEntry = this._OCSPResponders.queryElementAt(i, nsIOCSPResponder);
55 var menuitem = document.createElement("menuitem");
56 menuitem.setAttribute("value", ocspEntry.responseSigner);
57 menuitem.setAttribute("label", ocspEntry.responseSigner);
58 signingCA.firstChild.appendChild(menuitem);
61 var signingCAPref = document.getElementById("security.OCSP.signingCA");
62 if (!signingCAPref.hasUserValue)
63 signingCA.selectedIndex = 0;
65 // We need to initialize manually since auto-initialization is often
66 // called prior to menulist population above.
67 signingCA.value = signingCAPref.value;
69 this.chooseServiceURL();
72 _updateUI: function (called_by)
74 var signingCA = document.getElementById("security.OCSP.signingCA");
75 var serviceURL = document.getElementById("security.OCSP.URL");
76 var securityOCSPEnabled = document.getElementById("security.OCSP.enabled");
77 var requireWorkingOCSP = document.getElementById("security.OCSP.require");
78 var enableOCSPBox = document.getElementById("enableOCSPBox");
79 var certOCSP = document.getElementById("certOCSP");
80 var proxyOCSP = document.getElementById("proxyOCSP");
82 var OCSPPrefValue = parseInt(securityOCSPEnabled.value);
85 // the radio button changed, or we init the stored value from prefs
86 enableOCSPBox.checked = (OCSPPrefValue != 0);
89 // the user toggled the checkbox to enable/disable OCSP
91 if (enableOCSPBox.checked) {
92 // now enabled. if we have a cached radio val, restore it.
93 // if not, use the first setting
94 new_val = (this._cacheRadio > 0) ? this._cacheRadio : 1;
97 // now disabled. remember current value
98 this._cacheRadio = OCSPPrefValue;
100 securityOCSPEnabled.value = OCSPPrefValue = new_val;
103 certOCSP.disabled = (OCSPPrefValue == 0);
104 proxyOCSP.disabled = (OCSPPrefValue == 0);
105 signingCA.disabled = serviceURL.disabled = OCSPPrefValue == 0 || OCSPPrefValue == 1;
106 requireWorkingOCSP.disabled = (OCSPPrefValue == 0);
111 chooseServiceURL: function ()
113 var signingCA = document.getElementById("signingCA");
114 var serviceURL = document.getElementById("serviceURL");
115 var CA = signingCA.value;
117 const nsIOCSPResponder = Components.interfaces.nsIOCSPResponder;
118 for (var i = 0; i < this._OCSPResponders.length; ++i) {
119 var ocspEntry = this._OCSPResponders.queryElementAt(i, nsIOCSPResponder);
120 if (CA == ocspEntry.responseSigner) {
121 serviceURL.value = ocspEntry.serviceURL;