Trap known exceptions during request config processing.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 13 Sep 2005 04:54:42 +0000 (04:54 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 13 Sep 2005 04:54:42 +0000 (04:54 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@1802 cb58f699-b61c-0410-a6fe-9272a202ed29

apache/mod_apache.cpp
isapi_shib/isapi_shib.cpp

index bc17e47..461ec90 100644 (file)
@@ -324,9 +324,7 @@ extern "C" int shib_check_user(request_rec* r)
   threadid << "[" << getpid() << "] shib_check_user" << '\0';
   saml::NDC ndc(threadid.str().c_str());
 
-#ifndef _DEBUG
   try {
-#endif
     ShibTargetApache sta(r);
 
     // Check user authentication and export information, then set the handler bypass
@@ -340,9 +338,13 @@ extern "C" int shib_check_user(request_rec* r)
 
     // export happened successfully..  this user is ok.
     return OK;
-
+  }
+  catch (SAMLException& e) {
+    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an exception: %s", e.what());
+    return SERVER_ERROR;
+  }
 #ifndef _DEBUG
-  catch (...) {
+  catch (...) {
     ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an uncaught exception!");
     return SERVER_ERROR;
   }
@@ -373,9 +375,7 @@ extern "C" int shib_handler(request_rec* r)
 
   ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_handler(%d): ENTER: %s", (int)getpid(), r->handler);
 
-#ifndef _DEBUG
   try {
-#endif
     ShibTargetApache sta(r);
 
     pair<bool,void*> res = sta.doHandler();
@@ -383,9 +383,13 @@ extern "C" int shib_handler(request_rec* r)
 
     ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "doHandler() did not do anything.");
     return SERVER_ERROR;
-
+  }
+  catch (SAMLException& e) {
+    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an exception: %s", e.what());
+    return SERVER_ERROR;
+  }
 #ifndef _DEBUG
-  catch (...) {
+  catch (...) {
     ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an uncaught exception!");
     return SERVER_ERROR;
   }
@@ -408,9 +412,7 @@ extern "C" int shib_auth_checker(request_rec* r)
   threadid << "[" << getpid() << "] shib_auth_checker" << '\0';
   saml::NDC ndc(threadid.str().c_str());
 
-#ifndef _DEBUG
   try {
-#endif
     ShibTargetApache sta(r);
 
     pair<bool,void*> res = sta.doCheckAuthZ();
@@ -418,9 +420,13 @@ extern "C" int shib_auth_checker(request_rec* r)
 
     // We're all okay.
     return OK;
-
+  }
+  catch (SAMLException& e) {
+    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an exception: %s", e.what());
+    return SERVER_ERROR;
+  }
 #ifndef _DEBUG
-  catch (...) {
+  catch (...) {
     ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an uncaught exception!");
     return SERVER_ERROR;
   }
index b72de8a..26ba6b5 100644 (file)
@@ -531,15 +531,19 @@ 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
-            return WriteClientError(pfc,"Server detected unexpected IIS error.");
+            return WriteClientError(pfc,"Shibboleth Filter detected unexpected IIS error.");
+    }
+    catch (SAMLException& e) {
+        LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, e.what());
+        return WriteClientError(pfc,"Shibboleth Filter caught an exception, check Event Log for details.");
     }
 #ifndef _DEBUG
     catch(...) {
-        return WriteClientError(pfc,"Server caught an unknown exception.");
+        return WriteClientError(pfc,"Shibboleth Filter caught an unknown exception.");
     }
 #endif
 
-    return WriteClientError(pfc,"Server reached unreachable code, save my walrus!");
+    return WriteClientError(pfc,"Shibboleth Filter reached unreachable code, save my walrus!");
 }
         
 
@@ -771,9 +775,13 @@ extern "C" DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
         else
             return WriteClientError(lpECB,"Server detected unexpected IIS error.");
     }
+    catch (SAMLException& e) {
+        LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, e.what());
+        return WriteClientError(lpECB,"Shibboleth Extension caught an exception, check Event Log for details.");
+    }
 #ifndef _DEBUG
     catch(...) {
-        return WriteClientError(lpECB,"Server caught an unknown exception.");
+        return WriteClientError(lpECB,"Shibboleth Extension caught an unknown exception.");
     }
 #endif