Switch encoders to metadata-based recipient parameter.
authorScott Cantor <cantor.2@osu.edu>
Fri, 25 May 2007 05:58:15 +0000 (05:58 +0000)
committerScott Cantor <cantor.2@osu.edu>
Fri, 25 May 2007 05:58:15 +0000 (05:58 +0000)
14 files changed:
config_win32.h
saml/binding/MessageEncoder.h
saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp
saml/saml1/binding/impl/SAML1POSTEncoder.cpp
saml/saml1/binding/impl/SAML1SOAPEncoder.cpp
saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp
saml/saml2/binding/impl/SAML2POSTEncoder.cpp
saml/saml2/binding/impl/SAML2RedirectEncoder.cpp
saml/saml2/binding/impl/SAML2SOAPEncoder.cpp
samltest/saml1/binding/SAML1ArtifactTest.h
samltest/saml1/binding/SAML1POSTTest.h
samltest/saml2/binding/SAML2ArtifactTest.h
samltest/saml2/binding/SAML2POSTTest.h
samltest/saml2/binding/SAML2RedirectTest.h

index cfd83a1..b992639 100644 (file)
@@ -90,9 +90,6 @@
 /* Version number of package */
 #define VERSION "2.0"
 
-/* Define if you wish to disable XML-Security-dependent features. */
-/* #undef XMLTOOLING_NO_XMLSEC */
-
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
 
index 1bc8e1c..7941e02 100644 (file)
@@ -36,6 +36,9 @@ namespace opensaml {
     namespace saml2p {
         class SAML_API SAML2Artifact;
     };
+    namespace saml2md {
+        class SAML_API EntityDescriptor;
+    };
 
     /**
      * Interface to SAML protocol binding message encoders.
@@ -78,7 +81,7 @@ namespace opensaml {
              * @param relyingParty  the party that will recieve the artifact
              * @return a SAML 1.x artifact with a random assertion handle
              */
-            virtual SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const=0;
+            virtual SAMLArtifact* generateSAML1Artifact(const saml2md::EntityDescriptor* relyingParty) const=0;
 
             /**
              * Generate a SAML 2.0 artifact suitable for consumption by the relying party.
@@ -86,7 +89,7 @@ namespace opensaml {
              * @param relyingParty  the party that will recieve the artifact
              * @return a SAML 2.0 artifact with a random message handle
              */
-            virtual saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const=0;
+            virtual saml2p::SAML2Artifact* generateSAML2Artifact(const saml2md::EntityDescriptor* relyingParty) const=0;
         };
 
         /**
@@ -115,7 +118,7 @@ namespace opensaml {
          * @param genericResponse   reference to interface for sending transport response      
          * @param xmlObject         XML message to encode
          * @param destination       destination URL for message
-         * @param recipientID       optional entityID of message recipient
+         * @param recipient         optional message recipient
          * @param relayState        optional RelayState value to accompany message
          * @param credential        optional Credential to supply signing key
          * @param signatureAlg      optional signature algorithm identifier
@@ -125,7 +128,7 @@ namespace opensaml {
             xmltooling::GenericResponse& genericResponse,
             xmltooling::XMLObject* xmlObject,
             const char* destination,
-            const char* recipientID=NULL,
+            const saml2md::EntityDescriptor* recipient=NULL,
             const char* relayState=NULL,
             const xmltooling::Credential* credential=NULL,
             const XMLCh* signatureAlg=NULL,
index 5920997..3d05905 100644 (file)
@@ -27,6 +27,7 @@
 #include "binding/SAMLArtifact.h"
 #include "saml1/core/Assertions.h"
 #include "saml1/core/Protocols.h"
+#include "saml2/metadata/Metadata.h"
 
 #include <log4cpp/Category.hh>
 #include <xmltooling/XMLToolingConfig.h>
@@ -36,6 +37,7 @@
 
 using namespace opensaml::saml1;
 using namespace opensaml::saml1p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace xmltooling;
@@ -54,7 +56,7 @@ namespace opensaml {
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
                 const Credential* credential=NULL,
                 const XMLCh* signatureAlg=NULL,
@@ -73,7 +75,7 @@ long SAML1ArtifactEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
     const Credential* credential,
     const XMLCh* signatureAlg,
@@ -106,12 +108,13 @@ long SAML1ArtifactEncoder::encode(
     // Obtain a fresh artifact.
     if (!m_artifactGenerator)
         throw BindingException("SAML 1.x Artifact Encoder requires an ArtifactGenerator instance.");
-    log.debug("obtaining new artifact for relying party (%s)", recipientID ? recipientID : "unknown");
-    auto_ptr<SAMLArtifact> artifact(m_artifactGenerator->generateSAML1Artifact(recipientID));
+    auto_ptr_char recipientID(recipient ? recipient->getEntityID() : NULL);
+    log.debug("obtaining new artifact for relying party (%s)", recipientID.get() ? recipientID.get() : "unknown");
+    auto_ptr<SAMLArtifact> artifact(m_artifactGenerator->generateSAML1Artifact(recipient));
     
     // Store the assertion. Last step in storage will be to delete the XML.
     log.debug("storing artifact and content in map");
-    mapper->storeContent(xmlObject, artifact.get(), recipientID);
+    mapper->storeContent(xmlObject, artifact.get(), recipientID.get());
 
     // Generate redirect.
     string loc = destination;
index 6b4a7d4..4525a18 100644 (file)
@@ -34,6 +34,7 @@
 #include <xmltooling/util/TemplateEngine.h>
 
 using namespace opensaml::saml1p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace xmltooling;
@@ -52,7 +53,7 @@ namespace opensaml {
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
                 const Credential* credential=NULL,
                 const XMLCh* signatureAlg=NULL,
@@ -88,7 +89,7 @@ long SAML1POSTEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
     const Credential* credential,
     const XMLCh* signatureAlg,
index c8e9e56..197ee0b 100644 (file)
@@ -33,6 +33,7 @@
 #include <xmltooling/soap/SOAP.h>
 
 using namespace opensaml::saml1p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace soap11;
@@ -52,7 +53,7 @@ namespace opensaml {
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
                 const Credential* credential=NULL,
                 const XMLCh* signatureAlg=NULL,
@@ -71,7 +72,7 @@ long SAML1SOAPEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
     const Credential* credential,
     const XMLCh* signatureAlg,
index cafd1b0..749d83d 100644 (file)
@@ -26,6 +26,7 @@
 #include "binding/MessageEncoder.h"
 #include "saml2/binding/SAML2Artifact.h"
 #include "saml2/core/Protocols.h"
+#include "saml2/metadata/Metadata.h"
 
 #include <fstream>
 #include <sstream>
@@ -36,6 +37,7 @@
 #include <xmltooling/util/URLEncoder.h>
 
 using namespace opensaml::saml2p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace xmltooling;
@@ -54,7 +56,7 @@ namespace opensaml {
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
                 const Credential* credential=NULL,
                 const XMLCh* signatureAlg=NULL,
@@ -93,7 +95,7 @@ long SAML2ArtifactEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
     const Credential* credential,
     const XMLCh* signatureAlg,
@@ -129,8 +131,9 @@ long SAML2ArtifactEncoder::encode(
     // Obtain a fresh artifact.
     if (!m_artifactGenerator)
         throw BindingException("SAML 2.0 HTTP-Artifact Encoder requires an ArtifactGenerator instance.");
-    log.debug("obtaining new artifact for relying party (%s)", recipientID ? recipientID : "unknown");
-    auto_ptr<SAMLArtifact> artifact(m_artifactGenerator->generateSAML2Artifact(recipientID));
+    auto_ptr_char recipientID(recipient ? recipient->getEntityID() : NULL);
+    log.debug("obtaining new artifact for relying party (%s)", recipientID.get() ? recipientID.get() : "unknown");
+    auto_ptr<SAMLArtifact> artifact(m_artifactGenerator->generateSAML2Artifact(recipient));
 
     if (credential) {
         // Signature based on native XML signing.
@@ -159,7 +162,7 @@ long SAML2ArtifactEncoder::encode(
     
     // Store the message. Last step in storage will be to delete the XML.
     log.debug("storing artifact and content in map");
-    mapper->storeContent(xmlObject, artifact.get(), recipientID);
+    mapper->storeContent(xmlObject, artifact.get(), recipientID.get());
 
     if (m_template.empty()) {
         // Generate redirect.
index f8242db..efa5a57 100644 (file)
@@ -34,6 +34,7 @@
 #include <xmltooling/util/TemplateEngine.h>
 
 using namespace opensaml::saml2p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace xmltooling;
@@ -52,7 +53,7 @@ namespace opensaml {
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
                 const Credential* credential=NULL,
                 const XMLCh* signatureAlg=NULL,
@@ -93,7 +94,7 @@ long SAML2POSTEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
     const Credential* credential,
     const XMLCh* signatureAlg,
index 24050d6..9135c8d 100644 (file)
@@ -35,6 +35,7 @@
 #include <xmltooling/util/URLEncoder.h>
 
 using namespace opensaml::saml2p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace xmltooling;
@@ -57,7 +58,7 @@ namespace opensaml {
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
                 const Credential* credential=NULL,
                 const XMLCh* signatureAlg=NULL,
@@ -76,7 +77,7 @@ long SAML2RedirectEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
     const Credential* credential,
     const XMLCh* signatureAlg,
index 24b05d1..fccae38 100644 (file)
@@ -33,6 +33,7 @@
 #include <xmltooling/soap/SOAP.h>
 
 using namespace opensaml::saml2p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace soap11;
@@ -52,7 +53,7 @@ namespace opensaml {
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
                 const Credential* credential=NULL,
                 const XMLCh* signatureAlg=NULL,
@@ -73,7 +74,7 @@ long SAML2SOAPEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
     const Credential* credential,
     const XMLCh* signatureAlg,
index 5ae1dc8..d7ddf2c 100644 (file)
@@ -62,7 +62,10 @@ public:
                 SAMLConfig::getConfig().MessageEncoderManager.newPlugin(samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT, NULL)\r
                 );\r
             encoder->setArtifactGenerator(this);\r
-            encoder->encode(*this,toSend.get(),"https://sp.example.org/SAML/SSO","https://sp.example.org/","state",cred);\r
+            Locker locker(m_metadata);\r
+            encoder->encode(\r
+                *this,toSend.get(),"https://sp.example.org/SAML/SSO",m_metadata->getEntityDescriptor("https://sp.example.org/"),"state",cred\r
+                );\r
             toSend.release();\r
             \r
             // Decode message.\r
@@ -71,7 +74,6 @@ public:
                 SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT, NULL)\r
                 );\r
             decoder->setArtifactResolver(this);\r
-            Locker locker(m_metadata);\r
             auto_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));\r
             \r
             // Test the results.\r
@@ -92,11 +94,11 @@ public:
         }\r
     }\r
 \r
-    SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const {\r
+    SAMLArtifact* generateSAML1Artifact(const EntityDescriptor* relyingParty) const {\r
         return new SAMLArtifactType0001(SAMLConfig::getConfig().hashSHA1("https://idp.example.org/"));\r
     }\r
     \r
-    saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const {\r
+    saml2p::SAML2Artifact* generateSAML2Artifact(const EntityDescriptor* relyingParty) const {\r
         throw BindingException("Not implemented.");\r
     }\r
     \r
index eb8278c..81c1d7e 100644 (file)
@@ -46,11 +46,11 @@ public:
                 );
             janitor.release();
 
-            CredentialCriteria cc;\r
-            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);\r
-            Locker clocker(m_creds);\r
-            const Credential* cred = m_creds->resolve(&cc);\r
-            TSM_ASSERT("Retrieved credential was null", cred!=NULL);\r
+            CredentialCriteria cc;
+            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+            Locker clocker(m_creds);
+            const Credential* cred = m_creds->resolve(&cc);
+            TSM_ASSERT("Retrieved credential was null", cred!=NULL);
 
             // Freshen timestamp and ID.
             toSend->setIssueInstant(time(NULL));
@@ -70,7 +70,11 @@ public:
                     samlconstants::SAML1_PROFILE_BROWSER_POST, encoder_config->getDocumentElement()
                     )
                 );
-            encoder->encode(*this,toSend.get(),"https://sp.example.org/SAML/SSO","https://sp.example.org/","state",cred);
+
+            Locker locker(m_metadata);
+            encoder->encode(
+                *this,toSend.get(),"https://sp.example.org/SAML/SSO",m_metadata->getEntityDescriptor("https://sp.example.org/"),"state",cred
+                );
             toSend.release();
             
             // Decode message.
@@ -78,7 +82,6 @@ public:
             auto_ptr<MessageDecoder> decoder(
                 SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML1_PROFILE_BROWSER_POST, NULL)
                 );
-            Locker locker(m_metadata);
             auto_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             
             // Test the results.
index ee5b5f0..336e403 100644 (file)
@@ -64,7 +64,10 @@ public:
                 SAMLConfig::getConfig().MessageEncoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_ARTIFACT, NULL)\r
                 );\r
             encoder->setArtifactGenerator(this);\r
-            encoder->encode(*this,toSend.get(),"https://sp.example.org/SAML/SSO","https://sp.example.org/","state",cred);\r
+            Locker locker(m_metadata);
+            encoder->encode(
+                *this,toSend.get(),"https://sp.example.org/SAML/SSO",m_metadata->getEntityDescriptor("https://sp.example.org/"),"state",cred
+                );
             toSend.release();\r
             \r
             // Decode message.\r
@@ -73,7 +76,6 @@ public:
                 SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_ARTIFACT, NULL)\r
                 );\r
             decoder->setArtifactResolver(this);\r
-            Locker locker(m_metadata);\r
             auto_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));\r
             \r
             // Test the results.\r
@@ -94,11 +96,11 @@ public:
         }\r
     }\r
     \r
-    SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const {\r
+    SAMLArtifact* generateSAML1Artifact(const EntityDescriptor* relyingParty) const {\r
         throw BindingException("Not implemented.");\r
     }\r
     \r
-    saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const {\r
+    saml2p::SAML2Artifact* generateSAML2Artifact(const EntityDescriptor* relyingParty) const {\r
         return new SAML2ArtifactType0004(SAMLConfig::getConfig().hashSHA1("https://idp.example.org/"),1);\r
     }\r
     \r
index 814873e..aed926c 100644 (file)
@@ -46,11 +46,11 @@ public:
                 );
             janitor.release();
 
-            CredentialCriteria cc;\r
-            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);\r
-            Locker clocker(m_creds);\r
-            const Credential* cred = m_creds->resolve(&cc);\r
-            TSM_ASSERT("Retrieved credential was null", cred!=NULL);\r
+            CredentialCriteria cc;
+            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+            Locker clocker(m_creds);
+            const Credential* cred = m_creds->resolve(&cc);
+            TSM_ASSERT("Retrieved credential was null", cred!=NULL);
 
             // Freshen timestamp and ID.
             toSend->setIssueInstant(time(NULL));
@@ -70,7 +70,10 @@ public:
                     samlconstants::SAML20_BINDING_HTTP_POST, encoder_config->getDocumentElement()
                     )
                 );
-            encoder->encode(*this,toSend.get(),"https://sp.example.org/SAML/SSO","https://sp.example.org/","state",cred);
+            Locker locker(m_metadata);
+            encoder->encode(
+                *this,toSend.get(),"https://sp.example.org/SAML/SSO",m_metadata->getEntityDescriptor("https://sp.example.org/"),"state",cred
+                );
             toSend.release();
             
             // Decode message.
@@ -78,7 +81,6 @@ public:
             auto_ptr<MessageDecoder> decoder(
                 SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_POST, NULL)
                 );
-            Locker locker(m_metadata);
             auto_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             
             // Test the results.
@@ -114,11 +116,11 @@ public:
                 );
             janitor.release();
 
-            CredentialCriteria cc;\r
-            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);\r
-            Locker clocker(m_creds);\r
-            const Credential* cred = m_creds->resolve(&cc);\r
-            TSM_ASSERT("Retrieved credential was null", cred!=NULL);\r
+            CredentialCriteria cc;
+            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+            Locker clocker(m_creds);
+            const Credential* cred = m_creds->resolve(&cc);
+            TSM_ASSERT("Retrieved credential was null", cred!=NULL);
 
             // Freshen timestamp and ID.
             toSend->setIssueInstant(time(NULL));
@@ -138,7 +140,10 @@ public:
                     samlconstants::SAML20_BINDING_HTTP_POST_SIMPLESIGN, encoder_config->getDocumentElement()
                     )
                 );
-            encoder->encode(*this,toSend.get(),"https://sp.example.org/SAML/SSO","https://sp.example.org/","state",cred);
+            Locker locker(m_metadata);
+            encoder->encode(
+                *this,toSend.get(),"https://sp.example.org/SAML/SSO",m_metadata->getEntityDescriptor("https://sp.example.org/"),"state",cred
+                );
             toSend.release();
             
             // Decode message.
@@ -146,7 +151,6 @@ public:
             auto_ptr<MessageDecoder> decoder(
                 SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_POST_SIMPLESIGN, NULL)
                 );
-            Locker locker(m_metadata);
             auto_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             
             // Test the results.
index 59e51fd..31df7f7 100644 (file)
@@ -46,11 +46,11 @@ public:
                 );
             janitor.release();
 
-            CredentialCriteria cc;\r
-            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);\r
-            Locker clocker(m_creds);\r
-            const Credential* cred = m_creds->resolve(&cc);\r
-            TSM_ASSERT("Retrieved credential was null", cred!=NULL);\r
+            CredentialCriteria cc;
+            cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+            Locker clocker(m_creds);
+            const Credential* cred = m_creds->resolve(&cc);
+            TSM_ASSERT("Retrieved credential was null", cred!=NULL);
 
             // Freshen timestamp and ID.
             toSend->setIssueInstant(time(NULL));
@@ -60,7 +60,10 @@ public:
             auto_ptr<MessageEncoder> encoder(
                 SAMLConfig::getConfig().MessageEncoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_REDIRECT, NULL)
                 );
-            encoder->encode(*this,toSend.get(),"https://sp.example.org/SAML/SSO","https://sp.example.org/","state",cred);
+            Locker locker(m_metadata);
+            encoder->encode(
+                *this,toSend.get(),"https://sp.example.org/SAML/SSO",m_metadata->getEntityDescriptor("https://sp.example.org/"),"state",cred
+                );
             toSend.release();
             
             // Decode message.
@@ -68,7 +71,6 @@ public:
             auto_ptr<MessageDecoder> decoder(
                 SAMLConfig::getConfig().MessageDecoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_REDIRECT, NULL)
                 );
-            Locker locker(m_metadata);
             auto_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));
             
             // Test the results.