Working version.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Wed, 9 Jul 2003 17:57:15 +0000 (17:57 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Wed, 9 Jul 2003 17:57:15 +0000 (17:57 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@623 cb58f699-b61c-0410-a6fe-9272a202ed29

isapi_shib/cgiparse.c
isapi_shib/isapi_shib.cpp
isapi_shib/isapi_shib.dsp

index b67a004..dd3a3f8 100644 (file)
@@ -61,8 +61,6 @@
 
 #include "cgiparse.h"
 
-__declspec(thread) char* pch=NULL;
-
 /* Parsing routines modified from NCSA source. */
 char *makeword(char *line, char stop)
 {
@@ -81,7 +79,7 @@ char *makeword(char *line, char stop)
     return word;
 }
 
-char *fmakeword(char stop, int *cl)
+char *fmakeword(char stop, int *cl, char** ppch)
 {
     int wsize;
     char *word;
@@ -93,7 +91,7 @@ char *fmakeword(char stop, int *cl)
 
     while(1)
     {
-        word[ll] = *(pch++);
+        word[ll] = *((*ppch)++);
         if(ll==wsize-1)
         {
             word[ll+1] = '\0';
@@ -155,6 +153,7 @@ typedef struct Query
 HQUERY ParseQuery(LPEXTENSION_CONTROL_BLOCK lpECB)
 {
     int cl;
+    char* pch;
     HQUERY hQuery=NULL;
     HQUERY hLast=NULL;
 
@@ -190,7 +189,7 @@ HQUERY ParseQuery(LPEXTENSION_CONTROL_BLOCK lpECB)
         }
 
         /* hLast is now the current block to use. */
-        hLast->value=fmakeword('&',&cl);
+        hLast->value=fmakeword('&',&cl,&pch);
         plustospace(hLast->value);
         unescape_url(hLast->value);
         hLast->name=makeword(hLast->value,'=');
index 422b62b..a4bd936 100644 (file)
@@ -144,6 +144,7 @@ extern "C" BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer)
 
     try
     {
+        ShibTargetConfig::preinit();
         g_Config = &(ShibTargetConfig::init(SHIBTARGET_SHIRE, getenv("SHIBCONFIG")));
         ShibINI& ini = g_Config->getINI();
 
@@ -196,10 +197,9 @@ extern "C" BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer)
                 "Filter startup failed with SAML exception, check shire log for help.");
         return FALSE;
     }
-    catch (...)
+    catch (runtime_error& e)
     {
-        LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL,
-                "Filter startup failed with unexpected exception, check shire log for help.");
+        LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, e.what());
         return FALSE;
     }
 
@@ -673,9 +673,9 @@ extern "C" DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificat
         {
             string assertion;
             RM::serialize(*(assertions[0]), assertion);
-//            string::size_type lfeed;
-//            while ((lfeed=exp.find('\n'))!=string::npos)
-//                exp.erase(lfeed,1);
+            string::size_type lfeed;
+            while ((lfeed=assertion.find('\n'))!=string::npos)
+                assertion.erase(lfeed,1);
             pn->SetHeader(pfc,"Shib-Attributes:",const_cast<char*>(assertion.c_str()));
         }
         
@@ -723,7 +723,8 @@ extern "C" DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificat
                         else
                             header=header + ';' + value;
                     }
-                    pn->SetHeader(pfc,const_cast<char*>(hname),const_cast<char*>(header.c_str()));
+                    string hname2=string(hname) + ':';
+                    pn->SetHeader(pfc,const_cast<char*>(hname2.c_str()),const_cast<char*>(header.c_str()));
                 }
             }
         }
@@ -744,11 +745,11 @@ extern "C" DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificat
         if (e==ERROR_NO_DATA)
             return WriteClientError(pfc,"A required variable or header was empty.");
         else
-            WriteClientError(pfc,"Server detected unexpected IIS error.");
+            return WriteClientError(pfc,"Server detected unexpected IIS error.");
     }
     catch(...)
     {
-        WriteClientError(pfc,"Server caught an unknown exception.");
+        return WriteClientError(pfc,"Server caught an unknown exception.");
     }
 
     return WriteClientError(pfc,"Server reached unreachable code!");
index f9da957..78846eb 100644 (file)
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 log4cpp.lib xerces-c_2.lib xsec_lib_02.lib advapi32.lib kernel32.lib saml.lib /nologo /dll /machine:I386 /libpath:"C:\log4cpp\lib" /libpath:"C:\xerces-c\lib" /libpath:"..\..\..\opensaml\c\saml\Release" /export:TerminateFilter /export:HttpFilterProc /export:GetFilterVersion
+# ADD LINK32 log4cpp.lib xerces-c_2.lib xsec_lib_02.lib advapi32.lib kernel32.lib saml.lib /nologo /dll /machine:I386 /libpath:"C:\log4cpp\lib" /libpath:"C:\xerces-c\lib" /libpath:"..\..\..\opensaml\c\saml\Release" /export:GetExtensionVersion /export:GetFilterVersion /export:TerminateExtension /export:TerminateFilter /export:HttpFilterProc /export:HttpExtensionProc
 # SUBTRACT LINK32 /pdb:none
 
 !ELSEIF  "$(CFG)" == "isapi_shib - Win32 Debug"
@@ -80,7 +80,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 log4cppD.lib xerces-c_2D.lib xsec_lib_02D.lib advapi32.lib kernel32.lib saml.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"C:\debug\log4cpp\lib" /libpath:"C:\debug\xerces-c\lib" /libpath:"..\..\..\opensaml\c\saml\Debug" /export:TerminateFilter /export:HttpFilterProc /export:GetFilterVersion
+# ADD LINK32 log4cppD.lib xerces-c_2D.lib xsec_lib_02D.lib advapi32.lib kernel32.lib saml.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"C:\debug\log4cpp\lib" /libpath:"C:\debug\xerces-c\lib" /libpath:"..\..\..\opensaml\c\saml\Debug" /export:GetExtensionVersion /export:GetFilterVersion /export:TerminateExtension /export:TerminateFilter /export:HttpFilterProc /export:HttpExtensionProc
 # SUBTRACT LINK32 /pdb:none
 
 !ENDIF