[cpp-sp] branch master updated: Add more Xerces exception handling.
Scott Cantor
cantor.2 at osu.edu
Fri Dec 14 12:10:15 EST 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=71981d79fab11c657c01fb460a8d4388278cc741
The following commit(s) were added to refs/heads/master by this push:
new 71981d7 Add more Xerces exception handling.
71981d7 is described below
commit 71981d79fab11c657c01fb460a8d4388278cc741
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Dec 14 12:10:08 2018 -0500
Add more Xerces exception handling.
---
plugins/TimeAccessControl.cpp | 33 ++++++++++++++++++++---------
shibsp/handler/impl/ExternalAuthHandler.cpp | 10 +++++++--
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/plugins/TimeAccessControl.cpp b/plugins/TimeAccessControl.cpp
index 7c41109..5725071 100644
--- a/plugins/TimeAccessControl.cpp
+++ b/plugins/TimeAccessControl.cpp
@@ -106,10 +106,16 @@ Rule::Rule(const DOMElement* e)
{
if (XMLString::equals(e->getLocalName(), TimeSinceAuthn)) {
m_type = TM_AUTHN;
- XMLDateTime dur(XMLHelper::getTextContent(e));
- dur.parseDuration();
- m_value = dur.getEpoch(true);
- return;
+ try {
+ XMLDateTime dur(XMLHelper::getTextContent(e));
+ dur.parseDuration();
+ m_value = dur.getEpoch(true);
+ return;
+ }
+ catch (const XMLException& e) {
+ auto_ptr_char temp(e.getMessage());
+ throw ConfigurationException(temp.get() ? temp.get() : "XMLException parsing duration in TimeSinceAuthn rule");
+ }
}
auto_ptr_char temp(XMLHelper::getTextContent(e));
@@ -130,10 +136,16 @@ Rule::Rule(const DOMElement* e)
if (XMLString::equals(e->getLocalName(), Time)) {
m_type = TM_TIME;
auto_ptr_XMLCh widen(tokens.back().c_str());
- XMLDateTime dt(widen.get());
- dt.parseDateTime();
- m_value = dt.getEpoch(false);
- return;
+ try {
+ XMLDateTime dt(widen.get());
+ dt.parseDateTime();
+ m_value = dt.getEpoch(false);
+ return;
+ }
+ catch (const XMLException& e) {
+ auto_ptr_char temp(e.getMessage());
+ throw ConfigurationException(temp.get() ? temp.get() : "XMLException parsing duration in Time rule");
+ }
}
m_value = lexical_cast<time_t>(tokens.back());
@@ -179,8 +191,9 @@ AccessControl::aclresult_t Rule::authorized(const SPRequest& request, const Sess
request.log(SPRequest::SPDebug, "elapsed time since authentication exceeds limit");
return shib_acl_false;
}
- catch (std::exception& e) {
- request.log(SPRequest::SPError, e.what());
+ catch (const XMLException& e) {
+ auto_ptr_char temp(e.getMessage());
+ request.log(SPRequest::SPError, temp.get() ? temp.get() : "XMLException parsing AuthnInstant from session");
}
}
}
diff --git a/shibsp/handler/impl/ExternalAuthHandler.cpp b/shibsp/handler/impl/ExternalAuthHandler.cpp
index 8b78c98..07ff3bf 100644
--- a/shibsp/handler/impl/ExternalAuthHandler.cpp
+++ b/shibsp/handler/impl/ExternalAuthHandler.cpp
@@ -450,8 +450,14 @@ pair<bool,long> ExternalAuth::processMessage(
param = httpRequest.getParameter("AuthnInstant");
if (param && *param) {
auto_ptr_XMLCh d(param);
- authn_instant.reset(new XMLDateTime(d.get()));
- authn_instant->parseDateTime();
+ try {
+ authn_instant.reset(new XMLDateTime(d.get()));
+ authn_instant->parseDateTime();
+ }
+ catch (const XMLException& e) {
+ auto_ptr_char temp(e.getMessage());
+ throw XMLObjectException(temp.get() ? temp.get() : "XMLException parsing date/time value.");
+ }
}
auto_ptr_XMLCh session_index(httpRequest.getParameter("SessionIndex"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list