using namespace opensaml::saml2;\r
\r
class SAML2ArtifactTest : public CxxTest::TestSuite,\r
- public SAMLBindingBaseTestCase, public MessageEncoder::ArtifactGenerator, public MessageDecoder::ArtifactResolver {\r
+ public SAMLBindingBaseTestCase, public MessageEncoder::ArtifactGenerator, public MessageDecoder::ArtifactResolver {\r
public:\r
void setUp() {\r
- m_fields.clear();\r
SAMLBindingBaseTestCase::setUp();\r
}\r
\r
void tearDown() {\r
- m_fields.clear();\r
SAMLBindingBaseTestCase::tearDown();\r
}\r
\r
void testSAML2Artifact() {\r
try {\r
+ QName idprole(samlconstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME);\r
+ SecurityPolicy policy(m_rules, m_metadata, &idprole, m_trust);\r
+\r
// Read message to use from file.\r
string path = data_path + "saml2/binding/SAML2Response.xml";\r
ifstream in(path.c_str());\r
toSend->setIssueInstant(time(NULL));\r
\r
// Encode message.\r
- auto_ptr<MessageEncoder> encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML2_ARTIFACT_ENCODER, NULL));\r
+ auto_ptr<MessageEncoder> encoder(\r
+ SAMLConfig::getConfig().MessageEncoderManager.newPlugin(samlconstants::SAML20_BINDING_HTTP_ARTIFACT, NULL)\r
+ );\r
encoder->setArtifactGenerator(this);\r
- encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds);\r
+ encoder->encode(*this,toSend.get(),"https://sp.example.org/SAML/SSO","https://sp.example.org/","state",m_creds);\r
toSend.release();\r
\r
// Decode message.\r
string relayState;\r
- const RoleDescriptor* issuer=NULL;\r
- bool trusted=false;\r
- QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME);\r
- auto_ptr<MessageDecoder> decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML2_ARTIFACT_DECODER, NULL));\r
+ auto_ptr<MessageDecoder> decoder(\r
+ 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(\r
- dynamic_cast<Response*>(\r
- decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust)\r
- )\r
- );\r
+ auto_ptr<Response> response(dynamic_cast<Response*>(decoder->decode(relayState,*this,policy)));\r
\r
// Test the results.\r
TSM_ASSERT_EQUALS("RelayState was not the expected result.", relayState, "state");\r
TSM_ASSERT("SAML Response not decoded successfully.", response.get());\r
- TSM_ASSERT("Message was not verified.", issuer && trusted);\r
- auto_ptr_char entityID(dynamic_cast<const EntityDescriptor*>(issuer->getParent())->getEntityID());\r
+ TSM_ASSERT("Message was not verified.", policy.getIssuer()!=NULL);\r
+ auto_ptr_char entityID(policy.getIssuer()->getName());\r
TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/"));\r
TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1);\r
\r
// Trigger a replay.\r
- TSM_ASSERT_THROWS("Did not catch the replay.", \r
- decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust),\r
- BindingException);\r
+ TSM_ASSERT_THROWS("Did not catch the replay.", decoder->decode(relayState,*this,policy), BindingException);\r
}\r
catch (XMLToolingException& ex) {\r
TS_TRACE(ex.what());\r
throw;\r
}\r
}\r
-\r
- const char* getMethod() const {\r
- return "GET";\r
- } \r
-\r
- const char* getRequestURL() const {\r
- return "https://sp.example.org/SAML/Artifact";\r
- }\r
- \r
- const char* getQueryString() const {\r
- return NULL;\r
- }\r
\r
SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const {\r
throw BindingException("Not implemented.");\r
}\r
\r
saml1p::Response* resolve(\r
- bool& authenticated,\r
const vector<SAMLArtifact*>& artifacts,\r
const IDPSSODescriptor& idpDescriptor,\r
- const X509TrustEngine* trustEngine=NULL\r
+ SecurityPolicy& policy\r
) const {\r
throw BindingException("Not implemented.");\r
}\r
\r
ArtifactResponse* resolve(\r
- bool& authenticated,\r
const SAML2Artifact& artifact,\r
const SSODescriptorType& ssoDescriptor,\r
- const X509TrustEngine* trustEngine=NULL\r
+ SecurityPolicy& policy\r
) const {\r
XMLObject* xmlObject =\r
SAMLConfig::getConfig().getArtifactMap()->retrieveContent(&artifact, "https://sp.example.org/");\r
sc->setValue(StatusCode::SUCCESS);\r
response->marshall();\r
SchemaValidators.validate(response.get());\r
- authenticated = true;\r
return response.release();\r
}\r
};\r