1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsIAuthModule.h"
7 # include "nsAuthSSPI.h"
9 # include "nsAuthSambaNTLM.h"
12 #include "nsAuthGSSAPI.h"
13 #include "nsAuthSASL.h"
14 #include "nsNTLMAuthModule.h"
15 #include "nsNSSComponent.h"
18 already_AddRefed
<nsIAuthModule
> nsIAuthModule::CreateInstance(
20 nsCOMPtr
<nsIAuthModule
> auth
;
21 if (!nsCRT::strcmp(aType
, "kerb-gss")) {
22 auth
= new nsAuthGSSAPI(PACKAGE_TYPE_KERBEROS
);
23 } else if (!nsCRT::strcmp(aType
, "negotiate-gss")) {
24 auth
= new nsAuthGSSAPI(PACKAGE_TYPE_NEGOTIATE
);
26 } else if (!nsCRT::strcmp(aType
, "negotiate-sspi")) {
27 auth
= new nsAuthSSPI();
28 } else if (!nsCRT::strcmp(aType
, "kerb-sspi")) {
29 auth
= new nsAuthSSPI(PACKAGE_TYPE_KERBEROS
);
30 } else if (!nsCRT::strcmp(aType
, "sys-ntlm")) {
31 auth
= new nsAuthSSPI(PACKAGE_TYPE_NTLM
);
32 #elif !defined(XP_MACOSX)
33 } else if (!nsCRT::strcmp(aType
, "sys-ntlm")) {
34 RefPtr
<nsAuthSambaNTLM
> sambaAuth
= new nsAuthSambaNTLM();
36 nsresult rv
= sambaAuth
->SpawnNTLMAuthHelper();
38 // Failure here probably means that cached credentials were not available
42 auth
= std::move(sambaAuth
);
44 } else if (!nsCRT::strcmp(aType
, "sasl-gssapi")) {
45 auth
= new nsAuthSASL();
46 } else if (!nsCRT::strcmp(aType
, "ntlm") && XRE_IsParentProcess() &&
47 EnsureNSSInitializedChromeOrContent()) {
48 RefPtr
<nsNTLMAuthModule
> ntlmAuth
= new nsNTLMAuthModule();
50 nsresult rv
= ntlmAuth
->InitTest();
55 auth
= std::move(ntlmAuth
);
63 mozilla::LazyLogModule
gNegotiateLog("negotiateauth");