Shift property set logging to its own category.
[shibboleth/sp.git] / shibsp / handler / impl / AbstractHandler.cpp
index e1f3801..3f2e0da 100644 (file)
@@ -66,6 +66,7 @@ namespace shibsp {
     SHIBSP_DLLLOCAL PluginManager< Handler,string,pair<const DOMElement*,const char*> >::Factory AssertionLookupFactory;
     SHIBSP_DLLLOCAL PluginManager< Handler,string,pair<const DOMElement*,const char*> >::Factory MetadataGeneratorFactory;
     SHIBSP_DLLLOCAL PluginManager< Handler,string,pair<const DOMElement*,const char*> >::Factory StatusHandlerFactory;
+    SHIBSP_DLLLOCAL PluginManager< Handler,string,pair<const DOMElement*,const char*> >::Factory SessionHandlerFactory;
 };
 
 void SHIBSP_API shibsp::registerHandlers()
@@ -82,8 +83,9 @@ void SHIBSP_API shibsp::registerHandlers()
     conf.ArtifactResolutionServiceManager.registerFactory(SAML20_BINDING_SOAP, SAML2ArtifactResolutionFactory);
 
     conf.HandlerManager.registerFactory(SAML20_BINDING_URI, AssertionLookupFactory);
-    conf.HandlerManager.registerFactory("MetadataGenerator", MetadataGeneratorFactory);
-    conf.HandlerManager.registerFactory("Status", StatusHandlerFactory);
+    conf.HandlerManager.registerFactory(METADATA_GENERATOR_HANDLER, MetadataGeneratorFactory);
+    conf.HandlerManager.registerFactory(STATUS_HANDLER, StatusHandlerFactory);
+    conf.HandlerManager.registerFactory(SESSION_HANDLER, SessionHandlerFactory);
 
     conf.LogoutInitiatorManager.registerFactory(CHAINING_LOGOUT_INITIATOR, ChainingLogoutInitiatorFactory);
     conf.LogoutInitiatorManager.registerFactory(LOCAL_LOGOUT_INITIATOR, LocalLogoutInitiatorFactory);
@@ -104,7 +106,7 @@ void SHIBSP_API shibsp::registerHandlers()
 AbstractHandler::AbstractHandler(
     const DOMElement* e, Category& log, DOMNodeFilter* filter, const map<string,string>* remapper
     ) : m_log(log), m_configNS(shibspconstants::SHIB2SPCONFIG_NS) {
-    load(e,log,filter,remapper);
+    load(e,NULL,filter,remapper);
 }
 
 #ifndef SHIBSP_LITE
@@ -300,7 +302,9 @@ void AbstractHandler::preserveRelayState(const Application& application, HTTPRes
         throw ConfigurationException("Unsupported relayState mechanism ($1).", params(1,mech.second));
 }
 
-void AbstractHandler::recoverRelayState(const Application& application, HTTPRequest& httpRequest, string& relayState, bool clear) const
+void AbstractHandler::recoverRelayState(
+    const Application& application, const HTTPRequest& request, HTTPResponse& response, string& relayState, bool clear
+    ) const
 {
     SPConfig& conf = SPConfig::getConfig();
 
@@ -354,34 +358,30 @@ void AbstractHandler::recoverRelayState(const Application& application, HTTPRequ
         }
     }
     
-    if (conf.isEnabled(SPConfig::InProcess)) {
-        if (relayState == "cookie") {
-            // Pull the value from the "relay state" cookie.
-            pair<string,const char*> relay_cookie = application.getCookieNameProps("_shibstate_");
-            // In process, we should be able to cast down to a full SPRequest.
-            SPRequest& request = dynamic_cast<SPRequest&>(httpRequest);
-            const char* state = request.getCookie(relay_cookie.first.c_str());
-            if (state && *state) {
-                // URL-decode the value.
-                char* rscopy=strdup(state);
-                XMLToolingConfig::getConfig().getURLEncoder()->decode(rscopy);
-                relayState = rscopy;
-                free(rscopy);
-                
-                if (clear)
-                    request.setCookie(relay_cookie.first.c_str(),relay_cookie.second);
-                return;
-            }
-
-            relayState.erase();
-        }
-
-        // Check for "default" value.
-        if (relayState.empty() || relayState == "default") {
-            pair<bool,const char*> homeURL=application.getString("homeURL");
-            relayState=homeURL.first ? homeURL.second : "/";
+    if (relayState == "cookie") {
+        // Pull the value from the "relay state" cookie.
+        pair<string,const char*> relay_cookie = application.getCookieNameProps("_shibstate_");
+        const char* state = request.getCookie(relay_cookie.first.c_str());
+        if (state && *state) {
+            // URL-decode the value.
+            char* rscopy=strdup(state);
+            XMLToolingConfig::getConfig().getURLEncoder()->decode(rscopy);
+            relayState = rscopy;
+            free(rscopy);
+            
+            if (clear)
+                response.setCookie(relay_cookie.first.c_str(),relay_cookie.second);
             return;
         }
+
+        relayState.erase();
+    }
+
+    // Check for "default" value.
+    if (relayState.empty() || relayState == "default") {
+        pair<bool,const char*> homeURL=application.getString("homeURL");
+        relayState=homeURL.first ? homeURL.second : "/";
+        return;
     }
 
     if (relayState == "default")