[cpp-sp] branch main updated: Start migration of error handling code.
Scott Cantor
cantor.2 at osu.edu
Mon Jan 6 13:29:52 UTC 2025
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=18c5e86cc4fe2066a7b508c65d96af7d02f9da84
The following commit(s) were added to refs/heads/main by this push:
new 18c5e86c Start migration of error handling code.
18c5e86c is described below
commit 18c5e86cc4fe2066a7b508c65d96af7d02f9da84
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Jan 6 08:29:48 2025 -0500
Start migration of error handling code.
---
apache/mod_shib_24.cpp | 6 +-
fastcgi/shibauthorizer.cpp | 8 +-
fastcgi/shibresponder.cpp | 10 +-
iis7_shib/IIS7Request.cpp | 12 +-
iis7_shib/ShibHttpModule.cpp | 2 +-
shibsp/AbstractSPRequest.cpp | 36 +++---
shibsp/AbstractSPRequest.h | 11 +-
shibsp/Application.h | 5 +-
shibsp/Makefile.am | 4 +-
shibsp/SPConfig.cpp | 14 ---
shibsp/SPRequest.h | 12 ++
shibsp/ServiceProvider.cpp | 146 ++++++------------------
shibsp/ServiceProvider.h | 5 -
shibsp/attribute/Attribute.cpp | 8 +-
shibsp/exceptions.h | 143 +++++++++++++++++++----
shibsp/handler/impl/AbstractHandler.cpp | 23 ++--
shibsp/handler/impl/AdminLogoutInitiator.cpp | 6 +-
shibsp/handler/impl/AssertionLookup.cpp | 2 +-
shibsp/handler/impl/AttributeCheckerHandler.cpp | 6 +-
shibsp/handler/impl/DiscoveryFeed.cpp | 6 +-
shibsp/handler/impl/LogoutHandler.cpp | 15 +--
shibsp/handler/impl/MetadataGenerator.cpp | 3 +-
shibsp/handler/impl/SecuredHandler.cpp | 3 +-
shibsp/handler/impl/StatusHandler.cpp | 15 ++-
shibsp/impl/AgentConfig.cpp | 1 -
shibsp/impl/XMLApplication.cpp | 9 +-
shibsp/impl/XMLServiceProvider.cpp | 2 +-
shibsp/io/HTTPResponse.h | 18 +--
shibsp/io/impl/HTTPResponse.cpp | 6 +-
shibsp/remoting/ddf.h | 24 ++--
shibsp/remoting/impl/ddf.cpp | 28 ++---
31 files changed, 283 insertions(+), 306 deletions(-)
diff --git a/apache/mod_shib_24.cpp b/apache/mod_shib_24.cpp
index 88afc53f..8edfe411 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 XMLToolingException("Attempt to spoof header ($1) was detected.", params(1, rawname));
+ throw SessionException(string("Attempt to spoof header ") + rawname + " was detected.");
}
apr_table_unset(m_req->headers_in, rawname);
apr_table_set(m_req->headers_in, rawname, g_unsetHeaderValue.c_str());
@@ -573,14 +573,14 @@ public:
}
}
long sendResponse(istream& in, long status) {
- if (status != XMLTOOLING_HTTP_STATUS_OK)
+ if (status != SHIBSP_HTTP_STATUS_OK)
m_req->status = status;
char buf[1024];
while (in) {
in.read(buf,1024);
ap_rwrite(buf,in.gcount(),m_req);
}
- if (status != XMLTOOLING_HTTP_STATUS_OK && status != XMLTOOLING_HTTP_STATUS_ERROR)
+ if (status != SHIBSP_HTTP_STATUS_OK && status != SHIBSP_HTTP_STATUS_ERROR)
return status;
return DONE;
}
diff --git a/fastcgi/shibauthorizer.cpp b/fastcgi/shibauthorizer.cpp
index 8d2b3853..3c0b6c13 100644
--- a/fastcgi/shibauthorizer.cpp
+++ b/fastcgi/shibauthorizer.cpp
@@ -221,10 +221,10 @@ public:
// so custom Shib errors will get turned into a generic page.
const char* codestr="Status: 500 Server Error";
switch (status) {
- case XMLTOOLING_HTTP_STATUS_NOTMODIFIED: codestr="Status: 304 Not Modified"; break;
- case XMLTOOLING_HTTP_STATUS_UNAUTHORIZED: codestr="Status: 401 Authorization Required"; break;
- case XMLTOOLING_HTTP_STATUS_FORBIDDEN: codestr="Status: 403 Forbidden"; break;
- case XMLTOOLING_HTTP_STATUS_NOTFOUND: codestr="Status: 404 Not Found"; break;
+ case SHIBSP_HTTP_STATUS_NOTMODIFIED: codestr="Status: 304 Not Modified"; break;
+ case SHIBSP_HTTP_STATUS_UNAUTHORIZED: codestr="Status: 401 Authorization Required"; break;
+ case SHIBSP_HTTP_STATUS_FORBIDDEN: codestr="Status: 403 Forbidden"; break;
+ case SHIBSP_HTTP_STATUS_NOTFOUND: codestr="Status: 404 Not Found"; break;
}
cout << codestr << "\r\n" << hdr << "\r\n";
char buf[1024];
diff --git a/fastcgi/shibresponder.cpp b/fastcgi/shibresponder.cpp
index 3b75719e..7379180b 100644
--- a/fastcgi/shibresponder.cpp
+++ b/fastcgi/shibresponder.cpp
@@ -177,11 +177,11 @@ public:
const char* codestr="Status: 200 OK";
switch (status) {
- case XMLTOOLING_HTTP_STATUS_ERROR: codestr="Status: 500 Server Error"; break;
- case XMLTOOLING_HTTP_STATUS_UNAUTHORIZED: codestr="Status: 401 Authorization Required"; break;
- case XMLTOOLING_HTTP_STATUS_FORBIDDEN: codestr="Status: 403 Forbidden"; break;
- case XMLTOOLING_HTTP_STATUS_NOTFOUND: codestr="Status: 404 Not Found"; break;
- case XMLTOOLING_HTTP_STATUS_NOTMODIFIED: codestr="Status: 304 Not Modified"; break;
+ case SHIBSP_HTTP_STATUS_ERROR: codestr="Status: 500 Server Error"; break;
+ case SHIBSP_HTTP_STATUS_UNAUTHORIZED: codestr="Status: 401 Authorization Required"; break;
+ case SHIBSP_HTTP_STATUS_FORBIDDEN: codestr="Status: 403 Forbidden"; break;
+ case SHIBSP_HTTP_STATUS_NOTFOUND: codestr="Status: 404 Not Found"; break;
+ case SHIBSP_HTTP_STATUS_NOTMODIFIED: codestr="Status: 304 Not Modified"; break;
}
cout << codestr << "\r\n" << hdr << "\r\n";
char buf[1024];
diff --git a/iis7_shib/IIS7Request.cpp b/iis7_shib/IIS7Request.cpp
index f8fb80d0..a6336683 100644
--- a/iis7_shib/IIS7Request.cpp
+++ b/iis7_shib/IIS7Request.cpp
@@ -361,11 +361,11 @@ long IIS7Request::sendResponse(istream& in, long status)
{
const char* codestr="200 OK";
switch (status) {
- case XMLTOOLING_HTTP_STATUS_NOTMODIFIED: codestr="304 Not Modified"; break;
- case XMLTOOLING_HTTP_STATUS_UNAUTHORIZED: codestr="401 Authorization Required"; break;
- case XMLTOOLING_HTTP_STATUS_FORBIDDEN: codestr="403 Forbidden"; break;
- case XMLTOOLING_HTTP_STATUS_NOTFOUND: codestr="404 Not Found"; break;
- case XMLTOOLING_HTTP_STATUS_ERROR: codestr="500 Server Error"; break;
+ case SHIBSP_HTTP_STATUS_NOTMODIFIED: codestr="304 Not Modified"; break;
+ case SHIBSP_HTTP_STATUS_UNAUTHORIZED: codestr="401 Authorization Required"; break;
+ case SHIBSP_HTTP_STATUS_FORBIDDEN: codestr="403 Forbidden"; break;
+ case SHIBSP_HTTP_STATUS_NOTFOUND: codestr="404 Not Found"; break;
+ case SHIBSP_HTTP_STATUS_ERROR: codestr="500 Server Error"; break;
}
HRESULT hr = m_response->SetStatus(static_cast<USHORT>(status), codestr);
@@ -440,7 +440,7 @@ void IIS7Request::logFatal(const string& operation, HRESULT hr) const
string msg(operation + " failed: " + lexical_cast<string>(hr));
log(SPRequest::SPCrit, msg.c_str());
if (m_response) {
- m_response->SetStatus(static_cast<USHORT>(XMLTOOLING_HTTP_STATUS_ERROR), "Fatal Server Error", 0, hr);
+ m_response->SetStatus(static_cast<USHORT>(SHIBSP_HTTP_STATUS_ERROR), "Fatal Server Error", 0, hr);
}
}
diff --git a/iis7_shib/ShibHttpModule.cpp b/iis7_shib/ShibHttpModule.cpp
index 54646992..98997b52 100644
--- a/iis7_shib/ShibHttpModule.cpp
+++ b/iis7_shib/ShibHttpModule.cpp
@@ -84,7 +84,7 @@ ShibHttpModule::DoFilter(
if (!g_spoofKey.empty() && filter.isUseHeaders()) {
const HRESULT hr(pHttpContext->GetRequest()->SetHeader(SpoofHeaderName, g_spoofKey.c_str(), static_cast<USHORT>(g_spoofKey.length()), TRUE));
if (FAILED(hr)) {
- (void)pHttpContext->GetResponse()->SetStatus(static_cast<USHORT>(filter.XMLTOOLING_HTTP_STATUS_ERROR), "Fatal Server Error", 0, hr);
+ (void)pHttpContext->GetResponse()->SetStatus(static_cast<USHORT>(HTTPResponse::SHIBSP_HTTP_STATUS_ERROR), "Fatal Server Error", 0, hr);
return RQ_NOTIFICATION_FINISH_REQUEST;
}
}
diff --git a/shibsp/AbstractSPRequest.cpp b/shibsp/AbstractSPRequest.cpp
index 515f517a..ea49d8fc 100644
--- a/shibsp/AbstractSPRequest.cpp
+++ b/shibsp/AbstractSPRequest.cpp
@@ -21,6 +21,8 @@
#include "internal.h"
#include "exceptions.h"
#include "AbstractSPRequest.h"
+#include "Agent.h"
+#include "AgentConfig.h"
#include "Application.h"
#include "ServiceProvider.h"
#include "SessionCache.h"
@@ -42,7 +44,9 @@ SPRequest::~SPRequest()
AbstractSPRequest::AbstractSPRequest(const char* category)
- : m_log(Category::getInstance(category)), m_sp(SPConfig::getConfig().getServiceProvider()),
+ : m_log(Category::getInstance(category)),
+ m_agent(AgentConfig::getConfig().getAgent()),
+ m_sp(SPConfig::getConfig().getServiceProvider()),
m_mapper(nullptr), m_app(nullptr), m_sessionTried(false), m_session(nullptr)
{
if (m_sp)
@@ -59,6 +63,11 @@ AbstractSPRequest::~AbstractSPRequest()
m_sp->unlock();
}
+const Agent& AbstractSPRequest::getAgent() const
+{
+ return m_agent;
+}
+
const ServiceProvider& AbstractSPRequest::getServiceProvider() const
{
return *m_sp;
@@ -68,17 +77,13 @@ RequestMapper::Settings AbstractSPRequest::getRequestSettings() const
{
if (!m_mapper) {
// Map request to application and content settings.
- m_mapper = m_sp->getRequestMapper();
+ m_mapper = m_agent.getRequestMapper();
m_mapper->lock_shared();
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
- );
+ if (m_log.isDebugEnabled()) {
+ m_log.debug("mapped %s to %s", getRequestURL(), m_settings.first->getString("applicationId", ""));
}
- */
}
return m_settings;
}
@@ -105,21 +110,14 @@ Session* AbstractSPRequest::getSession(bool checkTimeout, bool ignoreAddress, bo
// Need address checking and timeout settings.
time_t timeout = 3600;
if (checkTimeout || !ignoreAddress) {
- const PropertySet* props = getApplication().getPropertySet("Sessions");
- if (props) {
- if (checkTimeout) {
- pair<bool,unsigned int> p = props->getUnsignedInt("timeout");
- if (p.first)
- timeout = p.second;
- }
- pair<bool,bool> pcheck = props->getBool("consistentAddress");
- if (pcheck.first)
- ignoreAddress = !pcheck.second;
+ if (checkTimeout) {
+ timeout = getRequestSettings().first->getUnsignedInt("timeout", 3600);
}
+ ignoreAddress = !getRequestSettings().first->getBool("consistentAddress", true);
}
// The cache will either silently pass a session or nullptr back, or throw an exception out.
- Session* session = getServiceProvider().getSessionCache()->find(
+ Session* session = getAgent().getSessionCache()->find(
getApplication(), *this, (ignoreAddress ? nullptr : getRemoteAddr().c_str()), (checkTimeout ? &timeout : nullptr)
);
if (cache)
diff --git a/shibsp/AbstractSPRequest.h b/shibsp/AbstractSPRequest.h
index 5f57b124..09cfc494 100644
--- a/shibsp/AbstractSPRequest.h
+++ b/shibsp/AbstractSPRequest.h
@@ -22,7 +22,8 @@
#define __shibsp_abstreq_h__
#include <shibsp/SPRequest.h>
-#include <boost/scoped_ptr.hpp>
+
+#include <memory>
namespace shibsp {
@@ -59,6 +60,7 @@ namespace shibsp {
virtual ~AbstractSPRequest();
// Virtual function overrides.
+ const Agent& getAgent() const;
const ServiceProvider& getServiceProvider() const;
RequestMapper::Settings getRequestSettings() const;
const Application& getApplication() const;
@@ -78,16 +80,17 @@ namespace shibsp {
private:
Category& m_log;
- ServiceProvider* m_sp;
+ Agent& m_agent;
+ ServiceProvider* m_sp; // TODO: remove
mutable RequestMapper* m_mapper;
mutable RequestMapper::Settings m_settings;
- mutable const Application* m_app;
+ mutable const Application* m_app; // TODO: remove
mutable bool m_sessionTried;
mutable Session* m_session;
std::string m_uri;
mutable std::string m_url;
mutable std::string m_handlerURL;
- mutable boost::scoped_ptr<CGIParser> m_parser;
+ mutable std::unique_ptr<CGIParser> m_parser;
};
#if defined (_MSC_VER)
diff --git a/shibsp/Application.h b/shibsp/Application.h
index b4f16ac9..8cb3eba3 100644
--- a/shibsp/Application.h
+++ b/shibsp/Application.h
@@ -33,12 +33,9 @@
#include <vector>
namespace xmltooling {
- class XMLTOOL_API CredentialResolver;
class XMLTOOL_API RWLock;
- class XMLTOOL_API SOAPTransport;
- class XMLTOOL_API StorageService;
- class XMLTOOL_API TrustEngine;
};
+
namespace shibsp {
class SHIBSP_API Attribute;
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index 6a2fdc0d..32407005 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -78,7 +78,6 @@ utilinclude_HEADERS = \
util/PropertySet.h \
util/ReloadableXMLFile.h \
util/SPConstants.h \
- util/TemplateParameters.h \
util/URLEncoder.h
noinst_HEADERS = \
@@ -90,13 +89,13 @@ noinst_HEADERS = \
logging/impl/AbstractLoggingService.h \
logging/impl/LoggingServiceSPI.h \
logging/impl/StringUtil.h \
- remoting/impl/SocketListener.h \
util/Misc.h
libshibsp_la_SOURCES = \
AbstractSPRequest.cpp \
Agent.cpp \
Application.cpp \
+ exceptions.cpp \
ServiceProvider.cpp \
SPConfig.cpp \
version.cpp \
@@ -150,7 +149,6 @@ libshibsp_la_SOURCES = \
util/PathResolver.cpp \
util/ReloadableXMLFile.cpp \
util/SPConstants.cpp \
- util/TemplateParameters.cpp \
util/URLEncoder.cpp
diff --git a/shibsp/SPConfig.cpp b/shibsp/SPConfig.cpp
index eb53207a..ce967758 100644
--- a/shibsp/SPConfig.cpp
+++ b/shibsp/SPConfig.cpp
@@ -43,7 +43,6 @@
#include <xmltooling/version.h>
#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/util/ParserPool.h>
-#include <xmltooling/util/TemplateEngine.h>
#include <xmltooling/util/Threads.h>
#include <xmltooling/util/XMLHelper.h>
@@ -52,11 +51,6 @@ using namespace xmltooling;
using namespace boost;
using namespace std;
-DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
-DECL_XMLTOOLING_EXCEPTION_FACTORY(SessionException,shibsp);
-
namespace shibsp {
class SHIBSP_DLLLOCAL SPInternalConfig : public SPConfig
{
@@ -138,14 +132,6 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
log.warn("failed to load schema catalogs into validating parser");
}
- XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
- XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
-
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
- REGISTER_XMLTOOLING_EXCEPTION_FACTORY(SessionException,shibsp);
-
registerAttributeFactories();
if (isEnabled(Handlers)) {
diff --git a/shibsp/SPRequest.h b/shibsp/SPRequest.h
index 09303e76..cead45fd 100644
--- a/shibsp/SPRequest.h
+++ b/shibsp/SPRequest.h
@@ -28,6 +28,7 @@
namespace shibsp {
+ class SHIBSP_API Agent;
class SHIBSP_API Application;
class SHIBSP_API ServiceProvider;
class SHIBSP_API Session;
@@ -48,8 +49,17 @@ namespace shibsp {
public:
virtual ~SPRequest();
+ /**
+ * Returns the Agent processing the request.
+ *
+ * @return reference to Agent
+ */
+ virtual const Agent& getAgent() const=0;
+
/**
* Returns the locked ServiceProvider processing the request.
+ *
+ * TODO: remove
*
* @return reference to ServiceProvider
*/
@@ -65,6 +75,8 @@ namespace shibsp {
/**
* Returns the Application governing the request.
+ *
+ * TODO: remove
*
* @return reference to Application
*/
diff --git a/shibsp/ServiceProvider.cpp b/shibsp/ServiceProvider.cpp
index 60800a51..99aa1f33 100644
--- a/shibsp/ServiceProvider.cpp
+++ b/shibsp/ServiceProvider.cpp
@@ -30,7 +30,6 @@
#include "handler/SessionInitiator.h"
#include "util/Date.h"
#include "util/PathResolver.h"
-#include "util/TemplateParameters.h"
#include "util/URLEncoder.h"
#include <fstream>
@@ -41,8 +40,9 @@
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
-// This is there until we figure out the TemplateEngine remediation/removal.
-#include <xmltooling/XMLToolingConfig.h>
+#ifndef HAVE_STRCASECMP
+# define strcasecmp _stricmp
+#endif
using namespace shibsp;
using namespace xmltooling;
@@ -51,39 +51,20 @@ using namespace std;
namespace shibsp {
SHIBSP_DLLLOCAL PluginManager<ServiceProvider,string,const DOMElement*>::Factory XMLServiceProviderFactory;
- long SHIBSP_DLLLOCAL sendError(
- Category& log, SPRequest& request, const Application* app, const char* page, TemplateParameters& tp, bool mayRedirect=true
+ long SHIBSP_DLLLOCAL handleError(
+ Category& log, SPRequest& request, const Session* session=nullptr, const exception* ex=nullptr, bool mayRedirect=true
)
{
// The properties we need can be set in the RequestMap, or the Errors element.
- bool mderror = false;
- bool accesserror = (strcmp(page, "access")==0);
+ bool externalParameters = false;
const char* redirectErrors = nullptr;
- const char* pathname = nullptr;
-
- // Strictly for error handling, detect a nullptr application and point at the default.
- if (!app)
- app = request.getServiceProvider().getApplication(nullptr);
- const PropertySet* props = app->getPropertySet("Errors");
+ const agent_exception* richEx = dynamic_cast<const agent_exception*>(ex);
- // If the externalParameters option isn't set, clear out the request field.
- pair<bool,bool> externalParameters =
- props ? props->getBool("externalParameters") : pair<bool,bool>(false,false);
- if (!externalParameters.first || !externalParameters.second) {
- tp.m_request = nullptr;
- }
-
- // Now look for settings in the request map of the form pageError.
+ // Now look for settings in the request map.
try {
RequestMapper::Settings settings = request.getRequestSettings();
- if (mderror)
- pathname = settings.first->getString("metadataError");
- if (!pathname) {
- string pagename(page);
- pagename += "Error";
- pathname = settings.first->getString(pagename.c_str());
- }
+ externalParameters = settings.first->getBool("externalParameters", false);
if (mayRedirect)
redirectErrors = settings.first->getString("redirectErrors");
}
@@ -91,62 +72,23 @@ namespace shibsp {
log.error(ex.what());
}
- // Check for redirection on errors instead of template.
- if (mayRedirect) {
- if (!redirectErrors && props)
- redirectErrors = props->getString("redirectErrors").second;
- if (redirectErrors) {
- string loc(redirectErrors);
- request.absolutize(loc);
- loc = loc + '?' + tp.toQueryString();
- return request.sendRedirect(loc.c_str());
- }
- }
-
- request.setContentType("text/html");
- request.setResponseHeader("Expires","Wed, 01 Jan 1997 12:00:00 GMT");
- request.setResponseHeader("Cache-Control","private,no-store,no-cache,max-age=0");
-
- // Nothing in the request map, so check for a property named "page" in the Errors property set.
- if (!pathname && props) {
- if (mderror)
- pathname=props->getString("metadata").second;
- if (!pathname)
- pathname=props->getString(page).second;
- }
-
- // If there's still no template to use, just use pageError.html unless it's an access issue.
- string fname;
- if (!pathname) {
- if (!accesserror) {
- fname = string(mderror ? "metadata" : page) + "Error.html";
- pathname = fname.c_str();
- }
- }
- else {
- fname = pathname;
- }
-
- // If we have a template to use, use it.
- if (!fname.empty()) {
- ifstream infile(AgentConfig::getConfig().getPathResolver().resolve(fname, PathResolver::SHIBSP_CFG_FILE).c_str());
- if (infile) {
- tp.setPropertySet(props);
- stringstream str;
- XMLToolingConfig::getConfig().getTemplateEngine()->run(infile, str, tp, tp.getRichException());
- return request.sendError(str);
+ // Check for redirection on errors.
+ if (mayRedirect && redirectErrors) {
+ string loc(redirectErrors);
+ request.absolutize(loc);
+ const agent_exception* richEx = dynamic_cast<const agent_exception*>(ex);
+ if (richEx) {
+ // TODO: probably alter how this works or what's included.
+ loc = loc + '?' + richEx->toQueryString();
}
+ return request.sendRedirect(loc.c_str());
}
- // If we got here, then either it's an access error or a template failed.
- if (accesserror) {
- istringstream msg("Access Denied");
- return request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_FORBIDDEN);
- }
+ // TODO: this probably changes significantly, but ultimately we're trying to pass
+ // back a status code.
- log.error("sendError could not process error template (%s)", pathname);
istringstream msg("Internal Server Error. Please contact the site administrator.");
- return request.sendError(msg);
+ return request.sendResponse(msg, richEx ? richEx->getStatusCode() : HTTPResponse::SHIBSP_HTTP_STATUS_ERROR);
}
void SHIBSP_DLLLOCAL clearHeaders(SPRequest& request) {
@@ -303,11 +245,7 @@ pair<bool,long> ServiceProvider::doAuthentication(SPRequest& request, bool handl
if (!request.isSecure()) {
const char* redirectToSSL = settings.first->getString("redirectToSSL");
if (redirectToSSL) {
-#ifdef HAVE_STRCASECMP
if (!strcasecmp("GET",request.getMethod()) || !strcasecmp("HEAD",request.getMethod())) {
-#else
- if (!stricmp("GET",request.getMethod()) || !stricmp("HEAD",request.getMethod())) {
-#endif
// Compute the new target URL
string redirectURL = string("https://") + request.getHostname();
if (strcmp(redirectToSSL,"443")) {
@@ -317,9 +255,8 @@ pair<bool,long> ServiceProvider::doAuthentication(SPRequest& request, bool handl
return make_pair(true, request.sendRedirect(redirectURL.c_str()));
}
else {
- TemplateParameters tp;
- tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
- return make_pair(true, sendError(log, request, app, "ssl", tp, false));
+ agent_exception ex("Access via unencrypted HTTP was blocked.");
+ return make_pair(true, handleError(log, request, nullptr, &ex, false));
}
}
}
@@ -428,9 +365,7 @@ pair<bool,long> ServiceProvider::doAuthentication(SPRequest& request, bool handl
}
catch (const exception& e) {
request.log(Priority::SHIB_ERROR, e.what());
- TemplateParameters tp(&e);
- tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
- return make_pair(true, sendError(log, request, app, "session", tp));
+ return make_pair(true, handleError(log, request, nullptr, &e));
}
}
@@ -483,9 +418,9 @@ pair<bool,long> ServiceProvider::doAuthorization(SPRequest& request) const
case AccessControl::shib_acl_false:
{
log.warn("access control provider denied access");
- TemplateParameters tp(nullptr, nullptr, session);
- tp.m_map["requestURL"] = targetURL;
- return make_pair(true, sendError(log, request, app, "access", tp, false));
+ agent_exception ex("Access to resource denied.");
+ ex.setStatusCode(HTTPResponse::SHIBSP_HTTP_STATUS_FORBIDDEN);
+ return make_pair(true, handleError(log, request, session, nullptr, false));
}
default:
@@ -499,9 +434,7 @@ pair<bool,long> ServiceProvider::doAuthorization(SPRequest& request) const
}
catch (const exception& e) {
request.log(Priority::SHIB_ERROR, e.what());
- TemplateParameters tp(&e, nullptr, session);
- tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
- return make_pair(true, sendError(log, request, app, "access", tp));
+ return make_pair(true, handleError(log, request, nullptr, &e));
}
}
@@ -535,7 +468,7 @@ pair<bool,long> ServiceProvider::doExport(SPRequest& request, bool requireSessio
// Still no data?
if (!session) {
if (requireSession)
- throw XMLToolingException("Unable to obtain session to export to request.");
+ throw SessionException("Unable to obtain session to export to request.");
else
return make_pair(false, 0L); // just bail silently
}
@@ -587,9 +520,7 @@ pair<bool,long> ServiceProvider::doExport(SPRequest& request, bool requireSessio
}
catch (const exception& e) {
request.log(Priority::SHIB_ERROR, e.what());
- TemplateParameters tp(&e, nullptr, session);
- tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
- return make_pair(true, sendError(log, request, app, "session", tp));
+ return make_pair(true, handleError(log, request, session, &e));
}
}
@@ -608,11 +539,7 @@ pair<bool,long> ServiceProvider::doHandler(SPRequest& request) const
if (!request.isSecure()) {
const char* redirectToSSL = settings.first->getString("redirectToSSL");
if (redirectToSSL) {
-#ifdef HAVE_STRCASECMP
if (!strcasecmp("GET",request.getMethod()) || !strcasecmp("HEAD",request.getMethod())) {
-#else
- if (!stricmp("GET",request.getMethod()) || !stricmp("HEAD",request.getMethod())) {
-#endif
// Compute the new target URL
string redirectURL = string("https://") + request.getHostname();
if (strcmp(redirectToSSL,"443")) {
@@ -622,9 +549,7 @@ pair<bool,long> ServiceProvider::doHandler(SPRequest& request) const
return make_pair(true, request.sendRedirect(redirectURL.c_str()));
}
else {
- TemplateParameters tp;
- tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
- return make_pair(true,sendError(log, request, app, "ssl", tp, false));
+ throw IOException("Blocked non-SSL access to Shibboleth handler.");
}
}
}
@@ -644,10 +569,6 @@ pair<bool,long> ServiceProvider::doHandler(SPRequest& request) const
// Process incoming request.
pair<bool,bool> handlerSSL = sessionProps->getBool("handlerSSL");
- // Make sure this is SSL, if it should be
- if ((!handlerSSL.first || handlerSSL.second) && !request.isSecure())
- 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).
const Handler* handler = app->getHandler(targetURL.c_str() + strlen(handlerURL));
@@ -669,9 +590,6 @@ pair<bool,long> ServiceProvider::doHandler(SPRequest& request) const
catch (const exception&) {
}
lock_guard<Session> slocker(*session, adopt_lock); // pop existing lock on exit
- TemplateParameters tp(&e, nullptr, session);
- tp.m_map["requestURL"] = targetURL.substr(0, targetURL.find('?'));
- //stp.m_request = &request;
- return make_pair(true, sendError(log, request, app, "session", tp));
+ return make_pair(true, handleError(log, request, session, &e));
}
}
diff --git a/shibsp/ServiceProvider.h b/shibsp/ServiceProvider.h
index 8c62cf76..1b0382f4 100644
--- a/shibsp/ServiceProvider.h
+++ b/shibsp/ServiceProvider.h
@@ -26,11 +26,6 @@
#include <set>
#include <xmltooling/Lockable.h>
-namespace xmltooling {
- class XMLTOOL_API SOAPTransport;
- class XMLTOOL_API StorageService;
-};
-
namespace shibsp {
class SHIBSP_API Application;
diff --git a/shibsp/attribute/Attribute.cpp b/shibsp/attribute/Attribute.cpp
index da913fd4..06467e41 100644
--- a/shibsp/attribute/Attribute.cpp
+++ b/shibsp/attribute/Attribute.cpp
@@ -33,13 +33,7 @@
#endif
#include "util/SPConstants.h"
-#include <xmltooling/XMLObject.h>
-#include <xmltooling/security/SecurityHelper.h>
-#include <xmltooling/util/XMLHelper.h>
-#include <xercesc/util/XMLUniDefs.hpp>
-
using namespace shibsp;
-using namespace xmltooling;
using namespace std;
namespace shibsp {
@@ -182,6 +176,6 @@ Attribute* Attribute::unmarshall(DDF& in)
{
map<string,AttributeFactory*>::const_iterator i = m_factoryMap.find(in.name() ? in.name() : "");
if (i == m_factoryMap.end())
- throw AttributeException("No registered factory for Attribute of type ($1).", params(1,in.name()));
+ throw AttributeException(string("No registered factory for Attribute of type ") + in.name());
return (i->second)(in);
}
diff --git a/shibsp/exceptions.h b/shibsp/exceptions.h
index 849b42c4..1bac5048 100644
--- a/shibsp/exceptions.h
+++ b/shibsp/exceptions.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.
*/
/**
@@ -28,14 +22,121 @@
#define __shibsp_exceptions_h__
#include <shibsp/base.h>
-#include <xmltooling/exceptions.h>
+
+#include <exception>
+#include <string>
+#include <unordered_map>
+
+/**
+ * Declares an SP exception subclass.
+ *
+ * @param name the exception class
+ * @param linkage linkage specification for class
+ * @param base the base class
+ */
+#define DECL_SHIBSP_EXCEPTION(name,linkage,base) \
+ class linkage name : public base { \
+ public: \
+ name(const char* msg=nullptr) : base(msg) {} \
+ name(const std::string& msg) : base(msg) {} \
+ virtual ~name() noexcept {} \
+ }
namespace shibsp {
-
- DECL_XMLTOOLING_EXCEPTION(AttributeException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,xmltooling::XMLToolingException,Exceptions during attribute processing.);
- 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.);
- DECL_XMLTOOLING_EXCEPTION(SessionException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp,xmltooling::XMLToolingException,Exceptions during session processing.);
+
+#if defined (_MSC_VER)
+ #pragma warning( push )
+ #pragma warning( disable : 4250 4251 )
+#endif
+
+ /**
+ * Base exception class, supports attaching additional data for error handling.
+ */
+ class SHIBSP_EXCEPTIONAPI(SHIBSP_API) agent_exception : public std::exception
+ {
+ public:
+ virtual ~agent_exception() noexcept;
+
+ /**
+ * Constructs an exception using a message.
+ *
+ * @param msg error message
+ */
+ agent_exception(const char* msg=nullptr);
+
+ /**
+ * Constructs an exception using a message.
+ *
+ * @param msg error message
+ */
+ agent_exception(const std::string& msg);
+
+ /**
+ * Returns the error message, after processing any parameter references.
+ *
+ * @return the processed message
+ */
+ const char* what() const noexcept;
+
+ /**
+ * Gets the HTTP status code for the error condition.
+ *
+ * @return status code
+ */
+ int getStatusCode() const noexcept;
+
+ /**
+ * Sets the HTTP status code for the error condition if not the default of 500.
+ *
+ * @param code status code
+ */
+ void setStatusCode(int code) noexcept;
+
+ /**
+ * Gets the properties attacked to this exception.
+ *
+ * @return property map
+ */
+ const std::unordered_map<std::string,std::string>& getProperties() const noexcept;
+
+ /**
+ * Attach a set of named properties to the exception.
+ *
+ * @param params properties to attach
+ */
+ void addProperties(const std::unordered_map<std::string,std::string>& props);
+
+ /**
+ * Attach a single named property.
+ *
+ * @param name the property name
+ * @param value the property value
+ */
+ void addProperty(const char* name, const char* value);
+
+ /**
+ * Returns a set of query string name/value pairs, URL-encoded, representing the
+ * exception's type, message, and parameters.
+ *
+ * @return the query string representation
+ */
+ std::string toQueryString() const;
+
+ private:
+ int m_status;
+ std::string m_msg;
+ std::unordered_map<std::string,std::string> m_props;
+ };
+
+ DECL_SHIBSP_EXCEPTION(AttributeException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp::agent_exception);
+ DECL_SHIBSP_EXCEPTION(ConfigurationException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp::agent_exception);
+ DECL_SHIBSP_EXCEPTION(IOException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp::agent_exception);
+ DECL_SHIBSP_EXCEPTION(RemotintgException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp::agent_exception);
+ DECL_SHIBSP_EXCEPTION(SessionException,SHIBSP_EXCEPTIONAPI(SHIBSP_API),shibsp::agent_exception);
+
+#if defined (_MSC_VER)
+ #pragma warning( pop )
+#endif
};
diff --git a/shibsp/handler/impl/AbstractHandler.cpp b/shibsp/handler/impl/AbstractHandler.cpp
index ab913c4a..3e240319 100644
--- a/shibsp/handler/impl/AbstractHandler.cpp
+++ b/shibsp/handler/impl/AbstractHandler.cpp
@@ -30,7 +30,6 @@
#include "util/CGIParser.h"
#include "util/SPConstants.h"
#include "util/PathResolver.h"
-#include "util/TemplateParameters.h"
#include "util/URLEncoder.h"
#include <vector>
@@ -39,13 +38,8 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
-#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/util/URLEncoder.h>
-
-#include <xmltooling/XMLToolingConfig.h>
using namespace shibsp;
-using namespace xmltooling;
using namespace xercesc;
using namespace boost;
using namespace std;
@@ -213,8 +207,8 @@ void Handler::preserveRelayState(const Application& application, HTTPResponse& r
rsKey = lexical_cast<string>(time(nullptr)) + '_' + rsKey;
string shib_cookie_name = "_shibstate_" + rsKey;
response.setCookie(shib_cookie_name.c_str(),
- XMLToolingConfig::getConfig().getURLEncoder()->encode(relayState.c_str()).c_str(),
- 0, HTTPResponse::SAMESITE_NONE);
+ AgentConfig::getConfig().getURLEncoder().encode(relayState.c_str()).c_str(),
+ 0, HTTPResponse::SAMESITE_NONE);
relayState = "cookie:" + rsKey;
}
}
@@ -264,7 +258,7 @@ void Handler::preserveRelayState(const Application& application, HTTPResponse& r
}
}
else {
- throw ConfigurationException("Unsupported relayState mechanism ($1).", params(1,mech.second));
+ throw ConfigurationException("Unsupported relayState mechanism.");
}
}
@@ -350,7 +344,7 @@ void Handler::recoverRelayState(
if (state && *state) {
// URL-decode the value.
char* rscopy = strdup(state);
- XMLToolingConfig::getConfig().getURLEncoder()->decode(rscopy);
+ AgentConfig::getConfig().getURLEncoder().decode(rscopy);
relayState = rscopy;
free(rscopy);
if (clear) {
@@ -562,7 +556,7 @@ void AbstractHandler::preservePostData(
mech.second+=3;
if (!*mech.second) {
postData.destroy();
- throw ConfigurationException("Unsupported postData mechanism ($1).", params(1, mech.second - 3));
+ throw ConfigurationException("Unsupported postData mechanism.");
}
string postkey;
@@ -629,7 +623,7 @@ void AbstractHandler::preservePostData(
}
else {
postData.destroy();
- throw ConfigurationException("Unsupported postData mechanism ($1).", params(1,mech.second));
+ throw ConfigurationException("Unsupported postData mechanism.");
}
}
@@ -700,6 +694,9 @@ long AbstractHandler::sendPostResponse(
{
HTTPResponse::sanitizeURL(url);
+ // TODO: this will require handling by the hub.
+
+ /*
const PropertySet* props=application.getPropertySet("Sessions");
pair<bool,const char*> postTemplate = props ? props->getString("postTemplate") : pair<bool,const char*>(true,nullptr);
if (!postTemplate.first)
@@ -732,6 +729,8 @@ long AbstractHandler::sendPostResponse(
httpResponse.setResponseHeader("Pragma", "no-cache");
}
return httpResponse.sendResponse(str);
+ */
+ return 0;
}
string AbstractHandler::getPostCookieName(const Application& app, const char* relayState) const
diff --git a/shibsp/handler/impl/AdminLogoutInitiator.cpp b/shibsp/handler/impl/AdminLogoutInitiator.cpp
index 60d1abd4..dd977e47 100644
--- a/shibsp/handler/impl/AdminLogoutInitiator.cpp
+++ b/shibsp/handler/impl/AdminLogoutInitiator.cpp
@@ -176,7 +176,7 @@ pair<bool,long> AdminLogoutInitiator::doRequest(const Application& application,
// Something's horribly wrong.
m_log.error("no session parameter supplied for request");
istringstream msg("NO SESSION PARAMETER");
- return make_pair(true, httpResponse.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_BADREQUEST));
+ return make_pair(true, httpResponse.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_BADREQUEST));
}
Session* session = nullptr;
@@ -191,7 +191,7 @@ pair<bool,long> AdminLogoutInitiator::doRequest(const Application& application,
if (!session) {
application.getServiceProvider().getSessionCache()->remove(application, sessionId);
istringstream msg("NOT FOUND");
- return make_pair(true, httpResponse.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_NOTFOUND));
+ return make_pair(true, httpResponse.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_NOTFOUND));
}
time_t revocationExp = session->getExpiration();
@@ -231,7 +231,7 @@ pair<bool,long> AdminLogoutInitiator::doRequest(const Application& application,
application.getServiceProvider().getSessionCache()->remove(application, sessionId, revocationExp);
istringstream msg("OK");
- return make_pair(true, httpResponse.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_OK));
+ return make_pair(true, httpResponse.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_OK));
}
#ifndef SHIBSP_LITE
diff --git a/shibsp/handler/impl/AssertionLookup.cpp b/shibsp/handler/impl/AssertionLookup.cpp
index dd0ae923..7fd58ef0 100644
--- a/shibsp/handler/impl/AssertionLookup.cpp
+++ b/shibsp/handler/impl/AssertionLookup.cpp
@@ -115,7 +115,7 @@ pair<bool,long> AssertionLookup::run(SPRequest& request, bool isHandler) const
catch (std::exception& ex) {
m_log.error("error while processing request: %s", ex.what());
istringstream msg("Assertion Lookup Failed");
- return make_pair(true, request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_ERROR));
+ return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_ERROR));
}
}
diff --git a/shibsp/handler/impl/AttributeCheckerHandler.cpp b/shibsp/handler/impl/AttributeCheckerHandler.cpp
index 6ce8a805..c1e5d5f0 100644
--- a/shibsp/handler/impl/AttributeCheckerHandler.cpp
+++ b/shibsp/handler/impl/AttributeCheckerHandler.cpp
@@ -35,7 +35,6 @@
#include "attribute/Attribute.h"
#include "handler/AbstractHandler.h"
#include "util/PathResolver.h"
-#include "util/TemplateParameters.h"
#include <memory>
#include <mutex>
@@ -45,7 +44,6 @@
#include <boost/bind.hpp>
#include <boost/algorithm/string.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
-#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/util/XMLHelper.h>
using namespace shibsp;
@@ -191,7 +189,7 @@ pair<bool,long> AttributeCheckerHandler::run(SPRequest& request, bool isHandler)
ifstream infile(m_template.c_str());
if (infile) {
const PropertySet* props = request.getApplication().getPropertySet("Errors");
- TemplateParameters tp(nullptr, props, session);
+ //TemplateParameters tp(nullptr, props, session);
// If the externalParameters option isn't set, don't populate the request field.
pair<bool,bool> externalParameters =
@@ -201,7 +199,7 @@ pair<bool,long> AttributeCheckerHandler::run(SPRequest& request, bool isHandler)
}
stringstream str;
- XMLToolingConfig::getConfig().getTemplateEngine()->run(infile, str, tp);
+ //XMLToolingConfig::getConfig().getTemplateEngine()->run(infile, str, tp);
if (m_flushSession && session) {
time_t revocationExp = session->getExpiration();
sessionLocker.unlock(); // unlock the session
diff --git a/shibsp/handler/impl/DiscoveryFeed.cpp b/shibsp/handler/impl/DiscoveryFeed.cpp
index ecc48cec..72934ee6 100644
--- a/shibsp/handler/impl/DiscoveryFeed.cpp
+++ b/shibsp/handler/impl/DiscoveryFeed.cpp
@@ -201,13 +201,13 @@ pair<bool,long> DiscoveryFeed::run(SPRequest& request, bool isHandler) const
if (s.empty()) {
m_log.debug("client's cache tag matches our feed");
istringstream msg("Not Modified");
- return make_pair(true, request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_NOTMODIFIED));
+ return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_NOTMODIFIED));
}
string fname = m_dir + '/' + request.getApplication().getHash() + '_' + s + ".json";
ifstream feed(fname.c_str());
if (!feed)
- throw ConfigurationException("Unable to access cached feed in ($1).", params(1,fname.c_str()));
+ throw ConfigurationException("Unable to access cached feed.");
if (m_cacheToClient) {
string etag = '"' + s + '"';
request.setResponseHeader("ETag", etag.c_str());
@@ -218,7 +218,7 @@ pair<bool,long> DiscoveryFeed::run(SPRequest& request, bool isHandler) const
catch (std::exception& ex) {
request.log(Priority::SHIB_ERROR, string("error while processing request:") + ex.what());
istringstream msg("Discovery Request Failed");
- return make_pair(true, request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_ERROR));
+ return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_ERROR));
}
}
diff --git a/shibsp/handler/impl/LogoutHandler.cpp b/shibsp/handler/impl/LogoutHandler.cpp
index 3a245750..b65b4b40 100644
--- a/shibsp/handler/impl/LogoutHandler.cpp
+++ b/shibsp/handler/impl/LogoutHandler.cpp
@@ -32,16 +32,13 @@
#include "SessionCache.h"
#include "SPRequest.h"
#include "handler/LogoutHandler.h"
-#include "util/TemplateParameters.h"
#include "util/PathResolver.h"
#include "util/URLEncoder.h"
#include <fstream>
#include <boost/lexical_cast.hpp>
-#include <xmltooling/XMLToolingConfig.h>
using namespace shibsp;
-using namespace xmltooling;
using namespace boost;
using namespace std;
@@ -71,8 +68,8 @@ pair<bool,long> LogoutHandler::sendLogoutPage(
string fname(prop.second);
ifstream infile(AgentConfig::getConfig().getPathResolver().resolve(fname, PathResolver::SHIBSP_CFG_FILE).c_str());
if (!infile)
- throw ConfigurationException("Unable to access $1 HTML template.", params(1,prop.second));
- TemplateParameters tp;
+ throw ConfigurationException("Unable to access HTML template.");
+ //TemplateParameters tp;
// If the externalParameters option isn't set, don't populate the request field.
pair<bool,bool> externalParameters =
@@ -81,10 +78,10 @@ pair<bool,long> LogoutHandler::sendLogoutPage(
//tp.m_request = &request;
}
- tp.setPropertySet(props);
- tp.m_map["logoutStatus"] = "Logout completed successfully."; // Backward compatibility.
+ //tp.setPropertySet(props);
+ //tp.m_map["logoutStatus"] = "Logout completed successfully."; // Backward compatibility.
stringstream str;
- XMLToolingConfig::getConfig().getTemplateEngine()->run(infile, str, tp);
+ //XMLToolingConfig::getConfig().getTemplateEngine()->run(infile, str, tp);
return make_pair(true,response.sendResponse(str));
}
@@ -107,7 +104,7 @@ void LogoutHandler::receive(DDF& in, ostream& out)
DDF ret(nullptr);
DDFJanitor jout(ret);
if (in["notify"].integer() != 1)
- throw ListenerException("Unsupported operation.");
+ throw RemotintgException("Unsupported operation.");
// Find application.
const char* aid=in["application_id"].string();
diff --git a/shibsp/handler/impl/MetadataGenerator.cpp b/shibsp/handler/impl/MetadataGenerator.cpp
index 27bc7635..2687f5fd 100644
--- a/shibsp/handler/impl/MetadataGenerator.cpp
+++ b/shibsp/handler/impl/MetadataGenerator.cpp
@@ -37,7 +37,6 @@
#include <boost/iterator/indirect_iterator.hpp>
using namespace shibsp;
-using namespace xmltooling;
using namespace boost;
using namespace std;
@@ -367,7 +366,7 @@ pair<bool,long> MetadataGenerator::run(SPRequest& request, bool isHandler) const
catch (std::exception& ex) {
m_log.error("error while processing request: %s", ex.what());
istringstream msg("Metadata Request Failed");
- return make_pair(true, request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_ERROR));
+ return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_ERROR));
}
}
diff --git a/shibsp/handler/impl/SecuredHandler.cpp b/shibsp/handler/impl/SecuredHandler.cpp
index ae12aea7..82ca17ab 100644
--- a/shibsp/handler/impl/SecuredHandler.cpp
+++ b/shibsp/handler/impl/SecuredHandler.cpp
@@ -35,7 +35,6 @@
#include <sstream>
using namespace shibsp;
-using namespace xmltooling;
using namespace boost;
using namespace std;
@@ -104,7 +103,7 @@ pair<bool,long> SecuredHandler::run(SPRequest& request, bool isHandler) const
if (find_if(m_acl.begin(), m_acl.end(), boost::bind(contains, _1, request.getRemoteAddr().c_str())) == m_acl.end()) {
request.log(Priority::SHIB_WARN, string("handler request blocked from invalid address (") + request.getRemoteAddr() + ')');
istringstream msg("Access Denied");
- return make_pair(true, request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_FORBIDDEN));
+ return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_FORBIDDEN));
}
}
return make_pair(false, 0L);
diff --git a/shibsp/handler/impl/StatusHandler.cpp b/shibsp/handler/impl/StatusHandler.cpp
index d0ae6bf1..beb7280a 100644
--- a/shibsp/handler/impl/StatusHandler.cpp
+++ b/shibsp/handler/impl/StatusHandler.cpp
@@ -47,7 +47,6 @@
using namespace shibsp;
using namespace xmltooling;
-using namespace boost;
using namespace std;
namespace shibsp {
@@ -211,7 +210,7 @@ namespace shibsp {
}
private:
- mutable scoped_ptr<CGIParser> m_parser;
+ mutable boost::scoped_ptr<CGIParser> m_parser;
const char* m_url;
const char* m_scheme;
const char* m_query;
@@ -279,7 +278,7 @@ pair<bool,long> StatusHandler::run(SPRequest& request, bool isHandler) const
return unwrap(request, out);
}
}
- catch (XMLToolingException& ex) {
+ catch (exception& ex) {
m_log.error("error while processing request: %s", ex.what());
XMLDateTime now(time(nullptr), false);
now.parseDateTime();
@@ -294,9 +293,9 @@ pair<bool,long> StatusHandler::run(SPRequest& request, bool isHandler) const
<< "' OpenSAML-C='" << gOpenSAMLDotVersionStr
#endif
<< "' Shibboleth='" << PACKAGE_VERSION << "'/>";
- systemInfo(msg) << "<Status><Exception type='" << ex.getClassName() << "'>" << ex.what() << "</Exception></Status>";
+ systemInfo(msg) << "<Status><Exception>" << ex.what() << "</Exception></Status>";
msg << "</StatusHandler>";
- return make_pair(true, request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_ERROR));
+ return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_ERROR));
}
catch (std::exception& ex) {
m_log.error("error while processing request: %s", ex.what());
@@ -315,7 +314,7 @@ pair<bool,long> StatusHandler::run(SPRequest& request, bool isHandler) const
<< "' Shibboleth='" << PACKAGE_VERSION << "'/>";
systemInfo(msg) << "<Status><Exception type='std::exception'>" << ex.what() << "</Exception></Status>";
msg << "</StatusHandler>";
- return make_pair(true, request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_ERROR));
+ return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_ERROR));
}
}
@@ -333,8 +332,8 @@ void StatusHandler::receive(DDF& in, ostream& out)
// Wrap a response shim.
DDF ret(nullptr);
DDFJanitor jout(ret);
- scoped_ptr<HTTPRequest> req(getRequest(*app, in));
- scoped_ptr<HTTPResponse> resp(getResponse(*app, ret));
+ boost::scoped_ptr<HTTPRequest> req(getRequest(*app, in));
+ boost::scoped_ptr<HTTPResponse> resp(getResponse(*app, ret));
// Since we're remoted, the result should either be a throw, a false/0 return,
// which we just return as an empty structure, or a response/redirect,
diff --git a/shibsp/impl/AgentConfig.cpp b/shibsp/impl/AgentConfig.cpp
index 6cdd1d16..0da6b699 100644
--- a/shibsp/impl/AgentConfig.cpp
+++ b/shibsp/impl/AgentConfig.cpp
@@ -51,7 +51,6 @@
#endif
using namespace shibsp;
-using namespace xmltooling;
using namespace boost::property_tree;
using namespace std;
diff --git a/shibsp/impl/XMLApplication.cpp b/shibsp/impl/XMLApplication.cpp
index 51d72d99..5a51ea55 100644
--- a/shibsp/impl/XMLApplication.cpp
+++ b/shibsp/impl/XMLApplication.cpp
@@ -137,7 +137,7 @@ XMLApplication::XMLApplication(
m_redirectLimit = REDIRECT_LIMIT_ALLOW;
}
else {
- throw ConfigurationException("Unrecognized redirectLimit setting ($1)", params(1, prop.second));
+ throw ConfigurationException(string("Unrecognized redirectLimit setting ") + prop.second);
}
prop = sessionProps->getString("redirectAllow");
if (prop.first) {
@@ -306,7 +306,7 @@ template <class T> T* XMLApplication::doChainedPlugins(
return pluginMgr.newPlugin(t.c_str(), child, m_deprecationSupport);
}
else {
- throw ConfigurationException("$1 element had no type attribute.", params(1, pluginType));
+ throw ConfigurationException("Eelement had no type attribute.");
}
}
catch (const std::exception& ex) {
@@ -695,10 +695,7 @@ string XMLApplication::getNotificationURL(const char* resource, bool front, unsi
// Should never happen...
if (!handler || (*handler!='/' && strncmp(handler,"http:",5) && strncmp(handler,"https:",6)))
- throw ConfigurationException(
- "Invalid Location property ($1) in Notify element for Application ($2)",
- params(2, handler ? handler : "null", getId())
- );
+ throw ConfigurationException("Invalid Location property in Notify element");
// The "Location" property can be in one of three formats:
//
diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp
index 2fed70ef..fd63c686 100644
--- a/shibsp/impl/XMLServiceProvider.cpp
+++ b/shibsp/impl/XMLServiceProvider.cpp
@@ -346,7 +346,7 @@ boost::shared_ptr<Application> XMLConfigImpl::findExternalOverride(const char* i
string id2(XMLHelper::getAttrString(doc->getDocumentElement(), nullptr, _id));
if (id2 != id)
- throw ConfigurationException("External override's id ($1) did not match the expected value", params(1, id2.c_str()));
+ throw ConfigurationException("External override's id did not match the expected value.");
boost::shared_ptr<XMLApplication> iapp(
new XMLApplication(config, doc->getDocumentElement(), m_deprecationSupport, m_defaultApplication, doc)
diff --git a/shibsp/io/HTTPResponse.h b/shibsp/io/HTTPResponse.h
index 56afe511..0b7a6e52 100644
--- a/shibsp/io/HTTPResponse.h
+++ b/shibsp/io/HTTPResponse.h
@@ -111,20 +111,20 @@ namespace shibsp {
* <p>The URL will be validated with the sanitizeURL method below.
*
* @param url location to redirect client
- * @return a result code to return from the calling MessageEncoder
+ * @return a result code to return
*/
virtual long sendRedirect(const char* url);
/** Some common HTTP status codes. */
enum status_t {
- XMLTOOLING_HTTP_STATUS_OK = 200,
- XMLTOOLING_HTTP_STATUS_MOVED = 302,
- XMLTOOLING_HTTP_STATUS_NOTMODIFIED = 304,
- XMLTOOLING_HTTP_STATUS_BADREQUEST = 400,
- XMLTOOLING_HTTP_STATUS_UNAUTHORIZED = 401,
- XMLTOOLING_HTTP_STATUS_FORBIDDEN = 403,
- XMLTOOLING_HTTP_STATUS_NOTFOUND = 404,
- XMLTOOLING_HTTP_STATUS_ERROR = 500
+ SHIBSP_HTTP_STATUS_OK = 200,
+ SHIBSP_HTTP_STATUS_MOVED = 302,
+ SHIBSP_HTTP_STATUS_NOTMODIFIED = 304,
+ SHIBSP_HTTP_STATUS_BADREQUEST = 400,
+ SHIBSP_HTTP_STATUS_UNAUTHORIZED = 401,
+ SHIBSP_HTTP_STATUS_FORBIDDEN = 403,
+ SHIBSP_HTTP_STATUS_NOTFOUND = 404,
+ SHIBSP_HTTP_STATUS_ERROR = 500
};
long sendError(std::istream& inputStream);
diff --git a/shibsp/io/impl/HTTPResponse.cpp b/shibsp/io/impl/HTTPResponse.cpp
index c023f45a..1ce5b5e2 100644
--- a/shibsp/io/impl/HTTPResponse.cpp
+++ b/shibsp/io/impl/HTTPResponse.cpp
@@ -156,15 +156,15 @@ void HTTPResponse::setResponseHeader(const char* name, const char* value, bool)
long HTTPResponse::sendRedirect(const char* url)
{
sanitizeURL(url);
- return XMLTOOLING_HTTP_STATUS_MOVED;
+ return SHIBSP_HTTP_STATUS_MOVED;
}
long HTTPResponse::sendError(istream& inputStream)
{
- return sendResponse(inputStream, XMLTOOLING_HTTP_STATUS_ERROR);
+ return sendResponse(inputStream, SHIBSP_HTTP_STATUS_ERROR);
}
long HTTPResponse::sendResponse(istream& inputStream)
{
- return sendResponse(inputStream, XMLTOOLING_HTTP_STATUS_OK);
+ return sendResponse(inputStream, SHIBSP_HTTP_STATUS_OK);
}
diff --git a/shibsp/remoting/ddf.h b/shibsp/remoting/ddf.h
index cfa6d260..c634a132 100644
--- a/shibsp/remoting/ddf.h
+++ b/shibsp/remoting/ddf.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.
*/
/**
diff --git a/shibsp/remoting/impl/ddf.cpp b/shibsp/remoting/impl/ddf.cpp
index 0f416853..3bb8169d 100644
--- a/shibsp/remoting/impl/ddf.cpp
+++ b/shibsp/remoting/impl/ddf.cpp
@@ -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.
*/
/**
@@ -25,12 +19,12 @@
*/
#include "internal.h"
+#include "exceptions.h"
#include "remoting/ddf.h"
#include "util/Misc.h"
#include <stdexcept>
#include <iomanip>
-#include <xmltooling/exceptions.h>
#include <boost/lexical_cast.hpp>
using namespace shibsp;
@@ -181,7 +175,7 @@ DDF DDF::copy() const
return DDF(m_handle->name);
case ddf_body_t::DDF_STRING:
case ddf_body_t::DDF_STRING_UNSAFE:
- return DDF(m_handle->name,m_handle->value.string,(m_handle->type==ddf_body_t::DDF_STRING)); return DDF(m_handle->name,m_handle->value.string,(m_handle->type==ddf_body_t::DDF_STRING));
+ return DDF(m_handle->name,m_handle->value.string,(m_handle->type==ddf_body_t::DDF_STRING));
case ddf_body_t::DDF_INT:
return DDF(m_handle->name,m_handle->value.integer);
case ddf_body_t::DDF_LONG:
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list