From 394b49de99f47a6c0b5306dae992801ead289ad3 Mon Sep 17 00:00:00 2001 From: cantor Date: Sun, 11 Mar 2007 04:21:34 +0000 Subject: [PATCH] Rework address handling based on app/location. git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2194 cb58f699-b61c-0410-a6fe-9272a202ed29 --- shibsp/SPConfig.h | 10 +++++----- shibsp/handler/AssertionConsumerService.h | 9 ++++++++- shibsp/handler/RemotedHandler.h | 12 ++++++++---- shibsp/handler/impl/AbstractHandler.cpp | 2 +- shibsp/handler/impl/AssertionConsumerService.cpp | 6 +++++- shibsp/handler/impl/RemotedHandler.cpp | 12 +++++------- shibsp/handler/impl/SAML1Consumer.cpp | 8 +++++--- 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/shibsp/SPConfig.h b/shibsp/SPConfig.h index c785e87..917abdb 100644 --- a/shibsp/SPConfig.h +++ b/shibsp/SPConfig.h @@ -156,12 +156,12 @@ namespace shibsp { /** * Manages factories for Handler plugins that implement AssertionConsumerService functionality. */ - xmltooling::PluginManager AssertionConsumerServiceManager; + xmltooling::PluginManager< Handler,std::pair > AssertionConsumerServiceManager; /** * Manages factories for Handler plugins that implement customized functionality. */ - xmltooling::PluginManager HandlerManager; + xmltooling::PluginManager< Handler,std::pair > HandlerManager; /** * Manages factories for ListenerService plugins. @@ -171,7 +171,7 @@ namespace shibsp { /** * Manages factories for Handler plugins that implement ManageNameIDService functionality. */ - xmltooling::PluginManager ManageNameIDServiceManager; + xmltooling::PluginManager< Handler,std::pair > ManageNameIDServiceManager; /** * Manages factories for RequestMapper plugins. @@ -191,12 +191,12 @@ namespace shibsp { /** * Manages factories for Handler plugins that implement SessionInitiator functionality. */ - xmltooling::PluginManager SessionInitiatorManager; + xmltooling::PluginManager< Handler,std::pair > SessionInitiatorManager; /** * Manages factories for Handler plugins that implement SingleLogoutService functionality. */ - xmltooling::PluginManager SingleLogoutServiceManager; + xmltooling::PluginManager< Handler,std::pair > SingleLogoutServiceManager; protected: SPConfig() : attribute_value_delimeter(';'), m_serviceProvider(NULL), m_features(0) {} diff --git a/shibsp/handler/AssertionConsumerService.h b/shibsp/handler/AssertionConsumerService.h index e632f41..d6f3a5f 100644 --- a/shibsp/handler/AssertionConsumerService.h +++ b/shibsp/handler/AssertionConsumerService.h @@ -49,7 +49,14 @@ namespace shibsp { void receive(DDF& in, std::ostream& out); protected: - AssertionConsumerService(const DOMElement* e, log4cpp::Category& log); + /** + * Constructor + * + * @param e root of DOM configuration + * @param appId ID of application that "owns" the handler + * @param log a logging object to use + */ + AssertionConsumerService(const DOMElement* e, const char* appId, log4cpp::Category& log); /** * Implement protocol-specific handling of the incoming decoded message. diff --git a/shibsp/handler/RemotedHandler.h b/shibsp/handler/RemotedHandler.h index 9420bb5..b26be6e 100644 --- a/shibsp/handler/RemotedHandler.h +++ b/shibsp/handler/RemotedHandler.h @@ -38,7 +38,14 @@ namespace shibsp { virtual ~RemotedHandler(); protected: - RemotedHandler(); + RemotedHandler() {} + + /** + * Establishes message remoting using the supplied address. + * + * @param address a unique "address" for remote message handling + */ + void setAddress(const char* address); /** * Wraps a request by creating an outgoing data flow with the data needed @@ -79,9 +86,6 @@ namespace shibsp { /** Message address for remote half. */ std::string m_address; - - private: - static unsigned int m_counter; }; }; diff --git a/shibsp/handler/impl/AbstractHandler.cpp b/shibsp/handler/impl/AbstractHandler.cpp index 7808ddc..a61f40c 100644 --- a/shibsp/handler/impl/AbstractHandler.cpp +++ b/shibsp/handler/impl/AbstractHandler.cpp @@ -40,7 +40,7 @@ using namespace xercesc; using namespace std; namespace shibsp { - SHIBSP_DLLLOCAL PluginManager::Factory SAML1ConsumerFactory; + SHIBSP_DLLLOCAL PluginManager>::Factory SAML1ConsumerFactory; }; void SHIBSP_API shibsp::registerHandlers() diff --git a/shibsp/handler/impl/AssertionConsumerService.cpp b/shibsp/handler/impl/AssertionConsumerService.cpp index 891dbe9..7e0eb03 100644 --- a/shibsp/handler/impl/AssertionConsumerService.cpp +++ b/shibsp/handler/impl/AssertionConsumerService.cpp @@ -41,10 +41,14 @@ using namespace xmltooling; using namespace log4cpp; using namespace std; -AssertionConsumerService::AssertionConsumerService(const DOMElement* e, Category& log) +AssertionConsumerService::AssertionConsumerService(const DOMElement* e, const char* appId, Category& log) : AbstractHandler(e, log), m_decoder(NULL), m_configNS(SHIB2SPCONFIG_NS), m_role(samlconstants::SAML20MD_NS, opensaml::saml2md::IDPSSODescriptor::LOCAL_NAME) { + string address(appId); + address += getString("Location").second; + address += "::run::ACS"; + setAddress(address.c_str()); if (SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess)) m_decoder = SAMLConfig::getConfig().MessageDecoderManager.newPlugin(getString("Binding").second,e); } diff --git a/shibsp/handler/impl/RemotedHandler.cpp b/shibsp/handler/impl/RemotedHandler.cpp index 385fa6c..a66e073 100644 --- a/shibsp/handler/impl/RemotedHandler.cpp +++ b/shibsp/handler/impl/RemotedHandler.cpp @@ -21,6 +21,7 @@ */ #include "internal.h" +#include "exceptions.h" #include "ServiceProvider.h" #include "handler/RemotedHandler.h" @@ -202,13 +203,11 @@ long RemotedResponse::sendRedirect(const char* url) } -unsigned int RemotedHandler::m_counter = 0; - -RemotedHandler::RemotedHandler() +void RemotedHandler::setAddress(const char* address) { - m_address += ('A' + (m_counter++)); - m_address += "::run::RemotedHandler"; - + if (!m_address.empty()) + throw ConfigurationException("Cannot register a remoting address twice for the same Handler."); + m_address = address; SPConfig& conf = SPConfig::getConfig(); if (conf.isEnabled(SPConfig::OutOfProcess)) { ListenerService* listener = conf.getServiceProvider()->getListenerService(false); @@ -225,7 +224,6 @@ RemotedHandler::~RemotedHandler() ListenerService* listener=conf.getServiceProvider()->getListenerService(false); if (listener && conf.isEnabled(SPConfig::OutOfProcess)) listener->unregListener(m_address.c_str(),this); - m_counter--; } DDF RemotedHandler::wrap(const SPRequest& request, const vector* headers, bool certs) const diff --git a/shibsp/handler/impl/SAML1Consumer.cpp b/shibsp/handler/impl/SAML1Consumer.cpp index b293d09..6b402e5 100644 --- a/shibsp/handler/impl/SAML1Consumer.cpp +++ b/shibsp/handler/impl/SAML1Consumer.cpp @@ -54,7 +54,9 @@ namespace shibsp { class SHIBSP_DLLLOCAL SAML1Consumer : public AssertionConsumerService { public: - SAML1Consumer(const DOMElement* e) : AssertionConsumerService(e, Category::getInstance(SHIBSP_LOGCAT".SAML1")) {} + SAML1Consumer(const DOMElement* e, const char* appId) + : AssertionConsumerService(e, appId, Category::getInstance(SHIBSP_LOGCAT".SAML1")) { + } virtual ~SAML1Consumer() {} private: @@ -71,9 +73,9 @@ namespace shibsp { #pragma warning( pop ) #endif - Handler* SHIBSP_DLLLOCAL SAML1ConsumerFactory(const DOMElement* const & e) + Handler* SHIBSP_DLLLOCAL SAML1ConsumerFactory(const pair& p) { - return new SAML1Consumer(e); + return new SAML1Consumer(p.first, p.second); } }; -- 2.1.4