2 * Copyright 2009 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * SecurityPolicyRule that ignores a message while indicating "success".
24 #include "exceptions.h"
25 #include "binding/SecurityPolicyRule.h"
27 #include <xmltooling/logging.h>
28 #include <xmltooling/util/XMLHelper.h>
30 using namespace opensaml;
31 using namespace xmltooling::logging;
32 using namespace xmltooling;
37 class SAML_DLLLOCAL IgnoreRule : public SecurityPolicyRule
40 IgnoreRule(const DOMElement* e)
41 : m_log(Category::getInstance(SAML_LOGCAT".SecurityPolicyRule.Ignore")), m_qname(XMLHelper::getNodeValueAsQName(e)) {
43 throw SecurityPolicyException("No schema type or element name supplied to Ignore rule.");
45 virtual ~IgnoreRule() {
49 const char* getType() const {
50 return IGNORE_POLICY_RULE;
52 bool evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const {
53 if (message.getSchemaType()) {
54 if (*m_qname != *(message.getSchemaType()))
56 m_log.info("ignoring condition with type (%s)", message.getSchemaType()->toString().c_str());
59 if (*m_qname != message.getElementQName())
61 m_log.info("ignoring condition (%s)", message.getElementQName().toString().c_str());
68 xmltooling::QName* m_qname;
71 SecurityPolicyRule* SAML_DLLLOCAL IgnoreRuleFactory(const DOMElement* const & e)
73 return new IgnoreRule(e);