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 "nsIGenericFactory.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 //-----------------------------------------------------------------------------
212 static nsModuleComponentInfo components
[] = {
215 NS_AUTH_MODULE_CONTRACTID_PREFIX
"kerb-gss",
216 nsKerbGSSAPIAuthConstructor
218 { "nsAuthNegoGSSAPI",
219 NS_NEGOTIATEAUTH_CID
,
220 NS_AUTH_MODULE_CONTRACTID_PREFIX
"negotiate-gss",
221 nsGSSAPIAuthConstructor
223 #if defined( USE_SSPI )
225 NS_NEGOTIATEAUTHSSPI_CID
,
226 NS_AUTH_MODULE_CONTRACTID_PREFIX
"negotiate-sspi",
227 nsAuthSSPIConstructor
231 NS_AUTH_MODULE_CONTRACTID_PREFIX
"kerb-sspi",
232 nsKerbSSPIAuthConstructor
236 NS_AUTH_MODULE_CONTRACTID_PREFIX
"sys-ntlm",
237 nsSysNTLMAuthConstructor
241 NS_SAMBANTLMAUTH_CID
,
242 NS_AUTH_MODULE_CONTRACTID_PREFIX
"sys-ntlm",
243 nsSambaNTLMAuthConstructor
246 { "nsHttpNegotiateAuth",
247 NS_HTTPNEGOTIATEAUTH_CID
,
248 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX
"negotiate",
249 nsHttpNegotiateAuthConstructor
253 NS_AUTH_MODULE_CONTRACTID_PREFIX
"sasl-gssapi",
254 nsAuthSASLConstructor
258 //-----------------------------------------------------------------------------
259 #if defined( PR_LOGGING )
260 PRLogModuleInfo
*gNegotiateLog
;
262 // setup nspr logging ...
263 PR_STATIC_CALLBACK(nsresult
)
264 InitNegotiateAuth(nsIModule
*self
)
266 gNegotiateLog
= PR_NewLogModule("negotiateauth");
270 #define InitNegotiateAuth nsnull
273 PR_STATIC_CALLBACK(void)
274 DestroyNegotiateAuth(nsIModule
*self
)
276 nsAuthGSSAPI::Shutdown();
279 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsAuthModule
, components
,
280 InitNegotiateAuth
, DestroyNegotiateAuth
)