CPPOST-15 - Adds APIs to support advanced metadata providers.
[shibboleth/cpp-sp.git] / shibsp / handler / impl / StatusHandler.cpp
index 5a5a11b..41e9f1f 100644 (file)
@@ -31,6 +31,7 @@
 using namespace shibsp;
 #ifndef SHIBSP_LITE
 # include "SessionCache.h"
+# include "metadata/MetadataProviderCriteria.h"
 # include <saml/version.h>
 using namespace opensaml::saml2md;
 using namespace opensaml;
@@ -421,7 +422,18 @@ pair<bool,long> StatusHandler::processMessage(
             status = "<Partial/>";
         }
 
-        s << "<Application id='" << application.getId() << "' entityID='" << application.getString("entityID").second << "'/>";
+        const PropertySet* relyingParty=NULL;
+        param=httpRequest.getParameter("entityID");
+        if (param) {
+            MetadataProvider* m = application.getMetadataProvider();
+            Locker mlock(m);
+            relyingParty = application.getRelyingParty(m->getEntityDescriptor(MetadataProviderCriteria(application, param)).first);
+        }
+        else {
+            relyingParty = &application;
+        }
+
+        s << "<Application id='" << application.getId() << "' entityID='" << relyingParty->getString("entityID").second << "'/>";
 
         s << "<Handlers>";
         vector<const Handler*> handlers;
@@ -434,15 +446,6 @@ pair<bool,long> StatusHandler::processMessage(
         }
         s << "</Handlers>";
 
-        const PropertySet* relyingParty=NULL;
-        param=httpRequest.getParameter("entityID");
-        if (param) {
-            MetadataProvider* m = application.getMetadataProvider();
-            Locker mlock(m);
-            relyingParty = application.getRelyingParty(m->getEntityDescriptor(MetadataProvider::Criteria(param)).first);
-        }
-        if (!relyingParty)
-            relyingParty = application.getRelyingParty(NULL);
         CredentialResolver* credResolver=application.getCredentialResolver();
         if (credResolver) {
             Locker credLocker(credResolver);