[shibboleth-sp2] 41/89: SSPCPP-688 - Error handling should have access to the message type.
Ferenc Wágner
wferi at moszumanska.debian.org
Thu Sep 1 09:24:07 UTC 2016
This is an automated email from the git hooks/post-receive script.
wferi pushed a commit to branch master
in repository shibboleth-sp2.
commit cca2ce814d7aee7b9bf90a7c68dbd8d85baef709
Author: Scott Cantor <cantor.2 at osu.edu>
Date: Thu Jun 2 14:00:32 2016 -0400
SSPCPP-688 - Error handling should have access to the message type.
https://issues.shibboleth.net/jira/browse/SSPCPP-688
---
shibsp/ServiceProvider.cpp | 19 ++++++++++++-------
shibsp/TransactionLog.h | 23 +++++++++++++++--------
shibsp/handler/AssertionConsumerService.h | 3 ++-
shibsp/handler/Handler.h | 7 +++++++
shibsp/handler/LogoutHandler.h | 2 ++
shibsp/handler/SessionInitiator.h | 1 +
shibsp/handler/impl/AbstractHandler.cpp | 5 +++++
shibsp/handler/impl/AssertionConsumerService.cpp | 6 ++++++
shibsp/handler/impl/LogoutHandler.cpp | 4 ++++
shibsp/handler/impl/SAML2NameIDMgmt.cpp | 5 +++++
shibsp/handler/impl/SessionInitiator.cpp | 5 +++++
11 files changed, 64 insertions(+), 16 deletions(-)
diff --git a/shibsp/ServiceProvider.cpp b/shibsp/ServiceProvider.cpp
index 3d38c4f..e7f0b0e 100644
--- a/shibsp/ServiceProvider.cpp
+++ b/shibsp/ServiceProvider.cpp
@@ -668,13 +668,18 @@ pair<bool,long> ServiceProvider::doHandler(SPRequest& request) const
if (!handler)
throw ConfigurationException("Shibboleth handler invoked at an unconfigured location.");
- pair<bool,long> hret = handler->run(request);
-
- // Did the handler run successfully?
- if (hret.first)
- return hret;
-
- throw ConfigurationException("Configured Shibboleth handler failed to process the request.");
+ try {
+ pair<bool, long> hret = handler->run(request);
+ // Did the handler run successfully?
+ if (hret.first)
+ return hret;
+ throw ConfigurationException("Configured Shibboleth handler failed to process the request.");
+ }
+ catch (XMLToolingException& ex) {
+ if (!ex.getProperty("eventType") && handler->getEventType())
+ ex.addProperty("eventType", handler->getEventType());
+ throw;
+ }
}
catch (exception& e) {
request.log(SPRequest::SPError, e.what());
diff --git a/shibsp/TransactionLog.h b/shibsp/TransactionLog.h
index 1f738de..c4a8fbc 100644
--- a/shibsp/TransactionLog.h
+++ b/shibsp/TransactionLog.h
@@ -24,9 +24,11 @@
* Formatted event record logging.
*/
-#if !defined (__shibsp_txlog_h__) && !defined(SHIBSP_LITE)
+#if !defined (__shibsp_txlog_h__)
#define __shibsp_txlog_h__
+#ifndef SHIBSP_LITE
+
#include <shibsp/base.h>
#include <xmltooling/logging.h>
#include <xmltooling/Lockable.h>
@@ -257,15 +259,20 @@ namespace shibsp {
* Registers Event classes into the runtime.
*/
void SHIBSP_API registerEvents();
+};
- /** Login event. */
- #define LOGIN_EVENT "Login"
+#endif
- /** Logout event. */
- #define LOGOUT_EVENT "Logout"
+/** Login event. */
+#define LOGIN_EVENT "Login"
- /** AuthnRequest event. */
- #define AUTHNREQUEST_EVENT "AuthnRequest"
-};
+/** Logout event. */
+#define LOGOUT_EVENT "Logout"
+
+/** AuthnRequest event. */
+#define AUTHNREQUEST_EVENT "AuthnRequest"
+
+/** NameIDMgmt event. */
+#define NAMEIDMGMT_EVENT "NameIDMgmt"
#endif /* __shibsp_txlog_h__ */
diff --git a/shibsp/handler/AssertionConsumerService.h b/shibsp/handler/AssertionConsumerService.h
index 45e8309..a775f91 100644
--- a/shibsp/handler/AssertionConsumerService.h
+++ b/shibsp/handler/AssertionConsumerService.h
@@ -234,7 +234,7 @@ namespace shibsp {
) const;
/**
- * Creates a new AuthnRequestEvent for the event log.
+ * Creates a new LoginEvent for the event log.
*
* @param application the Application associated with the event
* @param request the HTTP client request associated with the event
@@ -246,6 +246,7 @@ namespace shibsp {
const char* getType() const;
const XMLCh* getProtocolFamily() const;
#endif
+ const char* getEventType() const;
private:
std::pair<bool,long> processMessage(
const Application& application, const xmltooling::HTTPRequest& httpRequest, xmltooling::HTTPResponse& httpResponse
diff --git a/shibsp/handler/Handler.h b/shibsp/handler/Handler.h
index 3a9a325..b582506 100644
--- a/shibsp/handler/Handler.h
+++ b/shibsp/handler/Handler.h
@@ -152,6 +152,13 @@ namespace shibsp {
*/
virtual const char* getType() const;
#endif
+
+ /**
+ * Get the type of event, as input to error handling in response to errors raised by this handler.
+ *
+ * @return an event type for error handling
+ */
+ virtual const char* getEventType() const;
};
/** Registers Handler implementations. */
diff --git a/shibsp/handler/LogoutHandler.h b/shibsp/handler/LogoutHandler.h
index 02a4862..a0db1c7 100644
--- a/shibsp/handler/LogoutHandler.h
+++ b/shibsp/handler/LogoutHandler.h
@@ -75,6 +75,8 @@ namespace shibsp {
*/
void receive(DDF& in, std::ostream& out);
+ const char* getEventType() const;
+
protected:
LogoutHandler();
diff --git a/shibsp/handler/SessionInitiator.h b/shibsp/handler/SessionInitiator.h
index 046d0be..c4e8c05 100644
--- a/shibsp/handler/SessionInitiator.h
+++ b/shibsp/handler/SessionInitiator.h
@@ -118,6 +118,7 @@ namespace shibsp {
*/
void doGenerateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const;
#endif
+ const char* getEventType() const;
};
/** Registers SessionInitiator implementations. */
diff --git a/shibsp/handler/impl/AbstractHandler.cpp b/shibsp/handler/impl/AbstractHandler.cpp
index f364221..ecbd753 100644
--- a/shibsp/handler/impl/AbstractHandler.cpp
+++ b/shibsp/handler/impl/AbstractHandler.cpp
@@ -166,6 +166,11 @@ const XMLCh* Handler::getProtocolFamily() const
return nullptr;
}
+const char* Handler::getEventType() const
+{
+ return nullptr;
+}
+
void Handler::log(SPRequest::SPLogLevel level, const string& msg) const
{
Category::getInstance(SHIBSP_LOGCAT ".Handler").log(
diff --git a/shibsp/handler/impl/AssertionConsumerService.cpp b/shibsp/handler/impl/AssertionConsumerService.cpp
index 881e887..6e18f90 100644
--- a/shibsp/handler/impl/AssertionConsumerService.cpp
+++ b/shibsp/handler/impl/AssertionConsumerService.cpp
@@ -29,6 +29,7 @@
#include "Application.h"
#include "ServiceProvider.h"
#include "SPRequest.h"
+#include "TransactionLog.h"
#include "handler/AssertionConsumerService.h"
#include "util/CGIParser.h"
#include "util/SPConstants.h"
@@ -338,6 +339,11 @@ void AssertionConsumerService::checkAddress(const Application& application, cons
}
}
+const char* AssertionConsumerService::getEventType() const
+{
+ return LOGIN_EVENT;
+}
+
#ifndef SHIBSP_LITE
const XMLCh* AssertionConsumerService::getProtocolFamily() const
diff --git a/shibsp/handler/impl/LogoutHandler.cpp b/shibsp/handler/impl/LogoutHandler.cpp
index ae989ef..81946ad 100644
--- a/shibsp/handler/impl/LogoutHandler.cpp
+++ b/shibsp/handler/impl/LogoutHandler.cpp
@@ -53,6 +53,10 @@ LogoutHandler::~LogoutHandler()
{
}
+const char* LogoutHandler::getEventType() const {
+ return LOGOUT_EVENT;
+}
+
pair<bool,long> LogoutHandler::sendLogoutPage(
const Application& application, const HTTPRequest& request, HTTPResponse& response, bool local, const char* status
) const
diff --git a/shibsp/handler/impl/SAML2NameIDMgmt.cpp b/shibsp/handler/impl/SAML2NameIDMgmt.cpp
index 933e493..273c2cd 100644
--- a/shibsp/handler/impl/SAML2NameIDMgmt.cpp
+++ b/shibsp/handler/impl/SAML2NameIDMgmt.cpp
@@ -29,6 +29,7 @@
#include "Application.h"
#include "ServiceProvider.h"
#include "SPRequest.h"
+#include "TransactionLog.h"
#include "handler/AbstractHandler.h"
#include "handler/RemotedHandler.h"
#include "util/SPConstants.h"
@@ -101,6 +102,10 @@ namespace shibsp {
return samlconstants::SAML20P_NS;
}
+ const char* getEventType() const {
+ return NAMEIDMGMT_EVENT;
+ }
+
private:
pair<bool,long> doRequest(const Application& application, const HTTPRequest& httpRequest, HTTPResponse& httpResponse) const;
diff --git a/shibsp/handler/impl/SessionInitiator.cpp b/shibsp/handler/impl/SessionInitiator.cpp
index 3110ec7..f5280c8 100644
--- a/shibsp/handler/impl/SessionInitiator.cpp
+++ b/shibsp/handler/impl/SessionInitiator.cpp
@@ -27,6 +27,7 @@
#include "internal.h"
#include "exceptions.h"
#include "SPRequest.h"
+#include "TransactionLog.h"
#include "handler/SessionInitiator.h"
using namespace shibsp;
@@ -74,6 +75,10 @@ SessionInitiator::~SessionInitiator()
{
}
+const char* SessionInitiator::getEventType() const {
+ return LOGIN_EVENT;
+}
+
#ifndef SHIBSP_LITE
const char* SessionInitiator::getType() const
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git
More information about the Pkg-shibboleth-devel
mailing list