[cpp-opensaml] branch master updated: Eliminate namespace parameter to message codec plugins.

Scott Cantor cantor.2 at osu.edu
Wed Feb 14 14:16:59 EST 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository cpp-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-opensaml.git;a=commit;h=de6059fce7d09a27c286530020f43b709f96fa13

The following commit(s) were added to refs/heads/master by this push:
       new  de6059f   Eliminate namespace parameter to message codec plugins.
de6059f is described below

commit de6059fce7d09a27c286530020f43b709f96fa13
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Feb 14 14:16:39 2018 -0500

    Eliminate namespace parameter to message codec plugins.
---
 saml/SAMLConfig.h                                |  4 +-
 saml/binding/impl/MessageDecoder.cpp             | 16 ++++----
 saml/binding/impl/MessageEncoder.cpp             | 18 ++++-----
 saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp |  2 +-
 saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp |  2 +-
 saml/saml1/binding/impl/SAML1POSTDecoder.cpp     |  2 +-
 saml/saml1/binding/impl/SAML1POSTEncoder.cpp     | 29 ++++++++++----
 saml/saml1/binding/impl/SAML1SOAPDecoder.cpp     |  2 +-
 saml/saml1/binding/impl/SAML1SOAPEncoder.cpp     |  2 +-
 saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp |  2 +-
 saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp | 49 +++++++++++++++++++-----
 saml/saml2/binding/impl/SAML2ECPDecoder.cpp      |  2 +-
 saml/saml2/binding/impl/SAML2ECPEncoder.cpp      | 36 +++++++++++------
 saml/saml2/binding/impl/SAML2POSTDecoder.cpp     |  2 +-
 saml/saml2/binding/impl/SAML2POSTEncoder.cpp     | 34 +++++++++++-----
 saml/saml2/binding/impl/SAML2RedirectDecoder.cpp |  2 +-
 saml/saml2/binding/impl/SAML2RedirectEncoder.cpp |  2 +-
 saml/saml2/binding/impl/SAML2SOAPDecoder.cpp     |  2 +-
 saml/saml2/binding/impl/SAML2SOAPEncoder.cpp     |  2 +-
 samltest/saml1/binding/SAML1ArtifactTest.h       |  8 +---
 samltest/saml1/binding/SAML1POSTTest.h           |  6 +--
 samltest/saml2/binding/SAML2ArtifactTest.h       |  8 +---
 samltest/saml2/binding/SAML2POSTTest.h           | 12 ++----
 samltest/saml2/binding/SAML2RedirectTest.h       |  8 +---
 24 files changed, 152 insertions(+), 100 deletions(-)

diff --git a/saml/SAMLConfig.h b/saml/SAMLConfig.h
index b1b3a43..cf52428 100644
--- a/saml/SAMLConfig.h
+++ b/saml/SAMLConfig.h
@@ -175,10 +175,10 @@ namespace opensaml {
         virtual const saml2md::ContactPerson* getContactPerson(const saml2md::RoleDescriptor& role) const=0;
 
         /** Manages factories for MessageDecoder plugins. */
-        xmltooling::PluginManager< MessageDecoder,std::string,std::pair<const xercesc::DOMElement*,const XMLCh*> > MessageDecoderManager;
+        xmltooling::PluginManager<MessageDecoder,std::string,const xercesc::DOMElement*> MessageDecoderManager;
 
         /** Manages factories for MessageEncoder plugins. */
-        xmltooling::PluginManager< MessageEncoder,std::string,std::pair<const xercesc::DOMElement*,const XMLCh*> > MessageEncoderManager;
+        xmltooling::PluginManager<MessageEncoder,std::string,const xercesc::DOMElement*> MessageEncoderManager;
 
         /** Manages factories for SAMLArtifact plugins. */
         xmltooling::PluginManager<SAMLArtifact,std::string,const char*> SAMLArtifactManager;
diff --git a/saml/binding/impl/MessageDecoder.cpp b/saml/binding/impl/MessageDecoder.cpp
index 973761e..6e4bcc8 100644
--- a/saml/binding/impl/MessageDecoder.cpp
+++ b/saml/binding/impl/MessageDecoder.cpp
@@ -39,17 +39,17 @@ using namespace std;
 
 namespace opensaml {
     namespace saml1p {
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML1ArtifactDecoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML1POSTDecoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML1SOAPDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML1ArtifactDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML1POSTDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML1SOAPDecoderFactory;
     };
 
     namespace saml2p {
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2ArtifactDecoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2POSTDecoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2RedirectDecoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2SOAPDecoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageDecoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2ECPDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML2ArtifactDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML2POSTDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML2RedirectDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML2SOAPDecoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageDecoder,string,const DOMElement*>::Factory SAML2ECPDecoderFactory;
     };
 };
 
diff --git a/saml/binding/impl/MessageEncoder.cpp b/saml/binding/impl/MessageEncoder.cpp
index 221f9b1..6d4f490 100644
--- a/saml/binding/impl/MessageEncoder.cpp
+++ b/saml/binding/impl/MessageEncoder.cpp
@@ -38,18 +38,18 @@ using namespace std;
 
 namespace opensaml {
     namespace saml1p {
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML1ArtifactEncoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML1POSTEncoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML1SOAPEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML1ArtifactEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML1POSTEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML1SOAPEncoderFactory;
     }; 
 
     namespace saml2p {
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2ArtifactEncoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2POSTEncoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2POSTSimpleSignEncoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2RedirectEncoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2SOAPEncoderFactory;
-        SAML_DLLLOCAL PluginManager< MessageEncoder,string,pair<const DOMElement*,const XMLCh*> >::Factory SAML2ECPEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML2ArtifactEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML2POSTEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML2POSTSimpleSignEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML2RedirectEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML2SOAPEncoderFactory;
+        SAML_DLLLOCAL PluginManager<MessageEncoder,string,const DOMElement*>::Factory SAML2ECPEncoderFactory;
     };
 };
 
diff --git a/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp b/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp
index 75b92f3..10462cd 100644
--- a/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp
+++ b/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp
@@ -63,7 +63,7 @@ namespace opensaml {
                 ) const;
         };
 
-        MessageDecoder* SAML_DLLLOCAL SAML1ArtifactDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageDecoder* SAML_DLLLOCAL SAML1ArtifactDecoderFactory(const DOMElement* const&)
         {
             return new SAML1ArtifactDecoder();
         }
diff --git a/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp b/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp
index de833f2..552c214 100644
--- a/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp
+++ b/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp
@@ -73,7 +73,7 @@ namespace opensaml {
                 ) const;
         };                
 
-        MessageEncoder* SAML_DLLLOCAL SAML1ArtifactEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML1ArtifactEncoderFactory(const DOMElement* const &)
         {
             return new SAML1ArtifactEncoder();
         }
diff --git a/saml/saml1/binding/impl/SAML1POSTDecoder.cpp b/saml/saml1/binding/impl/SAML1POSTDecoder.cpp
index c559fc5..dbe9eca 100644
--- a/saml/saml1/binding/impl/SAML1POSTDecoder.cpp
+++ b/saml/saml1/binding/impl/SAML1POSTDecoder.cpp
@@ -66,7 +66,7 @@ namespace opensaml {
                 ) const;
         };                
 
-        MessageDecoder* SAML_DLLLOCAL SAML1POSTDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageDecoder* SAML_DLLLOCAL SAML1POSTDecoderFactory(const DOMElement* const &)
         {
             return new SAML1POSTDecoder();
         }
diff --git a/saml/saml1/binding/impl/SAML1POSTEncoder.cpp b/saml/saml1/binding/impl/SAML1POSTEncoder.cpp
index 918166d..95a1267 100644
--- a/saml/saml1/binding/impl/SAML1POSTEncoder.cpp
+++ b/saml/saml1/binding/impl/SAML1POSTEncoder.cpp
@@ -55,7 +55,7 @@ namespace opensaml {
         class SAML_DLLLOCAL SAML1POSTEncoder : public MessageEncoder
         {
         public:
-            SAML1POSTEncoder(const DOMElement* e, const XMLCh* ns);
+            SAML1POSTEncoder(const DOMElement* e);
             virtual ~SAML1POSTEncoder() {}
 
             const XMLCh* getProtocolFamily() const {
@@ -79,20 +79,33 @@ namespace opensaml {
             string m_template;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML1POSTEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML1POSTEncoderFactory(const DOMElement* const & e)
         {
-            return new SAML1POSTEncoder(p.first, p.second);
+            return new SAML1POSTEncoder(e);
         }
     };
 };
 
-static const XMLCh _template[] = UNICODE_LITERAL_8(t,e,m,p,l,a,t,e);
-
-SAML1POSTEncoder::SAML1POSTEncoder(const DOMElement* e, const XMLCh* ns)
-    : m_template(XMLHelper::getAttrString(e, "bindingTemplate.html", _template, ns))
+SAML1POSTEncoder::SAML1POSTEncoder(const DOMElement* e)
 {
+    // Fishy alert: we ignore the namespace and look for a matching DOM Attr node by name only.
+    // Can't use DOM 1 calls, so we have to walk the attribute list by hand.
+
+    static const XMLCh _template[] = UNICODE_LITERAL_8(t, e, m, p, l, a, t, e);
+
+    const DOMNamedNodeMap* attributes = e->getAttributes();
+    XMLSize_t size = attributes ? attributes->getLength() : 0;
+    for (XMLSize_t i = 0; i < size; ++i) {
+        const DOMNode* attr = attributes->item(i);
+        if (XMLString::equals(attr->getLocalName(), _template)) {
+            auto_ptr_char val(attr->getNodeValue());
+            if (val.get())
+                m_template = val.get();
+        }
+    }
+
     if (m_template.empty())
-        throw XMLToolingException("SAML1POSTEncoder requires template XML attribute.");
+        m_template = "bindingTemplate.html";
     XMLToolingConfig::getConfig().getPathResolver()->resolve(m_template, PathResolver::XMLTOOLING_CFG_FILE);
 }
 
diff --git a/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp b/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp
index 58949d3..7e2f54d 100644
--- a/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp
+++ b/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp
@@ -64,7 +64,7 @@ namespace opensaml {
                 ) const;
         };                
 
-        MessageDecoder* SAML_DLLLOCAL SAML1SOAPDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageDecoder* SAML_DLLLOCAL SAML1SOAPDecoderFactory(const DOMElement* const &)
         {
             return new SAML1SOAPDecoder();
         }
diff --git a/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp b/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp
index c5f41f5..aefb1e7 100644
--- a/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp
+++ b/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp
@@ -75,7 +75,7 @@ namespace opensaml {
                 ) const;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML1SOAPEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML1SOAPEncoderFactory(const DOMElement* const &)
         {
             return new SAML1SOAPEncoder();
         }
diff --git a/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp b/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp
index 46ec815..72557c4 100644
--- a/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp
@@ -64,7 +64,7 @@ namespace opensaml {
                 ) const;
         };
 
-        MessageDecoder* SAML_DLLLOCAL SAML2ArtifactDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageDecoder* SAML_DLLLOCAL SAML2ArtifactDecoderFactory(const DOMElement* const &)
         {
             return new SAML2ArtifactDecoder();
         }
diff --git a/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp b/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp
index 51e2528..6735f94 100644
--- a/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp
+++ b/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp
@@ -57,7 +57,7 @@ namespace opensaml {
         class SAML_DLLLOCAL SAML2ArtifactEncoder : public MessageEncoder
         {
         public:
-            SAML2ArtifactEncoder(const DOMElement* e, const XMLCh* ns);
+            SAML2ArtifactEncoder(const DOMElement* e);
             virtual ~SAML2ArtifactEncoder() {}
 
             const XMLCh* getProtocolFamily() const {
@@ -80,22 +80,51 @@ namespace opensaml {
             string m_template;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML2ArtifactEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML2ArtifactEncoderFactory(const DOMElement* const & e)
         {
-            return new SAML2ArtifactEncoder(p.first, p.second);
+            return new SAML2ArtifactEncoder(e);
         }
     };
 
-    static const XMLCh _template[] =    UNICODE_LITERAL_8(t,e,m,p,l,a,t,e);
-    static const XMLCh postArtifact[] = UNICODE_LITERAL_12(p,o,s,t,A,r,t,i,f,a,c,t);
 };
 
-SAML2ArtifactEncoder::SAML2ArtifactEncoder(const DOMElement* e, const XMLCh* ns)
+SAML2ArtifactEncoder::SAML2ArtifactEncoder(const DOMElement* e)
 {
-    if (XMLHelper::getAttrBool(e, false, postArtifact, ns)) {
-        m_template = XMLHelper::getAttrString(e, "bindingTemplate.html", _template, ns);
-        if (!m_template.empty())
-            XMLToolingConfig::getConfig().getPathResolver()->resolve(m_template, PathResolver::XMLTOOLING_CFG_FILE);
+    // Fishy alert: we ignore the namespace and look for a matching DOM Attr node by name only.
+    // Can't use DOM 1 calls, so we have to walk the attribute list by hand.
+
+    static const XMLCh postArtifact[] = UNICODE_LITERAL_12(p, o, s, t, A, r, t, i, f, a, c, t);
+    static const XMLCh _template[] = UNICODE_LITERAL_8(t, e, m, p, l, a, t, e);
+
+    const DOMNamedNodeMap* attributes = e->getAttributes();
+    XMLSize_t size = attributes ? attributes->getLength() : 0;
+
+    bool post = false;
+    for (XMLSize_t i = 0; i < size; ++i) {
+        const DOMNode* attr = attributes->item(i);
+        if (XMLString::equals(attr->getLocalName(), postArtifact)) {
+            const XMLCh* val = attr->getNodeValue();
+            if (val) {
+                if (*val == chLatin_t || *val == chDigit_1)
+                    post = true;
+            }
+        }
+    }
+
+    if (post) {
+        for (XMLSize_t i = 0; i < size; ++i) {
+            const DOMNode* attr = attributes->item(i);
+            if (XMLString::equals(attr->getLocalName(), _template)) {
+                auto_ptr_char val(attr->getNodeValue());
+                if (val.get())
+                    m_template = val.get();
+            }
+        }
+
+        if (m_template.empty())
+            m_template = "bindingTemplate.html";
+
+        XMLToolingConfig::getConfig().getPathResolver()->resolve(m_template, PathResolver::XMLTOOLING_CFG_FILE);
     }
 }
 
diff --git a/saml/saml2/binding/impl/SAML2ECPDecoder.cpp b/saml/saml2/binding/impl/SAML2ECPDecoder.cpp
index d571b1b..7d7045e 100644
--- a/saml/saml2/binding/impl/SAML2ECPDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2ECPDecoder.cpp
@@ -61,7 +61,7 @@ namespace opensaml {
                 ) const;
         };                
 
-        MessageDecoder* SAML_DLLLOCAL SAML2ECPDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageDecoder* SAML_DLLLOCAL SAML2ECPDecoderFactory(const DOMElement* const &)
         {
             return new SAML2ECPDecoder();
         }
diff --git a/saml/saml2/binding/impl/SAML2ECPEncoder.cpp b/saml/saml2/binding/impl/SAML2ECPEncoder.cpp
index 12a9b4f..9f6545b 100644
--- a/saml/saml2/binding/impl/SAML2ECPEncoder.cpp
+++ b/saml/saml2/binding/impl/SAML2ECPEncoder.cpp
@@ -53,19 +53,13 @@ using namespace std;
 namespace opensaml {
     namespace saml2p {              
         
-        static const XMLCh ProviderName[] = UNICODE_LITERAL_12(P,r,o,v,i,d,e,r,N,a,m,e);
+        static const XMLCh ProviderName[] = UNICODE_LITERAL_12(P, r, o, v, i, d, e, r, N, a, m, e);
 
         class SAML_DLLLOCAL SAML2ECPEncoder : public MessageEncoder
         {
         public:
-            SAML2ECPEncoder(const DOMElement* e, const XMLCh* ns) : m_actor("http://schemas.xmlsoap.org/soap/actor/next"),
-                    m_providerName(e ? e->getAttributeNS(ns, ProviderName) : nullptr) {
-                DOMElement* child = e ? XMLHelper::getFirstChildElement(e, SAML20P_NS, IDPList::LOCAL_NAME) : nullptr;
-                if (child)
-                    m_idpList.reset(dynamic_cast<IDPList*>(XMLObjectBuilder::buildOneFromElement(child)));
-            }
-            virtual ~SAML2ECPEncoder() {
-            }
+            SAML2ECPEncoder(const DOMElement* e);
+            virtual ~SAML2ECPEncoder() {}
 
             const XMLCh* getProtocolFamily() const {
                 return samlconstants::SAML20P_NS;
@@ -90,13 +84,33 @@ namespace opensaml {
             AnyElementBuilder m_anyBuilder;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML2ECPEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML2ECPEncoderFactory(const DOMElement* const & e)
         {
-            return new SAML2ECPEncoder(p.first, p.second);
+            return new SAML2ECPEncoder(e);
         }
     };
 };
 
+SAML2ECPEncoder::SAML2ECPEncoder(const DOMElement* e)
+        : m_actor("http://schemas.xmlsoap.org/soap/actor/next"), m_providerName(nullptr) {
+
+    // Fishy alert: we ignore the namespace and look for a matching DOM Attr node by name only.
+    // Can't use DOM 1 calls, so we have to walk the attribute list by hand.
+
+    const DOMNamedNodeMap* attributes = e->getAttributes();
+    XMLSize_t size = attributes ? attributes->getLength() : 0;
+    for (XMLSize_t i = 0; i < size; ++i) {
+        const DOMNode* attr = attributes->item(i);
+        if (XMLString::equals(attr->getLocalName(), ProviderName)) {
+            m_providerName = attr->getNodeValue();
+        }
+    }
+
+    DOMElement* child = e ? XMLHelper::getFirstChildElement(e, SAML20P_NS, IDPList::LOCAL_NAME) : nullptr;
+    if (child)
+        m_idpList.reset(dynamic_cast<IDPList*>(XMLObjectBuilder::buildOneFromElement(child)));
+}
+
 long SAML2ECPEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
diff --git a/saml/saml2/binding/impl/SAML2POSTDecoder.cpp b/saml/saml2/binding/impl/SAML2POSTDecoder.cpp
index 24c5eb4..e7b36c0 100644
--- a/saml/saml2/binding/impl/SAML2POSTDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2POSTDecoder.cpp
@@ -65,7 +65,7 @@ namespace opensaml {
                 ) const;
         };                
 
-        MessageDecoder* SAML_DLLLOCAL SAML2POSTDecoderFactory(const pair<const DOMElement*,const XMLCh*>&)
+        MessageDecoder* SAML_DLLLOCAL SAML2POSTDecoderFactory(const DOMElement* const &)
         {
             return new SAML2POSTDecoder();
         }
diff --git a/saml/saml2/binding/impl/SAML2POSTEncoder.cpp b/saml/saml2/binding/impl/SAML2POSTEncoder.cpp
index 271d9f0..0241839 100644
--- a/saml/saml2/binding/impl/SAML2POSTEncoder.cpp
+++ b/saml/saml2/binding/impl/SAML2POSTEncoder.cpp
@@ -57,7 +57,7 @@ namespace opensaml {
         class SAML_DLLLOCAL SAML2POSTEncoder : public MessageEncoder
         {
         public:
-            SAML2POSTEncoder(const DOMElement* e, const XMLCh* ns, bool simple=false);
+            SAML2POSTEncoder(const DOMElement* e, bool simple=false);
             virtual ~SAML2POSTEncoder() {}
 
             const XMLCh* getProtocolFamily() const {
@@ -81,25 +81,39 @@ namespace opensaml {
             bool m_simple;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML2POSTEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML2POSTEncoderFactory(const DOMElement* const & e)
         {
-            return new SAML2POSTEncoder(p.first, p.second, false);
+            return new SAML2POSTEncoder(e, false);
         }
 
-        MessageEncoder* SAML_DLLLOCAL SAML2POSTSimpleSignEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML2POSTSimpleSignEncoderFactory(const DOMElement* const & e)
         {
-            return new SAML2POSTEncoder(p.first, p.second, true);
+            return new SAML2POSTEncoder(e, true);
         }
     };
 };
 
-static const XMLCh _template[] = UNICODE_LITERAL_8(t,e,m,p,l,a,t,e);
-
-SAML2POSTEncoder::SAML2POSTEncoder(const DOMElement* e, const XMLCh* ns, bool simple)
-    : m_template(XMLHelper::getAttrString(e, "bindingTemplate.html", _template, ns)), m_simple(simple)
+SAML2POSTEncoder::SAML2POSTEncoder(const DOMElement* e, bool simple) : m_simple(simple)
 {
+    // Fishy alert: we ignore the namespace and look for a matching DOM Attr node by name only.
+    // Can't use DOM 1 calls, so we have to walk the attribute list by hand.
+
+    static const XMLCh _template[] = UNICODE_LITERAL_8(t, e, m, p, l, a, t, e);
+
+    const DOMNamedNodeMap* attributes = e->getAttributes();
+    XMLSize_t size = attributes ? attributes->getLength() : 0;
+    for (XMLSize_t i = 0; i < size; ++i) {
+        const DOMNode* attr = attributes->item(i);
+        if (XMLString::equals(attr->getLocalName(), _template)) {
+            auto_ptr_char val(attr->getNodeValue());
+            if (val.get())
+                m_template = val.get();
+        }
+    }
+
     if (m_template.empty())
-        throw XMLToolingException("SAML2POSTEncoder requires template XML attribute.");
+        m_template = "bindingTemplate.html";
+
     XMLToolingConfig::getConfig().getPathResolver()->resolve(m_template, PathResolver::XMLTOOLING_CFG_FILE);
 }
 
diff --git a/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp b/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp
index e18c5a6..28ea7d8 100644
--- a/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp
@@ -65,7 +65,7 @@ namespace opensaml {
                 ) const;
         };
 
-        MessageDecoder* SAML_DLLLOCAL SAML2RedirectDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageDecoder* SAML_DLLLOCAL SAML2RedirectDecoderFactory(const DOMElement* const &)
         {
             return new SAML2RedirectDecoder();
         }
diff --git a/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp b/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp
index 3a56d3b..bb86386 100644
--- a/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp
+++ b/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp
@@ -79,7 +79,7 @@ namespace opensaml {
                 ) const;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML2RedirectEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML2RedirectEncoderFactory(const DOMElement* const &)
         {
             return new SAML2RedirectEncoder();
         }
diff --git a/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp b/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp
index 702d96a..816650d 100644
--- a/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2SOAPDecoder.cpp
@@ -64,7 +64,7 @@ namespace opensaml {
                 ) const;
         };                
 
-        MessageDecoder* SAML_DLLLOCAL SAML2SOAPDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageDecoder* SAML_DLLLOCAL SAML2SOAPDecoderFactory(const DOMElement* const &)
         {
             return new SAML2SOAPDecoder();
         }
diff --git a/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp b/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp
index 7183747..a8313dd 100644
--- a/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp
+++ b/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp
@@ -75,7 +75,7 @@ namespace opensaml {
                 ) const;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
+        MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const DOMElement* const &)
         {
             return new SAML2SOAPEncoder();
         }
diff --git a/samltest/saml1/binding/SAML1ArtifactTest.h b/samltest/saml1/binding/SAML1ArtifactTest.h
index b5946b8..7b8b6d0 100644
--- a/samltest/saml1/binding/SAML1ArtifactTest.h
+++ b/samltest/saml1/binding/SAML1ArtifactTest.h
@@ -66,9 +66,7 @@ public:
 
             // Encode message.
             boost::scoped_ptr<MessageEncoder> encoder(
-                SAMLConfig::getConfig().MessageEncoderManager.newPlugin(
-                    samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageEncoderManager.newPlugin(samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT, nullptr)
                 );
             Locker locker(m_metadata.get());
             encoder->encode(
@@ -85,9 +83,7 @@ public:
             // Decode message.
             string relayState;
             boost::scoped_ptr<MessageDecoder> decoder(
-                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(
-                    samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT, nullptr)
                 );
             decoder->setArtifactResolver(this);
             boost::scoped_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
diff --git a/samltest/saml1/binding/SAML1POSTTest.h b/samltest/saml1/binding/SAML1POSTTest.h
index 87bad33..b48e9bd 100644
--- a/samltest/saml1/binding/SAML1POSTTest.h
+++ b/samltest/saml1/binding/SAML1POSTTest.h
@@ -72,7 +72,7 @@ public:
             encoder_config->getDocumentElement()->setAttributeNS(nullptr,lit2.get(),lit3.get());
             boost::scoped_ptr<MessageEncoder> encoder(
                 SAMLConfig::getConfig().MessageEncoderManager.newPlugin(
-                    samlconstants::SAML1_PROFILE_BROWSER_POST, pair<const DOMElement*,const XMLCh*>(encoder_config->getDocumentElement(),nullptr)
+                    samlconstants::SAML1_PROFILE_BROWSER_POST, encoder_config->getDocumentElement()
                     )
                 );
 
@@ -91,9 +91,7 @@ public:
             // Decode message.
             string relayState;
             boost::scoped_ptr<MessageDecoder> decoder(
-                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(
-                    samlconstants::SAML1_PROFILE_BROWSER_POST, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML1_PROFILE_BROWSER_POST, nullptr)
                 );
             boost::scoped_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             
diff --git a/samltest/saml2/binding/SAML2ArtifactTest.h b/samltest/saml2/binding/SAML2ArtifactTest.h
index 96f80e6..d51d22b 100644
--- a/samltest/saml2/binding/SAML2ArtifactTest.h
+++ b/samltest/saml2/binding/SAML2ArtifactTest.h
@@ -67,9 +67,7 @@ public:
 
             // Encode message.
             boost::scoped_ptr<MessageEncoder> encoder(
-                SAMLConfig::getConfig().MessageEncoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_ARTIFACT, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageEncoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_ARTIFACT, nullptr)
                 );
             Locker locker(m_metadata.get());
             encoder->encode(
@@ -86,9 +84,7 @@ public:
             // Decode message.
             string relayState;
             boost::scoped_ptr<MessageDecoder> decoder(
-                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_ARTIFACT, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_ARTIFACT, nullptr)
                 );
             decoder->setArtifactResolver(this);
             boost::scoped_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
diff --git a/samltest/saml2/binding/SAML2POSTTest.h b/samltest/saml2/binding/SAML2POSTTest.h
index 87c9a75..e8f01f9 100644
--- a/samltest/saml2/binding/SAML2POSTTest.h
+++ b/samltest/saml2/binding/SAML2POSTTest.h
@@ -72,7 +72,7 @@ public:
             encoder_config->getDocumentElement()->setAttributeNS(nullptr,lit2.get(),lit3.get());
             boost::scoped_ptr<MessageEncoder> encoder(
                 SAMLConfig::getConfig().MessageEncoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_POST, pair<const DOMElement*,const XMLCh*>(encoder_config->getDocumentElement(), nullptr)
+                    samlconstants::SAML20_BINDING_HTTP_POST, encoder_config->getDocumentElement()
                     )
                 );
             Locker locker(m_metadata.get());
@@ -90,9 +90,7 @@ public:
             // Decode message.
             string relayState;
             boost::scoped_ptr<MessageDecoder> decoder(
-                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_POST, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_POST, nullptr)
                 );
             boost::scoped_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             
@@ -151,7 +149,7 @@ public:
             encoder_config->getDocumentElement()->setAttributeNS(nullptr,lit2.get(),lit3.get());
             boost::scoped_ptr<MessageEncoder> encoder(
                 SAMLConfig::getConfig().MessageEncoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_POST_SIMPLESIGN, pair<const DOMElement*,const XMLCh*>(encoder_config->getDocumentElement(),nullptr)
+                    samlconstants::SAML20_BINDING_HTTP_POST_SIMPLESIGN, encoder_config->getDocumentElement()
                     )
                 );
             Locker locker(m_metadata.get());
@@ -169,9 +167,7 @@ public:
             // Decode message.
             string relayState;
             boost::scoped_ptr<MessageDecoder> decoder(
-                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_POST_SIMPLESIGN, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_POST_SIMPLESIGN, nullptr)
                 );
             boost::scoped_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             
diff --git a/samltest/saml2/binding/SAML2RedirectTest.h b/samltest/saml2/binding/SAML2RedirectTest.h
index bbbb8da..6ab4d99 100644
--- a/samltest/saml2/binding/SAML2RedirectTest.h
+++ b/samltest/saml2/binding/SAML2RedirectTest.h
@@ -63,9 +63,7 @@ public:
     
             // Encode message.
             boost::scoped_ptr<MessageEncoder> encoder(
-                SAMLConfig::getConfig().MessageEncoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_REDIRECT, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageEncoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_REDIRECT, nullptr)
                 );
             Locker locker(m_metadata.get());
             encoder->encode(
@@ -82,9 +80,7 @@ public:
             // Decode message.
             string relayState;
             boost::scoped_ptr<MessageDecoder> decoder(
-                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(
-                    samlconstants::SAML20_BINDING_HTTP_REDIRECT, pair<const DOMElement*,const XMLCh*>(nullptr,nullptr)
-                    )
+                SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_REDIRECT, nullptr)
                 );
             boost::scoped_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list