Back to index

lightning-sunbird  0.9+nobinonly
nsNegotiateAuthFactory.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Negotiateauth
00015  *
00016  * The Initial Developer of the Original Code is IBM Corporation.
00017  * Portions created by the Initial Developer are Copyright (C) 2004
00018  * the Initial Developer. All Rights Reserved.
00019  *
00020  * Contributor(s):
00021  *   Darin Fisher <darin@meer.net>
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #include "nsIGenericFactory.h"
00038 #include "nsNegotiateAuth.h"
00039 
00040 //-----------------------------------------------------------------------------
00041 
00042 #define NS_HTTPNEGOTIATEAUTH_CID                   \
00043 { /* 75c80fd0-accb-432c-af59-ec60668c3990 */       \
00044   0x75c80fd0,                                      \
00045   0xaccb,                                          \
00046   0x432c,                                          \
00047   {0xaf, 0x59, 0xec, 0x60, 0x66, 0x8c, 0x39, 0x90} \
00048 }
00049 
00050 #include "nsHttpNegotiateAuth.h"
00051 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpNegotiateAuth)
00052 
00053 //-----------------------------------------------------------------------------
00054 
00055 #define NS_NEGOTIATEAUTH_CID                       \
00056 { /* 96ec4163-efc8-407a-8735-007fb26be4e8 */       \
00057   0x96ec4163,                                      \
00058   0xefc8,                                          \
00059   0x407a,                                          \
00060   {0x87, 0x35, 0x00, 0x7f, 0xb2, 0x6b, 0xe4, 0xe8} \
00061 }
00062 
00063 #if defined( USE_GSSAPI )
00064 #include "nsNegotiateAuthGSSAPI.h"
00065 
00066 #elif defined( USE_SSPI )
00067 #include "nsNegotiateAuthSSPI.h"
00068 
00069 static NS_METHOD
00070 nsSysNTLMAuthConstructor(nsISupports *outer, REFNSIID iid, void **result)
00071 {
00072   if (outer)
00073     return NS_ERROR_NO_AGGREGATION;
00074 
00075   nsNegotiateAuth *auth = new nsNegotiateAuth(PR_TRUE);
00076   if (!auth)
00077     return NS_ERROR_OUT_OF_MEMORY;
00078   
00079   NS_ADDREF(auth);
00080   nsresult rv = auth->QueryInterface(iid, result);
00081   NS_RELEASE(auth);
00082   return rv;
00083 }
00084 
00085 #define NS_SYSNTLMAUTH_CID                         \
00086 { /* dc195987-6e9a-47bc-b1fd-ab895d398833 */       \
00087   0xdc195987,                                      \
00088   0x6e9a,                                          \
00089   0x47bc,                                          \
00090   {0xb1, 0xfd, 0xab, 0x89, 0x5d, 0x39, 0x88, 0x33} \
00091 }
00092 
00093 #else
00094 #error "missing implementation"
00095 #endif
00096 
00097 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNegotiateAuth)
00098 
00099 
00100 //-----------------------------------------------------------------------------
00101 
00102 static nsModuleComponentInfo components[] = {
00103   { "nsNegotiateAuth", 
00104     NS_NEGOTIATEAUTH_CID,
00105     NS_AUTH_MODULE_CONTRACTID_PREFIX "negotiate",
00106     nsNegotiateAuthConstructor
00107   },
00108 #if defined( USE_SSPI )
00109   { "nsNegotiateAuthNTLM", 
00110     NS_SYSNTLMAUTH_CID,
00111     NS_AUTH_MODULE_CONTRACTID_PREFIX "sys-ntlm",
00112     nsSysNTLMAuthConstructor
00113   },
00114 #endif
00115   { "nsHttpNegotiateAuth", 
00116     NS_HTTPNEGOTIATEAUTH_CID,
00117     NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "negotiate",
00118     nsHttpNegotiateAuthConstructor
00119   }
00120 };
00121 
00122 //-----------------------------------------------------------------------------
00123 
00124 #if defined( PR_LOGGING )
00125 PRLogModuleInfo *gNegotiateLog;
00126 
00127 // setup nspr logging ...
00128 PR_STATIC_CALLBACK(nsresult)
00129 InitNegotiateAuth(nsIModule *self)
00130 {
00131   gNegotiateLog = PR_NewLogModule("negotiateauth");
00132   return NS_OK;
00133 }
00134 #else
00135 #define InitNegotiateAuth nsnull
00136 #endif
00137 
00138 NS_IMPL_NSGETMODULE_WITH_CTOR(nsNegotiateAuthModule, components, InitNegotiateAuth)