1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the Negotiateauth
16 * The Initial Developer of the Original Code is IBM Corporation.
17 * Portions created by the Initial Developer are Copyright (C) 2004
18 * the Initial Developer. All Rights Reserved.
21 * Darin Fisher <darin@meer.net>
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
37 #include "mozilla/ModuleUtils.h"
40 //-----------------------------------------------------------------------------
42 #define NS_HTTPNEGOTIATEAUTH_CID \
43 { /* 75c80fd0-accb-432c-af59-ec60668c3990 */ \
47 {0xaf, 0x59, 0xec, 0x60, 0x66, 0x8c, 0x39, 0x90} \
50 #include "nsHttpNegotiateAuth.h"
51 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpNegotiateAuth
)
52 //-----------------------------------------------------------------------------
54 #define NS_NEGOTIATEAUTH_CID \
55 { /* 96ec4163-efc8-407a-8735-007fb26be4e8 */ \
59 {0x87, 0x35, 0x00, 0x7f, 0xb2, 0x6b, 0xe4, 0xe8} \
61 #define NS_GSSAUTH_CID \
62 { /* dc8e21a0-03e4-11da-8cd6-0800200c9a66 */ \
66 {0x8c, 0xd6, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66} \
69 #include "nsAuthGSSAPI.h"
71 #if defined( USE_SSPI )
72 #include "nsAuthSSPI.h"
75 nsSysNTLMAuthConstructor(nsISupports
*outer
, REFNSIID iid
, void **result
)
78 return NS_ERROR_NO_AGGREGATION
;
80 nsAuthSSPI
*auth
= new nsAuthSSPI(PACKAGE_TYPE_NTLM
);
82 return NS_ERROR_OUT_OF_MEMORY
;
85 nsresult rv
= auth
->QueryInterface(iid
, result
);
91 nsKerbSSPIAuthConstructor(nsISupports
*outer
, REFNSIID iid
, void **result
)
94 return NS_ERROR_NO_AGGREGATION
;
96 nsAuthSSPI
*auth
= new nsAuthSSPI(PACKAGE_TYPE_KERBEROS
);
98 return NS_ERROR_OUT_OF_MEMORY
;
101 nsresult rv
= auth
->QueryInterface(iid
, result
);
106 #define NS_SYSNTLMAUTH_CID \
107 { /* dc195987-6e9a-47bc-b1fd-ab895d398833 */ \
111 {0xb1, 0xfd, 0xab, 0x89, 0x5d, 0x39, 0x88, 0x33} \
114 #define NS_NEGOTIATEAUTHSSPI_CID \
115 { /* 78d3b0c0-0241-11da-8cd6-0800200c9a66 */ \
119 {0x8c, 0xd6, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66} \
122 #define NS_KERBAUTHSSPI_CID \
123 { /* 8c3a0e20-03e5-11da-8cd6-0800200c9a66 */ \
127 {0x8c, 0xd6, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66} \
132 #define NS_SAMBANTLMAUTH_CID \
133 { /* bc54f001-6eb0-4e32-9f49-7e064d8e70ef */ \
137 {0x9f, 0x49, 0x7e, 0x06, 0x4d, 0x8e, 0x70, 0xef} \
140 #include "nsAuthSambaNTLM.h"
142 nsSambaNTLMAuthConstructor(nsISupports
*outer
, REFNSIID iid
, void **result
)
145 return NS_ERROR_NO_AGGREGATION
;
147 nsCOMPtr
<nsAuthSambaNTLM
> auth
= new nsAuthSambaNTLM();
149 return NS_ERROR_OUT_OF_MEMORY
;
151 nsresult rv
= auth
->SpawnNTLMAuthHelper();
153 // Failure here probably means that cached credentials were not available
157 return auth
->QueryInterface(iid
, result
);
163 nsKerbGSSAPIAuthConstructor(nsISupports
*outer
, REFNSIID iid
, void **result
)
166 return NS_ERROR_NO_AGGREGATION
;
168 nsAuthGSSAPI
*auth
= new nsAuthGSSAPI(PACKAGE_TYPE_KERBEROS
);
170 return NS_ERROR_OUT_OF_MEMORY
;
173 nsresult rv
= auth
->QueryInterface(iid
, result
);
179 nsGSSAPIAuthConstructor(nsISupports
*outer
, REFNSIID iid
, void **result
)
182 return NS_ERROR_NO_AGGREGATION
;
184 nsAuthGSSAPI
*auth
= new nsAuthGSSAPI(PACKAGE_TYPE_NEGOTIATE
);
186 return NS_ERROR_OUT_OF_MEMORY
;
189 nsresult rv
= auth
->QueryInterface(iid
, result
);
195 #if defined( USE_SSPI )
196 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthSSPI
)
199 #define NS_AUTHSASL_CID \
200 { /* 815e42e0-72cc-480f-934b-148e33c228a6 */ \
204 {0x93, 0x4b, 0x14, 0x8e, 0x33, 0xc2, 0x28, 0xa6} \
207 #include "nsAuthSASL.h"
208 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthSASL
)
210 NS_DEFINE_NAMED_CID(NS_GSSAUTH_CID
);
211 NS_DEFINE_NAMED_CID(NS_NEGOTIATEAUTH_CID
);
212 #if defined( USE_SSPI )
213 NS_DEFINE_NAMED_CID(NS_NEGOTIATEAUTHSSPI_CID
);
214 NS_DEFINE_NAMED_CID(NS_KERBAUTHSSPI_CID
);
215 NS_DEFINE_NAMED_CID(NS_SYSNTLMAUTH_CID
);
217 NS_DEFINE_NAMED_CID(NS_SAMBANTLMAUTH_CID
);
219 NS_DEFINE_NAMED_CID(NS_HTTPNEGOTIATEAUTH_CID
);
220 NS_DEFINE_NAMED_CID(NS_AUTHSASL_CID
);
223 static const mozilla::Module::CIDEntry kAuthCIDs
[] = {
224 { &kNS_GSSAUTH_CID
, false, NULL
, nsKerbGSSAPIAuthConstructor
},
225 { &kNS_NEGOTIATEAUTH_CID
, false, NULL
, nsGSSAPIAuthConstructor
},
226 #if defined( USE_SSPI )
227 { &kNS_NEGOTIATEAUTHSSPI_CID
, false, NULL
, nsAuthSSPIConstructor
},
228 { &kNS_KERBAUTHSSPI_CID
, false, NULL
, nsKerbSSPIAuthConstructor
},
229 { &kNS_SYSNTLMAUTH_CID
, false, NULL
, nsSysNTLMAuthConstructor
},
231 { &kNS_SAMBANTLMAUTH_CID
, false, NULL
, nsSambaNTLMAuthConstructor
},
233 { &kNS_HTTPNEGOTIATEAUTH_CID
, false, NULL
, nsHttpNegotiateAuthConstructor
},
234 { &kNS_AUTHSASL_CID
, false, NULL
, nsAuthSASLConstructor
},
238 static const mozilla::Module::ContractIDEntry kAuthContracts
[] = {
239 { NS_AUTH_MODULE_CONTRACTID_PREFIX
"kerb-gss", &kNS_GSSAUTH_CID
},
240 { NS_AUTH_MODULE_CONTRACTID_PREFIX
"negotiate-gss", &kNS_NEGOTIATEAUTH_CID
},
241 #if defined( USE_SSPI )
242 { NS_AUTH_MODULE_CONTRACTID_PREFIX
"negotiate-sspi", &kNS_NEGOTIATEAUTHSSPI_CID
},
243 { NS_AUTH_MODULE_CONTRACTID_PREFIX
"kerb-sspi", &kNS_KERBAUTHSSPI_CID
},
244 { NS_AUTH_MODULE_CONTRACTID_PREFIX
"sys-ntlm", &kNS_SYSNTLMAUTH_CID
},
246 { NS_AUTH_MODULE_CONTRACTID_PREFIX
"sys-ntlm", &kNS_SAMBANTLMAUTH_CID
},
248 { NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX
"negotiate", &kNS_HTTPNEGOTIATEAUTH_CID
},
249 { NS_AUTH_MODULE_CONTRACTID_PREFIX
"sasl-gssapi", &kNS_AUTHSASL_CID
},
253 //-----------------------------------------------------------------------------
254 #if defined( PR_LOGGING )
255 PRLogModuleInfo
*gNegotiateLog
;
257 // setup nspr logging ...
261 gNegotiateLog
= PR_NewLogModule("negotiateauth");
265 #define InitNegotiateAuth nsnull
269 DestroyNegotiateAuth()
271 nsAuthGSSAPI::Shutdown();
274 static const mozilla::Module kAuthModule
= {
275 mozilla::Module::kVersion
,
284 NSMODULE_DEFN(nsAuthModule
) = &kAuthModule
;