Generate RequestInitiator metadata extension from parentless SessionInitiators.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sat, 9 Oct 2010 22:36:43 +0000 (22:36 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sat, 9 Oct 2010 22:36:43 +0000 (22:36 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/branches/REL_2@3334 cb58f699-b61c-0410-a6fe-9272a202ed29

shibsp/handler/Handler.h
shibsp/handler/SessionInitiator.h
shibsp/handler/impl/AbstractHandler.cpp
shibsp/handler/impl/ChainingSessionInitiator.cpp
shibsp/handler/impl/SAMLDSSessionInitiator.cpp
shibsp/handler/impl/SessionInitiator.cpp

index 2940dfc..bb5ffc6 100644 (file)
@@ -125,8 +125,7 @@ namespace shibsp {
          * @param role          metadata role to decorate
          * @param handlerURL    base location of handler's endpoint
          */
-        virtual void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const {
-        }
+        virtual void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const;
 
         /**
          * Returns the "type" of the Handler plugin.
index 33b310a..f64fe18 100644 (file)
@@ -88,6 +88,7 @@ namespace shibsp {
 
 #ifndef SHIBSP_LITE
         const char* getType() const;
+        void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const;
 #endif
     };
     
index 07319d3..a27b5ce 100644 (file)
@@ -160,6 +160,14 @@ Handler::~Handler()
 {
 }
 
+#ifndef SHIBSP_LITE
+
+void Handler::generateMetadata(SPSSODescriptor& role, const char* handlerURL) const
+{
+}
+
+#endif
+
 const XMLCh* Handler::getProtocolFamily() const
 {
     return nullptr;
index f01cd31..1b4bfce 100644 (file)
@@ -52,6 +52,7 @@ namespace shibsp {
 
 #ifndef SHIBSP_LITE
         void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const {
+            SessionInitiator::generateMetadata(role, handlerURL);
             for (vector<SessionInitiator*>::const_iterator i = m_handlers.begin(); i!=m_handlers.end(); ++i)
                 (*i)->generateMetadata(role, handlerURL);
         }
index e1a31ea..4903de4 100644 (file)
@@ -27,7 +27,6 @@
 #include "handler/SessionInitiator.h"
 
 #include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/impl/AnyElement.h>
 #include <xmltooling/util/URLEncoder.h>
 
 using namespace shibsp;
@@ -58,8 +57,6 @@ namespace shibsp {
 
 #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);
-
             // Initial guess at index to use.
             pair<bool,unsigned int> ix = getUnsignedInt("index");
             if (!ix.first)
index 9972d3c..14aa7f2 100644 (file)
@@ -29,6 +29,11 @@ using namespace shibsp;
 using namespace xmltooling;
 using namespace std;
 
+#ifndef SHIBSP_LITE
+# include <saml/saml2/metadata/Metadata.h>
+using namespace opensaml::saml2md;
+#endif
+
 namespace shibsp {
     SHIBSP_DLLLOCAL PluginManager< SessionInitiator,string,pair<const DOMElement*,const char*> >::Factory ChainingSessionInitiatorFactory;
     SHIBSP_DLLLOCAL PluginManager< SessionInitiator,string,pair<const DOMElement*,const char*> >::Factory Shib1SessionInitiatorFactory;
@@ -70,6 +75,28 @@ const char* SessionInitiator::getType() const
 {
     return "SessionInitiator";
 }
+
+void SessionInitiator::generateMetadata(SPSSODescriptor& role, const char* handlerURL) const
+{
+    if (getParent())
+        return;
+    const char* loc = getString("Location").second;
+    string hurl(handlerURL);
+    if (*loc != '/')
+        hurl += '/';
+    hurl += loc;
+    auto_ptr_XMLCh widen(hurl.c_str());
+
+    RequestInitiator* ep = RequestInitiatorBuilder::buildRequestInitiator();
+    ep->setLocation(widen.get());
+    ep->setBinding(samlconstants::SP_REQUEST_INIT_NS);
+    Extensions* ext = role.getExtensions();
+    if (!ext) {
+        ext = ExtensionsBuilder::buildExtensions();
+        role.setExtensions(ext);
+    }
+    ext->getUnknownXMLObjects().push_back(ep);
+}
 #endif
 
 const set<string>& SessionInitiator::getSupportedOptions() const