https://issues.shibboleth.net/jira/browse/SSPCPP-229
authorScott Cantor <cantor.2@osu.edu>
Wed, 30 Sep 2009 21:36:40 +0000 (21:36 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 30 Sep 2009 21:36:40 +0000 (21:36 +0000)
shibsp/handler/impl/SAMLDSSessionInitiator.cpp
shibsp/handler/impl/WAYFSessionInitiator.cpp

index 5ff0878..e2ada3a 100644 (file)
@@ -122,6 +122,7 @@ pair<bool,long> SAMLDSSessionInitiator::run(SPRequest& request, string& entityID
     const char* option;
     bool isPassive=false;
     const Application& app=request.getApplication();
+    pair<bool,const char*> discoveryURL = pair<bool,const char*>(true, m_url);
 
     if (isHandler) {
         option = request.getParameter("SAMLDS");
@@ -140,6 +141,10 @@ pair<bool,long> SAMLDSSessionInitiator::run(SPRequest& request, string& entityID
         option = request.getParameter("isPassive");
         if (option)
             isPassive = !strcmp(option,"true");
+
+        option = request.getParameter("discoveryURL");
+        if (option)
+            discoveryURL.second = option;
     }
     else {
         // We're running as a "virtual handler" from within the filter.
@@ -148,9 +153,12 @@ pair<bool,long> SAMLDSSessionInitiator::run(SPRequest& request, string& entityID
         target=request.getRequestURL();
         pair<bool,bool> passopt = getBool("isPassive");
         isPassive = passopt.first && passopt.second;
+        discoveryURL = request.getRequestSettings().first->getString("discoveryURL");
     }
 
-    m_log.debug("sending request to SAMLDS (%s)", m_url);
+    if (!discoveryURL.first)
+        discoveryURL.second = m_url;
+    m_log.debug("sending request to SAMLDS (%s)", discoveryURL.second);
 
     // Compute the return URL. We start with a self-referential link.
     string returnURL=request.getHandlerURL(target.c_str());
@@ -212,7 +220,7 @@ pair<bool,long> SAMLDSSessionInitiator::run(SPRequest& request, string& entityID
         returnURL = returnURL + "&target=" + urlenc->encode(target.c_str());;
     }
 
-    string req=string(m_url) + (strchr(m_url,'?') ? '&' : '?') + "entityID=" + urlenc->encode(app.getString("entityID").second) +
+    string req=string(discoveryURL.second) + (strchr(discoveryURL.second,'?') ? '&' : '?') + "entityID=" + urlenc->encode(app.getString("entityID").second) +
         "&return=" + urlenc->encode(returnURL.c_str());
     if (m_returnParam)
         req = req + "&returnIDParam=" + m_returnParam;
index fb198f3..d76ed7b 100644 (file)
@@ -84,6 +84,7 @@ pair<bool,long> WAYFSessionInitiator::run(SPRequest& request, string& entityID,
     const char* option;
     const Handler* ACS=NULL;
     const Application& app=request.getApplication();
+    pair<bool,const char*> discoveryURL = pair<bool,const char*>(true, m_url);
 
     if (isHandler) {
         option=request.getParameter("acsIndex");
@@ -97,11 +98,16 @@ pair<bool,long> WAYFSessionInitiator::run(SPRequest& request, string& entityID,
         if (option)
             target = option;
         recoverRelayState(request.getApplication(), request, request, target, false);
+
+        option = request.getParameter("discoveryURL");
+        if (option)
+            discoveryURL.second = option;
     }
     else {
         // We're running as a "virtual handler" from within the filter.
         // The target resource is the current one and everything else is defaulted.
         target=request.getRequestURL();
+        discoveryURL = request.getRequestSettings().first->getString("discoveryURL");
     }
     
     // Since we're not passing by index, we need to fully compute the return URL.
@@ -131,7 +137,9 @@ pair<bool,long> WAYFSessionInitiator::run(SPRequest& request, string& entityID,
         }
     }
 
-    m_log.debug("sending request to WAYF (%s)", m_url);
+    if (!discoveryURL.first)
+        discoveryURL.second = m_url;
+    m_log.debug("sending request to WAYF (%s)", discoveryURL.second);
 
     // Compute the ACS URL. We add the ACS location to the base handlerURL.
     string ACSloc=request.getHandlerURL(target.c_str());
@@ -156,7 +164,7 @@ pair<bool,long> WAYFSessionInitiator::run(SPRequest& request, string& entityID,
     char timebuf[16];
     sprintf(timebuf,"%lu",time(NULL));
     const URLEncoder* urlenc = XMLToolingConfig::getConfig().getURLEncoder();
-    string req=string(m_url) + (strchr(m_url,'?') ? '&' : '?') + "shire=" + urlenc->encode(ACSloc.c_str()) +
+    string req=string(discoveryURL.second) + (strchr(discoveryURL.second,'?') ? '&' : '?') + "shire=" + urlenc->encode(ACSloc.c_str()) +
         "&time=" + timebuf + "&target=" + urlenc->encode(target.c_str()) +
         "&providerId=" + urlenc->encode(app.getString("entityID").second);