From: cantor Date: Thu, 15 Feb 2007 22:46:09 +0000 (+0000) Subject: Correct constness of transport API, handle both chunked and buffered encoding. X-Git-Tag: 2.4~1008 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fsp.git;a=commitdiff_plain;h=c65b3598d3fb4f4561b8955c86253d0f657ac684 Correct constness of transport API, handle both chunked and buffered encoding. git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2169 cb58f699-b61c-0410-a6fe-9272a202ed29 --- diff --git a/configs/shibboleth.xml.in b/configs/shibboleth.xml.in index e24d5c3..93d84a8 100644 --- a/configs/shibboleth.xml.in +++ b/configs/shibboleth.xml.in @@ -212,6 +212,7 @@ signedAssertions="false" requireConfidentiality="true" requireTransportAuth="true" + chunkedEncoding="true" connectTimeout="15" timeout="30" > diff --git a/schemas/shibboleth-spconfig-2.0.xsd b/schemas/shibboleth-spconfig-2.0.xsd index 4054f2e..ca63927 100644 --- a/schemas/shibboleth-spconfig-2.0.xsd +++ b/schemas/shibboleth-spconfig-2.0.xsd @@ -521,6 +521,7 @@ + diff --git a/shibsp/binding/SOAPClient.h b/shibsp/binding/SOAPClient.h index f19af64..6267048 100644 --- a/shibsp/binding/SOAPClient.h +++ b/shibsp/binding/SOAPClient.h @@ -64,7 +64,7 @@ namespace shibsp { * * @param transport reference to transport layer */ - void prepareTransport(const xmltooling::SOAPTransport& transport); + void prepareTransport(xmltooling::SOAPTransport& transport); /** Application supplied to client. */ const Application& m_app; diff --git a/shibsp/binding/impl/SOAPClient.cpp b/shibsp/binding/impl/SOAPClient.cpp index 7e9ec74..97363e8 100644 --- a/shibsp/binding/impl/SOAPClient.cpp +++ b/shibsp/binding/impl/SOAPClient.cpp @@ -38,6 +38,18 @@ using namespace xmltooling; using namespace log4cpp; using namespace std; +namespace { + class SHIBSP_DLLLOCAL _addcert : public binary_function { + public: + void operator()(X509Data* bag, XSECCryptoX509* cert) const { + safeBuffer& buf=cert->getDEREncodingSB(); + X509Certificate* x=X509CertificateBuilder::buildX509Certificate(); + x->setValue(buf.sbStrToXMLCh()); + bag->getX509Certificates().push_back(x); + } + }; +}; + SOAPClient::SOAPClient(const Application& application, opensaml::SecurityPolicy& policy) : opensaml::SOAPClient(policy), m_app(application), m_settings(NULL), m_credUse(NULL), m_credResolver(NULL) { @@ -51,18 +63,6 @@ SOAPClient::SOAPClient(const Application& application, opensaml::SecurityPolicy& policy.setTrustEngine(application.getTrustEngine()); } -namespace { - class SHIBSP_DLLLOCAL _addcert : public binary_function { - public: - void operator()(X509Data* bag, XSECCryptoX509* cert) const { - safeBuffer& buf=cert->getDEREncodingSB(); - X509Certificate* x=X509CertificateBuilder::buildX509Certificate(); - x->setValue(buf.sbStrToXMLCh()); - bag->getX509Certificates().push_back(x); - } - }; -}; - void SOAPClient::send(const soap11::Envelope& env, const KeyInfoSource& peer, const char* endpoint) { if (!m_peer) @@ -116,7 +116,7 @@ void SOAPClient::send(const soap11::Envelope& env, const KeyInfoSource& peer, co opensaml::SOAPClient::send(env, peer, endpoint); } -void SOAPClient::prepareTransport(const SOAPTransport& transport) +void SOAPClient::prepareTransport(SOAPTransport& transport) { #ifdef _DEBUG xmltooling::NDC("prepareTransport"); @@ -185,9 +185,12 @@ void SOAPClient::prepareTransport(const SOAPTransport& transport) transport.setConnectTimeout(m_settings->getUnsignedInt("connectTimeout").second); transport.setTimeout(m_settings->getUnsignedInt("timeout").second); - const HTTPSOAPTransport* http = dynamic_cast(&transport); - if (http) + HTTPSOAPTransport* http = dynamic_cast(&transport); + if (http) { + flag = m_settings->getBool("chunkedEncoding"); + http->useChunkedEncoding(!flag.first || flag.second); http->setRequestHeader("Shibboleth", PACKAGE_VERSION); + } } void SOAPClient::reset() diff --git a/util/samlquery.cpp b/util/samlquery.cpp index d1af42c..d71ea08 100644 --- a/util/samlquery.cpp +++ b/util/samlquery.cpp @@ -103,8 +103,7 @@ int main(int argc,char* argv[]) SPConfig::Trust | SPConfig::Credentials | SPConfig::AttributeResolver | - SPConfig::OutOfProcess | - SPConfig::Caching + SPConfig::OutOfProcess ); if (!conf.init(path)) return -10; @@ -171,22 +170,22 @@ int main(int argc,char* argv[]) continue; auto_ptr_char loc((*ep)->getLocation()); NameID* nameid = NameIDBuilder::buildNameID(); - Issuer* iss = IssuerBuilder::buildIssuer(); opensaml::saml2::Subject* subject = opensaml::saml2::SubjectBuilder::buildSubject(); + subject->setNameID(nameid); opensaml::saml2p::AttributeQuery* query = opensaml::saml2p::AttributeQueryBuilder::buildAttributeQuery(); + query->setSubject(subject); + Issuer* iss = IssuerBuilder::buildIssuer(); + query->setIssuer(iss); nameid->setName(name.get()); nameid->setFormat(format.get() ? format.get() : NameID::TRANSIENT); nameid->setNameQualifier(domain.get()); iss->setName(issuer.get()); - subject->setNameID(nameid); - query->setSubject(subject); - query->setIssuer(iss); SAML2SOAPClient client(soaper); client.sendSAML(query, *AA, loc.get()); srt = client.receiveSAML(); } catch (exception& ex) { - cerr << ex.what() << endl; + cerr << "Caught exception: " << ex.what() << endl << endl; soaper.reset(); } } @@ -214,13 +213,14 @@ int main(int argc,char* argv[]) auto_ptr_char loc((*ep)->getLocation()); NameIdentifier* nameid = NameIdentifierBuilder::buildNameIdentifier(); opensaml::saml1::Subject* subject = opensaml::saml1::SubjectBuilder::buildSubject(); + subject->setNameIdentifier(nameid); opensaml::saml1p::AttributeQuery* query = opensaml::saml1p::AttributeQueryBuilder::buildAttributeQuery(); + query->setSubject(subject); Request* request = RequestBuilder::buildRequest(); + request->setAttributeQuery(query); nameid->setName(name.get()); nameid->setFormat(format.get() ? format.get() : shibspconstants::SHIB1_NAMEID_FORMAT_URI); nameid->setNameQualifier(domain.get()); - subject->setNameIdentifier(nameid); - query->setSubject(subject); query->setResource(issuer.get()); request->setMinorVersion(ver==v11 ? 1 : 0); SAML1SOAPClient client(soaper); @@ -228,7 +228,7 @@ int main(int argc,char* argv[]) response = client.receiveSAML(); } catch (exception& ex) { - cerr << ex.what() << endl; + cerr << "Caught exception: " << ex.what() << endl << endl; soaper.reset(); } }