[cpp-sp] branch main updated: Remove old sources.

Scott Cantor cantor.2 at osu.edu
Tue Jun 3 14:24:45 UTC 2025


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=c0ba35308580d4a5498c8686f481922928d60f23

The following commit(s) were added to refs/heads/main by this push:
     new c0ba3530 Remove old sources.
c0ba3530 is described below

commit c0ba35308580d4a5498c8686f481922928d60f23
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jun 3 10:24:41 2025 -0400

    Remove old sources.
---
 shibsp/impl/XMLApplication.cpp     | 912 -------------------------------------
 shibsp/impl/XMLApplication.h       | 167 -------
 shibsp/impl/XMLServiceProvider.cpp | 644 --------------------------
 shibsp/impl/XMLServiceProvider.h   | 147 ------
 4 files changed, 1870 deletions(-)

diff --git a/shibsp/impl/XMLApplication.cpp b/shibsp/impl/XMLApplication.cpp
deleted file mode 100644
index 5a51ea55..00000000
--- a/shibsp/impl/XMLApplication.cpp
+++ /dev/null
@@ -1,912 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * XMLServiceProvider.cpp
- *
- * XML-based SP configuration and mgmt.
- */
-
-#include "internal.h"
-#include "ServiceProvider.h"
-#include "SPConfig.h"
-#include "handler/LogoutInitiator.h"
-#include "handler/SessionInitiator.h"
-#include "impl/XMLApplication.h"
-#include "util/SPConstants.h"
-#include "util/PluginManager.h"
-
-#define BOOST_BIND_GLOBAL_PLACEHOLDERS
-#include <boost/bind.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/algorithm/string.hpp>
-#include <xercesc/util/XMLStringTokenizer.hpp>
-#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/util/XMLConstants.h>
-#include <xmltooling/util/XMLHelper.h>
-
-using namespace shibsp;
-using namespace xmltooling;
-using namespace boost::algorithm;
-using namespace boost;
-using namespace std;
-
-namespace {
-
-    static vector<const Handler*> g_noHandlers;
-
-    static const XMLCh applicationId[] =        UNICODE_LITERAL_13(a,p,p,l,i,c,a,t,i,o,n,I,d);
-    static const XMLCh ApplicationOverride[] =  UNICODE_LITERAL_19(A,p,p,l,i,c,a,t,i,o,n,O,v,e,r,r,i,d,e);
-    static const XMLCh _AttributeExtractor[] =  UNICODE_LITERAL_18(A,t,t,r,i,b,u,t,e,E,x,t,r,a,c,t,o,r);
-    static const XMLCh _AttributeFilter[] =     UNICODE_LITERAL_15(A,t,t,r,i,b,u,t,e,F,i,l,t,e,r);
-    static const XMLCh _AttributeResolver[] =   UNICODE_LITERAL_17(A,t,t,r,i,b,u,t,e,R,e,s,o,l,v,e,r);
-    static const XMLCh _AssertionConsumerService[] = UNICODE_LITERAL_24(A,s,s,e,r,t,i,o,n,C,o,n,s,u,m,e,r,S,e,r,v,i,c,e);
-    static const XMLCh _Audience[] =            UNICODE_LITERAL_8(A,u,d,i,e,n,c,e);
-    static const XMLCh Binding[] =              UNICODE_LITERAL_7(B,i,n,d,i,n,g);
-    static const XMLCh Channel[]=               UNICODE_LITERAL_7(C,h,a,n,n,e,l);
-    static const XMLCh _CredentialResolver[] =  UNICODE_LITERAL_18(C,r,e,d,e,n,t,i,a,l,R,e,s,o,l,v,e,r);
-    static const XMLCh _default[] =             UNICODE_LITERAL_7(d,e,f,a,u,l,t);
-    static const XMLCh ExternalApplicationOverrides[] = UNICODE_LITERAL_28(E,x,t,e,r,n,a,l,A,p,p,l,i,c,a,t,i,o,n,O,v,e,r,r,i,d,e,s);
-    static const XMLCh _Handler[] =             UNICODE_LITERAL_7(H,a,n,d,l,e,r);
-    static const XMLCh _id[] =                  UNICODE_LITERAL_2(i,d);
-    static const XMLCh _index[] =               UNICODE_LITERAL_5(i,n,d,e,x);
-    static const XMLCh Location[] =             UNICODE_LITERAL_8(L,o,c,a,t,i,o,n);
-    static const XMLCh Logout[] =               UNICODE_LITERAL_6(L,o,g,o,u,t);
-    static const XMLCh _LogoutInitiator[] =     UNICODE_LITERAL_15(L,o,g,o,u,t,I,n,i,t,i,a,t,o,r);
-    static const XMLCh _MetadataProvider[] =    UNICODE_LITERAL_16(M,e,t,a,d,a,t,a,P,r,o,v,i,d,e,r);
-    static const XMLCh NameIDMgmt[] =           UNICODE_LITERAL_10(N,a,m,e,I,D,M,g,m,t);
-    static const XMLCh Notify[] =               UNICODE_LITERAL_6(N,o,t,i,f,y);
-    static const XMLCh _policyId[] =            UNICODE_LITERAL_8(p,o,l,i,c,y,I,d);
-    static const XMLCh RelyingParty[] =         UNICODE_LITERAL_12(R,e,l,y,i,n,g,P,a,r,t,y);
-    static const XMLCh _SessionInitiator[] =    UNICODE_LITERAL_16(S,e,s,s,i,o,n,I,n,i,t,i,a,t,o,r);
-    static const XMLCh _SingleLogoutService[] = UNICODE_LITERAL_19(S,i,n,g,l,e,L,o,g,o,u,t,S,e,r,v,i,c,e);
-    static const XMLCh SSO[] =                  UNICODE_LITERAL_3(S,S,O);
-    static const XMLCh _TrustEngine[] =         UNICODE_LITERAL_11(T,r,u,s,t,E,n,g,i,n,e);
-    static const XMLCh _type[] =                UNICODE_LITERAL_4(t,y,p,e);
-};
-
-XMLApplication::XMLApplication(
-    const ServiceProvider* sp,
-    DOMElement* e,
-    bool deprecationSupport,
-    const XMLApplication* base,
-    DOMDocument* doc
-    ) : Application(sp), m_base(base), m_acsDefault(nullptr), m_sessionInitDefault(nullptr), m_artifactResolutionDefault(nullptr),
-        m_deprecationSupport(deprecationSupport), m_doc(doc)
-{
-    Category& log = Category::getInstance(SHIBSP_LOGCAT ".Application");
-
-    // First load any property sets.
-    map<string,string> remapperMap;
-    remapperMap[shibspconstants::ASCII_SHIB2SPCONFIG_NS] = shibspconstants::ASCII_SHIB3SPCONFIG_NS;
-    remapperMap["relayStateLimit"] = "redirectLimit";
-    remapperMap["relayStateWhitelist"] = "redirectAllow";
-    remapperMap["redirectWhitelist"] = "redirectAllow";
-    DOMPropertySet::STLRemapper remapper(remapperMap);
-    load(e, nullptr, this, &remapper);
-
-    // Process redirect limit policy. Do this before assigning the parent pointer
-    // to ensure we get only our Sessions element.
-    const PropertySet* sessionProps = getPropertySet("Sessions");
-    if (sessionProps) {
-        pair<bool,const char*> prop = sessionProps->getString("redirectLimit");
-        if (prop.first) {
-            if (!strcmp(prop.second, "none"))
-                m_redirectLimit = REDIRECT_LIMIT_NONE;
-            else if (!strcmp(prop.second, "exact"))
-                m_redirectLimit = REDIRECT_LIMIT_EXACT;
-            else if (!strcmp(prop.second, "host"))
-                m_redirectLimit = REDIRECT_LIMIT_HOST;
-            else {
-                if (!strcmp(prop.second, "exact+allow")) {
-                    m_redirectLimit = REDIRECT_LIMIT_EXACT_ALLOW;
-                }
-                else if (!strcmp(prop.second, "host+allow")) {
-                    m_redirectLimit = REDIRECT_LIMIT_HOST_ALLOW;
-                }
-                else if (!strcmp(prop.second, "allow")) {
-                    m_redirectLimit = REDIRECT_LIMIT_ALLOW;
-                }
-                else if (!strcmp(prop.second, "exact+whitelist")) {
-                    SPConfig::getConfig().deprecation().warn("redirectLimit of \"exact+whitelist\" replaced by \"exact+allow\"");
-                    m_redirectLimit = REDIRECT_LIMIT_EXACT_ALLOW;
-                }
-                else if (!strcmp(prop.second, "host+whitelist")) {
-                    SPConfig::getConfig().deprecation().warn("redirectLimit of \"host+whitelist\" replaced by \"host+allow\"");
-                    m_redirectLimit = REDIRECT_LIMIT_HOST_ALLOW;
-                }
-                else if (!strcmp(prop.second, "whitelist")) {
-                    SPConfig::getConfig().deprecation().warn("redirectLimit of \"whitelist\" replaced by \"allow\"");
-                    m_redirectLimit = REDIRECT_LIMIT_ALLOW;
-                }
-                else {
-                    throw ConfigurationException(string("Unrecognized redirectLimit setting ") + prop.second);
-                }
-                prop = sessionProps->getString("redirectAllow");
-                if (prop.first) {
-                    string dup(prop.second);
-                    trim(dup);
-                    split(m_redirectAllow, dup, is_space(), algorithm::token_compress_on);
-                }
-            }
-        }
-        else if (base) {
-            m_redirectLimit = REDIRECT_LIMIT_INHERIT;
-        }
-        else {
-            m_redirectLimit = REDIRECT_LIMIT_NONE;
-            log.warn("redirectLimit not set, system will operate as an open redirector if not corrected");
-        }
-
-        // Audit some additional settings for logging purposes.
-        prop = sessionProps->getString("cookieProps");
-        if (!prop.first) {
-            log.warn("empty/missing cookieProps setting, set to \"https\" for SSL/TLS-only usage");
-        }
-        else if (!strcmp(prop.second, "http")) {
-            log.warn("insecure cookieProps setting, set to \"https\" for SSL/TLS-only usage");
-        }
-        else if (strcmp(prop.second, "https")) {
-            if (!strstr(prop.second, "secure"))
-                log.warn("custom cookieProps setting should include \"; secure\" for SSL/TLS-only usage");
-            else if (!strstr(prop.second, "HttpOnly"))
-                log.warn("custom cookieProps setting should include \"; HttpOnly\", site is vulnerable to client-side cookie theft");
-
-            while (*prop.second && isspace(*prop.second))
-                ++prop.second;
-            if (*prop.second != ';')
-                log.warn("custom cookieProps setting must begin with a semicolon (;) as a delimiter");
-        }
-
-        pair<bool,bool> handlerSSL = sessionProps->getBool("handlerSSL");
-        if (handlerSSL.first && !handlerSSL.second)
-            log.warn("handlerSSL should be enabled for SSL/TLS-enabled web sites");
-    }
-    else {
-        m_redirectLimit = base ? REDIRECT_LIMIT_INHERIT : REDIRECT_LIMIT_NONE;
-    }
-
-    // Assign parent.
-    if (base)
-        setParent(base);
-
-    SPConfig& conf=SPConfig::getConfig();
-
-    // This used to be an actual hash, but now it's just a hex-encode to avoid xmlsec dependency.
-    static char DIGITS[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
-    string tohash=getId();
-    tohash+=getString("entityID").second;
-    for (const char* ch = tohash.c_str(); *ch; ++ch) {
-        m_hash += (DIGITS[((unsigned char)(0xF0 & *ch)) >> 4 ]);
-        m_hash += (DIGITS[0x0F & *ch]);
-    }
-
-    doAttributeInfo(log);
-
-    if (conf.isEnabled(SPConfig::Handlers))
-        doHandlers(e, log);
-
-    // Notification.
-    const DOMNodeList* nlist = e->getElementsByTagNameNS(e->getNamespaceURI(), Notify);
-    for (XMLSize_t i = 0; nlist && i < nlist->getLength(); ++i) {
-        if (nlist->item(i)->getParentNode()->isSameNode(e)) {
-            const XMLCh* channel = static_cast<DOMElement*>(nlist->item(i))->getAttributeNS(nullptr, Channel);
-            string loc(XMLHelper::getAttrString(static_cast<DOMElement*>(nlist->item(i)), nullptr, Location));
-            if (!loc.empty()) {
-                if (channel && *channel == chLatin_f)
-                    m_frontLogout.push_back(loc);
-                else
-                    m_backLogout.push_back(loc);
-            }
-        }
-    }
-
-#ifndef SHIBSP_LITE
-    // Finally, load relying parties.
-    const DOMElement* child = XMLHelper::getFirstChildElement(e, RelyingParty);
-    while (child) {
-        if (child->hasAttributeNS(nullptr, saml2::Attribute::NAME_ATTRIB_NAME)) {
-            boost::shared_ptr<DOMPropertySet> rp(new DOMPropertySet());
-            rp->load(child, nullptr, this);
-            rp->setParent(this);
-            m_partyMap[child->getAttributeNS(nullptr, saml2::Attribute::NAME_ATTRIB_NAME)] = rp;
-        }
-        else if (child->hasAttributeNS(nullptr, _type)) {
-            string emtype(XMLHelper::getAttrString(child, nullptr, _type));
-            boost::shared_ptr<EntityMatcher> em(SAMLConfig::getConfig().EntityMatcherManager.newPlugin(emtype, child, m_deprecationSupport));
-            boost::shared_ptr<DOMPropertySet> rp(new DOMPropertySet());
-            rp->load(child, nullptr, this);
-            rp->setParent(this);
-            m_partyVec.push_back(make_pair(em, rp));
-        }
-        child = XMLHelper::getNextSiblingElement(child, RelyingParty);
-    }
-    if (base && m_partyMap.empty() && m_partyVec.empty() && (!base->m_partyMap.empty() || !base->m_partyVec.empty())) {
-        // For inheritance of RPs to work, we have to pull them in to the override by cloning the DOM.
-        child = XMLHelper::getFirstChildElement(base->getElement(), RelyingParty);
-        while (child) {
-            if (child->hasAttributeNS(nullptr, saml2::Attribute::NAME_ATTRIB_NAME)) {
-                DOMElement* rpclone = static_cast<DOMElement*>(child->cloneNode(true));
-                boost::shared_ptr<DOMPropertySet> rp(new DOMPropertySet());
-                rp->load(rpclone, nullptr, this);
-                rp->setParent(this);
-                m_partyMap[rpclone->getAttributeNS(nullptr, saml2::Attribute::NAME_ATTRIB_NAME)] = rp;
-            }
-            else if (child->hasAttributeNS(nullptr, _type)) {
-                DOMElement* rpclone = static_cast<DOMElement*>(child->cloneNode(true));
-                string emtype(XMLHelper::getAttrString(rpclone, nullptr, _type));
-                boost::shared_ptr<EntityMatcher> em(SAMLConfig::getConfig().EntityMatcherManager.newPlugin(emtype, rpclone, m_deprecationSupport));
-                boost::shared_ptr<DOMPropertySet> rp(new DOMPropertySet());
-                rp->load(rpclone, nullptr, this);
-                rp->setParent(this);
-                m_partyVec.push_back(make_pair(em, rp));
-            }
-            child = XMLHelper::getNextSiblingElement(child, RelyingParty);
-        }
-    }
-#endif
-}
-
-XMLApplication::~XMLApplication()
-{
-    if (m_doc)
-        m_doc->release();
-}
-
-template <class T> T* XMLApplication::doChainedPlugins(
-    const shibsp::PluginManager<T,string,const DOMElement*>& pluginMgr,
-    const char* pluginType,
-    const char* chainingType,
-    const XMLCh* localName,
-    DOMElement* e,
-    Category& log,
-    const char* dummyType
-    )
-{
-    string t;
-    DOMElement* child = XMLHelper::getFirstChildElement(e, localName);
-    if (child) {
-        // Check for multiple.
-        if (XMLHelper::getNextSiblingElement(child, localName)) {
-            log.info("multiple %s plugins, wrapping in a chain", pluginType);
-            DOMElement* chain = child->getOwnerDocument()->createElementNS(nullptr, localName);
-            while (child) {
-                chain->appendChild(child);
-                child = XMLHelper::getFirstChildElement(e, localName);
-            }
-            t = chainingType;
-            child = chain;
-            e->appendChild(chain);
-        }
-        else {
-            // Only a single one.
-            t = XMLHelper::getAttrString(child, nullptr, _type);
-        }
-
-        try {
-            if (!t.empty()) {
-                log.info("building %s of type %s...", pluginType, t.c_str());
-                return pluginMgr.newPlugin(t.c_str(), child, m_deprecationSupport);
-            }
-            else {
-                throw ConfigurationException("Eelement had no type attribute.");
-            }
-        }
-        catch (const std::exception& ex) {
-            log.crit("error building %s: %s", pluginType, ex.what());
-            if (dummyType) {
-                // Install a dummy version as a safety valve.
-                log.crit("installing safe %s in place of failed version", pluginType);
-                return pluginMgr.newPlugin(dummyType, nullptr, m_deprecationSupport);
-            }
-        }
-    }
-
-    return nullptr;
-}
-
-void XMLApplication::doAttributeInfo(Category& log)
-{
-    // Populate prefix pair.
-    m_attributePrefix.second = "HTTP_";
-    pair<bool,const char*> prefix = getString("attributePrefix");
-    if (prefix.first) {
-#ifdef HAVE_STRCASECMP
-        if (!strcasecmp(prefix.second, "HTTP_")) {
-#else
-        if (!stricmp(prefix.second, "HTTP_")) {
-#endif
-            log.warn("an attributePrefix of HTTP_ allows header smuggling and is unsafe; this will stop working in a future version");
-        }
-
-        m_attributePrefix.first = prefix.second;
-        const char* pch = prefix.second;
-        while (*pch) {
-            m_attributePrefix.second += (isalnum(*pch) ? toupper(*pch) : '_');
-            pch++;
-        }
-    }
-
-    pair<bool,const char*> attributes = getString("REMOTE_USER");
-    if (attributes.first) {
-        string dup(attributes.second);
-        trim(dup);
-        split(m_remoteUsers, dup, is_space(), algorithm::token_compress_on);
-    }
-
-    // Load attribute ID lists for REMOTE_USER and header clearing.
-    if (SPConfig::getConfig().isEnabled(SPConfig::InProcess)) {
-        attributes = getString("unsetHeaders");
-        if (attributes.first) {
-            string transformedprefix(m_attributePrefix.second);
-            const char* pch;
-            prefix = getString("metadataAttributePrefix");
-            if (prefix.first) {
-                pch = prefix.second;
-                while (*pch) {
-                    transformedprefix += (isalnum(*pch) ? toupper(*pch) : '_');
-                    pch++;
-                }
-            }
-
-            string dup(attributes.second);
-            trim(dup);
-            vector<string> headerNames;
-            split(headerNames, dup, is_space(), algorithm::token_compress_on);
-            for (vector<string>::const_iterator h = headerNames.begin(); h != headerNames.end(); ++h) {
-                string transformed;
-                const char* pch = h->c_str();
-                while (*pch) {
-                    transformed += (isalnum(*pch) ? toupper(*pch) : '_');
-                    pch++;
-                }
-                m_unsetHeaders.push_back(pair<string,string>(m_attributePrefix.first + *h, m_attributePrefix.second + transformed));
-                if (prefix.first)
-                    m_unsetHeaders.push_back(pair<string,string>(m_attributePrefix.first + prefix.second + *h, transformedprefix + transformed));
-            }
-            m_unsetHeaders.push_back(pair<string,string>(m_attributePrefix.first + "Shib-Application-ID", m_attributePrefix.second + "SHIB_APPLICATION_ID"));
-        }
-    }
-}
-
-void XMLApplication::doHandlers(const DOMElement* e, Category& log)
-{
-    SPConfig& conf = SPConfig::getConfig();
-
-    const PropertySet* sessions = getPropertySet("Sessions");
-
-    // Look for "shorthand" elements first.
-    set<string> protocols;
-    DOMElement* child = nullptr;
-    while (child) {
-        if (XMLHelper::isNodeNamed(child, nullptr, SSO)) {
-            if (false)
-                doSSO(protocols, child, log);
-            else
-                log.error("no ProtocolProvider, SSO auto-configure unsupported");
-        }
-        else if (XMLHelper::isNodeNamed(child, nullptr, Logout)) {
-            if (false)
-                doLogout(protocols, child, log);
-            else
-                log.error("no ProtocolProvider, Logout auto-configure unsupported");
-        }
-        else {
-            break;  // drop into next while loop
-        }
-        child = XMLHelper::getNextSiblingElement(child);
-    }
-
-    // Process other handlers.
-    bool hardACS=false, hardSessionInit=false, hardArt=false;
-    while (child) {
-        if (!child->hasAttributeNS(nullptr, Location)) {
-            auto_ptr_char hclass(child->getLocalName());
-            log.error("%s handler with no Location property cannot be processed for application (%s)",
-                hclass.get(), getId());
-            child = XMLHelper::getNextSiblingElement(child);
-            continue;
-        }
-
-        auto_ptr_char dupcheck(child->getAttributeNS(nullptr, Location));
-        if (dupcheck.get() && *dupcheck.get()) {
-            string _dupcheck(dupcheck.get());
-            if (*_dupcheck.begin() != '/')
-                _dupcheck.insert(_dupcheck.begin(), '/');
-            if (m_handlerMap.find(_dupcheck) != m_handlerMap.end()) {
-                auto_ptr_char hclass(child->getLocalName());
-                log.error("%s handler at duplicate Location (%s) will not be processed for application (%s)",
-                    hclass.get(), _dupcheck.c_str(), getId());
-                child = XMLHelper::getNextSiblingElement(child);
-                continue;
-            }
-        }
-
-        try {
-            boost::shared_ptr<Handler> handler;
-            if (XMLString::equals(child->getLocalName(), _AssertionConsumerService)) {
-                string bindprop(XMLHelper::getAttrString(child, nullptr, Binding));
-                if (bindprop.empty() || !*child->getAttributeNS(nullptr, Location)) {
-                    log.error("AssertionConsumerService element has empty Binding or Location attribute, skipping it...");
-                    child = XMLHelper::getNextSiblingElement(child);
-                    continue;
-                }
-                handler.reset(
-                    conf.AssertionConsumerServiceManager.newPlugin(bindprop.c_str(), pair<const DOMElement*,const char*>(child, getId()), m_deprecationSupport)
-                    );
-                m_acsIndexMap[handler->getUnsignedInt("index").second] = handler.get();
-
-                if (!hardACS) {
-                    pair<bool,bool> defprop = handler->getBool("isDefault");
-                    if (defprop.first) {
-                        if (defprop.second) {
-                            hardACS = true;
-                            m_acsDefault = handler.get();
-                        }
-                    }
-                    else if (!m_acsDefault)
-                        m_acsDefault = handler.get();
-                }
-            }
-            else if (XMLString::equals(child->getLocalName(), _SessionInitiator)) {
-                string t(XMLHelper::getAttrString(child, nullptr, _type));
-                if (t.empty()) {
-                    log.error("SessionInitiator element has no type attribute, skipping it...");
-                    child = XMLHelper::getNextSiblingElement(child);
-                    continue;
-                }
-                boost::shared_ptr<SessionInitiator> sihandler(
-                    conf.SessionInitiatorManager.newPlugin(t.c_str(), pair<const DOMElement*,const char*>(child, getId()), m_deprecationSupport)
-                    );
-                handler = sihandler;
-                pair<bool,const char*> si_id = handler->getString("id");
-                if (si_id.first && si_id.second)
-                    m_sessionInitMap[si_id.second] = sihandler.get();
-                if (!hardSessionInit) {
-                    pair<bool,bool> defprop = handler->getBool("isDefault");
-                    if (defprop.first) {
-                        if (defprop.second) {
-                            hardSessionInit = true;
-                            m_sessionInitDefault = sihandler.get();
-                        }
-                    }
-                    else if (!m_sessionInitDefault) {
-                        m_sessionInitDefault = sihandler.get();
-                    }
-                }
-            }
-            else if (XMLString::equals(child->getLocalName(), _LogoutInitiator)) {
-                string t(XMLHelper::getAttrString(child, nullptr, _type));
-                if (t.empty()) {
-                    log.error("LogoutInitiator element has no type attribute, skipping it...");
-                    child = XMLHelper::getNextSiblingElement(child);
-                    continue;
-                }
-                handler.reset(
-                    conf.LogoutInitiatorManager.newPlugin(t.c_str(), pair<const DOMElement*,const char*>(child, getId()), m_deprecationSupport)
-                    );
-            }
-            else if (XMLString::equals(child->getLocalName(), _SingleLogoutService)) {
-                string bindprop(XMLHelper::getAttrString(child, nullptr, Binding));
-                if (bindprop.empty() || !*child->getAttributeNS(nullptr, Location)) {
-                    log.error("SingleLogoutService element has empty Binding or Location attribute, skipping it...");
-                    child = XMLHelper::getNextSiblingElement(child);
-                    continue;
-                }
-                handler.reset(
-                    conf.SingleLogoutServiceManager.newPlugin(bindprop.c_str(), pair<const DOMElement*,const char*>(child, getId()), m_deprecationSupport)
-                    );
-            }
-            else {
-                string t(XMLHelper::getAttrString(child, nullptr, _type));
-                if (t.empty()) {
-                    log.error("Handler element has no type attribute, skipping it...");
-                    child = XMLHelper::getNextSiblingElement(child);
-                    continue;
-                }
-                handler.reset(conf.HandlerManager.newPlugin(t.c_str(), pair<const DOMElement*,const char*>(child, getId()), m_deprecationSupport));
-            }
-
-            m_handlers.push_back(handler);
-
-            // Insert into location map.
-            pair<bool,const char*> location = handler->getString("Location");
-            if (location.first && *location.second == '/')
-                m_handlerMap[location.second] = handler.get();
-            else if (location.first)
-                m_handlerMap[string("/") + location.second] = handler.get();
-        }
-        catch (const std::exception& ex) {
-            log.error("caught exception processing handler element: %s", ex.what());
-        }
-
-        child = XMLHelper::getNextSiblingElement(child);
-    }
-}
-
-void XMLApplication::doSSO(set<string>& protocols, DOMElement* e, Category& log)
-{
-}
-
-void XMLApplication::doLogout(set<string>& protocols, DOMElement* e, Category& log)
-{
-}
-
-void XMLApplication::doArtifactResolution(const char* protocol, DOMElement* e, Category& log)
-{
- 
-}
-
-DOMNodeFilter::FilterAction XMLApplication::acceptNode(const DOMNode* node) const
-{
-    const XMLCh* name=node->getLocalName();
-    if (XMLString::equals(name, ApplicationOverride) ||
-        XMLString::equals(name, _Audience) ||
-        XMLString::equals(name, Notify) ||
-        XMLString::equals(name, _Handler) ||
-        XMLString::equals(name, _AssertionConsumerService) ||
-        XMLString::equals(name, Logout) ||
-        XMLString::equals(name, _LogoutInitiator) ||
-        XMLString::equals(name, _SessionInitiator) ||
-        XMLString::equals(name, _SingleLogoutService) ||
-        XMLString::equals(name, SSO) ||
-        XMLString::equals(name, RelyingParty) ||
-        XMLString::equals(name, _MetadataProvider) ||
-        XMLString::equals(name, _TrustEngine) ||
-        XMLString::equals(name, _CredentialResolver) ||
-        XMLString::equals(name, _AttributeFilter) ||
-        XMLString::equals(name, _AttributeExtractor) ||
-        XMLString::equals(name, _AttributeResolver) ||
-        XMLString::equals(name, ExternalApplicationOverrides)) {
-        return FILTER_REJECT;
-    }
-
-    const XMLCh _cookieProps[] = UNICODE_LITERAL_11(c,o,o,k,i,e,P,r,o,p,s);
-    const XMLCh _http[] = UNICODE_LITERAL_4(h,t,t,p);
-    const XMLCh _https[] = UNICODE_LITERAL_5(h,t,t,p,s);
-    const XMLCh _Sessions[] = UNICODE_LITERAL_8(S,e,s,s,i,o,n,s);
-
-    if (XMLString::equals(name, _Sessions)) {
-        // This is a hack, but it's a fairly clean way to mutate a setting.
-        DOMNode* cookieProps = node->getAttributes()->getNamedItemNS(nullptr, _cookieProps);
-        if (cookieProps) {
-            const XMLCh* val = cookieProps->getNodeValue();
-            if (!val || (*val != chSemiColon && !XMLString::equals(val, _http) && !XMLString::equals(val, _https))) {
-                xstring newval(1, chSemiColon);
-                newval += chSpace;
-                newval += val;
-                cookieProps->setNodeValue(newval.c_str());
-            }
-        }
-    }
-
-    return FILTER_ACCEPT;
-}
-
-#ifndef SHIBSP_LITE
-
-pair<bool, const char*> XMLApplication::getString(const char* name, const char* ns) const
-{
-    if (!SPConfig::getConfig().isEnabled(SPConfig::InProcess)) {
-        if (!ns && !strcmp(name, "entityID")) {
-            const ListenerService* listener = getServiceProvider().getListenerService(false);
-            DDF* in = listener ? listener->getInput() : nullptr;
-            if (in) {
-                const char* entityID = in->getmember("_mapped")["entityID"].string();
-                if (entityID)
-                    return make_pair(true, entityID);
-            }
-        }
-    }
-
-    return DOMPropertySet::getString(name, ns);
-}
-
-pair<bool, const XMLCh*> XMLApplication::getXMLString(const char* name, const char* ns) const
-{
-    if (!SPConfig::getConfig().isEnabled(SPConfig::InProcess)) {
-        if (!ns && !strcmp(name, "entityID")) {
-            const ListenerService* listener = getServiceProvider().getListenerService(false);
-            DDF* in = listener ? listener->getInput() : nullptr;
-            if (in) {
-                void* entityID = in->getmember("_mapped")["entityID-16"].pointer();
-                if (entityID)
-                    return make_pair(true, reinterpret_cast<const XMLCh*>(entityID));
-            }
-        }
-    }
-
-    return DOMPropertySet::getXMLString(name, ns);
-}
-
-const PropertySet* XMLApplication::getRelyingParty(const EntityDescriptor* provider) const
-{
-    if (!provider)
-        return this;
-
-    // Check for exact match on name.
-    map< xstring,boost::shared_ptr<PropertySet> >::const_iterator i = m_partyMap.find(provider->getEntityID());
-    if (i != m_partyMap.end())
-        return i->second.get();
-
-    // Check for extensible matching.
-    vector < pair< boost::shared_ptr<EntityMatcher>,boost::shared_ptr<PropertySet> > >::const_iterator j;
-    for (j = m_partyVec.begin(); j != m_partyVec.end(); ++j) {
-        if (j->first->matches(*provider))
-            return j->second.get();
-    }
-
-    // Check for group match.
-    const EntitiesDescriptor* group = dynamic_cast<const EntitiesDescriptor*>(provider->getParent());
-    while (group) {
-        if (group->getName()) {
-            i = m_partyMap.find(group->getName());
-            if (i != m_partyMap.end())
-                return i->second.get();
-        }
-        group = dynamic_cast<const EntitiesDescriptor*>(group->getParent());
-    }
-    return this;
-}
-
-const PropertySet* XMLApplication::getRelyingParty(const XMLCh* entityID) const
-{
-    if (!entityID)
-        return this;
-    map< xstring,boost::shared_ptr<PropertySet> >::const_iterator i = m_partyMap.find(entityID);
-    return (i != m_partyMap.end()) ? i->second.get() : this;
-}
-
-#endif
-
-string XMLApplication::getNotificationURL(const char* resource, bool front, unsigned int index) const
-{
-    const vector<string>& locs = front ? m_frontLogout : m_backLogout;
-    if (locs.empty())
-        return m_base ? m_base->getNotificationURL(resource, front, index) : string();
-    else if (index >= locs.size())
-        return string();
-
-#ifdef HAVE_STRCASECMP
-    if (!resource || (strncasecmp(resource,"http://",7) && strncasecmp(resource,"https://",8)))
-#else
-    if (!resource || (strnicmp(resource,"http://",7) && strnicmp(resource,"https://",8)))
-#endif
-        throw ConfigurationException("Request URL was not absolute.");
-
-    const char* handler = locs[index].c_str();
-
-    // Should never happen...
-    if (!handler || (*handler!='/' && strncmp(handler,"http:",5) && strncmp(handler,"https:",6)))
-        throw ConfigurationException("Invalid Location property in Notify element");
-
-    // The "Location" property can be in one of three formats:
-    //
-    // 1) a full URI:       http://host/foo/bar
-    // 2) a hostless URI:   http:///foo/bar
-    // 3) a relative path:  /foo/bar
-    //
-    // #  Protocol  Host        Path
-    // 1  handler   handler     handler
-    // 2  handler   resource    handler
-    // 3  resource  resource    handler
-
-    const char* path = nullptr;
-
-    // Decide whether to use the handler or the resource for the "protocol"
-    const char* prot;
-    if (*handler != '/') {
-        prot = handler;
-    }
-    else {
-        prot = resource;
-        path = handler;
-    }
-
-    // break apart the "protocol" string into protocol, host, and "the rest"
-    const char* colon=strchr(prot,':');
-    colon += 3;
-    const char* slash=strchr(colon,'/');
-    if (!path)
-        path = slash;
-
-    // Compute the actual protocol and store.
-    string notifyURL(prot, colon-prot);
-
-    // create the "host" from either the colon/slash or from the target string
-    // If prot == handler then we're in either #1 or #2, else #3.
-    // If slash == colon then we're in #2.
-    if (prot != handler || slash == colon) {
-        colon = strchr(resource, ':');
-        colon += 3;      // Get past the ://
-        slash = strchr(colon, '/');
-    }
-    string host(colon, (slash ? slash-colon : strlen(colon)));
-
-    // Build the URL
-    notifyURL += host + path;
-    return notifyURL;
-}
-
-void XMLApplication::clearHeader(SPRequest& request, const char* rawname, const char* cginame) const
-{
-    if (!m_attributePrefix.first.empty()) {
-        string temp = m_attributePrefix.first + rawname;
-        string temp2 = m_attributePrefix.second + (cginame + 5);
-        request.clearHeader(temp.c_str(), temp2.c_str());
-    }
-    else if (m_base) {
-        m_base->clearHeader(request, rawname, cginame);
-    }
-    else {
-        request.clearHeader(rawname, cginame);
-    }
-}
-
-void XMLApplication::setHeader(SPRequest& request, const char* name, const char* value) const
-{
-    if (!m_attributePrefix.first.empty()) {
-        string temp = m_attributePrefix.first + name;
-        request.setHeader(temp.c_str(), value);
-    }
-    else if (m_base) {
-        m_base->setHeader(request, name, value);
-    }
-    else {
-        request.setHeader(name, value);
-    }
-}
-
-string XMLApplication::getSecureHeader(const SPRequest& request, const char* name) const
-{
-    if (!m_attributePrefix.first.empty()) {
-        string temp = m_attributePrefix.first + name;
-        return request.getSecureHeader(temp.c_str());
-    }
-    else if (m_base) {
-        return m_base->getSecureHeader(request,name);
-    }
-    else {
-        return request.getSecureHeader(name);
-    }
-}
-
-const SessionInitiator* XMLApplication::getDefaultSessionInitiator() const
-{
-    if (m_sessionInitDefault) return m_sessionInitDefault;
-    return m_base ? m_base->getDefaultSessionInitiator() : nullptr;
-}
-
-const SessionInitiator* XMLApplication::getSessionInitiatorById(const char* id) const
-{
-    map<string,const SessionInitiator*>::const_iterator i = m_sessionInitMap.find(id);
-    if (i != m_sessionInitMap.end()) return i->second;
-    return m_base ? m_base->getSessionInitiatorById(id) : nullptr;
-}
-
-const Handler* XMLApplication::getDefaultAssertionConsumerService() const
-{
-    if (m_acsDefault) return m_acsDefault;
-    return m_base ? m_base->getDefaultAssertionConsumerService() : nullptr;
-}
-
-const Handler* XMLApplication::getAssertionConsumerServiceByIndex(unsigned short index) const
-{
-    map<unsigned int,const Handler*>::const_iterator i = m_acsIndexMap.find(index);
-    if (i != m_acsIndexMap.end()) return i->second;
-    return m_base ? m_base->getAssertionConsumerServiceByIndex(index) : nullptr;
-}
-
-const Handler* XMLApplication::getAssertionConsumerServiceByProtocol(const XMLCh* protocol, const char* binding) const
-{
-    ACSProtocolMap::const_iterator i = m_acsProtocolMap.find(protocol);
-    if (i != m_acsProtocolMap.end() && !i->second.empty()) {
-        if (!binding || !*binding)
-            return i->second.front();
-        for (ACSProtocolMap::value_type::second_type::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
-            if (!strcmp(binding, (*j)->getString("Binding").second))
-                return *j;
-        }
-    }
-    return m_base ? m_base->getAssertionConsumerServiceByProtocol(protocol, binding) : nullptr;
-}
-
-const Handler* XMLApplication::getHandler(const char* path) const
-{
-    string wrap(path);
-    wrap = wrap.substr(0, wrap.find(';'));
-    map<string,const Handler*>::const_iterator i = m_handlerMap.find(wrap.substr(0, wrap.find('?')));
-    if (i != m_handlerMap.end())
-        return i->second;
-    return m_base ? m_base->getHandler(path) : nullptr;
-}
-
-void XMLApplication::getHandlers(vector<const Handler*>& handlers) const
-{
-    static void (vector<const Handler*>::* pb)(const Handler* const&) = &vector<const Handler*>::push_back;
-    // Copy all of the override's handlers.
-    for_each(m_handlers.begin(), m_handlers.end(), boost::bind(pb, boost::ref(handlers), boost::bind(&boost::shared_ptr<Handler>::get, _1)));
-    if (m_base) {
-        if (handlers.empty()) {
-            // If the override doesn't supply any handlers, copy the parent's in normal order.
-            for_each(m_base->m_handlers.begin(), m_base->m_handlers.end(), boost::bind(pb, boost::ref(handlers), boost::bind(&boost::shared_ptr<Handler>::get, _1)));
-        }
-        else {
-            // This unfortunately distorts the usual ordering when it comes to metadata generation, but avoiding that would be a lot of code.
-            for (map<string, const Handler*>::const_iterator h = m_base->m_handlerMap.begin(); h != m_base->m_handlerMap.end(); ++h) {
-                if (m_handlerMap.count(h->first) == 0)
-                    handlers.push_back(h->second);
-            }
-        }
-    }
-}
-
-void XMLApplication::limitRedirect(const GenericRequest& request, const char* url) const
-{
-    if (!url || *url == '/')
-        return;
-    if (m_redirectLimit == REDIRECT_LIMIT_INHERIT)
-        return m_base->limitRedirect(request, url);
-    if (m_redirectLimit != REDIRECT_LIMIT_NONE) {
-
-        // This is ugly, but the purpose is to prevent blocking legitimate redirects
-        // that lack a trailing slash after the hostname. If there are fewer than 3
-        // slashes, we assume the hostname wasn't terminated.
-        string urlcopy(url);
-        if (count(urlcopy.begin(), urlcopy.end(), '/') < 3) {
-            urlcopy += '/';
-        }
-
-        vector<string> allowlist;
-        if (m_redirectLimit == REDIRECT_LIMIT_EXACT || m_redirectLimit == REDIRECT_LIMIT_EXACT_ALLOW) {
-            // Scheme and hostname have to match.
-            if (request.isDefaultPort()) {
-                allowlist.push_back(string(request.getScheme()) + "://" + request.getHostname() + '/');
-            }
-            allowlist.push_back(string(request.getScheme()) + "://" + request.getHostname() + ':' + lexical_cast<string>(request.getPort()) + '/');
-        }
-        else if (m_redirectLimit == REDIRECT_LIMIT_HOST || m_redirectLimit == REDIRECT_LIMIT_HOST_ALLOW) {
-            // Allow any scheme or port.
-            allowlist.push_back(string("https://") + request.getHostname() + '/');
-            allowlist.push_back(string("http://") + request.getHostname() + '/');
-            allowlist.push_back(string("https://") + request.getHostname() + ':');
-            allowlist.push_back(string("http://") + request.getHostname() + ':');
-        }
-
-        if (!allowlist.empty()) {
-            for (vector<string>::const_iterator i = allowlist.begin(); i != allowlist.end(); ++i) {
-                if (istarts_with(urlcopy, *i)) {
-                    return;
-                }
-            }
-        }
-
-        if (!m_redirectAllow.empty()) {
-            for (vector<string>::const_iterator i = m_redirectAllow.begin(); i != m_redirectAllow.end(); ++i) {
-                if (istarts_with(urlcopy, *i)) {
-                    return;
-                }
-            }
-        }
-
-        Category::getInstance(SHIBSP_LOGCAT ".Application").warn("redirectLimit policy enforced, blocked redirect to (%s)", url);
-        throw XMLToolingException("Blocked unacceptable redirect location.");
-    }
-}
diff --git a/shibsp/impl/XMLApplication.h b/shibsp/impl/XMLApplication.h
deleted file mode 100644
index da0e3cee..00000000
--- a/shibsp/impl/XMLApplication.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * XMLApplication.h
- *
- * Internal declaration of Application subclass used by XML-based configurator.
- */
-
-#ifndef __shibsp_xmlapplication_h__
-#define __shibsp_xmlapplication_h__
-
-#include "Application.h"
-#include "exceptions.h"
-#include "SPRequest.h"
-#include "handler/Handler.h"
-#include "util/DOMPropertySet.h"
-#include "util/PluginManager.h"
-
-#include <boost/scoped_ptr.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace xmltooling {
-    class CredentialResolver;
-    class TrustEngine;
-};
-
-namespace shibsp {
-
-    class LogoutInitiator;
-    class ServiceProvider;
-    class SessionInitiator;
-
-#if defined (_MSC_VER)
-    #pragma warning( push )
-    #pragma warning( disable : 4250 )
-#endif
-
-    class SHIBSP_DLLLOCAL XMLApplication
-        : public Application, public DOMPropertySet, public xercesc::DOMNodeFilter
-    {
-    public:
-        XMLApplication(
-            const ServiceProvider*,
-            xercesc::DOMElement*,
-            bool deprecationSupport,
-            const XMLApplication* base=nullptr,
-            xercesc::DOMDocument* doc=nullptr);
-        virtual ~XMLApplication();
-
-        const char* getHash() const {
-            return m_hash.c_str();
-        }
-
-        std::string getNotificationURL(const char* resource, bool front, unsigned int index) const;
-
-        const std::vector<std::string>& getRemoteUserAttributeIds() const {
-            return (m_remoteUsers.empty() && m_base) ? m_base->getRemoteUserAttributeIds() : m_remoteUsers;
-        }
-
-        void clearHeader(SPRequest& request, const char* rawname, const char* cginame) const;
-        void setHeader(SPRequest& request, const char* name, const char* value) const;
-        std::string getSecureHeader(const SPRequest& request, const char* name) const;
-
-        const SessionInitiator* getDefaultSessionInitiator() const;
-        const SessionInitiator* getSessionInitiatorById(const char* id) const;
-        const Handler* getDefaultAssertionConsumerService() const;
-        const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const;
-        const Handler* getAssertionConsumerServiceByProtocol(const XMLCh* protocol, const char* binding=nullptr) const;
-        const Handler* getHandler(const char* path) const;
-        void getHandlers(std::vector<const Handler*>& handlers) const;
-        void limitRedirect(const GenericRequest& request, const char* url) const;
-
-        // Provides filter to exclude special config elements.
-        xercesc::DOMNodeFilter::FilterAction acceptNode(const xercesc::DOMNode* node) const;
-
-    private:
-        template <class T> T* doChainedPlugins(
-            const PluginManager<T, std::string, const xercesc::DOMElement*>& pluginMgr,
-            const char* pluginType,
-            const char* chainingType,
-            const XMLCh* localName,
-            xercesc::DOMElement* e,
-            Category& log,
-            const char* dummyType = nullptr
-        );
-        void doAttributeInfo(Category&);
-        void doHandlers(const xercesc::DOMElement*, Category&);
-        void doSSO(std::set<std::string>&, xercesc::DOMElement*, Category&);
-        void doLogout(std::set<std::string>&, xercesc::DOMElement*, Category&);
-        void doNameIDMgmt(std::set<std::string>&, xercesc::DOMElement*, Category&);
-        void doArtifactResolution(const char*, xercesc::DOMElement*, Category&);
-        const XMLApplication* m_base;
-        std::string m_hash;
-        std::pair<std::string, std::string> m_attributePrefix;
-
-        std::vector<std::string> m_remoteUsers, m_frontLogout, m_backLogout;
-
-        // manage handler objects
-        std::vector< boost::shared_ptr<Handler> > m_handlers;
-
-        // maps location (path info) to applicable handlers
-        std::map<std::string, const Handler*> m_handlerMap;
-
-        // maps unique indexes to consumer services
-        std::map<unsigned int, const Handler*> m_acsIndexMap;
-
-        // pointer to default consumer service
-        const Handler* m_acsDefault;
-
-        // maps protocol strings to supporting consumer service(s)
-        typedef std::map< xmltooling::xstring, std::vector<const Handler*> > ACSProtocolMap;
-        ACSProtocolMap m_acsProtocolMap;
-
-        // pointer to default session initiator
-        const SessionInitiator* m_sessionInitDefault;
-
-        // maps unique ID strings to session initiators
-        std::map<std::string, const SessionInitiator*> m_sessionInitMap;
-
-        // pointer to default artifact resolution service
-        const Handler* m_artifactResolutionDefault;
-
-        std::pair<bool,int> getArtifactEndpointIndex() const {
-            if (m_artifactResolutionDefault) return m_artifactResolutionDefault->getInt("index");
-            return m_base ? m_base->getArtifactEndpointIndex() : std::make_pair(false, 0);
-        }
-
-        enum {
-            REDIRECT_LIMIT_INHERIT,
-            REDIRECT_LIMIT_NONE,
-            REDIRECT_LIMIT_EXACT,
-            REDIRECT_LIMIT_HOST,
-            REDIRECT_LIMIT_ALLOW,
-            REDIRECT_LIMIT_EXACT_ALLOW,
-            REDIRECT_LIMIT_HOST_ALLOW
-        } m_redirectLimit;
-
-        std::vector<std::string> m_redirectAllow;
-        bool m_deprecationSupport;
-        xercesc::DOMDocument* m_doc;
-    };
-
-#if defined (_MSC_VER)
-    #pragma warning( pop )
-#endif
-
-}
-
-#endif /* __shibsp_xmlapplication_h__ */
diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp
deleted file mode 100644
index fd63c686..00000000
--- a/shibsp/impl/XMLServiceProvider.cpp
+++ /dev/null
@@ -1,644 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * XMLServiceProvider.cpp
- *
- * XML-based SP configuration and mgmt.
- */
-
-#include "internal.h"
-#include "version.h"
-#include "AgentConfig.h"
-#include "RequestMapper.h"
-#include "SessionCache.h"
-#include "SPConfig.h"
-#include "SPRequest.h"
-#include "impl/XMLApplication.h"
-#include "impl/XMLServiceProvider.h"
-#include "util/PathResolver.h"
-#include "util/SPConstants.h"
-
-#include <fstream>
-#include <boost/algorithm/string.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/version.h>
-#include <xmltooling/util/ParserPool.h>
-#include <xmltooling/util/TemplateEngine.h>
-#include <xmltooling/util/Threads.h>
-#include <xmltooling/util/XMLHelper.h>
-
-using namespace shibsp;
-using namespace xmltooling;
-using namespace boost;
-using namespace std;
-
-#ifndef min
-# define min(a,b)            (((a) < (b)) ? (a) : (b))
-#endif
-
-namespace {
-
-    static const XMLCh applicationId[] =        UNICODE_LITERAL_13(a,p,p,l,i,c,a,t,i,o,n,I,d);
-    static const XMLCh ApplicationDefaults[] =  UNICODE_LITERAL_19(A,p,p,l,i,c,a,t,i,o,n,D,e,f,a,u,l,t,s);
-    static const XMLCh ApplicationOverride[] =  UNICODE_LITERAL_19(A,p,p,l,i,c,a,t,i,o,n,O,v,e,r,r,i,d,e);
-    static const XMLCh _ArtifactMap[] =         UNICODE_LITERAL_11(A,r,t,i,f,a,c,t,M,a,p);
-    static const XMLCh _DataSealer[] =          UNICODE_LITERAL_10(D,a,t,a,S,e,a,l,e,r);
-    static const XMLCh _default[] =             UNICODE_LITERAL_7(d,e,f,a,u,l,t);
-    static const XMLCh _Extensions[] =          UNICODE_LITERAL_10(E,x,t,e,n,s,i,o,n,s);
-    static const XMLCh ExternalApplicationOverrides[] = UNICODE_LITERAL_28(E,x,t,e,r,n,a,l,A,p,p,l,i,c,a,t,i,o,n,O,v,e,r,r,i,d,e,s);
-    static const XMLCh _fatal[] =               UNICODE_LITERAL_5(f,a,t,a,l);
-    static const XMLCh _id[] =                  UNICODE_LITERAL_2(i,d);
-    static const XMLCh InProcess[] =            UNICODE_LITERAL_9(I,n,P,r,o,c,e,s,s);
-    static const XMLCh Library[] =              UNICODE_LITERAL_7(L,i,b,r,a,r,y);
-    static const XMLCh Listener[] =             UNICODE_LITERAL_8(L,i,s,t,e,n,e,r);
-    static const XMLCh logger[] =               UNICODE_LITERAL_6(l,o,g,g,e,r);
-    static const XMLCh _option[] =              UNICODE_LITERAL_6(o,p,t,i,o,n);
-    static const XMLCh OutOfProcess[] =         UNICODE_LITERAL_12(O,u,t,O,f,P,r,o,c,e,s,s);
-    static const XMLCh _path[] =                UNICODE_LITERAL_4(p,a,t,h);
-    static const XMLCh _ProtocolProvider[] =    UNICODE_LITERAL_16(P,r,o,t,o,c,o,l,P,r,o,v,i,d,e,r);
-    static const XMLCh _provider[] =            UNICODE_LITERAL_8(p,r,o,v,i,d,e,r);
-    static const XMLCh _ReplayCache[] =         UNICODE_LITERAL_11(R,e,p,l,a,y,C,a,c,h,e);
-    static const XMLCh _RequestMapper[] =       UNICODE_LITERAL_13(R,e,q,u,e,s,t,M,a,p,p,e,r);
-    static const XMLCh RequestMap[] =           UNICODE_LITERAL_10(R,e,q,u,e,s,t,M,a,p);
-    static const XMLCh SecurityPolicies[] =     UNICODE_LITERAL_16(S,e,c,u,r,i,t,y,P,o,l,i,c,i,e,s);
-    static const XMLCh _SecurityPolicyProvider[] = UNICODE_LITERAL_22(S,e,c,u,r,i,t,y,P,o,l,i,c,y,P,r,o,v,i,d,e,r);
-    static const XMLCh _SessionCache[] =        UNICODE_LITERAL_12(S,e,s,s,i,o,n,C,a,c,h,e);
-    static const XMLCh Site[] =                 UNICODE_LITERAL_4(S,i,t,e);
-    static const XMLCh _StorageService[] =      UNICODE_LITERAL_14(S,t,o,r,a,g,e,S,e,r,v,i,c,e);
-    static const XMLCh TCPListener[] =          UNICODE_LITERAL_11(T,C,P,L,i,s,t,e,n,e,r);
-    static const XMLCh tranLogFiller[] =        UNICODE_LITERAL_13(t,r,a,n,L,o,g,F,i,l,l,e,r);
-    static const XMLCh tranLogFormat[] =        UNICODE_LITERAL_13(t,r,a,n,L,o,g,F,o,r,m,a,t);
-    static const XMLCh TransportOption[] =      UNICODE_LITERAL_15(T,r,a,n,s,p,o,r,t,O,p,t,i,o,n);
-    static const XMLCh _type[] =                UNICODE_LITERAL_4(t,y,p,e);
-    static const XMLCh UnixListener[] =         UNICODE_LITERAL_12(U,n,i,x,L,i,s,t,e,n,e,r);
-};
-
-namespace shibsp {
-    ServiceProvider* XMLServiceProviderFactory(const DOMElement* const & e, bool deprecationSupport)
-    {
-        return new XMLConfig(e, deprecationSupport);
-    }
-};
-
-DOMNodeFilter::FilterAction XMLConfigImpl::acceptNode(const DOMNode* node) const
-{
-    if (!XMLString::equals(node->getNamespaceURI(),shibspconstants::SHIB2SPCONFIG_NS)
-            && !XMLString::equals(node->getNamespaceURI(), shibspconstants::SHIB3SPCONFIG_NS))
-        return FILTER_ACCEPT;
-    const XMLCh* name=node->getLocalName();
-    if (XMLString::equals(name,ApplicationDefaults) ||
-        XMLString::equals(name,_ArtifactMap) ||
-        XMLString::equals(name, _DataSealer) ||
-        XMLString::equals(name,_Extensions) ||
-        XMLString::equals(name,Listener) ||
-        XMLString::equals(name,_ProtocolProvider) ||
-        XMLString::equals(name,_RequestMapper) ||
-        XMLString::equals(name,_ReplayCache) ||
-        XMLString::equals(name,SecurityPolicies) ||
-        XMLString::equals(name,_SecurityPolicyProvider) ||
-        XMLString::equals(name,_SessionCache) ||
-        XMLString::equals(name,Site) ||
-        XMLString::equals(name,_StorageService) ||
-        XMLString::equals(name,TCPListener) ||
-        XMLString::equals(name,TransportOption) ||
-        XMLString::equals(name,UnixListener))
-        return FILTER_REJECT;
-
-    return FILTER_ACCEPT;
-}
-
-void XMLConfigImpl::doExtensions(const DOMElement* e, const char* label, Category& log)
-{
-    const DOMElement* exts = XMLHelper::getFirstChildElement(e, _Extensions);
-    if (exts) {
-        exts = XMLHelper::getFirstChildElement(exts, Library);
-        while (exts) {
-            string path(XMLHelper::getAttrString(exts, nullptr, _path));
-            try {
-                if (!path.empty()) {
-                    if (!XMLToolingConfig::getConfig().load_library(path.c_str(), (void*)exts))
-                        throw ConfigurationException("XMLToolingConfig::load_library failed.");
-                    log.debug("loaded %s extension library (%s)", label, path.c_str());
-                }
-            }
-            catch (const std::exception& e) {
-                if (XMLHelper::getAttrBool(exts, false, _fatal)) {
-                    log.crit("unable to load mandatory %s extension library %s: %s", label, path.c_str(), e.what());
-                    throw;
-                }
-                else {
-                    log.crit("unable to load optional %s extension library %s: %s", label, path.c_str(), e.what());
-                }
-            }
-            exts = XMLHelper::getNextSiblingElement(exts, Library);
-        }
-    }
-}
-
-void XMLConfigImpl::doCaching(const DOMElement* e, XMLConfig* conf, Category& log)
-{
-    const SPConfig& spConf = SPConfig::getConfig();
-
-    DOMElement* child = XMLHelper::getFirstChildElement(e, _SessionCache);
-    if (child) {
-        string t(XMLHelper::getAttrString(child, nullptr, _type));
-        if (!t.empty()) {
-            log.info("building SessionCache of type %s...", t.c_str());
-            conf->m_sessionCache.reset(spConf.SessionCacheManager.newPlugin(t.c_str(), child, m_deprecationSupport));
-        }
-    }
-    if (!conf->m_sessionCache) {
-        log.info("no SessionCache specified, using StorageService-backed instance");
-        conf->m_sessionCache.reset(spConf.SessionCacheManager.newPlugin(STORAGESERVICE_SESSION_CACHE, nullptr, m_deprecationSupport));
-    }
-}
-
-XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, XMLConfig* outer, Category& log)
-    : m_document(nullptr), m_defaultApplication(nullptr), m_deprecationSupport(false)
-{
-    const SPConfig& conf=SPConfig::getConfig();
-    XMLToolingConfig& xmlConf=XMLToolingConfig::getConfig();
-    const DOMElement* SHAR=XMLHelper::getFirstChildElement(e, OutOfProcess);
-    const DOMElement* SHIRE=XMLHelper::getFirstChildElement(e, InProcess);
-
-    // Initialize logging manually in order to redirect log messages as soon as possible.
-    // If no explicit config is supplied, we now assume the caller has done this, so that
-    // setuid processes can potentially do this as root.
-
-    // We also no longer do this on reloads, as this results in race conditions that could
-    // crash the process.
-
-    if (first && conf.isEnabled(SPConfig::Logging)) {
-        string logconf;
-        if (conf.isEnabled(SPConfig::OutOfProcess))
-            logconf = XMLHelper::getAttrString(SHAR, nullptr, logger);
-        else if (conf.isEnabled(SPConfig::InProcess))
-            logconf = XMLHelper::getAttrString(SHIRE, nullptr, logger);
-        if (logconf.empty())
-            logconf = XMLHelper::getAttrString(e, nullptr, logger);
-        if (!logconf.empty()) {
-            log.debug("loading new logging configuration from (%s), check log destination for status of configuration", logconf.c_str());
-            if (!XMLToolingConfig::getConfig().log_config(logconf.c_str()))
-                log.crit("failed to load new logging configuration from (%s)", logconf.c_str());
-        }
-    }
-
-    // Re-log library versions now that logging is set up.
-    log.info("Shibboleth SP Version %s", PACKAGE_VERSION);
-    log.info(
-        "Library versions: %s %s, Xerces-C %s, XMLTooling-C %s, Shibboleth %s",
-# if defined(LOG4SHIB_VERSION)
-    "log4shib", LOG4SHIB_VERSION,
-# elif defined(LOG4CPP_VERSION)
-    "log4cpp", LOG4CPP_VERSION,
-# else
-    "", "",
-# endif
-        XERCES_FULLVERSIONDOT, gXMLToolingDotVersionStr, gShibSPDotVersionStr
-        );
-
-    if (XMLString::equals(e->getNamespaceURI(), shibspconstants::SHIB2SPCONFIG_NS)) {
-        SPConfig::getConfig().deprecation().warn("legacy V2 configuration");
-        m_deprecationSupport = true;
-    }
-
-    // First load any property sets.
-    load(e, nullptr, this);
-
-    DOMElement* child;
-
-    // Much of the processing can only occur on the first instantiation.
-    if (first) {
-        // Set clock skew.
-        pair<bool,unsigned int> skew=getUnsignedInt("clockSkew");
-        if (skew.first)
-            xmlConf.clock_skew_secs=min(skew.second,(60*60*24*7*28));
-
-        pair<bool,const char*> unsafe = getString("unsafeChars");
-        if (unsafe.first)
-            TemplateEngine::unsafe_chars = unsafe.second;
-
-        unsafe = getString("allowedSchemes");
-        if (unsafe.first) {
-            HTTPResponse::getAllowedSchemes().clear();
-            string schemes(unsafe.second);
-            trim(schemes);
-            split(HTTPResponse::getAllowedSchemes(), schemes, is_space(), algorithm::token_compress_on);
-        }
-
-        // Extensions
-        doExtensions(e, "global", log);
-        if (conf.isEnabled(SPConfig::OutOfProcess))
-            doExtensions(SHAR, "out of process", log);
-
-        if (conf.isEnabled(SPConfig::InProcess))
-            doExtensions(SHIRE, "in process", log);
-
-        if (conf.isEnabled(SPConfig::Caching))
-            doCaching(e, outer, log);
-    } // end of first-time-only stuff
-
-    // Back to the fully dynamic stuff...next up is the RequestMapper.
-    if (conf.isEnabled(SPConfig::RequestMapping)) {
-        if (child = XMLHelper::getFirstChildElement(e, _RequestMapper)) {
-            string t(XMLHelper::getAttrString(child, nullptr, _type));
-            if (!t.empty()) {
-                log.info("building RequestMapper of type %s...", t.c_str());
-                m_requestMapper.reset(conf.RequestMapperManager.newPlugin(t.c_str(), child, m_deprecationSupport));
-            }
-        }
-        if (!m_requestMapper) {
-            log.info("no RequestMapper specified, using 'Native' plugin with empty/default map");
-            child = e->getOwnerDocument()->createElementNS(nullptr, _RequestMapper);
-            DOMElement* mapperDummy = e->getOwnerDocument()->createElementNS(e->getNamespaceURI(), RequestMap);
-            mapperDummy->setAttributeNS(nullptr, applicationId, _default);
-            child->appendChild(mapperDummy);
-            m_requestMapper.reset(conf.RequestMapperManager.newPlugin(NATIVE_REQUEST_MAPPER, child, m_deprecationSupport));
-        }
-    }
-
-    // Load the default application.
-    child = XMLHelper::getLastChildElement(e, ApplicationDefaults);
-    if (!child) {
-        log.crit("can't build default Application object, missing conf:ApplicationDefaults element?");
-        throw ConfigurationException("can't build default Application object, missing conf:ApplicationDefaults element?");
-    }
-    boost::shared_ptr<XMLApplication> defapp(new XMLApplication(outer, child, m_deprecationSupport));
-    m_appmap[defapp->getId()] = defapp;
-    m_defaultApplication = defapp.get();
-
-    // Load any overrides.
-    DOMElement* override = XMLHelper::getFirstChildElement(child, ApplicationOverride);
-    while (override) {
-        boost::shared_ptr<XMLApplication> iapp(new XMLApplication(outer, 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
-            m_appmap[iapp->getId()] = iapp;
-
-        override = XMLHelper::getNextSiblingElement(override, ApplicationOverride);
-    }
-
-    // Save off any external override paths.
-    override = XMLHelper::getFirstChildElement(child, ExternalApplicationOverrides);
-    while (override) {
-        string extoverridepath(XMLHelper::getAttrString(override, nullptr, _path));
-        AgentConfig::getConfig().getPathResolver().resolve(extoverridepath, PathResolver::SHIBSP_CFG_FILE);
-        if (!extoverridepath.empty()) {
-            log.info("adding external ApplicationOverride search path: %s", extoverridepath.c_str());
-            m_externalAppPaths.push_back(extoverridepath);
-        }
-
-        override = XMLHelper::getNextSiblingElement(override, ExternalApplicationOverrides);
-    }
-
-    if (!m_externalAppPaths.empty())
-        m_appMapLock.reset(Mutex::create());
-
-    // Check for extra AuthTypes to recognize.
-    if (conf.isEnabled(SPConfig::InProcess)) {
-        const PropertySet* inprocs = getPropertySet("InProcess");
-        if (inprocs) {
-            pair<bool,const char*> extraAuthTypes = inprocs->getString("extraAuthTypes");
-            if (extraAuthTypes.first) {
-                string types(extraAuthTypes.second);
-                trim(types);
-                split(outer->m_authTypes, types, is_space(), algorithm::token_compress_on);
-                outer->m_authTypes.insert("shibboleth");
-            }
-        }
-    }
-}
-
-boost::shared_ptr<Application> XMLConfigImpl::findExternalOverride(const char* id, const XMLConfig* config)
-{
-    for (vector<string>::const_iterator i = m_externalAppPaths.begin(); i != m_externalAppPaths.end(); ++i) {
-        string path(*i);
-        if (!ends_with(path, "/"))
-            path += '/';
-        path = path + id + "-override.xml";
-        try {
-            ifstream in(path.c_str());
-            if (in) {
-                DOMDocument* doc = XMLToolingConfig::getConfig().getValidatingParser().parse(in);
-                if (!XMLHelper::isNodeNamed(doc->getDocumentElement(), shibspconstants::SHIB3SPCONFIG_NS, ApplicationOverride)) {
-                    throw ConfigurationException("External override not rooted in conf:ApplicationOverride element.");
-                }
-
-                string id2(XMLHelper::getAttrString(doc->getDocumentElement(), nullptr, _id));
-                if (id2 != id)
-                    throw ConfigurationException("External override's id did not match the expected value.");
-
-                boost::shared_ptr<XMLApplication> iapp(
-                    new XMLApplication(config, doc->getDocumentElement(), m_deprecationSupport, m_defaultApplication, doc)
-                    );
-                return iapp;
-            }
-        }
-        catch (const std::exception& ex) {
-            config->m_log.error("Exception creating ApplicationOverride: %s", ex.what());
-        }
-    }
-
-    return boost::shared_ptr<XMLApplication>();
-}
-
-const Application* XMLConfig::getApplication(const char* applicationId) const
-{
-    Lock locker(m_impl->m_appMapLock);
-
-    map< string, boost::shared_ptr<Application> >::const_iterator i = m_impl->m_appmap.find(applicationId ? applicationId : "default");
-    Application* ret = (i != m_impl->m_appmap.end()) ? i->second.get() : nullptr;
-
-    if (!ret && m_impl->m_appMapLock && applicationId) {
-        m_log.info("application override (%s) not found, searching external sources", applicationId);
-        boost::shared_ptr<Application> newapp = m_impl->findExternalOverride(applicationId, this);
-        if (newapp) {
-            m_log.info("storing externally defined application override (%s)", applicationId);
-            ret = newapp.get();
-            m_impl->m_appmap[applicationId] = newapp;
-        }
-        else {
-            m_log.warn("application override (%s) not found in external sources", applicationId);
-        }
-    }
-
-    return ret;
-}
-
-#ifndef SHIBSP_LITE
-
-void XMLConfig::receive(DDF& in, ostream& out)
-{
-    if (!strcmp(in.name(), "get::RelayState")) {
-        const char* id = in["id"].string();
-        const char* key = in["key"].string();
-        if (!id || !key)
-            throw ListenerException("Required parameters missing for RelayState recovery.");
-
-        string relayState;
-        StorageService* storage = getStorageService(id);
-        if (storage) {
-            if (storage->readString("RelayState",key,&relayState)>0) {
-                if (in["clear"].integer())
-                    storage->deleteString("RelayState",key);
-            }
-            else if (storage->readText("RelayState",key,&relayState)>0) {
-                if (in["clear"].integer())
-                    storage->deleteText("RelayState",key);
-            }
-        }
-        else {
-            Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").error(
-                "Storage-backed RelayState with invalid StorageService ID (%s)", id
-                );
-        }
-
-        // Repack for return to caller.
-        DDF ret=DDF(nullptr).unsafe_string(relayState.c_str());
-        DDFJanitor jret(ret);
-        out << ret;
-    }
-    else if (!strcmp(in.name(), "set::RelayState")) {
-        const char* id = in["id"].string();
-        const char* value = in["value"].string();
-        if (!id || !value)
-            throw ListenerException("Required parameters missing for RelayState creation.");
-
-        string rsKey;
-        StorageService* storage = getStorageService(id);
-        if (storage) {
-            SAMLConfig::getConfig().generateRandomBytes(rsKey,32);
-            rsKey = SAMLArtifact::toHex(rsKey);
-            if (strlen(value) <= storage->getCapabilities().getStringSize())
-                storage->createString("RelayState", rsKey.c_str(), value, time(nullptr) + 600);
-            else
-                storage->createText("RelayState", rsKey.c_str(), value, time(nullptr) + 600);
-        }
-        else {
-            Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").error(
-                "Storage-backed RelayState with invalid StorageService ID (%s)", id
-                );
-        }
-
-        // Repack for return to caller.
-        DDF ret=DDF(nullptr).string(rsKey.c_str());
-        DDFJanitor jret(ret);
-        out << ret;
-    }
-    else if (!strcmp(in.name(), "get::PostData")) {
-        const char* id = in["id"].string();
-        const char* key = in["key"].string();
-        if (!id || !key)
-            throw ListenerException("Required parameters missing for PostData recovery.");
-
-        string postData;
-        StorageService* storage = getStorageService(id);
-        if (storage) {
-            if (storage->readText("PostData",key,&postData) > 0) {
-                storage->deleteText("PostData",key);
-            }
-        }
-        else {
-            Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").error(
-                "Storage-backed PostData with invalid StorageService ID (%s)", id
-                );
-        }
-        // If the data's empty, we'll send nothing back.
-        // If not, we don't need to round trip it, just send back the serialized DDF list.
-        if (postData.empty()) {
-            DDF ret(nullptr);
-            DDFJanitor jret(ret);
-            out << ret;
-        }
-        else {
-            out << postData;
-        }
-    }
-    else if (!strcmp(in.name(), "set::PostData")) {
-        const char* id = in["id"].string();
-        if (!id || !in["parameters"].islist())
-            throw ListenerException("Required parameters missing for PostData creation.");
-
-        string rsKey;
-        StorageService* storage = getStorageService(id);
-        if (storage) {
-            SAMLConfig::getConfig().generateRandomBytes(rsKey,32);
-            rsKey = SAMLArtifact::toHex(rsKey);
-            ostringstream params;
-            params << in["parameters"];
-            storage->createText("PostData", rsKey.c_str(), params.str().c_str(), time(nullptr) + 600);
-        }
-        else {
-            Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").error(
-                "Storage-backed PostData with invalid StorageService ID (%s)", id
-                );
-        }
-
-        // Repack for return to caller.
-        DDF ret=DDF(nullptr).string(rsKey.c_str());
-        DDFJanitor jret(ret);
-        out << ret;
-    }
-}
-
-#endif
-
-void XMLConfig::regListener(const char* address, Remoted* listener)
-{
-    m_listenerLock->wrlock();
-    SharedLock locker(m_listenerLock, false);
-
-    map< string,pair<Remoted*,Remoted*> >::iterator i = m_listenerMap.find(address);
-    if (i != m_listenerMap.end()) {
-        if (!i->second.first) {
-            // First slot is null. Look for second slot and move up if needed.
-            if (i->second.second) {
-                i->second.first = i->second.second;
-                i->second.second = listener;
-                Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").debug("registered second remoted message endpoint (%s)",address);
-            }
-            else {
-                // Both slots null, so put into first slot.
-                i->second.first = listener;
-                Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").debug("registered remoted message endpoint (%s)",address);
-            }
-        }
-        else if (!i->second.second) {
-            // First slot occupied, so put into empty second slot.
-            i->second.second = listener;
-            Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").debug("registered second remoted message endpoint (%s)",address);
-        }
-        else {
-            // This should never happen...?
-            throw ConfigurationException("Attempted to register more than two endpoints for a single listener address.");
-        }
-    }
-    else {
-        // Stick it in the first slot.
-        m_listenerMap[address] = pair<Remoted*, Remoted*>(listener, nullptr);
-        Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").debug("registered remoted message endpoint (%s)",address);
-    }
-}
-
-bool XMLConfig::unregListener(const char* address, Remoted* current)
-{
-    m_listenerLock->wrlock();
-    SharedLock locker(m_listenerLock, false);
-
-    map< string,pair<Remoted*,Remoted*> >::iterator i = m_listenerMap.find(address);
-    if (i != m_listenerMap.end()) {
-        if (i->second.first == current) {
-            if (i->second.second) {
-                // Promote second slot to first.
-                i->second.first = i->second.second;
-                i->second.second = nullptr;
-            }
-            else {
-                // Remove entirely.
-                m_listenerMap.erase(address);
-            }
-        }
-        else if (i->second.second == current) {
-            if (!i->second.first)
-                m_listenerMap.erase(address);
-            else
-                i->second.second = nullptr;
-        }
-        else {
-            return false;
-        }
-        Category::getInstance(SHIBSP_LOGCAT ".ServiceProvider").debug("unregistered remoted message endpoint (%s)", address);
-        return true;
-    }
-    return false;
-}
-
-Remoted* XMLConfig::lookupListener(const char* address) const
-{
-    SharedLock locker(m_listenerLock, true);
-    map< string,pair<Remoted*,Remoted*> >::const_iterator i = m_listenerMap.find(address);
-    if (i != m_listenerMap.end())
-        return i->second.first ? i->second.first : i->second.second;
-
-    locker.release()->unlock();   // free up the listener map
-
-    // Start iterating at slash boundaries.
-    const char* slash = strstr(address, "/");
-    while (slash) {
-        string appId(address, slash - address);
-        if (getApplication(appId.c_str())) {
-            SharedLock sublocker(m_listenerLock, true); // relock and check again
-            i = m_listenerMap.find(address);
-            if (i != m_listenerMap.end())
-                return i->second.first ? i->second.first : i->second.second;
-        }
-        slash = strstr(slash + 1, "/");
-    }
-
-    // Try a search based on the colons, which handles no embedded slashes in the address.
-    const char* colons = strstr(address, "::");
-    if (colons) {
-        string appId(address, colons - address);
-        if (getApplication(appId.c_str())) {
-            SharedLock sublocker(m_listenerLock, true); // relock and check again
-            i = m_listenerMap.find(address);
-            if (i != m_listenerMap.end())
-                return i->second.first ? i->second.first : i->second.second;
-        }
-    }
-    return nullptr;
-}
-
-XMLConfig::XMLConfig(const DOMElement* e, bool deprecationSupport)
-    : ReloadableXMLFile(e, xmltooling::logging::Category::getInstance(SHIBSP_LOGCAT ".Config"), true, deprecationSupport),
-        m_listenerLock(RWLock::create())
-{
-}
-
-XMLConfig::~XMLConfig()
-{
-    shutdown();
-}
-
-pair<bool,DOMElement*> XMLConfig::background_load()
-{
-    // Load from source using base class.
-    pair<bool,DOMElement*> raw = ReloadableXMLFile::load();
-
-    // If we own it, wrap it.
-    XercesJanitor<DOMDocument> docjanitor(raw.first ? raw.second->getOwnerDocument() : nullptr);
-
-    //scoped_ptr<XMLConfigImpl> impl(new XMLConfigImpl(raw.second, (m_impl==nullptr), this, m_log));
-    scoped_ptr<XMLConfigImpl> impl(nullptr);
-
-    // If we held the document, transfer it to the impl. If we didn't, it's a no-op.
-    impl->setDocument(docjanitor.release());
-
-    // Perform the swap inside a lock.
-    if (m_lock)
-        m_lock->wrlock();
-    SharedLock locker(m_lock, false);
-    m_impl.swap(impl);
-
-    return make_pair(false,(DOMElement*)nullptr);
-}
diff --git a/shibsp/impl/XMLServiceProvider.h b/shibsp/impl/XMLServiceProvider.h
deleted file mode 100644
index 94dc9b88..00000000
--- a/shibsp/impl/XMLServiceProvider.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * XMLApplication.h
- *
- * Internal declaration of Application subclass used by XML-based configurator.
- */
-
-#ifndef __shibsp_xmlserviceprov_h__
-#define __shibsp_xmlserviceprov_h__
-
-#include "Application.h"
-#include "exceptions.h"
-#include "ServiceProvider.h"
-#include "util/DOMPropertySet.h"
-#include "util/PluginManager.h"
-
-#include <xmltooling/util/ReloadableXMLFile.h>
-
-#include <boost/scoped_ptr.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace xmltooling {
-    class Mutex;
-    class RWLock;
-}
-
-namespace shibsp {
-
-#if defined (_MSC_VER)
-    #pragma warning( push )
-    #pragma warning( disable : 4250 )
-#endif
-
-    // Top-level configuration implementation
-    class SHIBSP_DLLLOCAL XMLConfig;
-    class SHIBSP_DLLLOCAL XMLConfigImpl : public DOMPropertySet, public xercesc::DOMNodeFilter
-    {
-    public:
-        XMLConfigImpl(const xercesc::DOMElement* e, bool first, XMLConfig* outer, Category& log);
-        ~XMLConfigImpl() {
-            if (m_document)
-                m_document->release();
-        }
-
-        std::map<std::string,Remoted*> m_listenerMap;
-        boost::scoped_ptr<RequestMapper> m_requestMapper;
-        boost::scoped_ptr<xmltooling::Mutex> m_appMapLock;
-        std::map< std::string, boost::shared_ptr<Application> > m_appmap;
-        std::vector<std::string> m_externalAppPaths;
-
-        boost::shared_ptr<Application> findExternalOverride(const char*, const XMLConfig*);
-
-        // Provides filter to exclude special config elements.
-        xercesc::DOMNodeFilter::FilterAction acceptNode(const xercesc::DOMNode* node) const;
-
-        void setDocument(xercesc::DOMDocument* doc) {
-            m_document = doc;
-        }
-
-    private:
-        void doExtensions(const xercesc::DOMElement*, const char*, Category&);
-        void doCaching(const xercesc::DOMElement*, XMLConfig*, Category&);
-
-        xercesc::DOMDocument* m_document;
-        const XMLApplication* m_defaultApplication;
-        bool m_deprecationSupport;
-    };
-
-    class SHIBSP_DLLLOCAL XMLConfig : public ServiceProvider, public xmltooling::ReloadableXMLFile
-    {
-    public:
-        XMLConfig(const xercesc::DOMElement* e, bool deprecationSupport=true);
-        virtual ~XMLConfig();
-
-        void init() {
-            background_load();
-        }
-
-        // PropertySet
-        const PropertySet* getParent() const { return m_impl->getParent(); }
-        void setParent(const PropertySet* parent) { return m_impl->setParent(parent); }
-        std::pair<bool, bool> getBool(const char* name) const { return m_impl->getBool(name); }
-        std::pair<bool, const char*> getString(const char* name) const { return m_impl->getString(name); }
-        std::pair<bool, unsigned int> getUnsignedInt(const char* name) const { return m_impl->getUnsignedInt(name); }
-        std::pair<bool, int> getInt(const char* name) const { return m_impl->getInt(name); }
-        const PropertySet* getPropertySet(const char* name) const { return m_impl->getPropertySet(name); }
-
-        SessionCache* getSessionCache(bool required = true) const {
-            if (required && !m_sessionCache)
-                throw ConfigurationException("No SessionCache available.");
-            return m_sessionCache.get();
-        }
-
-        RequestMapper* getRequestMapper(bool required = true) const {
-            if (required && !m_impl->m_requestMapper)
-                throw ConfigurationException("No RequestMapper available.");
-            return m_impl->m_requestMapper.get();
-        }
-
-        const Application* getApplication(const char* applicationId) const;
-
-        void regListener(const char* address, Remoted* svc);
-        bool unregListener(const char* address, Remoted* current);
-        Remoted* lookupListener(const char* address) const;
-
-    protected:
-        std::pair<bool,xercesc::DOMElement*> background_load();
-
-    private:
-        friend class XMLConfigImpl;
-
-        boost::scoped_ptr<xmltooling::RWLock> m_listenerLock;
-        std::map< std::string,std::pair<Remoted*,Remoted*> > m_listenerMap;
-
-        // The order of these members actually matters. If we want to rely on auto-destruction, then
-        // anything dependent on anything else has to come later in the object so it will pop first.
-        // Remoring is the lowest, then the cache, and finally the rest.
-        boost::scoped_ptr<SessionCache> m_sessionCache;
-        boost::scoped_ptr<XMLConfigImpl> m_impl;
-    };
-
-#if defined (_MSC_VER)
-    #pragma warning( pop )
-#endif
-
-}
-
-#endif /* __shibsp_xmlserviceprov_h__ */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list