X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fbinding%2Fimpl%2FMessageFlowRule.cpp;h=af43c8e61d6d3829c41143b6712d39b3e170c681;hb=9fddf9054c76de6239295b98a559fcc75453effc;hp=93a2649198f4d02f2002e3d54022350e74cbc061;hpb=f9aa9375e0908e119af283278d00468a9b2249f5;p=shibboleth%2Fopensaml2.git diff --git a/saml/binding/impl/MessageFlowRule.cpp b/saml/binding/impl/MessageFlowRule.cpp index 93a2649..af43c8e 100644 --- a/saml/binding/impl/MessageFlowRule.cpp +++ b/saml/binding/impl/MessageFlowRule.cpp @@ -24,13 +24,13 @@ #include "exceptions.h" #include "binding/SecurityPolicyRule.h" -#include +#include #include #include using namespace opensaml; +using namespace xmltooling::logging; using namespace xmltooling; -using namespace log4cpp; using namespace std; namespace opensaml { @@ -78,38 +78,37 @@ void MessageFlowRule::evaluate(const XMLObject& message, const GenericRequest* r time_t skew = XMLToolingConfig::getConfig().clock_skew_secs; time_t issueInstant = policy.getIssueInstant(); if (issueInstant == 0) { - log.debug("unknown message timestamp, assuming current time for replay checking"); issueInstant = now; } else { if (issueInstant > now + skew) { log.errorStream() << "rejected not-yet-valid message, timestamp (" << issueInstant << "), newest allowed (" << now + skew << ")" << CategoryStream::ENDLINE; - throw BindingException("Message rejected, was issued in the future."); + throw SecurityPolicyException("Message rejected, was issued in the future."); } else if (issueInstant < now - skew - m_expires) { log.errorStream() << "rejected expired message, timestamp (" << issueInstant << "), oldest allowed (" << (now - skew - m_expires) << ")" << CategoryStream::ENDLINE; - throw BindingException("Message expired, was issued too long ago."); + throw SecurityPolicyException("Message expired, was issued too long ago."); } } // Check replay. if (m_checkReplay) { + const XMLCh* id = policy.getMessageID(); + if (!id || !*id) + return; + ReplayCache* replayCache = XMLToolingConfig::getConfig().getReplayCache(); if (!replayCache) { log.warn("no ReplayCache available, skipping requested replay check"); return; } - const XMLCh* id = policy.getMessageID(); - if (!id || !*id) { - log.debug("unknown message ID, no replay check possible"); - return; - } + auto_ptr_char temp(id); if (!replayCache->check("MessageFlow", temp.get(), issueInstant + skew + m_expires)) { log.error("replay detected of message ID (%s)", temp.get()); - throw BindingException("Rejecting replayed message ID ($1).", params(1,temp.get())); + throw SecurityPolicyException("Rejecting replayed message ID ($1).", params(1,temp.get())); } } }