Bug 1486217 - Make sending encrypted emails extensible. r=mkmelin
authorPatrick Brunschwig <patrick>
Sat, 08 Sep 2018 07:46:00 +0200
changeset 33098 d3cc5c00e5d6947f865dc8c12091fca8550b2239
parent 33097 eeb01d9f3e3eb4569fe9b12194f58ad44bfd32a8
child 33099 f3be60013adcfc2e2743421dc9c0c62cbaf62f4f
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersmkmelin
bugs1486217
Bug 1486217 - Make sending encrypted emails extensible. r=mkmelin
mail/extensions/smime/content/msgCompSMIMEOverlay.js
mailnews/build/nsMailModule.cpp
mailnews/compose/public/nsIMsgCompFields.idl
mailnews/compose/public/nsIMsgComposeSecure.idl
mailnews/compose/public/nsMsgCompCID.h
mailnews/compose/src/nsMsgCompFields.cpp
mailnews/compose/src/nsMsgCompFields.h
mailnews/compose/src/nsMsgSend.cpp
mailnews/extensions/smime/public/moz.build
mailnews/extensions/smime/public/nsIMsgSMIMECompFields.idl
mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
mailnews/extensions/smime/src/nsMsgComposeSecure.h
mailnews/extensions/smime/src/nsMsgSMIMECID.h
suite/extensions/smime/content/msgCompSMIMEOverlay.js
--- a/mail/extensions/smime/content/msgCompSMIMEOverlay.js
+++ b/mail/extensions/smime/content/msgCompSMIMEOverlay.js
@@ -23,24 +23,24 @@ var gEncryptOptionChanged;
 var gSignOptionChanged;
 
 function onComposerLoad()
 {
   // Are we already set up ? Or are the required fields missing ?
   if (gSMFields || !gMsgCompose || !gMsgCompose.compFields)
     return;
 
-  gMsgCompose.compFields.securityInfo = null;
+  gMsgCompose.compFields.composeSecure = null;
 
-  gSMFields = Cc["@mozilla.org/messenger-smime/composefields;1"]
-                .createInstance(Ci.nsIMsgSMIMECompFields);
+  gSMFields = Cc["@mozilla.org/messengercompose/composesecure;1"]
+                .createInstance(Ci.nsIMsgComposeSecure);
   if (!gSMFields)
     return;
 
-  gMsgCompose.compFields.securityInfo = gSMFields;
+  gMsgCompose.compFields.composeSecure = gSMFields;
 
   // Set up the initial security state.
   gSMFields.requireEncryptMessage =
     gCurrentIdentity.getIntAttribute("encryptionpolicy") == kEncryptionPolicy_Always;
   if (!gSMFields.requireEncryptMessage &&
       gEncryptedURIService &&
       gEncryptedURIService.isEncrypted(gMsgCompose.originalMsgURI))
   {
@@ -268,17 +268,17 @@ var SecurityController =
 
 function onComposerSendMessage()
 {
   let missingCount = new Object();
   let emailAddresses = new Object();
 
   try
   {
-    if (!gMsgCompose.compFields.securityInfo.requireEncryptMessage)
+    if (!gMsgCompose.compFields.composeSecure.requireEncryptMessage)
       return;
 
     Cc["@mozilla.org/messenger-smime/smimejshelper;1"]
       .createInstance(Ci.nsISMimeJSHelper)
       .getNoCertAddresses(gMsgCompose.compFields,
                                   missingCount,
                                   emailAddresses);
   }
--- a/mailnews/build/nsMailModule.cpp
+++ b/mailnews/build/nsMailModule.cpp
@@ -739,27 +739,25 @@ NS_DEFINE_NAMED_CID(NS_MSGMAILVIEWLIST_C
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgMdnGenerator)
 
 NS_DEFINE_NAMED_CID(NS_MSGMDNGENERATOR_CID);
 
 ////////////////////////////////////////////////////////////////////////////////
 // smime factories
 ////////////////////////////////////////////////////////////////////////////////
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeSecure)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSMIMEComposeFields)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSMimeJSHelper)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsEncryptedSMIMEURIsService)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCMSDecoder, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCMSEncoder, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCMSMessage, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCMSSecureMessage, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCertPicker, Init)
 
 NS_DEFINE_NAMED_CID(NS_MSGCOMPOSESECURE_CID);
-NS_DEFINE_NAMED_CID(NS_MSGSMIMECOMPFIELDS_CID);
 NS_DEFINE_NAMED_CID(NS_SMIMEJSJELPER_CID);
 NS_DEFINE_NAMED_CID(NS_SMIMEENCRYPTURISERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_CMSDECODER_CID);
 NS_DEFINE_NAMED_CID(NS_CMSENCODER_CID);
 NS_DEFINE_NAMED_CID(NS_CMSMESSAGE_CID);
 NS_DEFINE_NAMED_CID(NS_CMSSECUREMESSAGE_CID);
 NS_DEFINE_NAMED_CID(NS_CERT_PICKER_CID);
 
@@ -1027,17 +1025,16 @@ const mozilla::Module::CIDEntry kMailNew
   { &kNS_NNTPARTICLELIST_CID, false, NULL, nsNNTPArticleListConstructor },
   { &kNS_NEWSDOWNLOADDIALOGARGS_CID, false, NULL, nsNewsDownloadDialogArgsConstructor },
   // Mail View Entries
   { &kNS_MSGMAILVIEWLIST_CID, false, NULL, nsMsgMailViewListConstructor },
   // mdn Entries
   { &kNS_MSGMDNGENERATOR_CID, false, NULL, nsMsgMdnGeneratorConstructor },
   // SMime Entries
   { &kNS_MSGCOMPOSESECURE_CID, false, NULL, nsMsgComposeSecureConstructor },
-  { &kNS_MSGSMIMECOMPFIELDS_CID, false, NULL, nsMsgSMIMEComposeFieldsConstructor },
   { &kNS_SMIMEJSJELPER_CID, false, NULL, nsSMimeJSHelperConstructor },
   { &kNS_SMIMEENCRYPTURISERVICE_CID, false, NULL, nsEncryptedSMIMEURIsServiceConstructor },
   { &kNS_CMSDECODER_CID, false, NULL, nsCMSDecoderConstructor },
   { &kNS_CMSENCODER_CID, false, NULL, nsCMSEncoderConstructor },
   { &kNS_CMSMESSAGE_CID, false, NULL, nsCMSMessageConstructor },
   { &kNS_CMSSECUREMESSAGE_CID, false, NULL, nsCMSSecureMessageConstructor },
   { &kNS_CERT_PICKER_CID, false, nullptr, nsCertPickerConstructor },
   // Vcard Entries
@@ -1265,17 +1262,16 @@ const mozilla::Module::ContractIDEntry k
   { NS_NNTPARTICLELIST_CONTRACTID, &kNS_NNTPARTICLELIST_CID },
   { NS_NEWSDOWNLOADDIALOGARGS_CONTRACTID, &kNS_NEWSDOWNLOADDIALOGARGS_CID },
   // Mail View Entries
   { NS_MSGMAILVIEWLIST_CONTRACTID, &kNS_MSGMAILVIEWLIST_CID },
   // mdn Entries
   { NS_MSGMDNGENERATOR_CONTRACTID, &kNS_MSGMDNGENERATOR_CID },
   // SMime Entries
   { NS_MSGCOMPOSESECURE_CONTRACTID, &kNS_MSGCOMPOSESECURE_CID },
-  { NS_MSGSMIMECOMPFIELDS_CONTRACTID, &kNS_MSGSMIMECOMPFIELDS_CID },
   { NS_SMIMEJSHELPER_CONTRACTID, &kNS_SMIMEJSJELPER_CID },
   { NS_SMIMEENCRYPTURISERVICE_CONTRACTID, &kNS_SMIMEENCRYPTURISERVICE_CID },
   { NS_CMSSECUREMESSAGE_CONTRACTID, &kNS_CMSSECUREMESSAGE_CID },
   { NS_CMSDECODER_CONTRACTID, &kNS_CMSDECODER_CID },
   { NS_CMSENCODER_CONTRACTID, &kNS_CMSENCODER_CID },
   { NS_CMSMESSAGE_CONTRACTID, &kNS_CMSMESSAGE_CID },
   { NS_CERTPICKDIALOGS_CONTRACTID, &kNS_CERT_PICKER_CID },
   { NS_CERT_PICKER_CONTRACTID, &kNS_CERT_PICKER_CID },
--- a/mailnews/compose/public/nsIMsgCompFields.idl
+++ b/mailnews/compose/public/nsIMsgCompFields.idl
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "msgIStructuredHeaders.idl"
 
 interface nsIMsgAttachment;
 interface nsISimpleEnumerator;
+interface nsIMsgComposeSecure;
 
 /**
  * A collection of headers and other attributes for building a mail message.
  */
 [scriptable, uuid(10928477-4F24-4357-9397-FBD847F46F0A)]
 interface nsIMsgCompFields : msgIWritableStructuredHeaders {
 
   attribute AString from;
@@ -87,11 +88,13 @@ interface nsIMsgCompFields : msgIWritabl
   /**
    * Indicates whether we need to check if the current |DocumentCharset|
    * can represent all the characters in the message body. It should be
    * initialized to true and set to false when 'Send Anyway' is selected
    * by a user. (bug 249530)
    */
   attribute boolean needToCheckCharset;
 
-  attribute nsISupports securityInfo;
+  /**
+   * Object implementing encryption/signing functionality (e.g. S/MIME, PGP/MIME)
+   */
+  attribute nsIMsgComposeSecure composeSecure;
 };
-
--- a/mailnews/compose/public/nsIMsgComposeSecure.idl
+++ b/mailnews/compose/public/nsIMsgComposeSecure.idl
@@ -10,16 +10,64 @@
 interface nsIMsgCompFields;
 interface nsIMsgIdentity;
 interface nsIOutputStream;
 
 /* Security interface */
 [scriptable, uuid(245f2adc-410e-4bdb-91e2-a7bb42d61787)]
 interface nsIMsgComposeSecure : nsISupports
 {
-    // requiresCryptoEncapsulation --> returns true if the current message send requires us to go through
-    // some encryption work. In the case of false, you can disregard the compose secure object.
+    /**
+     * Set to true if the outgoing message shall be signed.
+     */
+    attribute boolean signMessage;
+
+    /**
+     * Set to true if the outgoing message shall be encrypted.
+     */
+    attribute boolean requireEncryptMessage;
+
+    /***************************************************************************
+     * The following functions are called during message creation by nsMsgSend,
+     * after the message source is completely prepared.
+     ***************************************************************************/
+
+    /**
+     * Determine if encryption and/or signing is required.
+     *
+     * @param aIdentity   - The sender's identity
+     * @param compFields  - Attributes of the composed message
+     *
+     * @return - Returns true if the creation of the message requires us to go through
+     *           some encryption work, and false otherwise.
+    */
     boolean requiresCryptoEncapsulation(in nsIMsgIdentity aIdentity, in nsIMsgCompFields aCompFields);
 
+    /**
+     * Start encryption work. Called before the encrypted data is processed.
+     *
+     * @param aStream     - Output stream that takes the resulting data
+     * @param aRecipients - RFC 2047-encoded list of all recipients (To:, Cc:, Bcc:, ... fields), separated by "," or ", "
+     *                      Recipients contain name and email addresses, just like they will be put into the message headers
+     * @param compFields  - Attributes of the composed message
+     * @param aIdentity   - The sender's identity
+     * @param sendReport  - Report feedback to the user
+     * @param aIsDraft    - True if send operation saves draft/template/etc., false if message is really sent (or sent later)
+     */
     void beginCryptoEncapsulation(in nsIOutputStream aStream, in string aRecipients, in nsIMsgCompFields aCompFields, in nsIMsgIdentity aIdentity, in nsIMsgSendReport sendReport, in boolean aIsDraft);
+
+    /**
+     * Process a part of the message data. Called multiple times, usually for every
+     * line of the data to be encrypted
+     *
+     * @param aBuf  - Buffer holding the data to be processed
+     * @param aLen  - Length of the buffer (number of characters)
+     */
+    void mimeCryptoWriteBlock(in string aBuf, in long aLen);
+
+    /**
+     * End encryption work. Called after the encrypted data is processed.
+     *
+     * @param aAbort      - True if the send operation was aborted
+     * @param sendReport  - Report feedback to the user
+     */
     void finishCryptoEncapsulation(in boolean aAbort, in nsIMsgSendReport sendReport);
-    void mimeCryptoWriteBlock(in string aBuf, in long aLen);
 };
--- a/mailnews/compose/public/nsMsgCompCID.h
+++ b/mailnews/compose/public/nsMsgCompCID.h
@@ -86,19 +86,19 @@ 0x0b63fb80, 0xbbba, 0x11d4,             
 
 //
 // nsMsgCompFields
 //
 #define NS_MSGCOMPFIELDS_CONTRACTID \
   "@mozilla.org/messengercompose/composefields;1"
 
 #define NS_MSGCOMPFIELDS_CID                    \
-{ /* 6D222BA0-BD46-11d2-8293-000000000000 */      \
- 0x6d222ba0, 0xbd46, 0x11d2,                      \
- {0x82, 0x93, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
+{ /* e64b0f51-0d7b-4e2f-8c60-3862ee8c174f */      \
+ 0xe64b0f51, 0x0d7b, 0x4e2f,                      \
+ {0x8c, 0x60, 0x38, 0x62, 0xee, 0x8c, 0x17, 0x4f}}
 
 //
 // nsMsgAttachment
 //
 #define NS_MSGATTACHMENT_CONTRACTID \
   "@mozilla.org/messengercompose/attachment;1"
 
 #define NS_MSGATTACHMENT_CID                    \
--- a/mailnews/compose/src/nsMsgCompFields.cpp
+++ b/mailnews/compose/src/nsMsgCompFields.cpp
@@ -653,26 +653,26 @@ NS_IMETHODIMP nsMsgCompFields::ConvertBo
       rv = ConvertBufToPlainText(body, flowed, delsp, formatted, disallowBreaks);
       if (NS_SUCCEEDED(rv))
         rv = SetBody(body);
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetSecurityInfo(nsISupports ** aSecurityInfo)
+NS_IMETHODIMP nsMsgCompFields::GetComposeSecure(nsIMsgComposeSecure ** aComposeSecure)
 {
-  NS_ENSURE_ARG_POINTER(aSecurityInfo);
-  NS_IF_ADDREF(*aSecurityInfo = mSecureCompFields);
+  NS_ENSURE_ARG_POINTER(aComposeSecure);
+  NS_IF_ADDREF(*aComposeSecure = mSecureCompFields);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetSecurityInfo(nsISupports * aSecurityInfo)
+NS_IMETHODIMP nsMsgCompFields::SetComposeSecure(nsIMsgComposeSecure * aComposeSecure)
 {
-  mSecureCompFields = aSecurityInfo;
+  mSecureCompFields = aComposeSecure;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgCompFields::GetDefaultCharacterSet(char * *aDefaultCharacterSet)
 {
   NS_ENSURE_ARG_POINTER(aDefaultCharacterSet);
   *aDefaultCharacterSet = ToNewCString(m_DefaultCharacterSet);
   return *aDefaultCharacterSet ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
--- a/mailnews/compose/src/nsMsgCompFields.h
+++ b/mailnews/compose/src/nsMsgCompFields.h
@@ -9,16 +9,17 @@
 #include "nsIMsgCompFields.h"
 #include "msgCore.h"
 #include "nsIAbCard.h"
 #include "nsIAbDirectory.h"
 #include "nsTArray.h"
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
+#include "nsIMsgComposeSecure.h"
 
 struct nsMsgRecipient
 {
   nsString mName;
   nsString mEmail;
   nsCOMPtr<nsIAbCard> mCard;
   nsCOMPtr<nsIAbDirectory> mDirectory;
 };
@@ -159,14 +160,14 @@ protected:
   bool        m_returnReceipt;
   bool        m_DSN;
   bool        m_bodyIsAsciiOnly;
   bool        m_forceMsgEncoding;
   int32_t     m_receiptHeaderType;        /* receipt header type */
   nsCString   m_DefaultCharacterSet;
   bool        m_needToCheckCharset;
 
-  nsCOMPtr<nsISupports> mSecureCompFields;
+  nsCOMPtr<nsIMsgComposeSecure> mSecureCompFields;
   nsCOMPtr<msgIWritableStructuredHeaders> mStructuredHeaders;
 };
 
 
 #endif /* _MsgCompFields_H_ */
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1170,17 +1170,17 @@ nsMsgComposeAndSend::PreProcessPart(nsMs
 
 nsresult nsMsgComposeAndSend::BeginCryptoEncapsulation ()
 {
   // Try to create a secure compose object. If we can create it, then query to see
   // if we need to use it for this send transaction.
 
   nsresult rv = NS_OK;
   nsCOMPtr<nsIMsgComposeSecure> secureCompose;
-  secureCompose = do_CreateInstance(NS_MSGCOMPOSESECURE_CONTRACTID, &rv);
+  rv = mCompFields->GetComposeSecure(getter_AddRefs(secureCompose));
   // it's not an error scenario of there is secure compose
   if (NS_FAILED(rv))
     return NS_OK;
 
   if (secureCompose)
   {
     bool requiresEncryptionWork = false;
     secureCompose->RequiresCryptoEncapsulation(mUserIdentity, mCompFields, &requiresEncryptionWork);
@@ -2747,20 +2747,20 @@ nsMsgComposeAndSend::InitCompositionFiel
   mCompFields->SetContentLanguage(fields->GetContentLanguage());
   mCompFields->SetReceiptHeaderType(receiptType);
 
   mCompFields->SetDSN(fields->GetDSN());
 
   mCompFields->SetBodyIsAsciiOnly(fields->GetBodyIsAsciiOnly());
   mCompFields->SetForceMsgEncoding(fields->GetForceMsgEncoding());
 
-  nsCOMPtr<nsISupports> secInfo;
-  fields->GetSecurityInfo(getter_AddRefs(secInfo));
-
-  mCompFields->SetSecurityInfo(secInfo);
+  nsCOMPtr<nsIMsgComposeSecure> compSec;
+  fields->GetComposeSecure(getter_AddRefs(compSec));
+
+  mCompFields->SetComposeSecure(compSec);
 
   bool needToCheckCharset;
   fields->GetNeedToCheckCharset(&needToCheckCharset);
   mCompFields->SetNeedToCheckCharset(needToCheckCharset);
 
   if ( m_deliver_mode != nsMsgSaveAsDraft && m_deliver_mode != nsMsgSaveAsTemplate )
   {
     // Check the fields for legitimacy...
@@ -3053,18 +3053,20 @@ nsMsgComposeAndSend::Init(
   bool strictly_mime = true;
   nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (pPrefBranch)
   {
     rv = pPrefBranch->GetBoolPref(PREF_MAIL_STRICTLY_MIME, &strictly_mime);
     rv = pPrefBranch->GetIntPref(PREF_MAIL_MESSAGE_WARNING_SIZE, (int32_t *) &mMessageWarningSize);
   }
 
-  nsCOMPtr<nsIMsgComposeSecure> secureCompose
-    = do_CreateInstance(NS_MSGCOMPOSESECURE_CONTRACTID, &rv);
+  nsCOMPtr<nsIMsgComposeSecure> secureCompose;
+  rv = fields->GetComposeSecure(getter_AddRefs(secureCompose));
+
+
   // It's not an error scenario if there is no secure compose.
   // The S/MIME extension may be unavailable.
   if (NS_SUCCEEDED(rv) && secureCompose)
   {
     bool requiresEncryptionWork = false;
     rv = secureCompose->RequiresCryptoEncapsulation(aUserIdentity, fields,
                                                     &requiresEncryptionWork);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/mailnews/extensions/smime/public/moz.build
+++ b/mailnews/extensions/smime/public/moz.build
@@ -1,15 +1,14 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsICertPickDialogs.idl',
     'nsIEncryptedSMIMEURIsSrvc.idl',
-    'nsIMsgSMIMECompFields.idl',
     'nsIMsgSMIMEHeaderSink.idl',
     'nsISMimeJSHelper.idl',
     'nsIUserCertPicker.idl',
 ]
 
 XPIDL_MODULE = 'msgsmime'
deleted file mode 100644
--- a/mailnews/extensions/smime/public/nsIMsgSMIMECompFields.idl
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-
-/* This is a private interface used exclusively by SMIME. NO ONE outside of extensions/smime
-   should have any knowledge nor should be referring to this interface.
-*/
-
-#include "nsISupports.idl"
-
-[scriptable, uuid(338E91F9-5970-4f81-B771-0822A32B1161)]
-interface nsIMsgSMIMECompFields : nsISupports
-{
-  attribute boolean signMessage;
-  attribute boolean requireEncryptMessage;
-};
--- a/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
+++ b/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
@@ -86,62 +86,25 @@ char
            prefix,
            rand_buf[0], rand_buf[1], rand_buf[2], rand_buf[3],
            rand_buf[4], rand_buf[5], rand_buf[6], rand_buf[7],
            rand_buf[8], rand_buf[9], rand_buf[10], rand_buf[11]);
 }
 
 // end of copied code which needs fixed....
 
-/////////////////////////////////////////////////////////////////////////////////////////
-// Implementation of nsMsgSMIMEComposeFields
-/////////////////////////////////////////////////////////////////////////////////////////
-
-NS_IMPL_ISUPPORTS(nsMsgSMIMEComposeFields, nsIMsgSMIMECompFields)
-
-nsMsgSMIMEComposeFields::nsMsgSMIMEComposeFields()
-:mSignMessage(false), mAlwaysEncryptMessage(false)
-{
-}
-
-nsMsgSMIMEComposeFields::~nsMsgSMIMEComposeFields()
-{
-}
-
-NS_IMETHODIMP nsMsgSMIMEComposeFields::SetSignMessage(bool value)
-{
-  mSignMessage = value;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsMsgSMIMEComposeFields::GetSignMessage(bool *_retval)
-{
-  *_retval = mSignMessage;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsMsgSMIMEComposeFields::SetRequireEncryptMessage(bool value)
-{
-  mAlwaysEncryptMessage = value;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsMsgSMIMEComposeFields::GetRequireEncryptMessage(bool *_retval)
-{
-  *_retval = mAlwaysEncryptMessage;
-  return NS_OK;
-}
 
 /////////////////////////////////////////////////////////////////////////////////////////
 // Implementation of nsMsgComposeSecure
 /////////////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS(nsMsgComposeSecure, nsIMsgComposeSecure)
 
 nsMsgComposeSecure::nsMsgComposeSecure()
+:mSignMessage(false), mAlwaysEncryptMessage(false)
 {
   /* member initializers and constructor code */
   mMultipartSignedBoundary  = 0;
   mBuffer = 0;
   mBufferedBytes = 0;
   mHashType = 0;
 }
 
@@ -156,16 +119,41 @@ nsMsgComposeSecure::~nsMsgComposeSecure(
     mEncryptionContext->Finish();
   }
 
   delete [] mBuffer;
 
   PR_FREEIF(mMultipartSignedBoundary);
 }
 
+NS_IMETHODIMP nsMsgComposeSecure::SetSignMessage(bool value)
+{
+  mSignMessage = value;
+  return NS_OK;
+}
+
+NS_IMETHODIMP nsMsgComposeSecure::GetSignMessage(bool *_retval)
+{
+  *_retval = mSignMessage;
+  return NS_OK;
+}
+
+NS_IMETHODIMP nsMsgComposeSecure::SetRequireEncryptMessage(bool value)
+{
+  mAlwaysEncryptMessage = value;
+  return NS_OK;
+}
+
+NS_IMETHODIMP nsMsgComposeSecure::GetRequireEncryptMessage(bool *_retval)
+{
+  *_retval = mAlwaysEncryptMessage;
+  return NS_OK;
+}
+
+
 NS_IMETHODIMP nsMsgComposeSecure::RequiresCryptoEncapsulation(nsIMsgIdentity * aIdentity, nsIMsgCompFields * aCompFields, bool * aRequiresEncryptionWork)
 {
   NS_ENSURE_ARG_POINTER(aRequiresEncryptionWork);
 
   *aRequiresEncryptionWork = false;
 
   bool alwaysEncryptMessages = false;
   bool signMessage = false;
@@ -273,46 +261,19 @@ void nsMsgComposeSecure::SetErrorWithPar
 nsresult nsMsgComposeSecure::ExtractEncryptionState(nsIMsgIdentity * aIdentity, nsIMsgCompFields * aComposeFields, bool * aSignMessage, bool * aEncrypt)
 {
   if (!aComposeFields && !aIdentity)
     return NS_ERROR_FAILURE; // kick out...invalid args....
 
   NS_ENSURE_ARG_POINTER(aSignMessage);
   NS_ENSURE_ARG_POINTER(aEncrypt);
 
-  nsCOMPtr<nsISupports> securityInfo;
-  if (aComposeFields)
-    aComposeFields->GetSecurityInfo(getter_AddRefs(securityInfo));
-
-  if (securityInfo) // if we were given security comp fields, use them.....
-  {
-    nsCOMPtr<nsIMsgSMIMECompFields> smimeCompFields = do_QueryInterface(securityInfo);
-    if (smimeCompFields)
-    {
-      smimeCompFields->GetSignMessage(aSignMessage);
-      smimeCompFields->GetRequireEncryptMessage(aEncrypt);
-      return NS_OK;
-    }
-  }
+  this->GetSignMessage(aSignMessage);
+  this->GetRequireEncryptMessage(aEncrypt);
 
-  // get the default info from the identity....
-  int32_t ep = 0;
-  nsresult testrv = aIdentity->GetIntAttribute("encryptionpolicy", &ep);
-  if (NS_FAILED(testrv)) {
-    *aEncrypt = false;
-  }
-  else {
-    *aEncrypt = (ep > 0);
-  }
-
-  testrv = aIdentity->GetBoolAttribute("sign_mail", aSignMessage);
-  if (NS_FAILED(testrv))
-  {
-    *aSignMessage = false;
-  }
   return NS_OK;
 }
 
 // Select a hash algorithm to sign message
 // based on subject public key type and size.
 static nsresult
 GetSigningHashFunction(nsIX509Cert *aSigningCert, int16_t *hashType)
 {
--- a/mailnews/extensions/smime/src/nsMsgComposeSecure.h
+++ b/mailnews/extensions/smime/src/nsMsgComposeSecure.h
@@ -2,17 +2,16 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef _nsMsgComposeSecure_H_
 #define _nsMsgComposeSecure_H_
 
 #include "nsIMsgComposeSecure.h"
-#include "nsIMsgSMIMECompFields.h"
 #include "nsCOMPtr.h"
 #include "nsICMSEncoder.h"
 #include "nsIX509Cert.h"
 #include "nsIStringBundle.h"
 #include "nsICryptoHash.h"
 #include "nsICMSMessage.h"
 #include "nsIMutableArray.h"
 #include "nsString.h"
@@ -21,30 +20,16 @@
 
 class nsIMsgCompFields;
 namespace mozilla {
 namespace mailnews {
 class MimeEncoder;
 }
 }
 
-class nsMsgSMIMEComposeFields : public nsIMsgSMIMECompFields
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMSGSMIMECOMPFIELDS
-
-  nsMsgSMIMEComposeFields();
-
-private:
-  virtual ~nsMsgSMIMEComposeFields();
-  bool mSignMessage;
-  bool mAlwaysEncryptMessage;
-};
-
 typedef enum {
   mime_crypto_none,            /* normal unencapsulated MIME message */
   mime_crypto_clear_signed,    /* multipart/signed encapsulation */
   mime_crypto_opaque_signed,   /* application/x-pkcs7-mime (signedData) */
   mime_crypto_encrypted,       /* application/x-pkcs7-mime */
   mime_crypto_signed_encrypted /* application/x-pkcs7-mime */
 } mimeDeliveryCryptoState;
 
@@ -73,16 +58,18 @@ private:
   nsresult MimeCryptoHackCerts(const char *aRecipients, nsIMsgSendReport *sendReport, bool aEncrypt, bool aSign, nsIMsgIdentity *aIdentity);
   bool InitializeSMIMEBundle();
   nsresult SMIMEBundleFormatStringFromName(const char *name,
                                            const char16_t **params,
                                            uint32_t numParams,
                                            nsAString& outString);
   nsresult ExtractEncryptionState(nsIMsgIdentity * aIdentity, nsIMsgCompFields * aComposeFields, bool * aSignMessage, bool * aEncrypt);
 
+  bool mSignMessage;
+  bool mAlwaysEncryptMessage;
   mimeDeliveryCryptoState mCryptoState;
   nsCOMPtr<nsIOutputStream> mStream;
   int16_t mHashType;
   nsCOMPtr<nsICryptoHash> mDataHash;
   nsAutoPtr<MimeEncoder> mSigEncoder;
   char *mMultipartSignedBoundary;
   nsString mSigningCertName;
   nsAutoCString mSigningCertDBKey;
--- a/mailnews/extensions/smime/src/nsMsgSMIMECID.h
+++ b/mailnews/extensions/smime/src/nsMsgSMIMECID.h
@@ -1,24 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsMsgSMIMECID_h__
 #define nsMsgSMIMECID_h__
 
-#define NS_MSGSMIMECOMPFIELDS_CONTRACTID \
-  "@mozilla.org/messenger-smime/composefields;1"
-
-#define NS_MSGSMIMECOMPFIELDS_CID                \
-{ /* 122C919C-96B7-49a0-BBC8-0ABC67EEFFE0 */     \
- 0x122c919c, 0x96b7, 0x49a0,                     \
- { 0xbb, 0xc8, 0xa, 0xbc, 0x67, 0xee, 0xff, 0xe0 }}
-
 #define NS_MSGCOMPOSESECURE_CID                  \
 { /* dd753201-9a23-4e08-957f-b3616bf7e012 */     \
  0xdd753201, 0x9a23, 0x4e08,                     \
  {0x95, 0x7f, 0xb3, 0x61, 0x6b, 0xf7, 0xe0, 0x12 }}
 
 #define NS_SMIMEJSHELPER_CONTRACTID \
   "@mozilla.org/messenger-smime/smimejshelper;1"
 
--- a/suite/extensions/smime/content/msgCompSMIMEOverlay.js
+++ b/suite/extensions/smime/content/msgCompSMIMEOverlay.js
@@ -21,24 +21,24 @@ var gEncryptOptionChanged;
 var gSignOptionChanged;
 
 function onComposerLoad()
 {
   // Are we already set up ? Or are the required fields missing ?
   if (gSMFields || !gMsgCompose || !gMsgCompose.compFields)
     return;
 
-  gMsgCompose.compFields.securityInfo = null;
+  gMsgCompose.compFields.composeSecure = null;
 
-  gSMFields = Cc["@mozilla.org/messenger-smime/composefields;1"]
-                .createInstance(Ci.nsIMsgSMIMECompFields);
+  gSMFields = Cc["@mozilla.org/messengercompose/composesecure;1"]
+                .createInstance(Ci.nsIMsgComposeSecure);
   if (!gSMFields)
     return;
 
-  gMsgCompose.compFields.securityInfo = gSMFields;
+  gMsgCompose.compFields.composeSecure = gSMFields;
 
   // Set up the initial security state.
   gSMFields.requireEncryptMessage =
     gCurrentIdentity.getIntAttribute("encryptionpolicy") == kEncryptionPolicy_Always;
   if (!gSMFields.requireEncryptMessage &&
       gEncryptedURIService &&
       gEncryptedURIService.isEncrypted(gMsgCompose.originalMsgURI))
   {
@@ -259,17 +259,17 @@ var SecurityController =
 
 function onComposerSendMessage()
 {
   let missingCount = new Object();
   let emailAddresses = new Object();
 
   try
   {
-    if (!gMsgCompose.compFields.securityInfo.requireEncryptMessage)
+    if (!gMsgCompose.compFields.composeSecure.requireEncryptMessage)
       return;
 
     Cc["@mozilla.org/messenger-smime/smimejshelper;1"]
       .createInstance(Ci.nsISMimeJSHelper)
       .getNoCertAddresses(gMsgCompose.compFields,
                                   missingCount,
                                   emailAddresses);
   }