From: cantor Date: Sat, 31 Oct 2009 20:28:20 +0000 (+0000) Subject: Auto-derive names of error templates if properties missing. X-Git-Tag: 2.4~168 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fsp.git;a=commitdiff_plain;h=07480e17f63a33f2117a4507a6dcc87124468f37 Auto-derive names of error templates if properties missing. git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/branches/REL_2@3167 cb58f699-b61c-0410-a6fe-9272a202ed29 --- diff --git a/shibsp/ServiceProvider.cpp b/shibsp/ServiceProvider.cpp index 52d0bac..a43a9e0 100644 --- a/shibsp/ServiceProvider.cpp +++ b/shibsp/ServiceProvider.cpp @@ -103,23 +103,30 @@ namespace shibsp { if (!pathname.first) pathname=props->getString(page); } - if (pathname.first) { - string fname(pathname.second); - ifstream infile(XMLToolingConfig::getConfig().getPathResolver()->resolve(fname, PathResolver::XMLTOOLING_CFG_FILE).c_str()); - if (infile) { - tp.setPropertySet(props); - stringstream str; - XMLToolingConfig::getConfig().getTemplateEngine()->run(infile, str, tp, tp.getRichException()); - return request.sendError(str); - } + + string fname; + if (!pathname.first) { + fname = string(page) + "Error.html"; + pathname.second = fname.c_str(); + } + else { + fname = pathname.second; + } + + ifstream infile(XMLToolingConfig::getConfig().getPathResolver()->resolve(fname, PathResolver::XMLTOOLING_CFG_FILE).c_str()); + if (infile) { + tp.setPropertySet(props); + stringstream str; + XMLToolingConfig::getConfig().getTemplateEngine()->run(infile, str, tp, tp.getRichException()); + return request.sendError(str); } - if (!strcmp(page,"access")) { + if (!strcmp(page, "access")) { istringstream msg("Access Denied"); return request.sendResponse(msg, HTTPResponse::XMLTOOLING_HTTP_STATUS_FORBIDDEN); } - log.error("sendError could not process error template (%s)", page); + log.error("sendError could not process error template (%s)", pathname.second); istringstream msg("Internal Server Error. Please contact the site administrator."); return request.sendError(msg); }