[cpp-sp] 04/04: SSPCPP-825 - Multiple <ApplicationOverride> results shibsp::ConfigurationException
Scott Cantor
cantor.2 at osu.edu
Wed Jul 18 12:33:12 EDT 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=c28fb03f17433fd07ff70cc5d959b2f912507a1c
commit c28fb03f17433fd07ff70cc5d959b2f912507a1c
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jul 18 12:32:04 2018 -0400
SSPCPP-825 - Multiple <ApplicationOverride> results shibsp::ConfigurationException
https://issues.shibboleth.net/jira/browse/SSPCPP-825
---
shibsp/impl/XMLApplication.cpp | 73 +++++++++++++++++++++++---------------
shibsp/impl/XMLServiceProvider.cpp | 2 +-
2 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/shibsp/impl/XMLApplication.cpp b/shibsp/impl/XMLApplication.cpp
index a40f261..508c7c8 100644
--- a/shibsp/impl/XMLApplication.cpp
+++ b/shibsp/impl/XMLApplication.cpp
@@ -675,6 +675,10 @@ void XMLApplication::doSSO(const ProtocolProvider& pp, set<string>& protocols, D
{
if (!e->hasChildNodes())
return;
+
+ // This denotes whether the SSO element has been processed before or is specific to an override.
+ bool hasChildElements = e->getFirstElementChild() != nullptr;
+
const DOMNamedNodeMap* ssoprops = e->getAttributes();
XMLSize_t ssopropslen = ssoprops ? ssoprops->getLength() : 0;
@@ -693,11 +697,13 @@ void XMLApplication::doSSO(const ProtocolProvider& pp, set<string>& protocols, D
log.info("auto-configuring SSO initiation for protocol (%s)", prot.get());
pair<bool,const XMLCh*> inittype = initiator->getXMLString("id");
if (inittype.first) {
- // Append a session initiator element of the designated type to the root element.
- DOMElement* sidom = e->getOwnerDocument()->createElementNS(e->getNamespaceURI(), _SessionInitiator);
- sidom->setAttributeNS(nullptr, _type, inittype.second);
- e->appendChild(sidom);
- log.info("adding SessionInitiator of type (%s) to chain (/Login)", initiator->getString("id").second);
+ if (!hasChildElements) {
+ // Append a session initiator element of the designated type to the root element.
+ DOMElement* sidom = e->getOwnerDocument()->createElementNS(e->getNamespaceURI(), _SessionInitiator);
+ sidom->setAttributeNS(nullptr, _type, inittype.second);
+ e->appendChild(sidom);
+ log.info("adding SessionInitiator of type (%s) to chain (/Login)", initiator->getString("id").second);
+ }
doArtifactResolution(pp, prot.get(), e, log);
protocols.insert(prot.get());
@@ -776,28 +782,33 @@ void XMLApplication::doSSO(const ProtocolProvider& pp, set<string>& protocols, D
static const XMLCh discoveryProtocol[] = UNICODE_LITERAL_17(d,i,s,c,o,v,e,r,y,P,r,o,t,o,c,o,l);
static const XMLCh discoveryURL[] = UNICODE_LITERAL_12(d,i,s,c,o,v,e,r,y,U,R,L);
static const XMLCh _URL[] = UNICODE_LITERAL_3(U,R,L);
- const XMLCh* discop = e->getAttributeNS(nullptr, discoveryProtocol);
- if (discop && *discop) {
- const XMLCh* discou = e->getAttributeNS(nullptr, discoveryURL);
- if (discou && *discou) {
- // Append a session initiator element of the designated type to the root element.
- DOMElement* sidom = e->getOwnerDocument()->createElementNS(e->getNamespaceURI(), _SessionInitiator);
- sidom->setAttributeNS(nullptr, _type, discop);
- sidom->setAttributeNS(nullptr, _URL, discou);
- e->appendChild(sidom);
- if (log.isInfoEnabled()) {
- auto_ptr_char dp(discop);
- log.info("adding SessionInitiator of type (%s) to chain (/Login)", dp.get());
+
+ if (!hasChildElements) {
+ const XMLCh* discop = e->getAttributeNS(nullptr, discoveryProtocol);
+ if (discop && *discop) {
+ const XMLCh* discou = e->getAttributeNS(nullptr, discoveryURL);
+ if (discou && *discou) {
+ // Append a session initiator element of the designated type to the root element.
+ DOMElement* sidom = e->getOwnerDocument()->createElementNS(e->getNamespaceURI(), _SessionInitiator);
+ sidom->setAttributeNS(nullptr, _type, discop);
+ sidom->setAttributeNS(nullptr, _URL, discou);
+ e->appendChild(sidom);
+ if (log.isInfoEnabled()) {
+ auto_ptr_char dp(discop);
+ log.info("adding SessionInitiator of type (%s) to chain (/Login)", dp.get());
+ }
+ }
+ else {
+ log.error("SSO discoveryProtocol specified without discoveryURL");
}
- }
- else {
- log.error("SSO discoveryProtocol specified without discoveryURL");
}
}
- // Attach default Location to SSO element.
- static const XMLCh _loc[] = { chForwardSlash, chLatin_L, chLatin_o, chLatin_g, chLatin_i, chLatin_n, chNull };
- e->setAttributeNS(nullptr, Location, _loc);
+ if (!hasChildElements) {
+ // Attach default Location to SSO element.
+ static const XMLCh _loc[] = { chForwardSlash, chLatin_L, chLatin_o, chLatin_g, chLatin_i, chLatin_n, chNull };
+ e->setAttributeNS(nullptr, Location, _loc);
+ }
// Instantiate Chaining initiator around the SSO element.
boost::shared_ptr<SessionInitiator> chain(
@@ -812,6 +823,10 @@ void XMLApplication::doLogout(const ProtocolProvider& pp, set<string>& protocols
{
if (!e->hasChildNodes())
return;
+
+ // This denotes whether the Logout element has been processed before or is specific to an override.
+ bool hasChildElements = e->getFirstElementChild() != nullptr;
+
const DOMNamedNodeMap* sloprops = e->getAttributes();
XMLSize_t slopropslen = sloprops ? sloprops->getLength() : 0;
@@ -828,11 +843,13 @@ void XMLApplication::doLogout(const ProtocolProvider& pp, set<string>& protocols
log.info("auto-configuring Logout initiation for protocol (%s)", prot.get());
pair<bool,const XMLCh*> inittype = initiator->getXMLString("id");
if (inittype.first) {
- // Append a logout initiator element of the designated type to the root element.
- DOMElement* lidom = e->getOwnerDocument()->createElementNS(e->getNamespaceURI(), _LogoutInitiator);
- lidom->setAttributeNS(nullptr, _type, inittype.second);
- e->appendChild(lidom);
- log.info("adding LogoutInitiator of type (%s) to chain (/Logout)", initiator->getString("id").second);
+ if (!hasChildElements) {
+ // Append a logout initiator element of the designated type to the root element.
+ DOMElement* lidom = e->getOwnerDocument()->createElementNS(e->getNamespaceURI(), _LogoutInitiator);
+ lidom->setAttributeNS(nullptr, _type, inittype.second);
+ e->appendChild(lidom);
+ log.info("adding LogoutInitiator of type (%s) to chain (/Logout)", initiator->getString("id").second);
+ }
if (protocols.count(prot.get()) == 0) {
doArtifactResolution(pp, prot.get(), e, log);
diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp
index ad09b26..2466ae9 100644
--- a/shibsp/impl/XMLServiceProvider.cpp
+++ b/shibsp/impl/XMLServiceProvider.cpp
@@ -566,7 +566,7 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, XMLConfig* outer,
// Load any overrides.
DOMElement* override = XMLHelper::getFirstChildElement(child, ApplicationOverride);
while (override) {
- boost::shared_ptr<XMLApplication> iapp(new XMLApplication(outer, m_protocolProvider.get(), override, m_deprecationSupport, defapp.get()));
+ boost::shared_ptr<XMLApplication> iapp(new XMLApplication(outer, m_protocolProvider.get(), override, m_deprecationSupport, m_defaultApplication));
if (m_appmap.count(iapp->getId()))
log.crit("found conf:ApplicationOverride element with duplicate id attribute (%s), skipping it", iapp->getId());
else
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list