From 31c82812d4fbec801984edc0a495dcc1b57b621e Mon Sep 17 00:00:00 2001 From: "mcgreer%netscape.com" Date: Tue, 1 May 2001 23:23:23 +0000 Subject: [PATCH] Checkin for bug #75123. Improves the cert manager to make it look more like the mock-up. Implementation of nsIOutlinerView to improve cert listings. r=javi, sr=blizzard --- .../pki/resources/content/CAOverlay.xul | 10 +- .../pki/resources/content/MineOverlay.xul | 26 +- .../pki/resources/content/WebSitesOverlay.xul | 10 +- .../pki/resources/content/certManager.js | 283 +++----- .../pki/resources/content/certManager.xul | 8 +- .../pki/resources/content/deletecert.js | 54 ++ .../pki/resources/content/deletecert.xul | 55 ++ .../pki/resources/content/editcerts.js | 167 +++-- .../pki/resources/content/editcerts.xul | 65 -- .../pki/resources/content/pref-security.js | 9 +- security/manager/pki/resources/jar.mn | 2 + .../resources/locale/en-US/certManager.dtd | 12 + .../pki/resources/locale/en-US/pippki.dtd | 3 + .../resources/locale/en-US/pippki.properties | 2 - security/manager/ssl/public/Makefile.in | 1 + security/manager/ssl/public/makefile.win | 1 + .../manager/ssl/public/nsICertOutliner.idl | 0 security/manager/ssl/public/nsIX509Cert.idl | 5 + security/manager/ssl/public/nsIX509CertDB.idl | 43 +- .../resources/locale/en-US/pipnss.properties | 22 + security/manager/ssl/src/Makefile.in | 1 + security/manager/ssl/src/makefile.win | 1 + security/manager/ssl/src/nsCertOutliner.cpp | 644 ++++++++++++++++++ security/manager/ssl/src/nsCertOutliner.h | 86 +++ security/manager/ssl/src/nsCertTree.cpp | 644 ++++++++++++++++++ security/manager/ssl/src/nsCertTree.h | 86 +++ security/manager/ssl/src/nsNSSCertificate.cpp | 421 ++++++++---- security/manager/ssl/src/nsNSSCertificate.h | 5 + security/manager/ssl/src/nsNSSModule.cpp | 9 + security/manager/ssl/src/nsPK11TokenDB.cpp | 5 +- security/manager/ssl/src/nsPKCS12Blob.cpp | 157 ++++- security/manager/ssl/src/nsPKCS12Blob.h | 4 +- 32 files changed, 2303 insertions(+), 538 deletions(-) create mode 100644 security/manager/pki/resources/content/deletecert.js create mode 100644 security/manager/pki/resources/content/deletecert.xul create mode 100644 security/manager/ssl/public/nsICertOutliner.idl create mode 100644 security/manager/ssl/src/nsCertOutliner.cpp create mode 100644 security/manager/ssl/src/nsCertOutliner.h create mode 100644 security/manager/ssl/src/nsCertTree.cpp create mode 100644 security/manager/ssl/src/nsCertTree.h diff --git a/security/manager/pki/resources/content/CAOverlay.xul b/security/manager/pki/resources/content/CAOverlay.xul index 2ca16264ba2..78ed8eda216 100644 --- a/security/manager/pki/resources/content/CAOverlay.xul +++ b/security/manager/pki/resources/content/CAOverlay.xul @@ -35,9 +35,13 @@ - - - + + + diff --git a/security/manager/pki/resources/content/MineOverlay.xul b/security/manager/pki/resources/content/MineOverlay.xul index 148b7e18bbf..44054391ce3 100644 --- a/security/manager/pki/resources/content/MineOverlay.xul +++ b/security/manager/pki/resources/content/MineOverlay.xul @@ -37,9 +37,29 @@ - - - + + + + + + + + + + + diff --git a/security/manager/pki/resources/content/WebSitesOverlay.xul b/security/manager/pki/resources/content/WebSitesOverlay.xul index f2890caae0b..619c67ba907 100644 --- a/security/manager/pki/resources/content/WebSitesOverlay.xul +++ b/security/manager/pki/resources/content/WebSitesOverlay.xul @@ -37,9 +37,13 @@ - - - + + + diff --git a/security/manager/pki/resources/content/certManager.js b/security/manager/pki/resources/content/certManager.js index d976fa5d43a..9fc9e50ba12 100644 --- a/security/manager/pki/resources/content/certManager.js +++ b/security/manager/pki/resources/content/certManager.js @@ -26,137 +26,80 @@ const nsFilePicker = "@mozilla.org/filepicker;1"; const nsIX509CertDB = Components.interfaces.nsIX509CertDB; const nsX509CertDB = "@mozilla.org/security/x509certdb;1"; const nsIX509Cert = Components.interfaces.nsIX509Cert; +const nsICertOutliner = Components.interfaces.nsICertOutliner; +const nsCertOutliner = "@mozilla.org/security/nsCertOutliner;1"; var selected_certs = []; var certdb; -var caCertNameList; -var serverCertNameList; -//var emailCertNameList; -var userCertNameList; +var caOutlinerView; +var serverOutlinerView; +//var emailOutlinerView; +var userOutlinerView; -var caOutlinerView = { - rowCount : 50, - setOutliner : function(outliner) {}, - getCellText : function(row, column) { - if (row >= caCertNameList.length) return ""; - var certstuff = caCertNameList[row]; - var delim = certstuff[0]; - var certstr = certstuff.split(delim); - if (certstr.length < 4) { - tokenname = "PSM Certificate Database"; - certname = certstr[1]; - certkey = certstr[2]; - } else { - tokenname = certstr[1]; - certname = certstr[2]; - certkey = certstr[3]; - } - if (column=="certcol") return certname; - else if (column=="tokencol") return tokenname; - else return certkey; - }, - getRowProperties : function(row, prop) {}, - getColumnProperties : function(column, prop) {}, - getCellProperties : function(cell, prop) {}, - isContainer : function(index) { return false; } -}; +function LoadCerts() +{ + certdb = Components.classes[nsX509CertDB].getService(nsIX509CertDB); -var serverOutlinerView = { - rowCount : 10, - setOutliner : function(outliner) {}, - getCellText : function(row, column) { - if (row >= serverCertNameList.length) return ""; - var certstuff = serverCertNameList[row]; - var delim = certstuff[0]; - var certstr = certstuff.split(delim); - if (certstr.length < 4) { - tokenname = "PSM Certificate Database"; - certname = certstr[1]; - certkey = certstr[2]; - } else { - tokenname = certstr[1]; - certname = certstr[2]; - certkey = certstr[3]; - } - if (column=="certcol") return certname; - else if (column=="tokencol") return tokenname; - else return certkey; - }, - getRowProperties : function(row, prop) {}, - getColumnProperties : function(column, prop) {}, - getCellProperties : function(cell, prop) {}, - isContainer : function(index) { return false; } -}; + caOutlinerView = Components.classes[nsCertOutliner] + .createInstance(nsICertOutliner); + caOutlinerView.loadCerts(nsIX509Cert.CA_CERT); + document.getElementById('ca-outliner') + .outlinerBoxObject.view = caOutlinerView; + + serverOutlinerView = Components.classes[nsCertOutliner] + .createInstance(nsICertOutliner); + serverOutlinerView.loadCerts(nsIX509Cert.SERVER_CERT); + document.getElementById('server-outliner') + .outlinerBoxObject.view = serverOutlinerView; /* -var emailOutlinerView = { - rowCount : 10, - setOutliner : function(outliner) {}, - getCellText : function(row, column) { - if (row >= emailCertNameList.length) return ""; - var certname = emailCertertNameList[row]; - var ti = certname.indexOf(":"); - var tokenname = "PSM Certificate Database"; - if (ti > 0) { - tokenname = certname.substring(0, ti); - certname = certname.substring(ti+1, certname.length); - } - var ki = certname.indexOf(1); - var keystr = certname.substring(ki+1, certname.length); - certname = certname.substring(0, ki); - if (column=="certcol") return certname; - else if (column=="tokencol") return tokenname; - else return keystr; - }, - getRowProperties : function(row, prop) {}, - getColumnProperties : function(column, prop) {}, - getCellProperties : function(cell, prop) {}, - isContainer : function(index) { return false; } -}; + emailOutlinerView = Components.classes[nsCertOutliner] + .createInstance(nsICertOutliner); + emailOutlinerView.loadCerts(nsIX509Cert.EMAIL_CERT); + document.getElementById('email-outliner') + .outlinerBoxObject.view = emailOutlinerView; */ -var userOutlinerView = { - rowCount : 10, - setOutliner : function(outliner) {}, - getCellText : function(row, column) { - if (row >= userCertNameList.length) return ""; - var certstuff = userCertNameList[row]; - var delim = certstuff[0]; - var certstr = certstuff.split(delim); - if (certstr.length < 4) { - tokenname = "PSM Certificate Database"; - certname = certstr[1]; - certkey = certstr[2]; - } else { - tokenname = certstr[1]; - certname = certstr[2]; - certkey = certstr[3]; - } - if (column=="certcol") return certname; - else if (column=="tokencol") return tokenname; - else return certkey; - }, - getRowProperties : function(row, prop) {}, - getColumnProperties : function(column, prop) {}, - getCellProperties : function(cell, prop) {}, - isContainer : function(index) { return false; } -}; + userOutlinerView = Components.classes[nsCertOutliner] + .createInstance(nsICertOutliner); + userOutlinerView.loadCerts(nsIX509Cert.USER_CERT); + document.getElementById('user-outliner') + .outlinerBoxObject.view = userOutlinerView; + +} + +function ReloadCerts() +{ + caOutlinerView.loadCerts(nsIX509Cert.CA_CERT); + serverOutlinerView.loadCerts(nsIX509Cert.SERVER_CERT); + //emailOutlinerView.loadCerts(nsIX509Cert.EMAIL_CERT); + userOutlinerView.loadCerts(nsIX509Cert.USER_CERT); +} 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 = caOutlinerView.selection; - if (mine_tab.selected) { + var items = null; + if (ca_tab.selected) { + items = caOutlinerView.selection; + } else if (mine_tab.selected) { items = userOutlinerView.selection; +/* + } else if (others_tab.selected) { + items = emailOutlinerView.selection; +*/ } else if (websites_tab.selected) { items = serverOutlinerView.selection; } - var nr = items.getRangeCount(); + selected_certs = []; + var cert = null; + var nr = 0; + if (items != null) nr = items.getRangeCount(); if (nr > 0) { - selected_certs = []; for (var i=0; i 0) { for (var i=0; i + onload="LoadCerts()">