1 # -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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 mozilla.org code.
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corp.
19 # Portions created by the Initial Developer are Copyright (C) 2001
20 # the Initial Developer. All Rights Reserved.
23 # Terry Hayes <thayes@netscape.com>
24 # Florian QUEZE <f.qu@queze.net>
25 # Ehsan Akhgari <ehsan.akhgari@gmail.com>
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK ***** */
43 viewCert :
function () {
48 _getSecurityInfo :
function() {
49 const nsIX509Cert = Components.interfaces.nsIX509Cert;
50 const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
51 const nsX509CertDB =
"@mozilla.org/security/x509certdb;1";
52 const nsISSLStatusProvider = Components.interfaces.nsISSLStatusProvider;
53 const nsISSLStatus = Components.interfaces.nsISSLStatus;
71 (ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_BROKEN);
73 (ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_INSECURE);
75 (ui.state & Components.interfaces.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
76 ui.QueryInterface(nsISSLStatusProvider);
77 var status = ui.SSLStatus;
79 if (!isInsecure && status) {
80 status.QueryInterface(nsISSLStatus);
81 var cert = status.serverCert;
83 this.mapIssuerOrganization(cert.issuerOrganization) || cert.issuerName;
88 encryptionAlgorithm : undefined,
89 encryptionStrength : undefined,
97 retval.encryptionAlgorithm = status.cipherName;
98 retval.encryptionStrength = status.secretKeyLength;
108 encryptionAlgorithm :
"",
109 encryptionStrength : 0,
113 fullLocation :
gWindow.location
119 _getSecurityUI :
function() {
120 if (
window.opener.gBrowser)
121 return window.opener.gBrowser.securityUI;
128 mapIssuerOrganization:
function(
name) {
131 if (
name ==
"RSA Data Security, Inc.")
return "Verisign, Inc.";
140 viewCookies :
function()
142 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
143 .getService(Components.interfaces.nsIWindowMediator);
144 var
win = wm.getMostRecentWindow(
"Browser:Cookies");
145 var eTLDService = Components.classes[
"@mozilla.org/network/effective-tld-service;1"].
146 getService(Components.interfaces.nsIEffectiveTLDService);
151 eTLD = eTLDService.getBaseDomain(uri);
155 eTLD = uri.asciiHost;
159 win.gCookiesWindow.setFilter(eTLD);
163 window.openDialog(
"chrome://browser/content/preferences/cookies.xul",
164 "Browser:Cookies",
"", {filterString : eTLD});
170 viewPasswords :
function()
172 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
173 .getService(Components.interfaces.nsIWindowMediator);
174 var
win = wm.getMostRecentWindow(
"Toolkit:PasswordManager");
176 win.setFilter(this._getSecurityInfo().hostName);
180 window.openDialog(
"chrome://passwordmgr/content/passwordManager.xul",
181 "Toolkit:PasswordManager",
"",
182 {filterString : this._getSecurityInfo().hostName});
189 var info =
security._getSecurityInfo();
191 document.getElementById(
"securityTab").hidden =
true;
192 document.getElementById(
"securityBox").collapsed =
true;
196 document.getElementById(
"securityTab").hidden =
false;
197 document.getElementById(
"securityBox").collapsed =
false;
200 const pageInfoBundle = document.getElementById(
"pageinfobundle");
203 setText(
"security-identity-domain-value", info.hostName);
205 var
owner, verifier, generalPageIdentityString;
206 if (info.cert && !info.isBroken) {
211 owner = info.cert.organization;
212 verifier =
security.mapIssuerOrganization(info.cAName);
213 generalPageIdentityString = pageInfoBundle.getFormattedString(
"generalSiteIdentity",
222 owner = pageInfoBundle.getString(
"securityNoOwner");
223 verifier =
security.mapIssuerOrganization(info.cAName ||
224 info.cert.issuerCommonName ||
225 info.cert.issuerName);
226 generalPageIdentityString =
owner;
231 owner = pageInfoBundle.getString(
"securityNoOwner");
232 verifier = pageInfoBundle.getString(
"notset");
233 generalPageIdentityString =
owner;
236 setText(
"security-identity-owner-value", owner);
237 setText(
"security-identity-verifier-value", verifier);
238 setText(
"general-security-identity", generalPageIdentityString);
241 var viewCert = document.getElementById(
"security-view-cert");
244 viewCert.collapsed =
false;
247 viewCert.collapsed =
true;
250 var yesStr = pageInfoBundle.getString(
"yes");
251 var noStr = pageInfoBundle.getString(
"no");
254 setText(
"security-privacy-cookies-value",
256 setText(
"security-privacy-passwords-value",
261 setText(
"security-privacy-history-value",
262 pageInfoBundle.getFormattedString(
"securityNVisits", [visitCount.toLocaleString()]));
264 else if (visitCount == 1) {
265 setText(
"security-privacy-history-value",
266 pageInfoBundle.getString(
"securityOneVisit"));
269 setText(
"security-privacy-history-value", noStr);
273 const pkiBundle = document.getElementById(
"pkiBundle");
279 hdr = pkiBundle.getString(
"pageInfo_MixedContent");
280 msg1 = pkiBundle.getString(
"pageInfo_Privacy_Mixed1");
281 msg2 = pkiBundle.getString(
"pageInfo_Privacy_None2");
283 else if (info.encryptionStrength >= 90) {
284 hdr = pkiBundle.getFormattedString(
"pageInfo_StrongEncryption",
285 [info.encryptionAlgorithm, info.encryptionStrength +
""]);
286 msg1 = pkiBundle.getString(
"pageInfo_Privacy_Strong1");
287 msg2 = pkiBundle.getString(
"pageInfo_Privacy_Strong2");
290 else if (info.encryptionStrength > 0) {
291 hdr = pkiBundle.getFormattedString(
"pageInfo_WeakEncryption",
292 [info.encryptionAlgorithm, info.encryptionStrength +
""]);
293 msg1 = pkiBundle.getFormattedString(
"pageInfo_Privacy_Weak1", [info.hostName]);
294 msg2 = pkiBundle.getString(
"pageInfo_Privacy_Weak2");
297 hdr = pkiBundle.getString(
"pageInfo_NoEncryption");
298 if (info.hostName !=
null)
299 msg1 = pkiBundle.getFormattedString(
"pageInfo_Privacy_None1", [info.hostName]);
301 msg1 = pkiBundle.getString(
"pageInfo_Privacy_None3");
302 msg2 = pkiBundle.getString(
"pageInfo_Privacy_None2");
304 setText(
"security-technical-shortform", hdr);
305 setText(
"security-technical-longform1", msg1);
306 setText(
"security-technical-longform2", msg2);
307 setText(
"general-security-privacy", hdr);
312 var
element = document.getElementById(
id);
315 if (element.localName ==
"textbox" || element.localName ==
"label")
316 element.value =
value;
318 if (element.hasChildNodes())
319 element.removeChild(element.firstChild);
320 var textNode = document.createTextNode(
value);
321 element.appendChild(textNode);
331 cd.viewCert(parent, cert);
338 var
cookieManager = Components.classes[
"@mozilla.org/cookiemanager;1"]
339 .getService(Components.interfaces.nsICookieManager2);
341 return cookieManager.countCookiesFromHost(
uri.asciiHost) > 0;
349 var passwordManager = Components.classes[
"@mozilla.org/login-manager;1"]
350 .getService(Components.interfaces.nsILoginManager);
351 return passwordManager.countLogins(
uri.prePath,
"",
"") > 0;
363 var historyService = Components.classes[
"@mozilla.org/browser/nav-history-service;1"]
364 .getService(Components.interfaces.nsINavHistoryService);
366 var
options = historyService.getNewQueryOptions();
367 options.resultType = options.RESULTS_AS_VISIT;
370 var query = historyService.getNewQuery();
371 query.endTimeReference = query.TIME_RELATIVE_TODAY;
375 var result = historyService.executeQuery(query, options);
376 result.root.containerOpen =
true;
377 return result.root.childCount;
function previousVisitCount(host, endTimeReference)
function securityOnLoad()
function setText(id, value)
function realmHasPasswords(uri)
const CERTIFICATEDIALOGS_CONTRACTID
getService(Ci.sbIFaceplateManager)
const nsICertificateDialogs
function hostHasCookies(uri)
function viewCertHelper(parent, cert)
BogusChannel prototype owner