#include "internal.h"
#include <shibsp/SPConfig.h>
-#include <shibsp/SPConstants.h>
#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/util/NDC.h>
#include <log4cpp/OstreamAppender.hh>
using namespace std;
using xmltooling::XMLToolingConfig;
+using xmltooling::PluginManager;
namespace {
STConfig g_Config;
#endif
PlugManager::Factory TCPListenerFactory;
//PlugManager::Factory MemoryListenerFactory;
-PlugManager::Factory MemoryCacheFactory;
-PlugManager::Factory XMLRequestMapFactory;
-PlugManager::Factory ShibSessionInitiatorFactory;
-PlugManager::Factory SAML1POSTFactory;
-PlugManager::Factory SAML1ArtifactFactory;
-PlugManager::Factory ShibLogoutFactory;
-//PlugManager::Factory htaccessFactory;
+
+PluginManager<SessionCache,const DOMElement*>::Factory MemoryCacheFactory;
+PluginManager<Handler,const DOMElement*>::Factory ShibSessionInitiatorFactory;
+PluginManager<Handler,const DOMElement*>::Factory SAML1POSTFactory;
+PluginManager<Handler,const DOMElement*>::Factory SAML1ArtifactFactory;
+PluginManager<Handler,const DOMElement*>::Factory ShibLogoutFactory;
ShibTargetConfig& ShibTargetConfig::getConfig()
{
#ifdef _DEBUG
xmltooling::NDC ndc("init");
#endif
- Category& log = Category::getInstance("shibtarget.Config");
+ Category& log = Category::getInstance(SHIBT_LOGCAT".Config");
if (!schemadir) {
log.fatal("XML schema directory not supplied");
SAMLConfig& samlConf=SAMLConfig::getConfig();
if (schemadir)
samlConf.schema_dir = schemadir;
- if (!samlConf.init() || !SPConfig::getConfig().init(NULL)) {
- log.fatal("failed to initialize SP library");
+ if (!samlConf.init()) {
+ log.fatal("failed to initialize OpenSAML1 library");
return false;
}
samlConf.term();
return false;
}
+
+ SPConfig& conf=SPConfig::getConfig();
+ if (!SPConfig::getConfig().init(NULL)) {
+ log.fatal("Failed to initialize SP library");
+ shibConf.term();
+ samlConf.term();
+ return false;
+ }
// Register built-in plugin types.
+ conf.ServiceProviderManager.registerFactory(XML_SERVICE_PROVIDER, XMLServiceProviderFactory);
- samlConf.getPlugMgr().regFactory(shibtarget::XML::MemorySessionCacheType,&MemoryCacheFactory);
- samlConf.getPlugMgr().regFactory(shibtarget::XML::LegacyRequestMapType,&XMLRequestMapFactory);
- samlConf.getPlugMgr().regFactory(shibtarget::XML::XMLRequestMapType,&XMLRequestMapFactory);
- samlConf.getPlugMgr().regFactory(shibtarget::XML::NativeRequestMapType,&XMLRequestMapFactory);
+ conf.SessionInitiatorManager.registerFactory(shibspconstants::SHIB1_SESSIONINIT_PROFILE_URI,&ShibSessionInitiatorFactory);
+ conf.AssertionConsumerServiceManager.registerFactory(samlconstants::SAML1_PROFILE_BROWSER_POST,&SAML1POSTFactory);
+ conf.AssertionConsumerServiceManager.registerFactory(samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT,&SAML1ArtifactFactory);
+ conf.SingleLogoutServiceManager.registerFactory(shibspconstants::SHIB1_LOGOUT_PROFILE_URI,&ShibLogoutFactory);
- auto_ptr_char temp1(shibspconstants::SHIB1_SESSIONINIT_PROFILE_URI);
- samlConf.getPlugMgr().regFactory(temp1.get(),&ShibSessionInitiatorFactory);
- samlConf.getPlugMgr().regFactory(samlconstants::SAML1_PROFILE_BROWSER_POST,&SAML1POSTFactory);
- samlConf.getPlugMgr().regFactory(samlconstants::SAML1_PROFILE_BROWSER_ARTIFACT,&SAML1ArtifactFactory);
- auto_ptr_char temp4(shibspconstants::SHIB1_LOGOUT_PROFILE_URI);
- samlConf.getPlugMgr().regFactory(temp4.get(),&ShibLogoutFactory);
-
- saml::XML::registerSchema(shibtarget::XML::SHIBTARGET_NS,shibtarget::XML::SHIBTARGET_SCHEMA_ID,NULL,false);
- saml::XML::registerSchema(samlconstants::SAML20MD_NS,shibtarget::XML::SAML2META_SCHEMA_ID,NULL,false);
- saml::XML::registerSchema(samlconstants::SAML20_NS,shibtarget::XML::SAML2ASSERT_SCHEMA_ID,NULL,false);
- saml::XML::registerSchema(xmlconstants::XMLENC_NS,shibtarget::XML::XMLENC_SCHEMA_ID,NULL,false);
+ conf.SessionCacheManager.registerFactory(MEMORY_SESSIONCACHE,&MemoryCacheFactory);
log.info("finished initializing");
return true;
#ifdef _DEBUG
xmltooling::NDC ndc("load");
#endif
- Category& log = Category::getInstance("shibtarget.Config");
+ Category& log = Category::getInstance(SHIBT_LOGCAT".Config");
if (!config) {
log.fatal("path to configuration file not supplied");
try {
log.info("loading configuration file: %s", config);
- static const XMLCh uri[] = { chLatin_u, chLatin_r, chLatin_i, chNull };
+ static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h);
DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(NULL);
DOMDocument* dummydoc=impl->createDocument();
- DOMElement* dummy = dummydoc->createElementNS(NULL,XML::Literals::ShibbolethTargetConfig);
+ xmltooling::XercesJanitor<DOMDocument> docjanitor(dummydoc);
+ DOMElement* dummy = dummydoc->createElementNS(NULL,path);
+
auto_ptr_XMLCh src(config);
- dummy->setAttributeNS(NULL,uri,src.get());
- m_ini=ShibTargetConfigFactory(dummy);
- dummydoc->release();
- m_ini->init();
+ dummy->setAttributeNS(NULL,path,src.get());
+
+ auto_ptr<ServiceProvider> sp(SPConfig::getConfig().ServiceProviderManager.newPlugin(XML_SERVICE_PROVIDER,dummy));
+ sp->init();
- pair<bool,unsigned int> skew=m_ini->getUnsignedInt("clockSkew");
+ pair<bool,unsigned int> skew=sp->getUnsignedInt("clockSkew");
SAMLConfig::getConfig().clock_skew_secs=skew.first ? skew.second : 180;
if (skew.first)
XMLToolingConfig::getConfig().clock_skew_secs=skew.second;
+ SPConfig::getConfig().setServiceProvider(sp.release());
m_tranLog=new FixedContextCategory(SHIBTRAN_LOGCAT);
m_tranLog->info("opened transaction log");
#ifdef _DEBUG
xmltooling::NDC ndc("shutdown");
#endif
- Category& log = Category::getInstance("shibtarget.Config");
+ Category& log = Category::getInstance(SHIBT_LOGCAT".Config");
log.info("shutting down the library");
delete m_tranLogLock;
m_tranLogLock = NULL;
//delete m_tranLog; // This is crashing for some reason, but we're shutting down anyway.
- delete m_ini;
- m_ini = NULL;
+ SPConfig::getConfig().term();
ShibConfig::getConfig().term();
SAMLConfig::getConfig().term();
- SPConfig::getConfig().term();
log.info("library shutdown complete");
}