Bug 1503053 - Port bug 1502774, part 2: Replace XPCOM use of auth module classes. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Tue, 30 Oct 2018 00:16:35 +0100
changeset 33617 fb4b473cb75ebc015fea4493120976a79451ffd6
parent 33616 089769dbf2568287383d74bb514286f3776b6149
child 33618 e6c4c2cd5363dd8e95439d7362a038550bab8122
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersbustage-fix
bugs1503053, 1502774
Bug 1503053 - Port bug 1502774, part 2: Replace XPCOM use of auth module classes. rs=bustage-fix
mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
mailnews/base/util/nsMsgProtocol.cpp
--- a/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
@@ -257,19 +257,18 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
   if (mSaslMechanism.EqualsLiteral("GSSAPI"))
   {
     nsAutoCString service;
     rv = mDirectoryUrl->GetAsciiHost(service);
     NS_ENSURE_SUCCESS(rv, rv);
 
     service.InsertLiteral("ldap@", 0);
 
-    nsCOMPtr<nsIAuthModule> authModule =
-      do_CreateInstance(NS_AUTH_MODULE_CONTRACTID_PREFIX "sasl-gssapi", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIAuthModule> authModule = 
+      nsIAuthModule::CreateInstance("sasl-gssapi");
 
     rv = mOperation->SaslBind(service, mSaslMechanism, authModule);
     if (NS_FAILED(rv))
     {
       NS_ERROR("nsAbLDAPMessageBase::OnLDAPInit(): "
                "failed to perform GSSAPI bind");
       mOperation = nullptr; // Break Listener -> Operation -> Listener ref cycle
       InitFailed();
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -857,18 +857,17 @@ nsresult nsMsgProtocol::PostMessage(nsIU
 nsresult nsMsgProtocol::DoGSSAPIStep1(const char *service, const char *username, nsCString &response)
 {
     nsresult rv;
 #ifdef DEBUG_BenB
     printf("GSSAPI step 1 for service %s, username %s\n", service, username);
 #endif
 
     // if this fails, then it means that we cannot do GSSAPI SASL.
-    m_authModule = do_CreateInstance(NS_AUTH_MODULE_CONTRACTID_PREFIX "sasl-gssapi", &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
+    m_authModule = nsIAuthModule::CreateInstance("sasl-gssapi");
 
     m_authModule->Init(service, nsIAuthModule::REQ_DEFAULT, nullptr, NS_ConvertUTF8toUTF16(username).get(), nullptr);
 
     void *outBuf;
     uint32_t outBufLen;
     rv = m_authModule->GetNextToken((void *)nullptr, 0, &outBuf, &outBufLen);
     if (NS_SUCCEEDED(rv) && outBuf)
     {
@@ -949,20 +948,17 @@ nsresult nsMsgProtocol::DoGSSAPIStep2(ns
 #endif
     return rv;
 }
 
 nsresult nsMsgProtocol::DoNtlmStep1(const nsACString &username, const nsAString &password, nsCString &response)
 {
     nsresult rv;
 
-    m_authModule = do_CreateInstance(NS_AUTH_MODULE_CONTRACTID_PREFIX "ntlm", &rv);
-    // if this fails, then it means that we cannot do NTLM auth.
-    if (NS_FAILED(rv) || !m_authModule)
-        return rv;
+    m_authModule = nsIAuthModule::CreateInstance("ntlm");
 
     m_authModule->Init(nullptr, 0, nullptr, NS_ConvertUTF8toUTF16(username).get(),
                        PromiseFlatString(password).get());
 
     void *outBuf;
     uint32_t outBufLen;
     rv = m_authModule->GetNextToken((void *)nullptr, 0, &outBuf, &outBufLen);
     if (NS_SUCCEEDED(rv) && outBuf)