Attribute filtering code.
[shibboleth/sp.git] / shibsp / Application.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/Application.h
19  * 
20  * Interface to a Shibboleth Application instance.
21  */
22
23 #ifndef __shibsp_app_h__
24 #define __shibsp_app_h__
25
26 #include <shibsp/util/PropertySet.h>
27 #include <saml/saml2/metadata/MetadataProvider.h>
28 #include <xmltooling/security/CredentialResolver.h>
29 #include <xmltooling/security/TrustEngine.h>
30
31 namespace shibsp {
32     
33     class SHIBSP_API AttributeExtractor;
34     class SHIBSP_API AttributeFilter;
35     class SHIBSP_API AttributeResolver;
36     class SHIBSP_API Handler;
37     class SHIBSP_API ServiceProvider;
38     class SHIBSP_API SessionInitiator;
39
40     /**
41      * Interface to a Shibboleth Application instance.
42      * 
43      * <p>An Application is a logical set of resources that act as a unit
44      * of session management and policy.
45      */
46     class SHIBSP_API Application : public virtual PropertySet
47     {
48         MAKE_NONCOPYABLE(Application);
49     protected:
50         Application() {}
51     public:
52         virtual ~Application() {}
53
54         /**
55          * Returns the owning ServiceProvider instance.
56          *
57          * @return a locked ServiceProvider
58          */
59         virtual const ServiceProvider& getServiceProvider() const=0;
60
61         /**
62          * Returns the Application's ID.
63          * 
64          * @return  the ID
65          */        
66         virtual const char* getId() const=0;
67
68         /**
69          * Returns a unique hash for the Application.
70          * 
71          * @return a value resulting from a hash of the Application's ID  
72          */
73         virtual const char* getHash() const=0;
74
75         /**
76          * Returns the name and cookie properties to use for this Application.
77          * 
78          * @param prefix    a value to prepend to the base cookie name
79          * @return  a pair containing the cookie name and the string to append to the cookie value
80          */
81         virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix) const;
82
83         /**
84          * Returns a MetadataProvider for use with this Application.
85          * 
86          * @return  a MetadataProvider instance, or NULL
87          */
88         virtual opensaml::saml2md::MetadataProvider* getMetadataProvider() const=0;
89         
90         /**
91          * Returns a TrustEngine for use with this Application.
92          * 
93          * @return  a TrustEngine instance, or NULL
94          */
95         virtual xmltooling::TrustEngine* getTrustEngine() const=0;
96
97         /**
98          * Returns an AttributeExtractor for use with this Application.
99          * 
100          * @return  an AttributeExtractor, or NULL
101          */
102         virtual AttributeExtractor* getAttributeExtractor() const=0;
103
104         /**
105          * Returns an AttributeFilter for use with this Application.
106          * 
107          * @return  an AttributeFilter, or NULL
108          */
109         virtual AttributeFilter* getAttributeFilter() const=0;
110
111         /**
112          * Returns an AttributeResolver for use with this Application.
113          * 
114          * @return  an AttributeResolver, or NULL
115          */
116         virtual AttributeResolver* getAttributeResolver() const=0;
117
118         /**
119          * Returns the CredentialResolver instance associated with this Application.
120          * 
121          * @return  a CredentialResolver, or NULL
122          */
123         virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
124
125         /**
126          * Returns configuration properties governing security interactions with a peer.
127          * 
128          * @param provider  a peer entity's metadata
129          * @return  the applicable PropertySet
130          */
131         virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
132
133         /**
134          * Returns the default SessionInitiator when automatically requesting a session.
135          * 
136          * @return the default SessionInitiator, or NULL
137          */
138         virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
139         
140         /**
141          * Returns a SessionInitiator with a particular ID when automatically requesting a session.
142          * 
143          * @param id    an identifier unique to the Application
144          * @return the designated SessionInitiator, or NULL
145          */
146         virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
147         
148         /**
149          * Returns the default AssertionConsumerService Handler
150          * for use in AuthnRequest messages.
151          * 
152          * @return the default AssertionConsumerService, or NULL
153          */
154         virtual const Handler* getDefaultAssertionConsumerService() const=0;
155
156         /**
157          * Returns an AssertionConsumerService Handler with a particular index
158          * for use in AuthnRequest messages.
159          * 
160          * @param index an index unique to an application
161          * @return the designated AssertionConsumerService, or NULL
162          */
163         virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
164
165         /**
166          * Returns one or more AssertionConsumerService Handlers that support
167          * a particular protocol binding.
168          * 
169          * @param binding   a protocol binding identifier
170          * @return a set of qualifying AssertionConsumerServices
171          */
172         virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
173         
174         /**
175          * Returns the Handler associated with a particular path/location.
176          * 
177          * @param path  the PATH_INFO appended to the end of a base Handler location
178          *              that invokes the Handler
179          * @return the mapped Handler, or NULL 
180          */
181         virtual const Handler* getHandler(const char* path) const=0;
182
183         /**
184          * Returns the set of audience values associated with this Application.
185          * 
186          * @return set of audience values associated with the Application
187          */
188         virtual const std::vector<const XMLCh*>& getAudiences() const=0;
189     };
190 };
191
192 #endif /* __shibsp_app_h__ */