Fixed attribute-based functors.
[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          * @param required  true iff an exception should be thrown if no MetadataProvider is available
87          * @return  a MetadataProvider instance, or NULL
88          */
89         virtual opensaml::saml2md::MetadataProvider* getMetadataProvider(bool required=true) const=0;
90         
91         /**
92          * Returns a TrustEngine for use with this Application.
93          * 
94          * @param required  true iff an exception should be thrown if no TrustEngine is available
95          * @return  a TrustEngine instance, or NULL
96          */
97         virtual xmltooling::TrustEngine* getTrustEngine(bool required=true) const=0;
98
99         /**
100          * Returns an AttributeExtractor for use with this Application.
101          * 
102          * @return  an AttributeExtractor, or NULL
103          */
104         virtual AttributeExtractor* getAttributeExtractor() const=0;
105
106         /**
107          * Returns an AttributeFilter for use with this Application.
108          * 
109          * @return  an AttributeFilter, or NULL
110          */
111         virtual AttributeFilter* getAttributeFilter() const=0;
112
113         /**
114          * Returns an AttributeResolver for use with this Application.
115          * 
116          * @return  an AttributeResolver, or NULL
117          */
118         virtual AttributeResolver* getAttributeResolver() const=0;
119
120         /**\r
121          * Returns a set of attribute IDs to use as a REMOTE_USER value.\r
122          * <p>The first attribute with a value (and only a single value) will be used.\r
123          *\r
124          * @return  a set of attribute IDs, or an empty set\r
125          */\r
126         virtual const std::set<std::string>& getRemoteUserAttributeIds() const=0;
127
128         /**
129          * Returns the CredentialResolver instance associated with this Application.
130          * 
131          * @return  a CredentialResolver, or NULL
132          */
133         virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
134
135         /**
136          * Returns configuration properties governing security interactions with a peer.
137          * 
138          * @param provider  a peer entity's metadata
139          * @return  the applicable PropertySet
140          */
141         virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
142
143         /**
144          * Returns the default SessionInitiator when automatically requesting a session.
145          * 
146          * @return the default SessionInitiator, or NULL
147          */
148         virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
149         
150         /**
151          * Returns a SessionInitiator with a particular ID when automatically requesting a session.
152          * 
153          * @param id    an identifier unique to the Application
154          * @return the designated SessionInitiator, or NULL
155          */
156         virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
157         
158         /**
159          * Returns the default AssertionConsumerService Handler
160          * for use in AuthnRequest messages.
161          * 
162          * @return the default AssertionConsumerService, or NULL
163          */
164         virtual const Handler* getDefaultAssertionConsumerService() const=0;
165
166         /**
167          * Returns an AssertionConsumerService Handler with a particular index
168          * for use in AuthnRequest messages.
169          * 
170          * @param index an index unique to an application
171          * @return the designated AssertionConsumerService, or NULL
172          */
173         virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
174
175         /**
176          * Returns one or more AssertionConsumerService Handlers that support
177          * a particular protocol binding.
178          * 
179          * @param binding   a protocol binding identifier
180          * @return a set of qualifying AssertionConsumerServices
181          */
182         virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
183         
184         /**
185          * Returns the Handler associated with a particular path/location.
186          * 
187          * @param path  the PATH_INFO appended to the end of a base Handler location
188          *              that invokes the Handler
189          * @return the mapped Handler, or NULL 
190          */
191         virtual const Handler* getHandler(const char* path) const=0;
192
193         /**
194          * Returns the set of audience values associated with this Application.
195          * 
196          * @return set of audience values associated with the Application
197          */
198         virtual const std::vector<const XMLCh*>& getAudiences() const=0;
199     };
200 };
201
202 #endif /* __shibsp_app_h__ */