2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
24 * SecurityPolicyRule that ignores a message while indicating "success".
28 #include "exceptions.h"
29 #include "binding/SecurityPolicyRule.h"
32 #include <xmltooling/logging.h>
33 #include <xmltooling/QName.h>
34 #include <xmltooling/XMLObject.h>
35 #include <xmltooling/util/XMLHelper.h>
37 using namespace opensaml;
38 using namespace xmltooling::logging;
39 using namespace xmltooling;
44 class SAML_DLLLOCAL IgnoreRule : public SecurityPolicyRule
47 IgnoreRule(const DOMElement* e)
48 : m_log(Category::getInstance(SAML_LOGCAT ".SecurityPolicyRule.Ignore")), m_qname(XMLHelper::getNodeValueAsQName(e)) {
50 throw SecurityPolicyException("No schema type or element name supplied to Ignore rule.");
52 virtual ~IgnoreRule() {}
54 const char* getType() const {
55 return IGNORE_POLICY_RULE;
57 bool evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const {
58 if (message.getSchemaType()) {
59 if (*m_qname.get() != *(message.getSchemaType()))
61 m_log.info("ignoring condition with type (%s)", message.getSchemaType()->toString().c_str());
64 if (*m_qname.get() != message.getElementQName())
66 m_log.info("ignoring condition (%s)", message.getElementQName().toString().c_str());
73 auto_ptr<xmltooling::QName> m_qname;
76 SecurityPolicyRule* SAML_DLLLOCAL IgnoreRuleFactory(const DOMElement* const & e)
78 return new IgnoreRule(e);