SSPCPP-616 - clean up concatenated string literals
[shibboleth/cpp-opensaml.git] / saml / binding / impl / MessageFlowRule.cpp
index f19c815..8b117cf 100644 (file)
@@ -1,23 +1,27 @@
-/*
- *  Copyright 2001-2009 Internet2
+/**
+ * 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.
  */
 
 /**
  * MessageFlowRule.cpp
  *
- * SAML replay and freshness checking SecurityPolicyRule
+ * SAML replay and freshness checking SecurityPolicyRule.
  */
 
 #include "internal.h"
@@ -28,6 +32,7 @@
 #include <xmltooling/logging.h>
 #include <xmltooling/XMLToolingConfig.h>
 #include <xmltooling/util/ReplayCache.h>
+#include <xmltooling/util/XMLHelper.h>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 using namespace opensaml;
@@ -62,21 +67,14 @@ static const XMLCh checkReplay[] = UNICODE_LITERAL_11(c,h,e,c,k,R,e,p,l,a,y);
 static const XMLCh expires[] = UNICODE_LITERAL_7(e,x,p,i,r,e,s);
 
 MessageFlowRule::MessageFlowRule(const DOMElement* e)
-    : m_checkReplay(true), m_expires(XMLToolingConfig::getConfig().clock_skew_secs)
+    : m_checkReplay(XMLHelper::getAttrBool(e, true, checkReplay)),
+        m_expires(XMLHelper::getAttrInt(e, XMLToolingConfig::getConfig().clock_skew_secs, expires))
 {
-    if (e) {
-        const XMLCh* attr = e->getAttributeNS(NULL, checkReplay);
-        if (attr && (*attr==chLatin_f || *attr==chDigit_0))
-            m_checkReplay = false;
-        attr = e->getAttributeNS(NULL, expires);
-        if (attr)
-            m_expires = XMLString::parseInt(attr);
-    }
 }
 
 bool MessageFlowRule::evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const
 {
-    Category& log=Category::getInstance(SAML_LOGCAT".SecurityPolicyRule.MessageFlow");
+    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);
 
     time_t now = policy.getTime();