Switch encoders to metadata-based recipient parameter.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / binding / SAML2ArtifactTest.h
index 593df73..336e403 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- *  Copyright 2001-2005 Internet2\r
+ *  Copyright 2001-2007 Internet2\r
  * \r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -38,7 +38,7 @@ public:
     void testSAML2Artifact() {\r
         try {\r
             QName idprole(samlconstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME);\r
-            SecurityPolicy policy(m_rules2, m_metadata, &idprole, m_trust);\r
+            SecurityPolicy policy(m_rules2, m_metadata, &idprole, m_trust, false);\r
 \r
             // Read message to use from file.\r
             string path = data_path + "saml2/binding/SAML2Response.xml";\r
@@ -50,6 +50,12 @@ public:
                 );\r
             janitor.release();\r
 \r
+            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
+\r
             // Freshen timestamp.\r
             toSend->setIssueInstant(time(NULL));\r
 \r
@@ -58,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",m_creds);\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
@@ -67,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
@@ -88,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
@@ -113,6 +121,7 @@ public:
             SAMLConfig::getConfig().getArtifactMap()->retrieveContent(&artifact, "https://sp.example.org/");\r
         Response* payload = dynamic_cast<Response*>(xmlObject);\r
         TSM_ASSERT("Not a response.", payload!=NULL);\r
+\r
         auto_ptr<ArtifactResponse> response(ArtifactResponseBuilder::buildArtifactResponse());\r
         response->setPayload(payload);\r
         Status* status = StatusBuilder::buildStatus();\r
@@ -122,6 +131,7 @@ public:
         sc->setValue(StatusCode::SUCCESS);\r
         response->marshall();\r
         SchemaValidators.validate(response.get());\r
+        policy.evaluate(*(response.get()), this);\r
         return response.release();\r
     }\r
 };\r