Starting to refactor session cache, eliminated IConfig class.
authorScott Cantor <cantor.2@osu.edu>
Wed, 17 Jan 2007 03:04:25 +0000 (03:04 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 17 Jan 2007 03:04:25 +0000 (03:04 +0000)
15 files changed:
Shibboleth.sln
odbc_ccache/odbc-ccache.cpp
shib-mysql-ccache/shib-mysql-ccache.cpp
shib-target/shib-ccache.cpp
shib-target/shib-config.cpp
shib-target/shib-handlers.cpp
shib-target/shib-ini.cpp
shib-target/shib-target.h
shibsp/Makefile.am
shibsp/SPConfig.cpp
shibsp/SPConfig.h
shibsp/ServiceProvider.h
shibsp/SessionCache.h
shibsp/impl/StorageServiceSessionCache.cpp [new file with mode: 0644]
shibsp/shibsp.vcproj

index 2602ebf..8b121dc 100644 (file)
@@ -2,46 +2,46 @@ Microsoft Visual Studio Solution File, Format Version 9.00
 # Visual Studio 2005
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "isapi_shib", "isapi_shib\isapi_shib.vcproj", "{87C25D4E-8D19-4513-B0BA-BC668BC2DEE3}"
        ProjectSection(ProjectDependencies) = postProject
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
-               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
                {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
+               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "isapi_shib_gui", "isapi_shib_gui\isapi_shib_gui.vcproj", "{D341DCD8-7DCD-43A2-8559-C07DAB838711}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_shib13", "apache\mod_shib13.vcproj", "{D243B43E-728E-4F32-BDFF-B3A897037C6D}"
        ProjectSection(ProjectDependencies) = postProject
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
-               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
                {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
+               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_shib20", "apache\mod_shib20.vcproj", "{68E9568B-476C-4289-B93C-893432378ADC}"
        ProjectSection(ProjectDependencies) = postProject
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
-               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
                {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
+               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nsapi_shib", "nsapi_shib\nsapi_shib.vcproj", "{1396D80A-8672-4224-9B02-95F3F4207CDB}"
        ProjectSection(ProjectDependencies) = postProject
-               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
                {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
+               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "posttest", "posttest\posttest.vcproj", "{16E70C47-789E-43D5-AFDF-964D386C3CB5}"
        ProjectSection(ProjectDependencies) = postProject
-               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
                {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
+               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shar", "shar\shar.vcproj", "{F13141B5-6C87-40BB-8D4E-5CC56EBB4C59}"
        ProjectSection(ProjectDependencies) = postProject
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
-               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
                {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
+               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shib", "shib\shib.vcproj", "{E6CAB6C8-1D73-4410-970A-52BF9EC57810}"
@@ -49,48 +49,49 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shib_mysql_ccache", "shib-mysql-ccache\shib_mysql_ccache.vcproj", "{54671467-CA4D-4BA3-9A27-15ED5576143D}"
        ProjectSection(ProjectDependencies) = postProject
                {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shibtarget", "shib-target\shibtarget.vcproj", "{84890110-2190-4AAE-9BDC-58F90DF71E4F}"
        ProjectSection(ProjectDependencies) = postProject
-               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
                {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
+               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shibtest", "shibtest\shibtest.vcproj", "{67AF22A3-C26E-40BE-B0CA-2ABEE5123763}"
        ProjectSection(ProjectDependencies) = postProject
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
-               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
                {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
+               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "siterefresh", "siterefresh\siterefresh.vcproj", "{4D02F36E-D2CD-4FD1-AC50-2941E27BB3FB}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testclient", "shar\testclient.vcproj", "{B3F1E899-86F9-4D3A-8026-B57D1A5B90B1}"
        ProjectSection(ProjectDependencies) = postProject
-               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
                {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
+               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xmlproviders", "xmlproviders\xmlproviders.vcproj", "{68E46D06-6B91-4C59-A700-78DD4D4C420B}"
        ProjectSection(ProjectDependencies) = postProject
-               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
                {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
+               {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odbc_ccache", "odbc_ccache\odbc_ccache.vcproj", "{DAC7FB99-038A-45C9-A27C-21B6C8D4CD1E}"
        ProjectSection(ProjectDependencies) = postProject
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
                {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_shib22", "apache\mod_shib22.vcproj", "{B44C0852-83B8-4FB2-A86E-097C9C8256D0}"
        ProjectSection(ProjectDependencies) = postProject
-               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
-               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
                {E6CAB6C8-1D73-4410-970A-52BF9EC57810} = {E6CAB6C8-1D73-4410-970A-52BF9EC57810}
+               {84890110-2190-4AAE-9BDC-58F90DF71E4F} = {84890110-2190-4AAE-9BDC-58F90DF71E4F}
+               {81F0F7A6-DC36-46EF-957F-F9E81D4403F6} = {81F0F7A6-DC36-46EF-957F-F9E81D4403F6}
        EndProjectSection
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server Modules", "Server Modules", "{26BA8F84-6E42-41FA-9B13-5D3F4B5B2050}"
index 6b9fe4c..f8f8cf5 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <shib-target/shib-target.h>
 #include <shibsp/exceptions.h>
+#include <shibsp/SPConfig.h>
 #include <log4cpp/Category.hh>
 #include <xmltooling/util/NDC.h>
 #include <xmltooling/util/Threads.h>
@@ -916,7 +917,7 @@ bool ODBCReplayCache::check(const char* str, time_t expires)
 
 // Factories
 
-IPlugIn* new_odbc_ccache(const DOMElement* e)
+SessionCache* new_odbc_ccache(const DOMElement* const & e)
 {
     return new ODBCCCache(e);
 }
@@ -931,12 +932,11 @@ extern "C" int SHIBODBC_EXPORTS saml_extension_init(void*)
 {
     // register this ccache type
     SAMLConfig::getConfig().getPlugMgr().regFactory(ODBC_REPLAYCACHE, &new_odbc_replay);
-    SAMLConfig::getConfig().getPlugMgr().regFactory(ODBC_SESSIONCACHE, &new_odbc_ccache);
+    SPConfig::getConfig().SessionCacheManager.registerFactory(ODBC_SESSIONCACHE, &new_odbc_ccache);
     return 0;
 }
 
 extern "C" void SHIBODBC_EXPORTS saml_extension_term()
 {
-    SAMLConfig::getConfig().getPlugMgr().unregFactory(ODBC_SESSIONCACHE);
     SAMLConfig::getConfig().getPlugMgr().unregFactory(ODBC_REPLAYCACHE);
 }
index ff5aec8..c6bccf4 100644 (file)
@@ -45,6 +45,7 @@
 #include <xmltooling/util/NDC.h>
 #include <xmltooling/util/Threads.h>
 #include <xmltooling/util/XMLHelper.h>
+#include <shibsp/SPConfig.h>
 using xmltooling::XMLHelper;
 
 #include <sstream>
@@ -61,6 +62,7 @@ using xmltooling::XMLHelper;
 #include <dmalloc.h>
 #endif
 
+using namespace shibsp;
 using namespace shibtarget;
 using namespace opensaml::saml2md;
 using namespace saml;
@@ -934,7 +936,7 @@ bool MySQLReplayCache::check(const char* str, time_t expires)
  * The registration functions here...
  */
 
-IPlugIn* new_mysql_ccache(const DOMElement* e)
+SessionCache* new_mysql_ccache(const DOMElement* const & e)
 {
     return new ShibMySQLCCache(e);
 }
@@ -948,7 +950,7 @@ extern "C" int SHIBMYSQL_EXPORTS saml_extension_init(void*)
 {
     // register this ccache type
     SAMLConfig::getConfig().getPlugMgr().regFactory(MYSQL_REPLAYCACHE, &new_mysql_replay);
-    SAMLConfig::getConfig().getPlugMgr().regFactory(MYSQL_SESSIONCACHE, &new_mysql_ccache);
+    SPConfig::getConfig().SessionCacheManager.registerFactory(MYSQL_SESSIONCACHE, &new_mysql_ccache);
     return 0;
 }
 
@@ -958,5 +960,4 @@ extern "C" void SHIBMYSQL_EXPORTS saml_extension_term()
     if (g_MySQLInitialized)
         mysql_server_end();
     SAMLConfig::getConfig().getPlugMgr().unregFactory(MYSQL_REPLAYCACHE);
-    SAMLConfig::getConfig().getPlugMgr().unregFactory(MYSQL_SESSIONCACHE);
 }
index 02482bd..bcbfa9d 100644 (file)
@@ -1605,7 +1605,7 @@ void* MemorySessionCache::cleanup_fcn(void* cache_p)
     return NULL;
 }
 
-IPlugIn* MemoryCacheFactory(const DOMElement* e)
+SessionCache* MemoryCacheFactory(const DOMElement* const & e)
 {
     // If this is a long-lived process, we return the "real" cache.
     if (SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess))
index e0d23ad..064c61a 100644 (file)
@@ -49,8 +49,8 @@ PlugManager::Factory UnixListenerFactory;
 #endif
 PlugManager::Factory TCPListenerFactory;
 //PlugManager::Factory MemoryListenerFactory;
-PlugManager::Factory MemoryCacheFactory;
 
+PluginManager<SessionCache,const DOMElement*>::Factory MemoryCacheFactory;
 PluginManager<Handler,const DOMElement*>::Factory ShibSessionInitiatorFactory;
 PluginManager<Handler,const DOMElement*>::Factory SAML1POSTFactory;
 PluginManager<Handler,const DOMElement*>::Factory SAML1ArtifactFactory;
@@ -106,7 +106,7 @@ bool STConfig::init(const char* schemadir)
     conf.AssertionConsumerServiceManager.registerFactory(samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT,&SAML1ArtifactFactory);
     conf.SingleLogoutServiceManager.registerFactory(shibspconstants::SHIB1_LOGOUT_PROFILE_URI,&ShibLogoutFactory);
     
-    samlConf.getPlugMgr().regFactory(MEMORY_SESSIONCACHE,&MemoryCacheFactory);
+    conf.SessionCacheManager.registerFactory(MEMORY_SESSIONCACHE,&MemoryCacheFactory);
     
     log.info("finished initializing");
     return true;
index 608625e..822b703 100644 (file)
@@ -311,7 +311,7 @@ DDF SAML1Consumer::receive(const DDF& in)
     log.debug("application: %s", app->getId());
 
     // Access the application config.
-    IConfig* conf=dynamic_cast<IConfig*>(SPConfig::getConfig().getServiceProvider());
+    ServiceProvider* conf=SPConfig::getConfig().getServiceProvider();
     xmltooling::Locker confLocker(conf);
 
     auto_ptr_XMLCh wrecipient(recipient);
@@ -347,7 +347,7 @@ DDF SAML1Consumer::receive(const DDF& in)
             bpr=app->getBrowserProfile()->receive(
                 samlResponse,
                 wrecipient.get(),
-                checkReplay.second ? conf->getReplayCache() : NULL,
+                NULL,
                 version.second
                 );
         }
@@ -366,7 +366,7 @@ DDF SAML1Consumer::receive(const DDF& in)
                 SAMLart,
                 wrecipient.get(),
                 artifactMapper.get(),
-                checkReplay.second ? conf->getReplayCache() : NULL,
+                NULL,
                 version.second
                 );
 
@@ -432,7 +432,7 @@ DDF SAML1Consumer::receive(const DDF& in)
 
     // Insert into cache.
     auto_ptr_char authContext(bpr.authnStatement->getAuthMethod());
-    string key=conf->getSessionCache()->insert(
+    string key=dynamic_cast<ISessionCache*>(conf->getSessionCache())->insert(
         app,
         role,
         client_address,
index 6eb3e9e..4fdbc4e 100644 (file)
@@ -56,7 +56,7 @@ namespace {
     class XMLApplication : public virtual IApplication, public DOMPropertySet, public DOMNodeFilter
     {
     public:
-        XMLApplication(const IConfig*, const DOMElement* e, const XMLApplication* base=NULL);
+        XMLApplication(const ServiceProvider*, const DOMElement* e, const XMLApplication* base=NULL);
         ~XMLApplication() { cleanup(); }
     
         // PropertySet
@@ -98,7 +98,7 @@ namespace {
     
     private:
         void cleanup();
-        const IConfig* m_ini;   // this is ok because its locking scope includes us
+        const ServiceProvider* m_sp;   // this is ok because its locking scope includes us
         const XMLApplication* m_base;
         string m_hash;
         vector<IAAP*> m_aaps;
@@ -175,11 +175,11 @@ namespace {
     #pragma warning( disable : 4250 )
 #endif
 
-    class XMLConfig : public IConfig, public ReloadableXMLFile
+    class XMLConfig : public ServiceProvider, public ReloadableXMLFile
     {
     public:
         XMLConfig(const DOMElement* e)
-            : ReloadableXMLFile(e), m_impl(NULL), m_listener(NULL), m_sessionCache(NULL), m_replayCache(NULL) {
+            : ReloadableXMLFile(e), m_impl(NULL), m_listener(NULL), m_sessionCache(NULL) {
         }
         
         void init() {
@@ -189,7 +189,6 @@ namespace {
         ~XMLConfig() {
             delete m_impl;
             delete m_sessionCache;
-            delete m_replayCache;
             delete m_listener;
         }
 
@@ -209,9 +208,18 @@ namespace {
             return m_listener;
         }
 
-        ISessionCache* getSessionCache() const {return m_sessionCache;}
-        IReplayCache* getReplayCache() const {return m_replayCache;}
-        RequestMapper* getRequestMapper() const {return m_impl->m_requestMapper;}
+        SessionCache* getSessionCache(bool required=true) const {
+            if (required && !m_sessionCache)
+                throw ConfigurationException("No SessionCache available.");
+            return m_sessionCache;
+        }
+
+        RequestMapper* getRequestMapper(bool required=true) const {
+            if (required && !m_impl->m_requestMapper)
+                throw ConfigurationException("No RequestMapper available.");
+            return m_impl->m_requestMapper;
+        }
+
         const Application* getApplication(const char* applicationId) const {
             map<string,Application*>::const_iterator i=m_impl->m_appmap.find(applicationId);
             return (i!=m_impl->m_appmap.end()) ? i->second : NULL;
@@ -233,8 +241,7 @@ namespace {
         friend class XMLConfigImpl;
         XMLConfigImpl* m_impl;
         mutable ListenerService* m_listener;
-        mutable ISessionCache* m_sessionCache;
-        mutable IReplayCache* m_replayCache;
+        mutable SessionCache* m_sessionCache;
     };
 
 #if defined (_MSC_VER)
@@ -282,10 +289,10 @@ ServiceProvider* shibtarget::XMLServiceProviderFactory(const DOMElement* const &
 }
 
 XMLApplication::XMLApplication(
-    const IConfig* ini,
+    const ServiceProvider* sp,
     const DOMElement* e,
     const XMLApplication* base
-    ) : m_ini(ini), m_base(base), m_metadata(NULL), m_trust(NULL), m_profile(NULL), m_binding(NULL), m_bindingHook(NULL),
+    ) : m_sp(sp), m_base(base), m_metadata(NULL), m_trust(NULL), m_profile(NULL), m_binding(NULL), m_bindingHook(NULL),
         m_credDefault(NULL), m_sessionInitDefault(NULL), m_acsDefault(NULL)
 {
 #ifdef _DEBUG
@@ -903,7 +910,6 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
         load(e,log,this,&root_remap);
 
         const DOMElement* child;
-        IPlugIn* plugin=NULL;
         string plugtype;
 
         // Much of the processing can only occur on the first instantiation.
@@ -957,33 +963,24 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
                 child=XMLHelper::getFirstChildElement(container,MemorySessionCache);
                 if (child) {
                     log.info("building Session Cache of type %s...",MEMORY_SESSIONCACHE);
-                    plugin=shibConf.getPlugMgr().newPlugin(MEMORY_SESSIONCACHE,child);
+                    m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(MEMORY_SESSIONCACHE,child);
                 }
                 else {
                     child=XMLHelper::getFirstChildElement(container,SessionCache);
                     if (child) {
                         xmltooling::auto_ptr_char type(child->getAttributeNS(NULL,_type));
                         log.info("building Session Cache of type %s...",type.get());
-                        plugin=shibConf.getPlugMgr().newPlugin(type.get(),child);
+                        m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(type.get(),child);
                     }
                     else {
                         log.info("custom SessionCache unspecified or no longer supported, building SessionCache of type %s...",MEMORY_SESSIONCACHE);
-                        plugin=shibConf.getPlugMgr().newPlugin(MEMORY_SESSIONCACHE,child);
-                    }
-                }
-                if (plugin) {
-                    ISessionCache* cache=dynamic_cast<ISessionCache*>(plugin);
-                    if (cache)
-                        m_outer->m_sessionCache=cache;
-                    else {
-                        delete plugin;
-                        log.fatal("plugin was not a Session Cache object");
-                        throw UnknownExtensionException("plugin was not a Session Cache object");
+                        m_outer->m_sessionCache=conf.SessionCacheManager.newPlugin(MEMORY_SESSIONCACHE,child);
                     }
                 }
                 
                 // Replay cache.
                 // TODO: switch to new cache interface
+                /*
                 child=XMLHelper::getFirstChildElement(container,ReplayCache);
                 if (child) {
                     xmltooling::auto_ptr_char type(child->getAttributeNS(NULL,_type));
@@ -995,6 +992,7 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
                     log.info("custom ReplayCache unspecified or no longer supported, building default ReplayCache...");
                     m_outer->m_replayCache=IReplayCache::getInstance();
                 }
+                */
             }
         } // end of first-time-only stuff
         
@@ -1060,7 +1058,7 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, const XMLConfig* o
             xmltooling::auto_ptr_char type(child->getAttributeNS(NULL,_type));
             log.info("building Attribute factory of type %s...",type.get());
             try {
-                plugin=shibConf.getPlugMgr().newPlugin(type.get(),child);
+                IPlugIn* plugin=shibConf.getPlugMgr().newPlugin(type.get(),child);
                 if (plugin) {
                     IAttributeFactory* fact=dynamic_cast<IAttributeFactory*>(plugin);
                     if (fact) {
index 2aa1547..782c31e 100644 (file)
@@ -31,6 +31,7 @@
 #include <shibsp/Handler.h>
 #include <shibsp/RequestMapper.h>
 #include <shibsp/ServiceProvider.h>
+#include <shibsp/SessionCache.h>
 #include <shibsp/remoting/ListenerService.h>
 
 // Old headers
@@ -191,7 +192,7 @@ namespace shibtarget {
      * remote and/or optimize calls by implementing custom versions of the
      * ISessionCacheEntry interface as required.
      */
-    struct SHIBTARGET_EXPORTS ISessionCache : public virtual saml::IPlugIn
+    struct SHIBTARGET_EXPORTS ISessionCache : virtual public shibsp::SessionCache
     {
         virtual std::string insert(
             const IApplication* application,
@@ -220,13 +221,6 @@ namespace shibtarget {
     #define ODBC_REPLAYCACHE    "edu.internet2.middleware.shibboleth.sp.provider.ODBCReplayCacheProvider"
 
 
-    struct SHIBTARGET_EXPORTS IConfig : public virtual shibsp::ServiceProvider
-    {
-        virtual ISessionCache* getSessionCache() const=0;
-        virtual saml::IReplayCache* getReplayCache() const=0;
-        virtual ~IConfig() {}
-    };
-
     class SHIBTARGET_EXPORTS ShibTargetConfig
     {
     public:
index 3ee1936..8924527 100644 (file)
@@ -56,6 +56,7 @@ libshibsp_la_SOURCES = \
        Application.cpp \
        ServiceProvider.cpp \
        SPConfig.cpp \
+       impl/StorageServiceSessionCache.cpp \
        impl/XMLAccessControl.cpp \
        impl/XMLRequestMapper.cpp \
        metadata/MetadataExtImpl.cpp \
index 7e4e5cc..f789410 100644 (file)
@@ -27,6 +27,7 @@
 #include "Handler.h"
 #include "RequestMapper.h"
 #include "ServiceProvider.h"
+#include "SessionCache.h"
 #include "SPConfig.h"
 #include "metadata/MetadataExt.h"
 #include "remoting/ListenerService.h"
@@ -100,6 +101,7 @@ bool SPInternalConfig::init(const char* catalog_path)
     registerAccessControls();
     registerListenerServices();
     registerRequestMappers();
+    registerSessionCaches();
     registerServiceProviders();
 
     log.info("library initialization complete");
@@ -119,6 +121,7 @@ void SPInternalConfig::term()
     
     SingleLogoutServiceManager.deregisterFactories();
     SessionInitiatorManager.deregisterFactories();
+    SessionCacheManager.deregisterFactories();
     ServiceProviderManager.deregisterFactories();
     RequestMapperManager.deregisterFactories();
     ManageNameIDServiceManager.deregisterFactories();
index 47f5e70..431b753 100644 (file)
@@ -38,6 +38,7 @@ namespace shibsp {
     class SHIBSP_API ListenerService;
     class SHIBSP_API RequestMapper;
     class SHIBSP_API ServiceProvider;
+    class SHIBSP_API SessionCache;
 
 #if defined (_MSC_VER)
     #pragma warning( push )
@@ -168,6 +169,11 @@ namespace shibsp {
         xmltooling::PluginManager<ServiceProvider,const xercesc::DOMElement*> ServiceProviderManager;
 
         /**
+         * Manages factories for SessionCache plugins.
+         */
+        xmltooling::PluginManager<SessionCache,const xercesc::DOMElement*> SessionCacheManager;
+
+        /**
          * Manages factories for Handler plugins that implement SessionInitiator functionality.
          */
         xmltooling::PluginManager<Handler,const xercesc::DOMElement*> SessionInitiatorManager;
index 565b43f..b6c55e1 100644 (file)
@@ -58,10 +58,18 @@ namespace shibsp {
         virtual void init()=0;
         
         /**
+         * Returns a SessionCache instance.
+         * 
+         * @param required  true iff an exception should be thrown if no SessionCache is available
+         * @return  a SessionCache
+         */
+        virtual SessionCache* getSessionCache(bool required=true) const=0;
+
+        /**
          * Returns a ListenerService instance.
          * 
          * @param required  true iff an exception should be thrown if no ListenerService is available
-         * @return  a ListenerService if available, or NULL
+         * @return  a ListenerService
          */
         virtual ListenerService* getListenerService(bool required=true) const=0;
         
@@ -76,9 +84,10 @@ namespace shibsp {
         /**
          * Returns a RequestMapper instance.
          * 
-         * @param a RequestMapper if available, or NULL
+         * @param required  true iff an exception should be thrown if no RequestMapper is available
+         * @param a RequestMapper
          */
-        virtual RequestMapper* getRequestMapper() const=0;
+        virtual RequestMapper* getRequestMapper(bool required=true) const=0;
         
         //virtual ISessionCache* getSessionCache() const=0;
         
index 492406a..e28b0fe 100644 (file)
@@ -59,19 +59,16 @@ namespace shibsp {
     class SHIBSP_API SessionCache
     {
         MAKE_NONCOPYABLE(SessionCache);
+    protected:
+        SessionCache() {}
     public:
-        /**
-         * Constructor
-         *
-         * @param e root of DOM to configure cache
-         */
-        SessionCache(const xercesc::DOMElement* e);
-
-        virtual ~SessionCache();
-
-        /** TODO: just a stub for now */
-        virtual Session* find(const char* key, const Application& app, const char* address)=0;
+        virtual ~SessionCache() {}
     };
+
+    /**
+     * Registers SessionCache classes into the runtime.
+     */
+    void SHIBSP_API registerSessionCaches();
 };
 
 #endif /* __shibsp_sessioncache_h__ */
diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp
new file mode 100644 (file)
index 0000000..060af66
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ *  Copyright 2001-2005 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/** StorageServiceSessionCache.cpp\r
+ * \r
+ * StorageService-based SessionCache implementation\r
+ */\r
+\r
+#include "internal.h"\r
+#include "SessionCache.h"\r
+#include "util/SPConstants.h"\r
+\r
+#include <log4cpp/Category.hh>\r
+#include <xmltooling/util/NDC.h>\r
+#include <xmltooling/util/XMLHelper.h>\r
+#include <xercesc/util/XMLUniDefs.hpp>\r
+\r
+using namespace shibsp;\r
+using namespace xmltooling;\r
+using namespace log4cpp;\r
+using namespace std;\r
+/*\r
+namespace shibsp {\r
+\r
+    SessionCache* SHIBSP_DLLLOCAL XMLRequestMapperFactory(const DOMElement* const & e)\r
+    {\r
+        return new XMLRequestMapper(e);\r
+    }\r
+\r
+}\r
+*/\r
+void SHIBSP_API shibsp::registerSessionCaches()\r
+{\r
+    //SPConfig::getConfig().SessionCacheManager.registerFactory(XML_REQUEST_MAPPER, XMLRequestMapperFactory);\r
+}\r
index e0796c5..3ccdea9 100644 (file)
                                Name="impl"\r
                                >\r
                                <File\r
+                                       RelativePath=".\impl\StorageServiceSessionCache.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath=".\impl\XMLAccessControl.cpp"\r
                                        >\r
                                </File>\r