Bug 496271, automation config for Tb2.0.0.22 build1, p=joduinn, r=me
[mozilla-1.9.git] / extensions / auth / nsAuthFactory.cpp
blob711f26980fbc54bb91dbfeb5d29c152a90a4d2b6
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
12 * License.
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.
20 * Contributor(s):
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"
38 #include "nsAuth.h"
40 //-----------------------------------------------------------------------------
42 #define NS_HTTPNEGOTIATEAUTH_CID \
43 { /* 75c80fd0-accb-432c-af59-ec60668c3990 */ \
44 0x75c80fd0, \
45 0xaccb, \
46 0x432c, \
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 */ \
56 0x96ec4163, \
57 0xefc8, \
58 0x407a, \
59 {0x87, 0x35, 0x00, 0x7f, 0xb2, 0x6b, 0xe4, 0xe8} \
61 #define NS_GSSAUTH_CID \
62 { /* dc8e21a0-03e4-11da-8cd6-0800200c9a66 */ \
63 0xdc8e21a0, \
64 0x03e4, \
65 0x11da, \
66 {0x8c, 0xd6, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66} \
69 #include "nsAuthGSSAPI.h"
71 #if defined( USE_SSPI )
72 #include "nsAuthSSPI.h"
74 static NS_METHOD
75 nsSysNTLMAuthConstructor(nsISupports *outer, REFNSIID iid, void **result)
77 if (outer)
78 return NS_ERROR_NO_AGGREGATION;
80 nsAuthSSPI *auth = new nsAuthSSPI(PACKAGE_TYPE_NTLM);
81 if (!auth)
82 return NS_ERROR_OUT_OF_MEMORY;
84 NS_ADDREF(auth);
85 nsresult rv = auth->QueryInterface(iid, result);
86 NS_RELEASE(auth);
87 return rv;
90 static NS_METHOD
91 nsKerbSSPIAuthConstructor(nsISupports *outer, REFNSIID iid, void **result)
93 if (outer)
94 return NS_ERROR_NO_AGGREGATION;
96 nsAuthSSPI *auth = new nsAuthSSPI(PACKAGE_TYPE_KERBEROS);
97 if (!auth)
98 return NS_ERROR_OUT_OF_MEMORY;
100 NS_ADDREF(auth);
101 nsresult rv = auth->QueryInterface(iid, result);
102 NS_RELEASE(auth);
103 return rv;
106 #define NS_SYSNTLMAUTH_CID \
107 { /* dc195987-6e9a-47bc-b1fd-ab895d398833 */ \
108 0xdc195987, \
109 0x6e9a, \
110 0x47bc, \
111 {0xb1, 0xfd, 0xab, 0x89, 0x5d, 0x39, 0x88, 0x33} \
114 #define NS_NEGOTIATEAUTHSSPI_CID \
115 { /* 78d3b0c0-0241-11da-8cd6-0800200c9a66 */ \
116 0x78d3b0c0, \
117 0x0241, \
118 0x11da, \
119 {0x8c, 0xd6, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66} \
122 #define NS_KERBAUTHSSPI_CID \
123 { /* 8c3a0e20-03e5-11da-8cd6-0800200c9a66 */ \
124 0x8c3a0e20, \
125 0x03e5, \
126 0x11da, \
127 {0x8c, 0xd6, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66} \
130 #else
132 #define NS_SAMBANTLMAUTH_CID \
133 { /* bc54f001-6eb0-4e32-9f49-7e064d8e70ef */ \
134 0xbc54f001, \
135 0x6eb0, \
136 0x4e32, \
137 {0x9f, 0x49, 0x7e, 0x06, 0x4d, 0x8e, 0x70, 0xef} \
140 #include "nsAuthSambaNTLM.h"
141 static NS_METHOD
142 nsSambaNTLMAuthConstructor(nsISupports *outer, REFNSIID iid, void **result)
144 if (outer)
145 return NS_ERROR_NO_AGGREGATION;
147 nsCOMPtr<nsAuthSambaNTLM> auth = new nsAuthSambaNTLM();
148 if (!auth)
149 return NS_ERROR_OUT_OF_MEMORY;
151 nsresult rv = auth->SpawnNTLMAuthHelper();
152 if (NS_FAILED(rv)) {
153 // Failure here probably means that cached credentials were not available
154 return rv;
157 return auth->QueryInterface(iid, result);
160 #endif
162 static NS_METHOD
163 nsKerbGSSAPIAuthConstructor(nsISupports *outer, REFNSIID iid, void **result)
165 if (outer)
166 return NS_ERROR_NO_AGGREGATION;
168 nsAuthGSSAPI *auth = new nsAuthGSSAPI(PACKAGE_TYPE_KERBEROS);
169 if (!auth)
170 return NS_ERROR_OUT_OF_MEMORY;
172 NS_ADDREF(auth);
173 nsresult rv = auth->QueryInterface(iid, result);
174 NS_RELEASE(auth);
175 return rv;
178 static NS_METHOD
179 nsGSSAPIAuthConstructor(nsISupports *outer, REFNSIID iid, void **result)
181 if (outer)
182 return NS_ERROR_NO_AGGREGATION;
184 nsAuthGSSAPI *auth = new nsAuthGSSAPI(PACKAGE_TYPE_NEGOTIATE);
185 if (!auth)
186 return NS_ERROR_OUT_OF_MEMORY;
188 NS_ADDREF(auth);
189 nsresult rv = auth->QueryInterface(iid, result);
190 NS_RELEASE(auth);
191 return rv;
195 #if defined( USE_SSPI )
196 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthSSPI)
197 #endif
199 #define NS_AUTHSASL_CID \
200 { /* 815e42e0-72cc-480f-934b-148e33c228a6 */ \
201 0x815e42e0, \
202 0x72cc, \
203 0x480f, \
204 {0x93, 0x4b, 0x14, 0x8e, 0x33, 0xc2, 0x28, 0xa6} \
207 #include "nsAuthSASL.h"
208 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthSASL)
210 //-----------------------------------------------------------------------------
212 static nsModuleComponentInfo components[] = {
213 { "nsAuthKerbGSS",
214 NS_GSSAUTH_CID,
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 )
224 { "nsAuthNegoSSPI",
225 NS_NEGOTIATEAUTHSSPI_CID,
226 NS_AUTH_MODULE_CONTRACTID_PREFIX "negotiate-sspi",
227 nsAuthSSPIConstructor
229 { "nsAuthKerbSSPI",
230 NS_KERBAUTHSSPI_CID,
231 NS_AUTH_MODULE_CONTRACTID_PREFIX "kerb-sspi",
232 nsKerbSSPIAuthConstructor
234 { "nsAuthSYSNTLM",
235 NS_SYSNTLMAUTH_CID,
236 NS_AUTH_MODULE_CONTRACTID_PREFIX "sys-ntlm",
237 nsSysNTLMAuthConstructor
239 #else
240 { "nsAuthSambaNTLM",
241 NS_SAMBANTLMAUTH_CID,
242 NS_AUTH_MODULE_CONTRACTID_PREFIX "sys-ntlm",
243 nsSambaNTLMAuthConstructor
245 #endif
246 { "nsHttpNegotiateAuth",
247 NS_HTTPNEGOTIATEAUTH_CID,
248 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "negotiate",
249 nsHttpNegotiateAuthConstructor
251 { "nsAuthSASL",
252 NS_AUTHSASL_CID,
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");
267 return NS_OK;
269 #else
270 #define InitNegotiateAuth nsnull
271 #endif
273 PR_STATIC_CALLBACK(void)
274 DestroyNegotiateAuth(nsIModule *self)
276 nsAuthGSSAPI::Shutdown();
279 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsAuthModule, components,
280 InitNegotiateAuth, DestroyNegotiateAuth)