Attribute filtering code.
[shibboleth/cpp-sp.git] / shibsp / attribute / filtering / BasicFilteringContext.h
1 /*
2  *  Copyright 2001-2007 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  * @file shibsp/attribute/filtering/BasicFilteringContext.h
19  * 
20  * A trivial FilteringContext implementation.
21  */
22
23 #ifndef __shibsp_basicfiltctx_h__
24 #define __shibsp_basicfiltctx_h__
25
26 #include <shibsp/attribute/filtering/FilteringContext.h>
27
28 namespace shibsp {
29
30     class SHIBSP_API BasicFilteringContext : public FilteringContext
31     {
32     public:
33         /**
34          * Constructor.
35          *
36          * @param app   reference to Application
37          * @param role  metadata role of attribute issuer, if any
38          */
39         BasicFilteringContext(const Application& app, const opensaml::saml2md::RoleDescriptor* role)
40                 : m_app(app), m_role(role), m_issuer(NULL) {
41             if (role)
42                 m_issuer = dynamic_cast<opensaml::saml2md::EntityDescriptor*>(role->getParent())->getEntityID();
43         }
44
45         virtual ~BasicFilteringContext() {}
46
47         const Application& getApplication() const {
48             return m_app;
49         }
50         const XMLCh* getAttributeRequester() const {
51             return m_app.getXMLString("entityID").second;
52         }
53         const XMLCh* getAttributeIssuer() const {
54             return m_issuer;
55         }
56         const opensaml::saml2md::RoleDescriptor* getAttributeRequesterMetadata() const {
57             return NULL;
58         }
59         const opensaml::saml2md::RoleDescriptor* getAttributeIssuerMetadata() const {
60             return m_role;
61         }
62
63     private:
64         const Application& m_app;
65         const opensaml::saml2md::RoleDescriptor* m_role;
66         const XMLCh* m_issuer;
67     };
68 };
69
70 #endif /* __shibsp_basicfiltctx_h__ */