From e46c7f31153c91b8db8b602907f0ab3d9a4109f0 Mon Sep 17 00:00:00 2001 From: "kaie%netscape.com" Date: Mon, 18 Feb 2002 15:36:30 +0000 Subject: [PATCH] b=115010 Implement "Message Security Info" when reading S/Mime messages. (includes b=115209 Only care for outermost signing/encryption level) r=javi/ducarroz sr=mscott --- .../resources/content/mailWindowOverlay.xul | 2 +- mailnews/extensions/smime/jar.mn | 7 + .../smime/public/nsIMsgSMIMEHeaderSink.idl | 8 +- .../smime/resources/content/contents.rdf | 15 ++ .../resources/content/msgCompSMIMEOverlay.js | 5 + .../resources/content/msgCompSMIMEOverlay.xul | 3 +- .../content/msgHdrViewSMIMEOverlay.js | 44 +++- .../content/msgHdrViewSMIMEOverlay.xul | 4 +- .../resources/content/msgReadSMIMEOverlay.js | 108 ++++++++ .../resources/content/msgReadSMIMEOverlay.xul | 53 ++++ .../resources/content/msgReadSecurityInfo.js | 247 ++++++++++++++++++ .../resources/content/msgReadSecurityInfo.xul | 105 ++++++++ .../locale/en-US/am-smime.properties | 5 - .../locale/en-US/msgCompSMIMEOverlay.dtd | 3 + .../locale/en-US/msgReadSMIMEOverlay.dtd | 4 + .../locale/en-US/msgReadSecurityInfo.dtd | 10 + .../locale/en-US/msgSecurityInfo.properties | 67 +++++ mailnews/mime/src/mimecms.cpp | 92 ++++--- mailnews/mime/src/mimemcms.cpp | 98 ++++--- security/manager/ssl/public/nsICMS.idl | 74 ++++++ security/manager/ssl/src/nsCMS.cpp | 103 +++++++- themes/classic/jar.mn | 1 + .../messenger/smime/msgReadSecurityInfo.css | 69 +++++ themes/modern/jar.mn | 1 + .../messenger/smime/msgReadSecurityInfo.css | 69 +++++ 25 files changed, 1100 insertions(+), 97 deletions(-) create mode 100644 mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.js create mode 100644 mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.xul create mode 100644 mailnews/extensions/smime/resources/content/msgReadSecurityInfo.js create mode 100644 mailnews/extensions/smime/resources/content/msgReadSecurityInfo.xul create mode 100644 mailnews/extensions/smime/resources/locale/en-US/msgReadSMIMEOverlay.dtd create mode 100644 mailnews/extensions/smime/resources/locale/en-US/msgReadSecurityInfo.dtd create mode 100644 mailnews/extensions/smime/resources/locale/en-US/msgSecurityInfo.properties create mode 100644 themes/classic/messenger/smime/msgReadSecurityInfo.css create mode 100644 themes/modern/messenger/smime/msgReadSecurityInfo.css diff --git a/mailnews/base/resources/content/mailWindowOverlay.xul b/mailnews/base/resources/content/mailWindowOverlay.xul index f41df8956e8e..87e58c4fe73c 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.xul +++ b/mailnews/base/resources/content/mailWindowOverlay.xul @@ -1087,7 +1087,7 @@ Rights Reserved. - + diff --git a/mailnews/extensions/smime/jar.mn b/mailnews/extensions/smime/jar.mn index 4ef8bc825ac3..47ec4ccb2ace 100644 --- a/mailnews/extensions/smime/jar.mn +++ b/mailnews/extensions/smime/jar.mn @@ -3,12 +3,19 @@ messenger.jar: content/messenger/am-smime.js (resources/content/am-smime.js) content/messenger-smime/msgCompSMIMEOverlay.js (resources/content/msgCompSMIMEOverlay.js) content/messenger-smime/msgCompSMIMEOverlay.xul (resources/content/msgCompSMIMEOverlay.xul) + content/messenger-smime/msgReadSMIMEOverlay.js (resources/content/msgReadSMIMEOverlay.js) + content/messenger-smime/msgReadSMIMEOverlay.xul (resources/content/msgReadSMIMEOverlay.xul) content/messenger-smime/msgHdrViewSMIMEOverlay.xul (resources/content/msgHdrViewSMIMEOverlay.xul) content/messenger-smime/msgHdrViewSMIMEOverlay.js (resources/content/msgHdrViewSMIMEOverlay.js) + content/messenger-smime/msgReadSecurityInfo.xul (resources/content/msgReadSecurityInfo.xul) + content/messenger-smime/msgReadSecurityInfo.js (resources/content/msgReadSecurityInfo.js) content/messenger-smime/contents.rdf (resources/content/contents.rdf) en-US.jar: locale/en-US/messenger/am-smime.dtd (resources/locale/en-US/am-smime.dtd) locale/en-US/messenger/am-smime.properties (resources/locale/en-US/am-smime.properties) locale/en-US/messenger-smime/msgCompSMIMEOverlay.dtd (resources/locale/en-US/msgCompSMIMEOverlay.dtd) + locale/en-US/messenger-smime/msgReadSMIMEOverlay.dtd (resources/locale/en-US/msgReadSMIMEOverlay.dtd) + locale/en-US/messenger-smime/msgReadSecurityInfo.dtd (resources/locale/en-US/msgReadSecurityInfo.dtd) + locale/en-US/messenger-smime/msgSecurityInfo.properties (resources/locale/en-US/msgSecurityInfo.properties) locale/en-US/messenger-smime/contents.rdf (resources/locale/en-US/contents.rdf) diff --git a/mailnews/extensions/smime/public/nsIMsgSMIMEHeaderSink.idl b/mailnews/extensions/smime/public/nsIMsgSMIMEHeaderSink.idl index 4dff91eca29b..a60741fff6c3 100644 --- a/mailnews/extensions/smime/public/nsIMsgSMIMEHeaderSink.idl +++ b/mailnews/extensions/smime/public/nsIMsgSMIMEHeaderSink.idl @@ -44,9 +44,13 @@ #include "nsISupports.idl" +interface nsIX509Cert; + [scriptable, uuid(25380FA1-E70C-4e82-B0BC-F31C2F41C470)] interface nsIMsgSMIMEHeaderSink : nsISupports { - void signedStatus(in boolean aValidSignature); - void encryptionStatus(in boolean aValidEncryption); + void signedStatus(in PRInt32 aNestingLevel, in PRInt32 aSignatureStatus, in nsIX509Cert aSignerCert); + void encryptionStatus(in PRInt32 aNestingLevel, in PRInt32 aEncryptionStatus); + + PRInt32 maxWantedNesting(); // 1 == only info on outermost nesting level wanted }; diff --git a/mailnews/extensions/smime/resources/content/contents.rdf b/mailnews/extensions/smime/resources/content/contents.rdf index 1d711f4ce15f..70e37ee939a9 100644 --- a/mailnews/extensions/smime/resources/content/contents.rdf +++ b/mailnews/extensions/smime/resources/content/contents.rdf @@ -21,6 +21,9 @@ + + + @@ -30,4 +33,16 @@ chrome://messenger-smime/content/msgHdrViewSMIMEOverlay.xul + + + chrome://messenger-smime/content/msgReadSMIMEOverlay.xul + + + + chrome://messenger-smime/content/msgReadSMIMEOverlay.xul + + + + chrome://messenger-smime/content/msgReadSMIMEOverlay.xul + diff --git a/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js b/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js index 04fe6f93cd4b..82882226d8ae 100644 --- a/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js +++ b/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js @@ -117,3 +117,8 @@ function setSecuritySettings() document.getElementById("menu_securityNoEncryption").setAttribute("checked", !smimeCompFields.alwaysEncryptMessage); document.getElementById("menu_securitySign").setAttribute("checked", smimeCompFields.signMessage); } + +function showMessageComposeSecurityStatus() +{ + dump("showSecurityStatus when composing message not yet implemented\n"); +} diff --git a/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.xul b/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.xul index 2bc9f9ca6a4c..d6b03b918195 100644 --- a/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.xul +++ b/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.xul @@ -42,9 +42,10 @@ accesskey="&menu_securityEncryptIfPossible.accesskey;" label="&menu_securityEncryptIfPossible.label;" disabled="true"/> + + - diff --git a/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js b/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js index 0e00fc19a061..ddf933c8c790 100644 --- a/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js +++ b/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js @@ -26,14 +26,31 @@ var gSignedUINode = null; var gEncryptedUINode = null; var gSMIMEContainer = null; +// manipulates some globals from msgReadSMIMEOverlay.js + +const nsICMSMessageErrors = Components.interfaces.nsICMSMessageErrors; + var smimeHeaderSink = { - signedStatus: function(aValidSignature) + maxWantedNesting: function() { + return 1; + }, + + signedStatus: function(aNestingLevel, aSignatureStatus, aSignerCert) + { + if (aNestingLevel > 1) { + // we are not interested + return; + } + + gSignatureStatus = aSignatureStatus; + gSignerCert = aSignerCert; + gSignedUINode.collapsed = false; gSMIMEContainer.collapsed = false; - if (aValidSignature) + if (nsICMSMessageErrors.SUCCESS == aSignatureStatus) { gSignedUINode.value = ""; } @@ -46,12 +63,19 @@ var smimeHeaderSink = gSignedUIVisible = true; }, - encryptionStatus: function(aValidEncryption) + encryptionStatus: function(aNestingLevel, aEncryptionStatus) { + if (aNestingLevel > 1) { + // we are not interested + return; + } + + gEncryptionStatus = aEncryptionStatus; + gEncryptedUINode.collapsed = false; gSMIMEContainer.collapsed = false; - if (aValidEncryption) + if (nsICMSMessageErrors.SUCCESS == aEncryptionStatus) { gEncryptedUINode.value = ""; } @@ -63,6 +87,7 @@ var smimeHeaderSink = gEncryptionUIVisible = true; }, + QueryInterface : function(iid) { if (iid.equals(Components.interfaces.nsIMsgSMIMEHeaderSink) || iid.equals(Components.interfaces.nsISupports)) @@ -73,7 +98,12 @@ var smimeHeaderSink = function onSMIMEStartHeaders() { - gSMIMEContainer.collapsed = true; + gEncryptionStatus = -1; + gSignatureStatus = -1; + + gSignerCert = null; + + gSMIMEContainer.collapsed = true; if (gEncryptionUIVisible) { @@ -110,7 +140,3 @@ function msgHdrViewSMIMEOnLoad(event) } addEventListener('messagepane-loaded', msgHdrViewSMIMEOnLoad, true); - -function showMessageSecurityInfo() -{ -} diff --git a/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.xul b/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.xul index 272e476b02f8..99b13061f5d4 100644 --- a/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.xul +++ b/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.xul @@ -29,8 +29,8 @@ - diff --git a/mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.js b/mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.js new file mode 100644 index 000000000000..abed0f8b7ea7 --- /dev/null +++ b/mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.js @@ -0,0 +1,108 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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 Netscape Communicator. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * 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 ***** */ + +var gEncryptionStatus = -1; +var gSignatureStatus = -1; +var gSignerCert = null; + +const nsPKIParamBlock = "@mozilla.org/security/pkiparamblock;1"; +const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock; + +function showMessageReadSecurityInfo() +{ + var pkiParams = Components.classes[nsPKIParamBlock].createInstance(nsIPKIParamBlock); + + // isupport array starts with index 1 + pkiParams.setISupportAtIndex(1, gSignerCert); + + var params = pkiParams.QueryInterface(Components.interfaces.nsIDialogParamBlock); + + // int array starts with index 0, but that is used for window exit status + params.SetInt(1, gSignatureStatus); + params.SetInt(2, gEncryptionStatus); + + window.openDialog('chrome://messenger-smime/content/msgReadSecurityInfo.xul', + '', 'chrome,resizable=1,modal=1,dialog=1', pkiParams ); +} + +var SecurityController = +{ + supportsCommand: function(command) + { + switch ( command ) + { + case "cmd_viewSecurityStatus": + return true; + + default: + return false; + } + }, + + isCommandEnabled: function(command) + { + switch ( command ) + { + case "cmd_viewSecurityStatus": + { + if (document.firstChild.getAttribute('windowtype') == "mail:messageWindow") + { + return ( gCurrentMessageUri != null); + } + else + { + if (GetNumSelectedMessages() > 0 && gDBView) + { + var enabled = new Object(); + enabled.value = false; + var checkStatus = new Object(); + gDBView.getCommandStatus(nsMsgViewCommandType.cmdRequiringMsgBody, enabled, checkStatus); + return enabled.value; + } + } + + return false; + } + + default: + return false; + } + return false; + } +}; + +top.controllers.appendController(SecurityController); diff --git a/mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.xul b/mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.xul new file mode 100644 index 000000000000..a6d1055b2904 --- /dev/null +++ b/mailnews/extensions/smime/resources/content/msgReadSMIMEOverlay.xul @@ -0,0 +1,53 @@ + + + + + + + +