<pathentry kind="src" path="shibsp"/>
<pathentry kind="out" path=""/>
<pathentry kind="src" path="odbc-store"/>
+<pathentry kind="src" path="apache"/>
</item>
</data>
</cdtproject>
if (!shar_checkonly) {
// Run the listener.
- if (!conf.getINI()->getListener()->run(&shibd_shutdown)) {
+ if (!conf.getINI()->getListenerService()->run(&shibd_shutdown)) {
fprintf(stderr, "listener failed to enter listen loop\n");
return -3;
}
}
// Run the listener
- if (!conf.getINI()->getListener()->run(&shibd_shutdown)) {
+ if (!conf.getINI()->getListenerService()->run(&shibd_shutdown)) {
fprintf(stderr, "listener failed to enter listen loop\n");
return -3;
}
DDFJanitor injan(in);
in.integer(atol(argv[1]));
- DDF out=conf.getINI()->getListener()->send(in);
+ DDF out=conf.getINI()->getListenerService()->send(in);
DDFJanitor outjan(out);
cerr << argv[1] << " -> " << out.integer() << "\n";
#include <log4cpp/Category.hh>
#include <log4cpp/FixedContextCategory.hh>
#include <shibsp/exceptions.h>
+#include <xmltooling/PluginManager.h>
#include <xmltooling/util/NDC.h>
#include <xmltooling/util/Threads.h>
private:
log4cpp::FixedContextCategory* m_tranLog;
xmltooling::Mutex* m_tranLogLock;
- static IConfig* ShibTargetConfigFactory(const DOMElement* e);
};
+
+ // TODO: move this over to shibsp lib.
+ xmltooling::PluginManager<shibsp::ServiceProvider,const DOMElement*>::Factory XMLServiceProviderFactory;
}
#endif
os << *tokens;
in.addmember("tokens.unfiltered").string(os.str().c_str());
- out=ShibTargetConfig::getConfig().getINI()->getListener()->send(in);
+ out=ShibTargetConfig::getConfig().getINI()->getListenerService()->send(in);
if (out["key"].isstring())
return out["key"].string();
throw opensaml::RetryableProfileException("A remoted cache insertion operation did not return a usable session key.");
in.addmember("client_address").string(client_addr);
try {
- out=ShibTargetConfig::getConfig().getINI()->getListener()->send(in);
+ out=ShibTargetConfig::getConfig().getINI()->getListenerService()->send(in);
if (!out.isstruct()) {
out.destroy();
return NULL;
in.addmember("application_id").string(application->getId());
in.addmember("client_address").string(client_addr);
- ShibTargetConfig::getConfig().getINI()->getListener()->send(in);
+ ShibTargetConfig::getConfig().getINI()->getListenerService()->send(in);
}
/*
SAMLConfig::getConfig().conn_timeout = m_AAConnectTimeout;
// Register for remoted messages.
- ListenerService* listener=ShibTargetConfig::getConfig().getINI()->getListener();
+ ListenerService* listener=ShibTargetConfig::getConfig().getINI()->getListenerService(false);
if (listener && SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess)) {
restoreInsert=listener->regListener("SessionCache::insert",this);
restoreFind=listener->regListener("SessionCache::find",this);
cleanup_thread->join(NULL);
// Unregister remoted messages.
- ListenerService* listener=ShibTargetConfig::getConfig().getINI()->getListener();
+ ListenerService* listener=ShibTargetConfig::getConfig().getINI()->getListenerService(false);
if (listener && SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess)) {
listener->unregListener("SessionCache::insert",this,restoreInsert);
listener->unregListener("SessionCache::find",this,restoreFind);
using namespace std;
using xmltooling::XMLToolingConfig;
+using xmltooling::PluginManager;
namespace {
STConfig g_Config;
#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;
}
ShibConfig& shibConf=ShibConfig::getConfig();
if (!shibConf.init()) {
log.fatal("Failed to initialize Shib library");
- SPConfig::getConfig().term();
+ samlConf.term();
+ return false;
+ }
+
+ if (!SPConfig::getConfig().init(NULL)) {
+ log.fatal("Failed to initialize SP library");
+ shibConf.term();
samlConf.term();
return false;
}
// Register built-in plugin types.
+ SPConfig::getConfig().ServiceProviderManager.registerFactory(XML_SERVICE_PROVIDER, XMLServiceProviderFactory);
samlConf.getPlugMgr().regFactory(MEMORY_SESSIONCACHE,&MemoryCacheFactory);
samlConf.getPlugMgr().regFactory(LEGACY_REQUESTMAP_PROVIDER,&XMLRequestMapFactory);
#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");
auto_ptr_XMLCh src(config);
dummy->setAttributeNS(NULL,path,src.get());
- m_ini=ShibTargetConfigFactory(dummy);
+ m_ini=dynamic_cast<IConfig*>(SPConfig::getConfig().ServiceProviderManager.newPlugin(XML_SERVICE_PROVIDER,dummy));
m_ini->init();
pair<bool,unsigned int> skew=m_ini->getUnsignedInt("clockSkew");
#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;
m_address += "::SAML1Consumer::run";
// Register for remoted messages.
- if (SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess)) {
- ListenerService* listener=ShibTargetConfig::getConfig().getINI()->getListener();
- if (listener)
- listener->regListener(m_address.c_str(),this);
- else
- throw ListenerException("Plugin requires a Listener service");
- }
+ if (SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess))
+ ShibTargetConfig::getConfig().getINI()->getListenerService()->regListener(m_address.c_str(),this);
}
SAML1Consumer::~SAML1Consumer()
{
- ListenerService* listener=ShibTargetConfig::getConfig().getINI()->getListener();
+ ListenerService* listener=ShibTargetConfig::getConfig().getINI()->getListenerService(false);
if (listener && SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess))
listener->unregListener(m_address.c_str(),this);
counter--;
in.addmember("application_id").string(st->getApplication()->getId());
in.addmember("client_address").string(st->getRemoteAddr());
- out=st->getConfig()->getListener()->send(in);
+ out=st->getConfig()->getListenerService()->send(in);
if (!out["key"].isstring())
throw opensaml::FatalProfileException("Remote processing of SAML 1.x Browser profile did not return a usable session key.");
string key=out["key"].string();
const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:target:config:1.0") const {return m_impl->getPropertySet(name,ns);}
const DOMElement* getElement() const {return m_impl->getElement();}
- // IConfig
- ListenerService* getListener() const {return m_listener;}
+ // ServiceProvider
+ ListenerService* getListenerService(bool required=true) const {
+ if (required && !m_listener)
+ throw ConfigurationException("No ListenerService available.");
+ return m_listener;
+ }
+
ISessionCache* getSessionCache() const {return m_sessionCache;}
IReplayCache* getReplayCache() const {return m_replayCache;}
IRequestMapper* getRequestMapper() const {return m_impl->m_requestMapper;}
}
-IConfig* STConfig::ShibTargetConfigFactory(const DOMElement* e)
+ServiceProvider* shibtarget::XMLServiceProviderFactory(const DOMElement* const & e)
{
return new XMLConfig(e);
}
#define SHIB_TARGET_H
// New headers
-#include <shibsp/base.h>
#include <shibsp/ListenerService.h>
-#include <shibsp/PropertySet.h>
+#include <shibsp/ServiceProvider.h>
#include <saml/saml2/metadata/MetadataProvider.h>
#include <xmltooling/security/TrustEngine.h>
-#include <xmltooling/signature/CredentialResolver.h>
// Old headers
#include <saml/saml.h>
#define NATIVE_REQUESTMAP_PROVIDER "edu.internet2.middleware.shibboleth.sp.provider.NativeRequestMapProvider"
#define LEGACY_REQUESTMAP_PROVIDER "edu.internet2.middleware.shibboleth.target.provider.XMLRequestMap"
- struct SHIBTARGET_EXPORTS IConfig : public virtual xmltooling::Lockable, public virtual shibsp::PropertySet, public virtual saml::IPlugIn
+ struct SHIBTARGET_EXPORTS IConfig : public virtual shibsp::ServiceProvider
{
- virtual void init()=0;
- virtual shibsp::ListenerService* getListener() const=0;
virtual ISessionCache* getSessionCache() const=0;
virtual saml::IReplayCache* getReplayCache() const=0;
virtual IRequestMapper* getRequestMapper() const=0;
virtual const IApplication* getApplication(const char* applicationId) const=0;
- virtual xmlsignature::CredentialResolver* getCredentialResolver(const char* id) const=0;
virtual ~IConfig() {}
};
PKIXTrustEngine.h \
PropertySet.h \
version.h \
+ ServiceProvider.h \
SocketListener.h \
SPConfig.h \
SPConstants.h
MetadataExtImpl.cpp \
MetadataExtSchemaValidators.cpp \
PKIXTrustEngine.cpp \
+ ServiceProvider.cpp \
SPConfig.cpp \
SPConstants.cpp \
SocketListener.cpp \
#include "ListenerService.h"
#include "MetadataExt.h"
#include "PKIXTrustEngine.h"
+#include "ServiceProvider.h"
#include "SPConfig.h"
#include <log4cpp/Category.hh>
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
- registerListenerServices();
registerMetadataExtClasses();
registerPKIXTrustEngine();
+ registerListenerServices();
+ registerServiceProviders();
log.info("library initialization complete");
return true;
Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
log.info("shutting down the library");
- //delete m_serviceProvider;
+ delete m_serviceProvider;
m_serviceProvider = NULL;
ListenerServiceManager.deregisterFactories();
+ ServiceProviderManager.deregisterFactories();
SAMLConfig::getConfig().term();
log.info("library shutdown complete");
*/
xmltooling::PluginManager<ListenerService,const xercesc::DOMElement*> ListenerServiceManager;
+ /**
+ * Manages factories for ServiceProvider plugins.
+ */
+ xmltooling::PluginManager<ServiceProvider,const xercesc::DOMElement*> ServiceProviderManager;
+
protected:
SPConfig() : m_serviceProvider(NULL) {}
--- /dev/null
+/*
+ * Copyright 2001-2006 Internet2
+ *
+ * Licensed 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.
+ */
+
+/**
+ * ServiceProvider.cpp
+ *
+ * Interface to a Shibboleth ServiceProvider instance.
+ */
+
+#include "internal.h"
+#include "ServiceProvider.h"
+
+#include <xercesc/dom/DOM.hpp>
+
+using namespace shibsp;
+using namespace xmltooling;
+using namespace xercesc;
+using namespace std;
+
+namespace shibsp {
+ //SHIBSP_DLLLOCAL PluginManager<ServiceProvider,const DOMElement*>::Factory XMLServiceProviderFactory;
+};
+
+void SHIBSP_API shibsp::registerServiceProviders()
+{
+ //SPConfig::getConfig().ServiceProviderManager.registerFactory(XML_SERVICE_PROVIDER, XMLServiceProviderFactory);
+}
--- /dev/null
+/*
+ * Copyright 2001-2006 Internet2
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @file shibsp/ServiceProvider.h
+ *
+ * Interface to a Shibboleth ServiceProvider instance.
+ */
+
+#ifndef __shibsp_sp_h__
+#define __shibsp_sp_h__
+
+#include <shibsp/PropertySet.h>
+#include <xmltooling/signature/CredentialResolver.h>
+
+namespace shibsp {
+
+ class ListenerService;
+
+ /**
+ * Interface to a Shibboleth ServiceProvider instance.
+ *
+ * <p>A ServiceProvider exposes configuration and infrastructure services required
+ * by the SP implementation, allowing a flexible configuration format.
+ */
+ class SHIBSP_API ServiceProvider : public virtual xmltooling::Lockable, public virtual PropertySet
+ {
+ MAKE_NONCOPYABLE(ServiceProvider);
+ protected:
+ ServiceProvider() {}
+ public:
+ virtual ~ServiceProvider() {}
+
+ /**
+ * Loads a configuration and prepares the instance for use.
+ *
+ * <p>Implemented as a separate method so that services can rely on
+ * other services while they initialize by accessing the ServiceProvider
+ * from the SPConfig singleton.
+ */
+ virtual void init()=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
+ */
+ virtual ListenerService* getListenerService(bool required=true) const=0;
+
+ /**
+ * Returns a CredentialResolver instance mapped to a key.
+ *
+ * @param id a NULL-terminated key identifying the CredentialResolver to the configuration
+ * @return a CredentialResolver if available, or NULL
+ */
+ virtual xmlsignature::CredentialResolver* getCredentialResolver(const char* id) const=0;
+
+ //virtual ISessionCache* getSessionCache() const=0;
+
+ //virtual IRequestMapper* getRequestMapper() const=0;
+
+ //virtual const IApplication* getApplication(const char* applicationId) const=0;
+ };
+
+ /**
+ * Registers ServiceProvider classes into the runtime.
+ */
+ void SHIBSP_API registerServiceProviders();
+
+ /** SP based on integrated XML and native server configuration. */
+ #define XML_SERVICE_PROVIDER "edu.internet2.middleware.shibboleth.sp.provider.XMLServiceProvider"
+};
+
+#endif /* __shibsp_sp_h__ */
>\r
</File>\r
<File\r
+ RelativePath=".\ServiceProvider.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\SocketListener.cpp"\r
>\r
</File>\r
>\r
</File>\r
<File\r
+ RelativePath=".\ServiceProvider.h"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\SocketListener.h"\r
>\r
</File>\r