From db73d545aa4ca3c1b31717bc71376270f315e727 Mon Sep 17 00:00:00 2001 From: cantor Date: Sat, 9 Oct 2010 21:56:48 +0000 Subject: [PATCH] Replace generic methods for creating DiscoveryResponse extension. git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/branches/REL_2@3333 cb58f699-b61c-0410-a6fe-9272a202ed29 --- shibsp/handler/impl/SAMLDSSessionInitiator.cpp | 36 ++++++++------------------ 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/shibsp/handler/impl/SAMLDSSessionInitiator.cpp b/shibsp/handler/impl/SAMLDSSessionInitiator.cpp index 9398d8a..e1a31ea 100644 --- a/shibsp/handler/impl/SAMLDSSessionInitiator.cpp +++ b/shibsp/handler/impl/SAMLDSSessionInitiator.cpp @@ -69,17 +69,13 @@ namespace shibsp { if (role.getExtensions()) { const vector& exts = const_cast(role.getExtensions())->getUnknownXMLObjects(); for (vector::const_reverse_iterator i = exts.rbegin(); i != exts.rend(); ++i) { - if (XMLString::equals((*i)->getElementQName().getLocalPart(), LOCAL_NAME) && - XMLString::equals((*i)->getElementQName().getNamespaceURI(), m_discoNS.get())) { - const AttributeExtensibleXMLObject* sub = dynamic_cast(*i); - if (sub) { - const XMLCh* val = sub->getAttribute(xmltooling::QName(nullptr,IndexedEndpointType::INDEX_ATTRIB_NAME)); - if (val) { - int maxindex = XMLString::parseInt(val); - if (ix.second <= maxindex) - ix.second = maxindex + 1; - break; - } + const DiscoveryResponse* sub = dynamic_cast(*i); + if (sub) { + pair val = sub->getIndex(); + if (val.first) { + if (ix.second <= val.second) + ix.second = val.second + 1; + break; } } } @@ -92,14 +88,10 @@ namespace shibsp { hurl += loc; auto_ptr_XMLCh widen(hurl.c_str()); - ostringstream os; - os << ix.second; - auto_ptr_XMLCh widen2(os.str().c_str()); - - ElementProxy* ep = new AnyElementImpl(m_discoNS.get(), LOCAL_NAME); - ep->setAttribute(xmltooling::QName(nullptr,EndpointType::LOCATION_ATTRIB_NAME), widen.get()); - ep->setAttribute(xmltooling::QName(nullptr,EndpointType::BINDING_ATTRIB_NAME), m_discoNS.get()); - ep->setAttribute(xmltooling::QName(nullptr,IndexedEndpointType::INDEX_ATTRIB_NAME), widen2.get()); + DiscoveryResponse* ep = DiscoveryResponseBuilder::buildDiscoveryResponse(); + ep->setLocation(widen.get()); + ep->setBinding(samlconstants::IDP_DISCOVERY_PROTOCOL_NS); + ep->setIndex(ix.second); Extensions* ext = role.getExtensions(); if (!ext) { ext = ExtensionsBuilder::buildExtensions(); @@ -113,9 +105,6 @@ namespace shibsp { const char* m_url; const char* m_returnParam; vector m_preservedOptions; -#ifndef SHIBSP_LITE - auto_ptr_XMLCh m_discoNS; -#endif }; #if defined (_MSC_VER) @@ -131,9 +120,6 @@ namespace shibsp { SAMLDSSessionInitiator::SAMLDSSessionInitiator(const DOMElement* e, const char* appId) : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".SessionInitiator.SAMLDS")), m_url(nullptr), m_returnParam(nullptr) -#ifndef SHIBSP_LITE - ,m_discoNS("urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol") -#endif { pair url = getString("URL"); if (!url.first) -- 2.1.4