Attempt at a metadata generation handler.
[shibboleth/sp.git] / shibsp / handler / impl / AssertionConsumerService.cpp
index 0a220f7..18ef907 100644 (file)
@@ -42,6 +42,7 @@
 using namespace samlconstants;
 using opensaml::saml2md::EntityDescriptor;
 using opensaml::saml2md::IDPSSODescriptor;
+using opensaml::saml2md::SPSSODescriptor;
 #else
 # include "lite/CommonDomainCookie.h"
 #endif
@@ -250,6 +251,20 @@ void AssertionConsumerService::checkAddress(
 
 #ifndef SHIBSP_LITE
 
+void AssertionConsumerService::generateMetadata(SPSSODescriptor& role, const char* handlerURL) const {
+    const char* loc = getString("Location").second;
+    string hurl(handlerURL);
+    if (*loc != '/')
+        hurl += '/';
+    hurl += loc;
+    auto_ptr_XMLCh widen(hurl.c_str());
+    saml2md::AssertionConsumerService* ep = saml2md::AssertionConsumerServiceBuilder::buildAssertionConsumerService();
+    ep->setLocation(widen.get());
+    ep->setBinding(getXMLString("Binding").second);
+    ep->setIndex(getXMLString("index").second);
+    role.getAssertionConsumerServices().push_back(ep);
+}
+
 class SHIBSP_DLLLOCAL DummyContext : public ResolutionContext
 {
 public:
@@ -409,19 +424,19 @@ void AssertionConsumerService::extractMessageDetails(const Assertion& assertion,
 
     if (policy.getIssuer() && !policy.getIssuerMetadata() && policy.getMetadataProvider()) {
         m_log.debug("searching metadata for assertion issuer...");
-        const EntityDescriptor* entity = policy.getMetadataProvider()->getEntityDescriptor(policy.getIssuer()->getName());\r
-        if (entity) {\r
-            m_log.debug("matched assertion issuer against metadata, searching for applicable role...");\r
-            const IDPSSODescriptor* idp=entity->getIDPSSODescriptor(protocol);\r
-            if (idp)\r
-                policy.setIssuerMetadata(idp);\r
-            else if (m_log.isWarnEnabled())\r
-                m_log.warn("unable to find compatible IdP role in metadata");\r
-        }\r
-        else if (m_log.isWarnEnabled()) {\r
-            auto_ptr_char iname(policy.getIssuer()->getName());\r
-            m_log.warn("no metadata found, can't establish identity of issuer (%s)", iname.get());\r
-        }\r
+        const EntityDescriptor* entity = policy.getMetadataProvider()->getEntityDescriptor(policy.getIssuer()->getName());
+        if (entity) {
+            m_log.debug("matched assertion issuer against metadata, searching for applicable role...");
+            const IDPSSODescriptor* idp=entity->getIDPSSODescriptor(protocol);
+            if (idp)
+                policy.setIssuerMetadata(idp);
+            else if (m_log.isWarnEnabled())
+                m_log.warn("unable to find compatible IdP role in metadata");
+        }
+        else if (m_log.isWarnEnabled()) {
+            auto_ptr_char iname(policy.getIssuer()->getName());
+            m_log.warn("no metadata found, can't establish identity of issuer (%s)", iname.get());
+        }
     }
 }