6c66f57c7d7d5cacda060012e0b80d2c97fd9311
[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 attributes            attributes being filtered
38          * @param role                  metadata role of Attribute issuer, if any
39          * @param authncontext_class    method/category of authentication event, if known
40          * @param authncontext_decl     specifics of authentication event, if known
41          */
42         BasicFilteringContext(
43             const Application& app,
44             const std::vector<Attribute*>& attributes,
45             const opensaml::saml2md::RoleDescriptor* role=NULL,
46             const XMLCh* authncontext_class=NULL,
47             const XMLCh* authncontext_decl=NULL
48             ) : m_app(app), m_role(role), m_issuer(NULL), m_class(authncontext_class), m_decl(authncontext_decl) {
49             if (role)
50                 m_issuer = dynamic_cast<opensaml::saml2md::EntityDescriptor*>(role->getParent())->getEntityID();
51             for (std::vector<Attribute*>::const_iterator a = attributes.begin(); a != attributes.end(); ++a)
52                 m_attributes.insert(std::multimap<std::string,Attribute*>::value_type((*a)->getId(), *a));
53         }
54
55         virtual ~BasicFilteringContext() {}
56
57         const Application& getApplication() const {
58             return m_app;
59         }
60         const XMLCh* getAuthnContextClassRef() const {
61             return m_class;
62         }
63         const XMLCh* getAuthnContextDeclRef() const {
64             return m_decl;
65         }
66         const XMLCh* getAttributeRequester() const {
67             return m_app.getXMLString("entityID").second;
68         }
69         const XMLCh* getAttributeIssuer() const {
70             return m_issuer;
71         }
72         const opensaml::saml2md::RoleDescriptor* getAttributeRequesterMetadata() const {
73             return NULL;
74         }
75         const opensaml::saml2md::RoleDescriptor* getAttributeIssuerMetadata() const {
76             return m_role;
77         }
78         const std::multimap<std::string,Attribute*>& getAttributes() const {
79             return m_attributes;
80         }
81
82     private:
83         const Application& m_app;
84         std::multimap<std::string,Attribute*> m_attributes;
85         const opensaml::saml2md::RoleDescriptor* m_role;
86         const XMLCh* m_issuer;
87         const XMLCh* m_class;
88         const XMLCh* m_decl;
89     };
90 };
91
92 #endif /* __shibsp_basicfiltctx_h__ */