0fe25ce016284259622cd3748afacfb525b75d84
[shibboleth/cpp-opensaml.git] / saml / binding / impl / NullSecurityRule.cpp
1 /*
2  *  Copyright 2001-2009 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * NullSecurityRule.cpp
19  * 
20  * SecurityPolicyRule that "disables" security. 
21  */
22
23 #include "internal.h"
24 #include "binding/SecurityPolicyRule.h"
25
26 #include <xmltooling/logging.h>
27
28 using namespace opensaml;
29 using namespace xmltooling::logging;
30 using namespace xmltooling;
31 using namespace std;
32
33 namespace opensaml {
34     class SAML_DLLLOCAL NullSecurityRule : public SecurityPolicyRule
35     {
36     public:
37         NullSecurityRule(const DOMElement* e) : m_log(Category::getInstance(SAML_LOGCAT".SecurityPolicyRule.NullSecurity")) {}
38         virtual ~NullSecurityRule() {}
39         
40         const char* getType() const {
41             return NULLSECURITY_POLICY_RULE;
42         }
43         bool evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const {
44             m_log.warn("security enforced using NULL policy rule, be sure you know what you're doing");
45             policy.setAuthenticated(true);
46             return true;
47         }
48
49     private:
50         Category& m_log;
51     };
52
53     SecurityPolicyRule* SAML_DLLLOCAL NullSecurityRuleFactory(const DOMElement* const & e)
54     {
55         return new NullSecurityRule(e);
56     }
57 };