X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml2%2Fbinding%2Fimpl%2FSAML2SOAPClient.cpp;h=4b077ba8bd949daaf701e743085a684e9c22c2c1;hb=b1614d3c1fc1f4230ab2a123f43994127c25462c;hp=673f5fca42587eea80b1187abd571a934ec8cdf5;hpb=932cfaae2176c2eba1a9938dc420591a9551a7f3;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml2/binding/impl/SAML2SOAPClient.cpp b/saml/saml2/binding/impl/SAML2SOAPClient.cpp index 673f5fc..4b077ba 100644 --- a/saml/saml2/binding/impl/SAML2SOAPClient.cpp +++ b/saml/saml2/binding/impl/SAML2SOAPClient.cpp @@ -37,29 +37,19 @@ using namespace xmltooling; using namespace log4cpp; using namespace std; -void SAML2SOAPClient::sendSAML(RequestAbstractType* request, const RoleDescriptor& peer, const char* endpoint) +void SAML2SOAPClient::sendSAML(RequestAbstractType* request, MetadataCredentialCriteria& peer, const char* endpoint) { - Envelope* env = EnvelopeBuilder::buildEnvelope(); + auto_ptr env(EnvelopeBuilder::buildEnvelope()); Body* body = BodyBuilder::buildBody(); env->setBody(body); body->getUnknownXMLObjects().push_back(request); - try { - send(env, peer, endpoint); - m_correlate = XMLString::replicate(request->getID()); - delete env; - } - catch (XMLToolingException&) { - // A bit weird...we have to "revert" things so that the request is isolated - // so the caller can free it. - request->getParent()->detach(); - request->detach(); - throw; - } + m_soaper.send(*env.get(), peer, endpoint); + m_correlate = XMLString::replicate(request->getID()); } StatusResponseType* SAML2SOAPClient::receiveSAML() { - auto_ptr env(receive()); + auto_ptr env(m_soaper.receive()); if (env.get()) { Body* body = env->getBody(); if (body && body->hasChildren()) { @@ -68,7 +58,7 @@ StatusResponseType* SAML2SOAPClient::receiveSAML() if (response) { // Check InResponseTo. - if (m_correlate && !XMLString::equals(m_correlate, response->getInResponseTo())) + if (m_correlate && response->getInResponseTo() && !XMLString::equals(m_correlate, response->getInResponseTo())) throw BindingException("InResponseTo attribute did not correlate with the Request ID."); // Check Status. @@ -79,7 +69,10 @@ StatusResponseType* SAML2SOAPClient::receiveSAML() throw BindingException("SAML Response contained an error."); } - m_policy.evaluate(*response); + m_soaper.getPolicy().evaluate(*response); + if (!m_soaper.getPolicy().isSecure()) + throw BindingException("Security policy could not authenticate the message."); + env.release(); body->detach(); // frees Envelope response->detach(); // frees Body