Support metadata generation in chained handlers.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Mon, 24 Dec 2007 22:30:49 +0000 (22:30 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Mon, 24 Dec 2007 22:30:49 +0000 (22:30 +0000)
Add metadata for DS handler.

git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2680 cb58f699-b61c-0410-a6fe-9272a202ed29

shibsp/handler/impl/ChainingLogoutInitiator.cpp
shibsp/handler/impl/ChainingSessionInitiator.cpp
shibsp/handler/impl/SAMLDSSessionInitiator.cpp

index 4d1e434..e8de4d6 100644 (file)
@@ -54,6 +54,11 @@ namespace shibsp {
         const char* getType() const {
             return "LogoutInitiator";
         }
+
+        void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const {
+            for (vector<Handler*>::const_iterator i = m_handlers.begin(); i!=m_handlers.end(); ++i)
+                (*i)->generateMetadata(role, handlerURL);
+        }
 #endif
 
     private:
index 951d790..a5f1235 100644 (file)
@@ -50,6 +50,13 @@ namespace shibsp {
         
         pair<bool,long> run(SPRequest& request, const char* entityID=NULL, bool isHandler=true) const;
 
+#ifndef SHIBSP_LITE
+        void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const {
+            for (vector<SessionInitiator*>::const_iterator i = m_handlers.begin(); i!=m_handlers.end(); ++i)
+                (*i)->generateMetadata(role, handlerURL);
+        }
+#endif
+
     private:
         vector<SessionInitiator*> m_handlers;
     };
index 20b1ff4..6084d76 100644 (file)
@@ -28,6 +28,7 @@
 #include "handler/SessionInitiator.h"
 
 #include <xmltooling/XMLToolingConfig.h>
+#include <xmltooling/impl/AnyElement.h>
 #include <xmltooling/util/URLEncoder.h>
 
 using namespace shibsp;
@@ -35,6 +36,10 @@ using namespace opensaml;
 using namespace xmltooling;
 using namespace std;
 
+#ifndef SHIBSP_LITE
+using namespace opensaml::saml2md;
+#endif
+
 namespace shibsp {
 
 #if defined (_MSC_VER)
@@ -46,7 +51,11 @@ namespace shibsp {
     {
     public:
         SAMLDSSessionInitiator(const DOMElement* e, const char* appId)
-                : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".SessionInitiator.SAMLDS")), m_url(NULL), m_returnParam(NULL) {
+                : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".SessionInitiator.SAMLDS")), m_url(NULL), m_returnParam(NULL)
+#ifndef SHIBSP_LITE
+                    ,m_discoNS("urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol")
+#endif
+        {
             pair<bool,const char*> url = getString("URL");
             if (!url.first)
                 throw ConfigurationException("SAMLDS SessionInitiator requires a URL property.");
@@ -59,9 +68,36 @@ namespace shibsp {
         
         pair<bool,long> run(SPRequest& request, const char* entityID=NULL, bool isHandler=true) const;
 
+#ifndef SHIBSP_LITE
+        void generateMetadata(SPSSODescriptor& role, const char* handlerURL) const {
+            static const XMLCh LOCAL_NAME[] = UNICODE_LITERAL_17(D,i,s,c,o,v,e,r,y,R,e,s,p,o,n,s,e);
+            const char* loc = getString("Location").second;
+            string hurl(handlerURL);
+            if (*loc != '/')
+                hurl += '/';
+            hurl += loc;
+            auto_ptr_XMLCh widen(hurl.c_str());
+            ElementProxy* ep = new AnyElementImpl(m_discoNS.get(), LOCAL_NAME);
+            ep->setAttribute(QName(NULL,EndpointType::LOCATION_ATTRIB_NAME), widen.get());
+            ep->setAttribute(QName(NULL,EndpointType::BINDING_ATTRIB_NAME), getXMLString("Binding").second);
+            pair<bool,const XMLCh*> ix = getXMLString("index");
+            ep->setAttribute(QName(NULL,IndexedEndpointType::INDEX_ATTRIB_NAME), ix.first ? ix.second : xmlconstants::XML_ONE);
+            
+            Extensions* ext = role.getExtensions();
+            if (!ext) {
+                ext = ExtensionsBuilder::buildExtensions();
+                role.setExtensions(ext);
+            }
+            ext->getUnknownXMLObjects().push_back(ep);
+        }
+#endif
+
     private:
         const char* m_url;
         const char* m_returnParam;
+#ifndef SHIBSP_LITE
+        auto_ptr_XMLCh m_discoNS;
+#endif
     };
 
 #if defined (_MSC_VER)