/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 2001 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Bob Lord * Ian McGreer * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ const nsIFilePicker = Components.interfaces.nsIFilePicker; const nsFilePicker = "@mozilla.org/filepicker;1"; const nsIX509CertDB = Components.interfaces.nsIX509CertDB; const nsX509CertDB = "@mozilla.org/security/x509certdb;1"; const nsIX509Cert = Components.interfaces.nsIX509Cert; const nsICertTree = Components.interfaces.nsICertTree; const nsCertTree = "@mozilla.org/security/nsCertTree;1"; const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock; const nsDialogParamBlock = "@mozilla.org/embedcomp/dialogparam;1"; const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock; const nsPKIParamBlock = "@mozilla.org/security/pkiparamblock;1"; const nsINSSCertCache = Components.interfaces.nsINSSCertCache; const nsNSSCertCache = "@mozilla.org/security/nsscertcache;1"; var key; var selected_certs = []; var selected_cert_index = []; var certdb; var caTreeView; var serverTreeView; var emailTreeView; var userTreeView; function LoadCerts() { window.crypto.enableSmartCardEvents = true; document.addEventListener("smartcard-insert", onSmartCardChange, false); document.addEventListener("smartcard-remove", onSmartCardChange, false); certdb = Components.classes[nsX509CertDB].getService(nsIX509CertDB); var certcache = Components.classes[nsNSSCertCache].createInstance(nsINSSCertCache); certcache.cacheAllCerts(); caTreeView = Components.classes[nsCertTree] .createInstance(nsICertTree); caTreeView.loadCertsFromCache(certcache, nsIX509Cert.CA_CERT); document.getElementById('ca-tree') .treeBoxObject.view = caTreeView; serverTreeView = Components.classes[nsCertTree] .createInstance(nsICertTree); serverTreeView.loadCertsFromCache(certcache, nsIX509Cert.SERVER_CERT); document.getElementById('server-tree') .treeBoxObject.view = serverTreeView; emailTreeView = Components.classes[nsCertTree] .createInstance(nsICertTree); emailTreeView.loadCertsFromCache(certcache, nsIX509Cert.EMAIL_CERT); document.getElementById('email-tree') .treeBoxObject.view = emailTreeView; userTreeView = Components.classes[nsCertTree] .createInstance(nsICertTree); userTreeView.loadCertsFromCache(certcache, nsIX509Cert.USER_CERT); document.getElementById('user-tree') .treeBoxObject.view = userTreeView; var rowCnt = userTreeView.rowCount; var enableBackupAllButton=document.getElementById('mine_backupAllButton'); if(rowCnt < 1) { enableBackupAllButton.setAttribute("disabled",true); } else { enableBackupAllButton.setAttribute("enabled",true); } if (certdb.isOcspOn) { document.getElementById('ocsp_info').removeAttribute("hidden"); } } function getSelectedTab() { var selTab = document.getElementById('certMgrTabbox').selectedItem; var selTabID = selTab.getAttribute('id'); if (selTabID == 'mine_tab') { key = "my_certs"; } else if (selTabID == "others_tab") { key = "others_certs"; } else if (selTabID == "websites_tab") { key = "web_certs"; } else if (selTabID == "ca_tab") { key = "ca_certs"; } return key; } function doHelpButton() { var uri = getSelectedTab(); openHelp(uri); } function getSelectedCerts() { var ca_tab = document.getElementById("ca_tab"); var mine_tab = document.getElementById("mine_tab"); var others_tab = document.getElementById("others_tab"); var websites_tab = document.getElementById("websites_tab"); var items = null; if (ca_tab.selected) { items = caTreeView.selection; } else if (mine_tab.selected) { items = userTreeView.selection; } else if (others_tab.selected) { items = emailTreeView.selection; } else if (websites_tab.selected) { items = serverTreeView.selection; } selected_certs = []; var cert = null; var nr = 0; if (items != null) nr = items.getRangeCount(); if (nr > 0) { for (var i=0; i 0) { for (var i=0; i=0; t--) { var s = params.GetString(t+1); if (s.length) { // This cert was deleted. treeView.removeCert(selected_cert_index[t]); } } treeView.selection.clearSelection(); } } function viewCerts() { getSelectedCerts(); var numcerts = selected_certs.length; if (!numcerts) return; for (var t=0; t