Prepare policy API for mix-in subclassing. Allow policy rules to distinguish success...
[shibboleth/cpp-opensaml.git] / saml / binding / impl / MessageFlowRule.cpp
index 45722fa..f371f1f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ namespace opensaml {
         const char* getType() const {
             return MESSAGEFLOW_POLICY_RULE;
         }
-        void evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const;
+        bool evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const;
     
     private:
         bool m_checkReplay;
@@ -72,7 +72,7 @@ MessageFlowRule::MessageFlowRule(const DOMElement* e)
     }
 }
 
-void MessageFlowRule::evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const
+bool MessageFlowRule::evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const
 {
     Category& log=Category::getInstance(SAML_LOGCAT".SecurityPolicyRule.MessageFlow");
     log.debug("evaluating message flow policy (replay checking %s, expiration %lu)", m_checkReplay ? "on" : "off", m_expires);
@@ -100,12 +100,12 @@ void MessageFlowRule::evaluate(const XMLObject& message, const GenericRequest* r
     if (m_checkReplay) {
         const XMLCh* id = policy.getMessageID();
         if (!id || !*id)
-            return;
+            return false;
 
         ReplayCache* replayCache = XMLToolingConfig::getConfig().getReplayCache();
         if (!replayCache) {
             log.warn("no ReplayCache available, skipping requested replay check");
-            return;
+            return false;
         }
 
         auto_ptr_char temp(id);
@@ -113,5 +113,7 @@ void MessageFlowRule::evaluate(const XMLObject& message, const GenericRequest* r
             log.error("replay detected of message ID (%s)", temp.get());
             throw SecurityPolicyException("Rejecting replayed message ID ($1).", params(1,temp.get()));
         }
+        return true;
     }
+    return false;
 }