[cpp-sp] branch main updated: Start moving code off xmltooling logging.
Scott Cantor
cantor.2 at osu.edu
Thu Nov 21 19:07:32 UTC 2024
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=334277dcb9e38eb94f1e684afc2370674a820605
The following commit(s) were added to refs/heads/main by this push:
new 334277dc Start moving code off xmltooling logging.
334277dc is described below
commit 334277dcb9e38eb94f1e684afc2370674a820605
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Nov 21 14:07:23 2024 -0500
Start moving code off xmltooling logging.
---
apache/mod_shib_24.cpp | 2 +-
shibsp/AbstractSPRequest.cpp | 9 +-
shibsp/AgentConfig.h | 119 ++++++++++++++++
shibsp/Makefile.am | 3 +-
shibsp/SPConfig.cpp | 28 +---
shibsp/SPConfig.h | 26 ++--
shibsp/ServiceProvider.cpp | 10 +-
shibsp/exceptions.h | 17 ---
shibsp/handler/AbstractHandler.h | 6 +-
shibsp/handler/AssertionConsumerService.h | 20 +--
shibsp/handler/SecuredHandler.h | 2 +-
shibsp/handler/SessionInitiator.h | 2 +-
shibsp/handler/impl/AbstractHandler.cpp | 16 +--
shibsp/handler/impl/AdminLogoutInitiator.cpp | 2 +
shibsp/handler/impl/AssertionConsumerService.cpp | 3 +-
shibsp/handler/impl/AssertionLookup.cpp | 8 +-
shibsp/handler/impl/DiscoveryFeed.cpp | 13 +-
shibsp/handler/impl/MetadataGenerator.cpp | 30 +---
shibsp/handler/impl/RemotedHandler.cpp | 10 +-
shibsp/handler/impl/SAML2SessionInitiator.cpp | 1 -
shibsp/handler/impl/SAMLDSSessionInitiator.cpp | 3 +-
shibsp/handler/impl/SessionHandler.cpp | 1 +
shibsp/handler/impl/SessionInitiator.cpp | 4 -
shibsp/handler/impl/StatusHandler.cpp | 13 +-
shibsp/{SPConfig.cpp => impl/AgentConfig.cpp} | 170 +++++++----------------
shibsp/impl/StorageServiceSessionCache.cpp | 1 -
shibsp/impl/StorageServiceSessionCache.h | 2 +-
shibsp/impl/StoredSession.cpp | 5 +-
shibsp/impl/XMLAccessControl.cpp | 4 +-
shibsp/impl/XMLApplication.cpp | 2 +-
shibsp/impl/XMLApplication.h | 20 ++-
shibsp/impl/XMLRequestMapper.cpp | 8 +-
shibsp/impl/XMLServiceProvider.cpp | 15 +-
shibsp/impl/XMLServiceProvider.h | 11 +-
shibsp/internal.h | 28 ++--
shibsp/remoting/impl/SocketListener.h | 3 +-
shibsp/util/DOMPropertySet.cpp | 2 +-
shibsp/util/DOMPropertySet.h | 8 +-
shibsp/util/PluginManager.h | 108 ++++++++++++++
39 files changed, 378 insertions(+), 357 deletions(-)
diff --git a/apache/mod_shib_24.cpp b/apache/mod_shib_24.cpp
index 0222a9b1..3934317a 100644
--- a/apache/mod_shib_24.cpp
+++ b/apache/mod_shib_24.cpp
@@ -479,7 +479,7 @@ public:
}
if (m_allhttp.count(cginame) > 0)
- throw opensaml::SecurityPolicyException("Attempt to spoof header ($1) was detected.", params(1, rawname));
+ throw XMLToolingException("Attempt to spoof header ($1) was detected.", params(1, rawname));
}
apr_table_unset(m_req->headers_in, rawname);
apr_table_set(m_req->headers_in, rawname, g_unsetHeaderValue.c_str());
diff --git a/shibsp/AbstractSPRequest.cpp b/shibsp/AbstractSPRequest.cpp
index 7ed4b90a..baaba8d9 100644
--- a/shibsp/AbstractSPRequest.cpp
+++ b/shibsp/AbstractSPRequest.cpp
@@ -35,7 +35,6 @@
#include <boost/lexical_cast.hpp>
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace std;
@@ -51,7 +50,7 @@ SPRequest::~SPRequest()
AbstractSPRequest::AbstractSPRequest(const char* category)
: m_sp(SPConfig::getConfig().getServiceProvider()),
m_mapper(nullptr), m_app(nullptr), m_sessionTried(false), m_session(nullptr),
- m_log(&Category::getInstance(category))
+ m_log(nullptr)
{
m_sp->lock();
}
@@ -79,11 +78,13 @@ RequestMapper::Settings AbstractSPRequest::getRequestSettings() const
m_mapper->lock();
m_settings = m_mapper->getSettings(*this);
+/*
if (reinterpret_cast<Category*>(m_log)->isDebugEnabled()) {
reinterpret_cast<Category*>(m_log)->debug(
"mapped %s to %s", getRequestURL(), m_settings.first->getString("applicationId").second
);
}
+ */
}
return m_settings;
}
@@ -350,6 +351,7 @@ void AbstractSPRequest::setCookie(const char* name, const char* value, time_t ex
void AbstractSPRequest::log(SPLogLevel level, const std::string& msg) const
{
+ /*
reinterpret_cast<Category*>(m_log)->log(
(level == SPDebug ? Priority::DEBUG :
(level == SPInfo ? Priority::INFO :
@@ -357,14 +359,17 @@ void AbstractSPRequest::log(SPLogLevel level, const std::string& msg) const
(level == SPError ? Priority::ERROR : Priority::CRIT)))),
msg
);
+ */
}
bool AbstractSPRequest::isPriorityEnabled(SPLogLevel level) const
{
+ /*
return reinterpret_cast<Category*>(m_log)->isPriorityEnabled(
(level == SPDebug ? Priority::DEBUG :
(level == SPInfo ? Priority::INFO :
(level == SPWarn ? Priority::WARN :
(level == SPError ? Priority::ERROR : Priority::CRIT))))
);
+ */
}
diff --git a/shibsp/AgentConfig.h b/shibsp/AgentConfig.h
new file mode 100644
index 00000000..3e64af5a
--- /dev/null
+++ b/shibsp/AgentConfig.h
@@ -0,0 +1,119 @@
+/**
+ * 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/AgentConfig.h
+ *
+ * Library/agent "global" configuration.
+ */
+
+#ifndef __shibsp_agentconfig_h__
+#define __shibsp_agentconfig_h__
+
+#include <shibsp/base.h>
+
+#include <memory>
+#include <string>
+#include <xmltooling/PluginManager.h>
+
+/**
+ * @namespace shibsp
+ * Shibboleth Service Provider Library
+ */
+
+namespace shibsp {
+
+ class SHIBSP_API AccessControl;
+ class SHIBSP_API Agent;
+ class SHIBSP_API Category;
+ class SHIBSP_API Handler;
+ class SHIBSP_API ListenerService;
+ class SHIBSP_API LoggingService;
+ class SHIBSP_API RequestMapper;
+ class SHIBSP_API SessionCache;
+ class SHIBSP_API SessionInitiator;
+
+#if defined (_MSC_VER)
+ #pragma warning( push )
+ #pragma warning( disable : 4250 4251 )
+#endif
+
+ /**
+ * Singleton interface that manages agent startup/shutdown.
+ */
+ class SHIBSP_API AgentConfig
+ {
+ MAKE_NONCOPYABLE(AgentConfig);
+ public:
+ AgentConfig();
+ virtual ~AgentConfig();
+
+ /**
+ * Returns the global configuration object for the agent.
+ *
+ * @return reference to the global agent configuration object
+ */
+ static AgentConfig& getConfig();
+
+ /**
+ * Initializes agent/library.
+ *
+ * Each process using the library MUST call this function exactly once
+ * before using any library classes.
+ *
+ * @param catalog_path delimited set of schema catalog files to load
+ * @param inst_prefix installation prefix for software
+ * @return true iff initialization was successful
+ */
+ virtual bool init(const char* inst_prefix=nullptr, const char* config_file=nullptr, bool rethrow=false);
+
+ /**
+ * Shuts down agent/library
+ *
+ * Each process using the library SHOULD call this function exactly once
+ * before terminating itself.
+ */
+ virtual void term();
+
+ /**
+ * Returns the global Agent instance.
+ *
+ * <p>This method will throw in the event the library is not yet initialized.</p>
+ *
+ * @return global Agent
+ */
+ virtual Agent& getAgent() const=0;
+
+ /**
+ * Returns the configured logging service.
+ *
+ * <p>This method will throw in the event the library is not yet initialized.</p>
+ *
+ * @return
+ */
+ virtual LoggingService& getLoggingService() const=0;
+
+ /**
+ * Helper for deprecation warnings about an at-risk feature or setting.
+ */
+ shibsp::Category& deprecation() const;
+ };
+
+#if defined (_MSC_VER)
+ #pragma warning( pop )
+#endif
+
+};
+
+#endif /* __shibsp_agentconfig_h__ */
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index 2274195c..d244609c 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -21,6 +21,7 @@ nodist_libshibspinclude_HEADERS = \
libshibspinclude_HEADERS = \
AbstractSPRequest.h \
AccessControl.h \
+ AgentConfig.h \
Application.h \
base.h \
exceptions.h \
@@ -105,10 +106,10 @@ libshibsp_la_SOURCES = \
handler/impl/SessionHandler.cpp \
handler/impl/SessionInitiator.cpp \
handler/impl/StatusHandler.cpp \
+ impl/XMLAccessControl.cpp \
impl/ChainingAccessControl.cpp \
impl/StoredSession.cpp \
impl/StorageServiceSessionCache.cpp \
- impl/XMLAccessControl.cpp \
impl/XMLApplication.cpp \
impl/XMLRequestMapper.cpp \
impl/XMLServiceProvider.cpp \
diff --git a/shibsp/SPConfig.cpp b/shibsp/SPConfig.cpp
index ec95c48b..beb77e7e 100644
--- a/shibsp/SPConfig.cpp
+++ b/shibsp/SPConfig.cpp
@@ -51,6 +51,7 @@
#include "remoting/ListenerService.h"
#include <ctime>
+#include <sstream>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xmltooling/version.h>
#include <xmltooling/XMLToolingConfig.h>
@@ -62,27 +63,14 @@
#include <xmltooling/util/XMLHelper.h>
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace boost;
using namespace std;
DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeExtractionException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeFilteringException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeResolutionException,shibsp);
DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
-#ifdef SHIBSP_LITE
-DECL_XMLTOOLING_EXCEPTION_FACTORY(BindingException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(SecurityPolicyException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(ProfileException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(FatalProfileException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(RetryableProfileException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(MetadataException,opensaml::saml2md);
-#endif
-
namespace shibsp {
class SHIBSP_DLLLOCAL SPInternalConfig : public SPConfig
{
@@ -211,21 +199,9 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeExtractionException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeFilteringException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeResolutionException,shibsp);
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
-#ifdef SHIBSP_LITE
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(BindingException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(SecurityPolicyException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ProfileException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(FatalProfileException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(RetryableProfileException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(MetadataException,opensaml::saml2md);
-#endif
-
registerAttributeFactories();
if (isEnabled(Handlers)) {
@@ -340,7 +316,7 @@ bool SPConfig::instantiate(const char* config, bool rethrow)
throw;
}
else {
- Category::getInstance(SHIBSP_LOGCAT ".Config").fatal("caught exception while loading configuration: %s", ex.what());
+ Category::getInstance(SHIBSP_LOGCAT ".Config").crit("caught exception while loading configuration: %s", ex.what());
}
}
return false;
diff --git a/shibsp/SPConfig.h b/shibsp/SPConfig.h
index 7dbf24f1..086b0209 100644
--- a/shibsp/SPConfig.h
+++ b/shibsp/SPConfig.h
@@ -28,10 +28,10 @@
#define __shibsp_config_h__
#include <shibsp/base.h>
+#include <shibsp/logging/Category.h>
+#include <shibsp/util/PluginManager.h>
#include <string>
-#include <xmltooling/logging.h>
-#include <xmltooling/PluginManager.h>
#include <xmltooling/QName.h>
#include <xercesc/dom/DOM.hpp>
@@ -166,57 +166,57 @@ namespace shibsp {
/**
* Manages factories for AccessControl plugins.
*/
- xmltooling::PluginManager<AccessControl,std::string,const xercesc::DOMElement*> AccessControlManager;
+ PluginManager<AccessControl,std::string,const xercesc::DOMElement*> AccessControlManager;
/**
* Manages factories for Handler plugins that implement AssertionConsumerService functionality.
*/
- xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > AssertionConsumerServiceManager;
+ PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > AssertionConsumerServiceManager;
/**
* Manages factories for Handler plugins that implement customized functionality.
*/
- xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > HandlerManager;
+ PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > HandlerManager;
/**
* Manages factories for ListenerService plugins.
*/
- xmltooling::PluginManager<ListenerService,std::string,const xercesc::DOMElement*> ListenerServiceManager;
+ PluginManager<ListenerService,std::string,const xercesc::DOMElement*> ListenerServiceManager;
/**
* Manages factories for Handler plugins that implement LogoutInitiator functionality.
*/
- xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > LogoutInitiatorManager;
+ PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > LogoutInitiatorManager;
/**
* Manages factories for RequestMapper plugins.
*/
- xmltooling::PluginManager<RequestMapper,std::string,const xercesc::DOMElement*> RequestMapperManager;
+ PluginManager<RequestMapper,std::string,const xercesc::DOMElement*> RequestMapperManager;
/**
* Manages factories for ServiceProvider plugins.
*/
- xmltooling::PluginManager<ServiceProvider,std::string,const xercesc::DOMElement*> ServiceProviderManager;
+ PluginManager<ServiceProvider,std::string,const xercesc::DOMElement*> ServiceProviderManager;
/**
* Manages factories for SessionCache plugins.
*/
- xmltooling::PluginManager<SessionCache,std::string,const xercesc::DOMElement*> SessionCacheManager;
+ PluginManager<SessionCache,std::string,const xercesc::DOMElement*> SessionCacheManager;
/**
* Manages factories for Handler plugins that implement SessionInitiator functionality.
*/
- xmltooling::PluginManager< SessionInitiator,std::string,std::pair<const xercesc::DOMElement*,const char*> > SessionInitiatorManager;
+ PluginManager< SessionInitiator,std::string,std::pair<const xercesc::DOMElement*,const char*> > SessionInitiatorManager;
/**
* Manages factories for Handler plugins that implement SingleLogoutService functionality.
*/
- xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > SingleLogoutServiceManager;
+ PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > SingleLogoutServiceManager;
/**
* Helper for deprecation warnings about an at-risk feature or setting.
*/
- xmltooling::logging::Category& deprecation() const;
+ Category& deprecation() const;
protected:
/** Global ServiceProvider instance. */
diff --git a/shibsp/ServiceProvider.cpp b/shibsp/ServiceProvider.cpp
index 32bea980..9e431e74 100644
--- a/shibsp/ServiceProvider.cpp
+++ b/shibsp/ServiceProvider.cpp
@@ -50,7 +50,6 @@
#include <xmltooling/util/XMLHelper.h>
using namespace shibsp;
-using namespace xmltooling::logging;
using namespace xmltooling;
using namespace std;
@@ -62,7 +61,7 @@ namespace shibsp {
)
{
// The properties we need can be set in the RequestMap, or the Errors element.
- bool mderror = dynamic_cast<const opensaml::saml2md::MetadataException*>(tp.getRichException())!=nullptr;
+ bool mderror = false;
bool accesserror = (strcmp(page, "access")==0);
pair<bool,const char*> redirectErrors = pair<bool,const char*>(false,nullptr);
pair<bool,const char*> pathname = pair<bool,const char*>(false,nullptr);
@@ -375,8 +374,7 @@ pair<bool,long> ServiceProvider::doAuthentication(SPRequest& request, bool handl
catch (const exception& e) {
log.warn("error during session lookup: %s", e.what());
// If it's not a retryable session failure, we throw to the outer handler for reporting.
- if (dynamic_cast<const opensaml::RetryableProfileException*>(&e) == nullptr)
- throw;
+ throw;
}
Locker slocker(session, false); // pop existing lock on exit
@@ -566,7 +564,7 @@ pair<bool,long> ServiceProvider::doExport(SPRequest& request, bool requireSessio
// Still no data?
if (!session) {
if (requireSession)
- throw opensaml::RetryableProfileException("Unable to obtain session to export to request.");
+ throw XMLToolingException("Unable to obtain session to export to request.");
else
return make_pair(false, 0L); // just bail silently
}
@@ -712,7 +710,7 @@ pair<bool,long> ServiceProvider::doHandler(SPRequest& request) const
// Make sure this is SSL, if it should be
if ((!handlerSSL.first || handlerSSL.second) && !request.isSecure())
- throw opensaml::FatalProfileException("Blocked non-SSL access to Shibboleth handler.");
+ throw xmltooling::XMLToolingException("Blocked non-SSL access to Shibboleth handler.");
// We dispatch based on our path info. We know the request URL begins with or equals the handler URL,
// so the path info is the next character (or null).
diff --git a/shibsp/exceptions.h b/shibsp/exceptions.h
index 7c964bde..7de77bba 100644
--- a/shibsp/exceptions.h
+++ b/shibsp/exceptions.h
@@ -33,26 +33,9 @@
namespace shibsp {
DECL_XMLTOOLING_EXCEPTION(AttributeException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,xmltooling::XMLToolingException,Exceptions during attribute processing.);
- DECL_XMLTOOLING_EXCEPTION(AttributeExtractionException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,shibsp::AttributeException,Exceptions during attribute extraction.);
- DECL_XMLTOOLING_EXCEPTION(AttributeFilteringException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,shibsp::AttributeException,Exceptions during attribute filtering.);
- DECL_XMLTOOLING_EXCEPTION(AttributeResolutionException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,shibsp::AttributeException,Exceptions during attribute resolution.);
DECL_XMLTOOLING_EXCEPTION(ConfigurationException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,xmltooling::XMLToolingException,Exceptions during configuration.);
DECL_XMLTOOLING_EXCEPTION(ListenerException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,xmltooling::XMLToolingException,Exceptions during inter-process communication.);
};
-#ifdef SHIBSP_LITE
-namespace opensaml {
- DECL_XMLTOOLING_EXCEPTION(BindingException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),opensaml,xmltooling::XMLToolingException,Exceptions in SAML binding processing);
- DECL_XMLTOOLING_EXCEPTION(SecurityPolicyException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),opensaml,xmltooling::XMLToolingException,Exceptions in security policy processing);
- DECL_XMLTOOLING_EXCEPTION(ProfileException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),opensaml,xmltooling::ValidationException,Exceptions in SAML profile processing);
- DECL_XMLTOOLING_EXCEPTION(FatalProfileException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),opensaml,ProfileException,Fatal exceptions in SAML profile processing);
- DECL_XMLTOOLING_EXCEPTION(RetryableProfileException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),opensaml,ProfileException,Non-fatal exceptions in SAML profile processing);
-
- namespace saml2md {
- DECL_XMLTOOLING_EXCEPTION(MetadataException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),opensaml::saml2md,xmltooling::XMLToolingException,Exceptions related to metadata use);
- };
-};
-#endif
-
#endif /* __shibsp_exceptions_h__ */
diff --git a/shibsp/handler/AbstractHandler.h b/shibsp/handler/AbstractHandler.h
index 3b9bd2e8..b25c0b01 100644
--- a/shibsp/handler/AbstractHandler.h
+++ b/shibsp/handler/AbstractHandler.h
@@ -28,12 +28,12 @@
#define __shibsp_abshandler_h__
#include <shibsp/handler/Handler.h>
+#include <shibsp/logging/Category.h>
#include <shibsp/remoting/ddf.h>
#include <shibsp/util/DOMPropertySet.h>
#include <map>
#include <string>
-#include <xmltooling/logging.h>
namespace xmltooling {
@@ -65,7 +65,7 @@ namespace shibsp {
*/
AbstractHandler(
const xercesc::DOMElement* e,
- xmltooling::logging::Category& log,
+ Category& log,
xercesc::DOMNodeFilter* filter=nullptr,
const Remapper* remapper=nullptr
);
@@ -231,7 +231,7 @@ namespace shibsp {
std::pair<bool,int> getInt(const char* name, const xmltooling::HTTPRequest& request, unsigned int type=HANDLER_PROPERTY_ALL) const;
/** Logging object. */
- xmltooling::logging::Category& m_log;
+ Category& m_log;
public:
virtual ~AbstractHandler();
diff --git a/shibsp/handler/AssertionConsumerService.h b/shibsp/handler/AssertionConsumerService.h
index 2ad89f89..de531b32 100644
--- a/shibsp/handler/AssertionConsumerService.h
+++ b/shibsp/handler/AssertionConsumerService.h
@@ -32,24 +32,6 @@
#include <boost/scoped_ptr.hpp>
-#ifndef SHIBSP_LITE
-namespace opensaml {
- class SAML_API Assertion;
- class SAML_API MessageDecoder;
- namespace saml1 {
- class SAML_API AuthenticationStatement;
- class SAML_API NameIdentifier;
- };
- namespace saml2 {
- class SAML_API AuthnStatement;
- class SAML_API NameID;
- };
- namespace saml2md {
- class SAML_API SPSSODescriptor;
- };
-};
-#endif
-
namespace shibsp {
class SHIBSP_API Attribute;
@@ -86,7 +68,7 @@ namespace shibsp {
AssertionConsumerService(
const xercesc::DOMElement* e,
const char* appId,
- xmltooling::logging::Category& log,
+ Category& log,
xercesc::DOMNodeFilter* filter=nullptr,
const Remapper* remapper=nullptr,
bool deprecationSupport=true
diff --git a/shibsp/handler/SecuredHandler.h b/shibsp/handler/SecuredHandler.h
index bae95473..ac2d7ec8 100644
--- a/shibsp/handler/SecuredHandler.h
+++ b/shibsp/handler/SecuredHandler.h
@@ -57,7 +57,7 @@ namespace shibsp {
*/
SecuredHandler(
const xercesc::DOMElement* e,
- xmltooling::logging::Category& log,
+ Category& log,
const char* aclProperty="acl",
const char* defaultACL=nullptr,
xercesc::DOMNodeFilter* filter=nullptr,
diff --git a/shibsp/handler/SessionInitiator.h b/shibsp/handler/SessionInitiator.h
index 35a96fb2..ec233c92 100644
--- a/shibsp/handler/SessionInitiator.h
+++ b/shibsp/handler/SessionInitiator.h
@@ -88,7 +88,7 @@ namespace shibsp {
std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
- const char* remap(const char* src, xmltooling::logging::Category& log) const;
+ const char* remap(const char* src, Category& log) const;
};
/** Registers SessionInitiator implementations. */
diff --git a/shibsp/handler/impl/AbstractHandler.cpp b/shibsp/handler/impl/AbstractHandler.cpp
index ec982d6b..000854ac 100644
--- a/shibsp/handler/impl/AbstractHandler.cpp
+++ b/shibsp/handler/impl/AbstractHandler.cpp
@@ -119,10 +119,10 @@ const char* Handler::getEventType() const
void Handler::log(SPRequest::SPLogLevel level, const string& msg) const
{
Category::getInstance(SHIBSP_LOGCAT ".Handler").log(
- (level == SPRequest::SPDebug ? Priority::DEBUG :
- (level == SPRequest::SPInfo ? Priority::INFO :
- (level == SPRequest::SPWarn ? Priority::WARN :
- (level == SPRequest::SPError ? Priority::ERROR : Priority::CRIT)))),
+ (level == SPRequest::SPDebug ? Priority::SHIB_DEBUG :
+ (level == SPRequest::SPInfo ? Priority::SHIB_INFO :
+ (level == SPRequest::SPWarn ? Priority::SHIB_WARN :
+ (level == SPRequest::SPError ? Priority::SHIB_ERROR : Priority::SHIB_CRIT)))),
msg
);
}
@@ -392,10 +392,10 @@ AbstractHandler::~AbstractHandler()
void AbstractHandler::log(SPRequest::SPLogLevel level, const string& msg) const
{
m_log.log(
- (level == SPRequest::SPDebug ? Priority::DEBUG :
- (level == SPRequest::SPInfo ? Priority::INFO :
- (level == SPRequest::SPWarn ? Priority::WARN :
- (level == SPRequest::SPError ? Priority::ERROR : Priority::CRIT)))),
+ (level == SPRequest::SPDebug ? Priority::SHIB_DEBUG :
+ (level == SPRequest::SPInfo ? Priority::SHIB_INFO :
+ (level == SPRequest::SPWarn ? Priority::SHIB_WARN :
+ (level == SPRequest::SPError ? Priority::SHIB_ERROR : Priority::SHIB_CRIT)))),
msg
);
}
diff --git a/shibsp/handler/impl/AdminLogoutInitiator.cpp b/shibsp/handler/impl/AdminLogoutInitiator.cpp
index 5a61d8ee..d7f4f0f6 100644
--- a/shibsp/handler/impl/AdminLogoutInitiator.cpp
+++ b/shibsp/handler/impl/AdminLogoutInitiator.cpp
@@ -32,6 +32,8 @@
#include "handler/SecuredHandler.h"
#include "handler/LogoutInitiator.h"
+#include <sstream>
+
using namespace shibsp;
using namespace xmltooling;
using namespace boost;
diff --git a/shibsp/handler/impl/AssertionConsumerService.cpp b/shibsp/handler/impl/AssertionConsumerService.cpp
index db24610d..c45e6249 100644
--- a/shibsp/handler/impl/AssertionConsumerService.cpp
+++ b/shibsp/handler/impl/AssertionConsumerService.cpp
@@ -40,7 +40,6 @@
using namespace shibspconstants;
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace boost;
using namespace std;
@@ -273,7 +272,7 @@ void AssertionConsumerService::checkAddress(const Application& application, cons
if (checkAddress.second) {
m_log.debug("checking client address");
if (httpRequest.getRemoteAddr() != issuedTo) {
- throw FatalProfileException(
+ throw XMLToolingException(
"Your client's current address ($client_addr) differs from the one used when you authenticated "
"to your identity provider. To correct this problem, you may need to bypass a proxy server. "
"Please contact your local support staff or help desk for assistance.",
diff --git a/shibsp/handler/impl/AssertionLookup.cpp b/shibsp/handler/impl/AssertionLookup.cpp
index d3fa43e0..dd0ae923 100644
--- a/shibsp/handler/impl/AssertionLookup.cpp
+++ b/shibsp/handler/impl/AssertionLookup.cpp
@@ -34,15 +34,9 @@
#include "handler/SecuredHandler.h"
#include "util/SPConstants.h"
+#include <sstream>
#include <boost/scoped_ptr.hpp>
-#ifndef SHIBSP_LITE
-# include <saml/exceptions.h>
-# include <saml/Assertion.h>
-# include <xmltooling/util/XMLHelper.h>
-using namespace opensaml;
-#endif
-
using namespace shibspconstants;
using namespace shibsp;
using namespace xmltooling;
diff --git a/shibsp/handler/impl/DiscoveryFeed.cpp b/shibsp/handler/impl/DiscoveryFeed.cpp
index efe66eb5..7f572764 100644
--- a/shibsp/handler/impl/DiscoveryFeed.cpp
+++ b/shibsp/handler/impl/DiscoveryFeed.cpp
@@ -34,23 +34,12 @@
#include <ctime>
#include <fstream>
+#include <sstream>
#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/util/Threads.h>
#include <xmltooling/util/PathResolver.h>
-#ifndef SHIBSP_LITE
-# include <queue>
-# include <saml/exceptions.h>
-# include <saml/SAMLConfig.h>
-# include <saml/saml2/metadata/DiscoverableMetadataProvider.h>
-#endif
-
using namespace shibsp;
-#ifndef SHIBSP_LITE
-using namespace opensaml::saml2md;
-using namespace opensaml;
-using namespace boost;
-#endif
using namespace xmltooling;
using namespace std;
diff --git a/shibsp/handler/impl/MetadataGenerator.cpp b/shibsp/handler/impl/MetadataGenerator.cpp
index 0459d802..27bc7635 100644
--- a/shibsp/handler/impl/MetadataGenerator.cpp
+++ b/shibsp/handler/impl/MetadataGenerator.cpp
@@ -32,39 +32,11 @@
#include "handler/RemotedHandler.h"
#include "handler/SecuredHandler.h"
+#include <sstream>
#include <boost/scoped_ptr.hpp>
#include <boost/iterator/indirect_iterator.hpp>
-#ifndef SHIBSP_LITE
-# include "attribute/resolver/AttributeExtractor.h"
-# include "metadata/MetadataProviderCriteria.h"
-# include <boost/ptr_container/ptr_vector.hpp>
-# include <saml/exceptions.h>
-# include <saml/SAMLConfig.h>
-# include <saml/signature/ContentReference.h>
-# include <saml/saml2/metadata/Metadata.h>
-# include <saml/saml2/metadata/MetadataProvider.h>
-# include <xmltooling/XMLToolingConfig.h>
-# include <xmltooling/encryption/Encryption.h>
-# include <xmltooling/security/Credential.h>
-# include <xmltooling/security/CredentialCriteria.h>
-# include <xmltooling/security/SecurityHelper.h>
-# include <xmltooling/signature/Signature.h>
-# include <xmltooling/util/ParserPool.h>
-# include <xmltooling/util/PathResolver.h>
-# include <xsec/dsig/DSIGConstants.hpp>
-# include <xercesc/framework/LocalFileInputSource.hpp>
-# include <xercesc/framework/Wrapper4InputSource.hpp>
-#endif
-
-
using namespace shibsp;
-#ifndef SHIBSP_LITE
-using namespace opensaml::saml2md;
-using namespace opensaml;
-using namespace xmlsignature;
-using namespace xmlencryption;
-#endif
using namespace xmltooling;
using namespace boost;
using namespace std;
diff --git a/shibsp/handler/impl/RemotedHandler.cpp b/shibsp/handler/impl/RemotedHandler.cpp
index e7ac7714..6c3a2651 100644
--- a/shibsp/handler/impl/RemotedHandler.cpp
+++ b/shibsp/handler/impl/RemotedHandler.cpp
@@ -32,20 +32,12 @@
#include "handler/RemotedHandler.h"
#include <algorithm>
+#include <sstream>
#include <boost/scoped_ptr.hpp>
#include <xmltooling/unicode.h>
#include <xercesc/util/Base64.hpp>
-#ifndef SHIBSP_LITE
-# include "util/CGIParser.h"
-# include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
-# include <xsec/enc/XSECCryptoException.hpp>
-# include <xsec/framework/XSECException.hpp>
-# include <xsec/framework/XSECProvider.hpp>
-#endif
-
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace xercesc;
using namespace boost;
diff --git a/shibsp/handler/impl/SAML2SessionInitiator.cpp b/shibsp/handler/impl/SAML2SessionInitiator.cpp
index a9b94f1a..5d1e206c 100644
--- a/shibsp/handler/impl/SAML2SessionInitiator.cpp
+++ b/shibsp/handler/impl/SAML2SessionInitiator.cpp
@@ -38,7 +38,6 @@
#include <boost/scoped_ptr.hpp>
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace boost;
using namespace std;
diff --git a/shibsp/handler/impl/SAMLDSSessionInitiator.cpp b/shibsp/handler/impl/SAMLDSSessionInitiator.cpp
index 1632a790..7bbfa744 100644
--- a/shibsp/handler/impl/SAMLDSSessionInitiator.cpp
+++ b/shibsp/handler/impl/SAMLDSSessionInitiator.cpp
@@ -35,7 +35,6 @@
#include <xmltooling/util/URLEncoder.h>
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace boost;
using namespace std;
@@ -118,7 +117,7 @@ pair<bool,long> SAMLDSSessionInitiator::run(SPRequest& request, string& entityID
if (isHandler) {
prop.second = request.getParameter("SAMLDS");
if (prop.second && !strcmp(prop.second,"1")) {
- saml2md::MetadataException ex("No identity provider was selected by user.");
+ XMLToolingException ex("No identity provider was selected by user.");
ex.addProperty("statusCode", "urn:oasis:names:tc:SAML:2.0:status:Requester");
ex.addProperty("statusCode2", "urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP");
ex.raise();
diff --git a/shibsp/handler/impl/SessionHandler.cpp b/shibsp/handler/impl/SessionHandler.cpp
index c777ae0b..1c06ec8f 100644
--- a/shibsp/handler/impl/SessionHandler.cpp
+++ b/shibsp/handler/impl/SessionHandler.cpp
@@ -34,6 +34,7 @@
#include "handler/SecuredHandler.h"
#include <ctime>
+#include <sstream>
using namespace shibsp;
using namespace xmltooling;
diff --git a/shibsp/handler/impl/SessionInitiator.cpp b/shibsp/handler/impl/SessionInitiator.cpp
index c79d8a89..97ea7e26 100644
--- a/shibsp/handler/impl/SessionInitiator.cpp
+++ b/shibsp/handler/impl/SessionInitiator.cpp
@@ -33,10 +33,6 @@ using namespace shibsp;
using namespace xmltooling;
using namespace std;
-#ifndef SHIBSP_LITE
-# include <saml/saml2/metadata/Metadata.h>
-using namespace opensaml::saml2md;
-#endif
namespace shibsp {
SHIBSP_DLLLOCAL PluginManager< SessionInitiator,string,pair<const DOMElement*,const char*> >::Factory ChainingSessionInitiatorFactory;
diff --git a/shibsp/handler/impl/StatusHandler.cpp b/shibsp/handler/impl/StatusHandler.cpp
index 9f7cb254..284b395a 100644
--- a/shibsp/handler/impl/StatusHandler.cpp
+++ b/shibsp/handler/impl/StatusHandler.cpp
@@ -33,6 +33,8 @@
#include "handler/SecuredHandler.h"
#include "util/CGIParser.h"
+#include <sstream>
+
#include <boost/iterator/indirect_iterator.hpp>
#include <boost/scoped_ptr.hpp>
#include <xmltooling/version.h>
@@ -43,17 +45,6 @@
#endif
using namespace shibsp;
-#ifndef SHIBSP_LITE
-# include "SessionCache.h"
-# include "metadata/MetadataProviderCriteria.h"
-# include <saml/version.h>
-# include <saml/saml2/metadata/Metadata.h>
-# include <xmltooling/security/Credential.h>
-# include <xmltooling/security/CredentialCriteria.h>
-using namespace opensaml::saml2md;
-using namespace opensaml;
-using namespace xmlsignature;
-#endif
using namespace xmltooling;
using namespace boost;
using namespace std;
diff --git a/shibsp/SPConfig.cpp b/shibsp/impl/AgentConfig.cpp
similarity index 60%
copy from shibsp/SPConfig.cpp
copy to shibsp/impl/AgentConfig.cpp
index ec95c48b..b0cb2737 100644
--- a/shibsp/SPConfig.cpp
+++ b/shibsp/impl/AgentConfig.cpp
@@ -1,145 +1,83 @@
/**
- * 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.
+ * 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
*
- * 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
*
- * 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.
+ * 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.
*/
/**
- * SPConfig.cpp
+ * AgentConfig.cpp
*
- * Library configuration.
+ * Library/agent configuration.
*/
#include "internal.h"
-#if defined(XMLTOOLING_LOG4SHIB)
-# ifndef SHIBSP_LOG4SHIB
-# error "Logging library mismatch (XMLTooling is using log4shib)."
-# endif
-#elif defined(XMLTOOLING_LOG4CPP)
-# ifndef SHIBSP_LOG4CPP
-# error "Logging library mismatch (XMLTooling is using log4cpp)."
-# endif
-#else
-# error "No supported logging library."
-#endif
-
#include "exceptions.h"
#include "version.h"
-#include "AccessControl.h"
-#include "RequestMapper.h"
-#include "ServiceProvider.h"
-#include "SessionCache.h"
-#include "SPConfig.h"
-#include "attribute/Attribute.h"
-#include "handler/LogoutInitiator.h"
-#include "handler/SessionInitiator.h"
-#include "remoting/ListenerService.h"
+#include "AgentConfig.h"
+#include "logging/Category.h"
#include <ctime>
-#include <xercesc/util/XMLUniDefs.hpp>
-#include <xmltooling/version.h>
-#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/util/NDC.h>
-#include <xmltooling/util/ParserPool.h>
-#include <xmltooling/util/PathResolver.h>
-#include <xmltooling/util/TemplateEngine.h>
-#include <xmltooling/util/Threads.h>
-#include <xmltooling/util/XMLHelper.h>
+#include <thread>
+#include <boost/property_tree/ptree.hpp>
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
+using namespace boost::property_tree;
using namespace boost;
using namespace std;
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeExtractionException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeFilteringException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeResolutionException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
-
-#ifdef SHIBSP_LITE
-DECL_XMLTOOLING_EXCEPTION_FACTORY(BindingException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(SecurityPolicyException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(ProfileException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(FatalProfileException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(RetryableProfileException,opensaml);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(MetadataException,opensaml::saml2md);
-#endif
-
namespace shibsp {
- class SHIBSP_DLLLOCAL SPInternalConfig : public SPConfig
+ class SHIBSP_DLLLOCAL AgentInternalConfig : public AgentConfig
{
public:
- SPInternalConfig() : m_initCount(0), m_lock(Mutex::create()) {}
- ~SPInternalConfig() {}
+ AgentInternalConfig() : m_initCount(0) {}
+ ~AgentInternalConfig() {}
- bool init(const char* catalog_path=nullptr, const char* inst_prefix=nullptr);
+ bool init(const char* inst_prefix=nullptr, const char* config_file=nullptr, bool rethrow=false);
void term();
+ Agent& getAgent() const;
+ LoggingService& getLoggingService() const;
+
private:
- int m_initCount;
- scoped_ptr<Mutex> m_lock;
+ unsigned int m_initCount;
+ mutex m_lock;
+ unique_ptr<Agent> m_agent;
+ unique_ptr<ptree> m_config;
};
- SPInternalConfig g_config;
+ AgentInternalConfig g_config;
}
-SPConfig& SPConfig::getConfig()
+AgentConfig& AgentConfig::getConfig()
{
return g_config;
}
-SPConfig::SPConfig() : attribute_value_delimeter(';'), m_serviceProvider(nullptr), m_features(0), m_configDoc(nullptr)
-{
-}
-
-SPConfig::~SPConfig()
+AgentConfig::AgentConfig()
{
}
-void SPConfig::setFeatures(unsigned long enabled)
+AgentConfig::~AgentConfig()
{
- m_features = enabled;
}
-unsigned long SPConfig::getFeatures() const {
- return m_features;
-}
-
-bool SPConfig::isEnabled(components_t feature) const
+Agent& AgentInternalConfig::getAgent() const
{
- return (m_features & feature)>0;
+ return *m_agent;
}
-ServiceProvider* SPConfig::getServiceProvider() const
-{
- return m_serviceProvider;
-}
-
-void SPConfig::setServiceProvider(ServiceProvider* serviceProvider)
-{
- delete m_serviceProvider;
- m_serviceProvider = serviceProvider;
-}
-
-bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
+/*
+bool AgentConfig::init(const char* inst_prefix, const char* config_file, bool rethrow)
{
if (!inst_prefix)
inst_prefix = getenv("SHIBSP_PREFIX");
@@ -211,21 +149,9 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeExtractionException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeFilteringException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeResolutionException,shibsp);
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
-#ifdef SHIBSP_LITE
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(BindingException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(SecurityPolicyException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ProfileException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(FatalProfileException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(RetryableProfileException,opensaml);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(MetadataException,opensaml::saml2md);
-#endif
-
registerAttributeFactories();
if (isEnabled(Handlers)) {
@@ -255,7 +181,7 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
return true;
}
-void SPConfig::term()
+void AgentConfig::term()
{
Category& log=Category::getInstance(SHIBSP_LOGCAT ".Config");
log.info("%s library shutting down", PACKAGE_STRING);
@@ -345,22 +271,25 @@ bool SPConfig::instantiate(const char* config, bool rethrow)
}
return false;
}
+*/
-bool SPInternalConfig::init(const char* catalog_path, const char* inst_prefix)
+bool AgentInternalConfig::init(const char* inst_prefix, const char* config_file, bool rethrow)
{
- Lock initLock(m_lock);
+ lock_guard<mutex> locker(m_lock);
if (m_initCount == INT_MAX) {
- Category::getInstance(SHIBSP_LOGCAT ".Config").crit("library initialized too many times");
+ if (rethrow) {
+ throw runtime_error("Library initialized too many times.");
+ }
return false;
}
- if (m_initCount >= 1) {
+ if (m_initCount > 0) {
++m_initCount;
return true;
}
- if (!SPConfig::init(catalog_path, inst_prefix)) {
+ if (!AgentConfig::init(inst_prefix, config_file, rethrow)) {
return false;
}
@@ -368,21 +297,22 @@ bool SPInternalConfig::init(const char* catalog_path, const char* inst_prefix)
return true;
}
-void SPInternalConfig::term()
+void AgentInternalConfig::term()
{
- Lock initLock(m_lock);
+ lock_guard<mutex> locker(m_lock);
+
if (m_initCount == 0) {
- Category::getInstance(SHIBSP_LOGCAT ".Config").crit("term without corresponding init");
+ throw runtime_error("Library terminated without initialization.");
return;
}
else if (--m_initCount > 0) {
return;
}
- SPConfig::term();
+ AgentConfig::term();
}
-Category& SPConfig::deprecation() const
+shibsp::Category& AgentConfig::deprecation() const
{
return Category::getInstance(SHIBSP_LOGCAT".DEPRECATION");
}
diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp
index aa0b75f1..dc5fa796 100644
--- a/shibsp/impl/StorageServiceSessionCache.cpp
+++ b/shibsp/impl/StorageServiceSessionCache.cpp
@@ -60,7 +60,6 @@
#include <xercesc/util/XMLDateTime.hpp>
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace boost;
using namespace std;
diff --git a/shibsp/impl/StorageServiceSessionCache.h b/shibsp/impl/StorageServiceSessionCache.h
index d4470183..d67915f1 100644
--- a/shibsp/impl/StorageServiceSessionCache.h
+++ b/shibsp/impl/StorageServiceSessionCache.h
@@ -183,7 +183,7 @@ namespace shibsp {
#endif
bool recover(const Application& app, const char* key, const char* data);
- xmltooling::logging::Category& m_log;
+ Category& m_log;
bool inproc;
bool shutdown;
boost::scoped_ptr<xmltooling::CondWait> shutdown_wait;
diff --git a/shibsp/impl/StoredSession.cpp b/shibsp/impl/StoredSession.cpp
index 8c1f3f26..eab517f3 100644
--- a/shibsp/impl/StoredSession.cpp
+++ b/shibsp/impl/StoredSession.cpp
@@ -47,7 +47,6 @@ using namespace opensaml::saml2md;
#endif
using namespace shibsp;
-using namespace opensaml;
using namespace xmltooling;
using namespace boost;
using namespace std;
@@ -178,7 +177,7 @@ void StoredSession::validate(const Application& app, const char* client_addr, ti
if (m_expires > 0) {
if (now > m_expires) {
m_cache->m_log.info("session expired (ID: %s)", getID());
- throw RetryableProfileException("Your session has expired, and you must re-authenticate.");
+ throw XMLToolingException("Your session has expired, and you must re-authenticate.");
}
}
@@ -188,7 +187,7 @@ void StoredSession::validate(const Application& app, const char* client_addr, ti
if (saddr && *saddr) {
if (!m_cache->compareAddresses(client_addr, saddr)) {
m_cache->m_log.warn("client address mismatch, client (%s), session (%s)", client_addr, saddr);
- throw RetryableProfileException(
+ throw XMLToolingException(
"Your IP address ($1) does not match the address recorded at the time the session was established.",
params(1, client_addr)
);
diff --git a/shibsp/impl/XMLAccessControl.cpp b/shibsp/impl/XMLAccessControl.cpp
index 687487d3..aea0b0ba 100644
--- a/shibsp/impl/XMLAccessControl.cpp
+++ b/shibsp/impl/XMLAccessControl.cpp
@@ -111,10 +111,12 @@ namespace shibsp {
class XMLAccessControl : public AccessControl, public ReloadableXMLFile
{
public:
+ XMLAccessControl(const DOMElement* e, bool deprecationSupport=true);
+ /*
XMLAccessControl(const DOMElement* e, bool deprecationSupport=true)
: ReloadableXMLFile(e, Category::getInstance(SHIBSP_LOGCAT ".AccessControl.XML"), true, deprecationSupport) {
background_load(); // guarantees an exception or the policy is loaded
- }
+ }*/
~XMLAccessControl() {
shutdown();
diff --git a/shibsp/impl/XMLApplication.cpp b/shibsp/impl/XMLApplication.cpp
index faeca43b..57527e33 100644
--- a/shibsp/impl/XMLApplication.cpp
+++ b/shibsp/impl/XMLApplication.cpp
@@ -937,6 +937,6 @@ void XMLApplication::limitRedirect(const GenericRequest& request, const char* ur
}
Category::getInstance(SHIBSP_LOGCAT ".Application").warn("redirectLimit policy enforced, blocked redirect to (%s)", url);
- throw opensaml::SecurityPolicyException("Blocked unacceptable redirect location.");
+ throw XMLToolingException("Blocked unacceptable redirect location.");
}
}
diff --git a/shibsp/impl/XMLApplication.h b/shibsp/impl/XMLApplication.h
index d1bfe829..a12c80f6 100644
--- a/shibsp/impl/XMLApplication.h
+++ b/shibsp/impl/XMLApplication.h
@@ -33,9 +33,7 @@
#include "handler/Handler.h"
#include "remoting/ListenerService.h"
#include "util/DOMPropertySet.h"
-
-#include <xmltooling/logging.h>
-#include <xmltooling/PluginManager.h>
+#include "util/PluginManager.h"
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
@@ -106,20 +104,20 @@ namespace shibsp {
private:
template <class T> T* doChainedPlugins(
- const xmltooling::PluginManager<T, std::string, const xercesc::DOMElement*>& pluginMgr,
+ const PluginManager<T, std::string, const xercesc::DOMElement*>& pluginMgr,
const char* pluginType,
const char* chainingType,
const XMLCh* localName,
xercesc::DOMElement* e,
- xmltooling::logging::Category& log,
+ Category& log,
const char* dummyType = nullptr
);
- void doAttributeInfo(xmltooling::logging::Category&);
- void doHandlers(const xercesc::DOMElement*, xmltooling::logging::Category&);
- void doSSO(std::set<std::string>&, xercesc::DOMElement*, xmltooling::logging::Category&);
- void doLogout(std::set<std::string>&, xercesc::DOMElement*, xmltooling::logging::Category&);
- void doNameIDMgmt(std::set<std::string>&, xercesc::DOMElement*, xmltooling::logging::Category&);
- void doArtifactResolution(const char*, xercesc::DOMElement*, xmltooling::logging::Category&);
+ 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;
diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index e79713c2..a5d8a949 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -122,10 +122,11 @@ namespace shibsp {
class XMLRequestMapper : public RequestMapper, public ReloadableXMLFile
{
public:
- XMLRequestMapper(const DOMElement* e, bool deprecationSupport=true)
+ XMLRequestMapper(const DOMElement* e, bool deprecationSupport=true);
+/* XMLRequestMapper(const DOMElement* e, bool deprecationSupport=true)
: ReloadableXMLFile(e, Category::getInstance(SHIBSP_LOGCAT ".RequestMapper"), true, deprecationSupport) {
background_load();
- }
+ }*/
~XMLRequestMapper() {
shutdown();
@@ -691,7 +692,8 @@ pair<bool,DOMElement*> XMLRequestMapper::background_load()
// If we own it, wrap it.
XercesJanitor<DOMDocument> docjanitor(raw.first ? raw.second->getOwnerDocument() : nullptr);
- scoped_ptr<XMLRequestMapperImpl> impl(new XMLRequestMapperImpl(raw.second, m_log));
+ //scoped_ptr<XMLRequestMapperImpl> impl(new XMLRequestMapperImpl(raw.second, m_log));
+ scoped_ptr<XMLRequestMapperImpl> 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());
diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp
index 5342737c..87438f5f 100644
--- a/shibsp/impl/XMLServiceProvider.cpp
+++ b/shibsp/impl/XMLServiceProvider.cpp
@@ -34,19 +34,11 @@
#include "impl/XMLServiceProvider.h"
#include "util/SPConstants.h"
-#if defined(XMLTOOLING_LOG4SHIB)
-# include <log4shib/PropertyConfigurator.hh>
-#elif defined(XMLTOOLING_LOG4CPP)
-# include <log4cpp/PropertyConfigurator.hh>
-#else
-# error "Supported logging library not available."
-#endif
#include <fstream>
#include <boost/algorithm/string.hpp>
#include <boost/tuple/tuple.hpp>
#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/version.h>
-#include <xmltooling/util/NDC.h>
#include <xmltooling/util/ParserPool.h>
#include <xmltooling/util/PathResolver.h>
#include <xmltooling/util/TemplateEngine.h>
@@ -149,7 +141,7 @@ void XMLConfigImpl::doExtensions(const DOMElement* e, const char* label, Categor
}
catch (const std::exception& e) {
if (XMLHelper::getAttrBool(exts, false, _fatal)) {
- log.fatal("unable to load mandatory %s extension library %s: %s", label, path.c_str(), e.what());
+ log.crit("unable to load mandatory %s extension library %s: %s", label, path.c_str(), e.what());
throw;
}
else {
@@ -326,7 +318,7 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, XMLConfig* outer,
// Load the default application.
child = XMLHelper::getLastChildElement(e, ApplicationDefaults);
if (!child) {
- log.fatal("can't build default Application object, missing conf:ApplicationDefaults element?");
+ 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));
@@ -675,7 +667,8 @@ pair<bool,DOMElement*> XMLConfig::background_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(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());
diff --git a/shibsp/impl/XMLServiceProvider.h b/shibsp/impl/XMLServiceProvider.h
index 0d56ef30..1d2c27e0 100644
--- a/shibsp/impl/XMLServiceProvider.h
+++ b/shibsp/impl/XMLServiceProvider.h
@@ -32,9 +32,8 @@
#include "ServiceProvider.h"
#include "remoting/ListenerService.h"
#include "util/DOMPropertySet.h"
+#include "util/PluginManager.h"
-#include <xmltooling/logging.h>
-#include <xmltooling/PluginManager.h>
#include <xmltooling/util/ReloadableXMLFile.h>
#include <boost/scoped_ptr.hpp>
@@ -57,7 +56,7 @@ namespace shibsp {
class SHIBSP_DLLLOCAL XMLConfigImpl : public DOMPropertySet, public xercesc::DOMNodeFilter
{
public:
- XMLConfigImpl(const xercesc::DOMElement* e, bool first, XMLConfig* outer, xmltooling::logging::Category& log);
+ XMLConfigImpl(const xercesc::DOMElement* e, bool first, XMLConfig* outer, Category& log);
~XMLConfigImpl() {
if (m_document)
m_document->release();
@@ -79,9 +78,9 @@ namespace shibsp {
}
private:
- void doExtensions(const xercesc::DOMElement*, const char*, xmltooling::logging::Category&);
- void doListener(const xercesc::DOMElement*, XMLConfig*, xmltooling::logging::Category&);
- void doCaching(const xercesc::DOMElement*, XMLConfig*, xmltooling::logging::Category&);
+ void doExtensions(const xercesc::DOMElement*, const char*, Category&);
+ void doListener(const xercesc::DOMElement*, XMLConfig*, Category&);
+ void doCaching(const xercesc::DOMElement*, XMLConfig*, Category&);
xercesc::DOMDocument* m_document;
const XMLApplication* m_defaultApplication;
diff --git a/shibsp/internal.h b/shibsp/internal.h
index 092332bd..409ae509 100644
--- a/shibsp/internal.h
+++ b/shibsp/internal.h
@@ -1,21 +1,15 @@
/**
- * 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.
+ * 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
*
- * 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
*
- * 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.
+ * 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.
*/
/*
@@ -47,14 +41,14 @@
#endif
#include "base.h"
+#include "AgentConfig.h"
#include "SPConfig.h"
+#include "logging/Category.h"
#include <memory>
-#include <xmltooling/logging.h>
#include <xmltooling/io/HTTPRequest.h>
#include <shibsp/Application.h>
-using namespace xmltooling::logging;
using namespace xercesc;
#endif /* __shibsp_internal_h__ */
diff --git a/shibsp/remoting/impl/SocketListener.h b/shibsp/remoting/impl/SocketListener.h
index 4a183e68..12809859 100644
--- a/shibsp/remoting/impl/SocketListener.h
+++ b/shibsp/remoting/impl/SocketListener.h
@@ -35,7 +35,6 @@
#include <boost/scoped_ptr.hpp>
#include <xercesc/dom/DOM.hpp>
-#include <xmltooling/logging.h>
#include <xmltooling/util/Threads.h>
#ifdef WIN32
@@ -81,7 +80,7 @@ namespace shibsp {
protected:
void set_retry_errors(const std::string& retry_errors);
bool log_error(const char* fn=nullptr, int* native_error=nullptr) const; // for OS-level errors
- xmltooling::logging::Category* log;
+ Category* log;
/// @endcond
private:
diff --git a/shibsp/util/DOMPropertySet.cpp b/shibsp/util/DOMPropertySet.cpp
index 08e376bc..789dbc0a 100644
--- a/shibsp/util/DOMPropertySet.cpp
+++ b/shibsp/util/DOMPropertySet.cpp
@@ -57,7 +57,7 @@ DOMPropertySet::STLRemapper::~STLRemapper()
{
}
-const char* DOMPropertySet::STLRemapper::remap(const char* src, xmltooling::logging::Category& log) const
+const char* DOMPropertySet::STLRemapper::remap(const char* src, Category& log) const
{
map<string,string>::const_iterator i = src ? m_rules.find(src) : m_rules.end();
if (i != m_rules.end()) {
diff --git a/shibsp/util/DOMPropertySet.h b/shibsp/util/DOMPropertySet.h
index c857cccf..37882da1 100644
--- a/shibsp/util/DOMPropertySet.h
+++ b/shibsp/util/DOMPropertySet.h
@@ -29,8 +29,8 @@
#include <shibsp/util/PropertySet.h>
+#include <set>
#include <boost/shared_ptr.hpp>
-#include <xmltooling/logging.h>
namespace xmltooling {
class QName;
@@ -77,7 +77,7 @@ namespace shibsp {
*
* @return the name to use
*/
- virtual const char* remap(const char* src, xmltooling::logging::Category& log) const=0;
+ virtual const char* remap(const char* src, Category& log) const=0;
};
/**
@@ -93,7 +93,7 @@ namespace shibsp {
STLRemapper(const std::map<std::string,std::string>& rules);
virtual ~STLRemapper();
- const char* remap(const char* src, xmltooling::logging::Category& log) const;
+ const char* remap(const char* src, Category& log) const;
private:
const std::map<std::string, std::string>& m_rules;
@@ -110,7 +110,7 @@ namespace shibsp {
*/
void load(
const xercesc::DOMElement* e,
- xmltooling::logging::Category* log=nullptr,
+ Category* log=nullptr,
xercesc::DOMNodeFilter* filter=nullptr,
const Remapper* remapper=nullptr,
const xmltooling::QName* unsetter=nullptr
diff --git a/shibsp/util/PluginManager.h b/shibsp/util/PluginManager.h
new file mode 100644
index 00000000..dfef762c
--- /dev/null
+++ b/shibsp/util/PluginManager.h
@@ -0,0 +1,108 @@
+/**
+ * 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/util/PluginManager.h
+ *
+ * Plugin management template.
+ */
+
+#ifndef __shibsp_plugin_h__
+#define __shibsp_plugin_h__
+
+#include <shibsp/base.h>
+
+#include <exception>
+#include <map>
+#include <string>
+
+#if defined (_MSC_VER)
+ #pragma warning( push )
+ #pragma warning( disable : 4250 4251 )
+#endif
+
+namespace shibsp {
+
+ /**
+ * Template for management/access to plugins constructed based on a Key type
+ * and arbitrary parameters.
+ *
+ * @param T class of plugin to manage
+ * @param Key the key for type lookup
+ * @param Params parameters for plugin construction
+ */
+ template <class T, class Key, typename Params> class PluginManager
+ {
+ public:
+ PluginManager() {}
+ ~PluginManager() {}
+
+ /** Factory function for plugin. */
+ typedef T* Factory(const Params&, bool deprecationSupport);
+
+ /**
+ * Registers the factory for a given type.
+ *
+ * @param type the key to the plugin type
+ * @param factory the factory function for the plugin type
+ */
+ void registerFactory(const Key& type, typename PluginManager::Factory* factory) {
+ if (factory)
+ m_map[type]=factory;
+ }
+
+ /**
+ * Unregisters the factory for a given type.
+ *
+ * @param type the key to the plugin type
+ */
+ void deregisterFactory(const Key& type) {
+ m_map.erase(type);
+ }
+
+ /**
+ * Unregisters all registered factories.
+ */
+ void deregisterFactories() {
+ m_map.clear();
+ }
+
+ /**
+ * Builds a new instance of a plugin of a given type, configuring it
+ * with the supplied parameters.
+ *
+ * @param type the key to the plugin type
+ * @param p parameters to configure plugin
+ * @param deprecationSupport true iff the plugin should recognize/support its deprecated features
+ *
+ * @return the constructed plugin
+ */
+ T* newPlugin(const Key& type, const Params& p, bool deprecationSupport) const {
+ typename std::map<Key, typename PluginManager::Factory*>::const_iterator i=m_map.find(type);
+ if (i==m_map.end())
+ throw std::invalid_argument("Unknown plugin type.");
+ return i->second(p, deprecationSupport);
+ }
+
+ private:
+ std::map<Key, typename PluginManager::Factory*> m_map;
+ };
+
+};
+
+#if defined (_MSC_VER)
+ #pragma warning( pop )
+#endif
+
+#endif /* __shibsp_plugin_h__ */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list