Implement artifact generation, start work on resolution support.
[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
28 #include <set>
29 #ifndef SHIBSP_LITE
30 # include <saml/binding/MessageEncoder.h>
31 # include <saml/saml2/metadata/MetadataProvider.h>
32 # include <xmltooling/security/CredentialResolver.h>
33 # include <xmltooling/security/TrustEngine.h>
34 #endif
35
36 namespace shibsp {
37     
38 #ifndef SHIBSP_LITE
39     class SHIBSP_API AttributeExtractor;
40     class SHIBSP_API AttributeFilter;
41     class SHIBSP_API AttributeResolver;
42 #endif
43     class SHIBSP_API Handler;
44     class SHIBSP_API ServiceProvider;
45     class SHIBSP_API SessionInitiator;
46     class SHIBSP_API SPRequest;
47
48     /**
49      * Interface to a Shibboleth Application instance.
50      * 
51      * <p>An Application is a logical set of resources that act as a unit
52      * of session management and policy.
53      */
54     class SHIBSP_API Application : public virtual PropertySet
55 #ifndef SHIBSP_LITE
56         ,public virtual opensaml::MessageEncoder::ArtifactGenerator
57 #endif
58     {
59         MAKE_NONCOPYABLE(Application);
60     protected:
61         Application() {}
62     public:
63         virtual ~Application() {}
64
65         /**
66          * Returns the owning ServiceProvider instance.
67          *
68          * @return a locked ServiceProvider
69          */
70         virtual const ServiceProvider& getServiceProvider() const=0;
71
72         /**
73          * Returns the Application's ID.
74          * 
75          * @return  the ID
76          */        
77         virtual const char* getId() const=0;
78
79         /**
80          * Returns a unique hash for the Application.
81          * 
82          * @return a value resulting from a computation over the Application's configuration
83          */
84         virtual const char* getHash() const=0;
85
86         /**
87          * Returns the name and cookie properties to use for this Application.
88          * 
89          * @param prefix    a value to prepend to the base cookie name
90          * @return  a pair containing the cookie name and the string to append to the cookie value
91          */
92         virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix) const;
93
94 #ifndef SHIBSP_LITE
95         /**
96          * Returns a MetadataProvider for use with this Application.
97          * 
98          * @param required  true iff an exception should be thrown if no MetadataProvider is available
99          * @return  a MetadataProvider instance, or NULL
100          */
101         virtual opensaml::saml2md::MetadataProvider* getMetadataProvider(bool required=true) const=0;
102         
103         /**
104          * Returns a TrustEngine for use with this Application.
105          * 
106          * @param required  true iff an exception should be thrown if no TrustEngine is available
107          * @return  a TrustEngine instance, or NULL
108          */
109         virtual xmltooling::TrustEngine* getTrustEngine(bool required=true) const=0;
110
111         /**
112          * Returns an AttributeExtractor for use with this Application.
113          * 
114          * @return  an AttributeExtractor, or NULL
115          */
116         virtual AttributeExtractor* getAttributeExtractor() const=0;
117
118         /**
119          * Returns an AttributeFilter for use with this Application.
120          * 
121          * @return  an AttributeFilter, or NULL
122          */
123         virtual AttributeFilter* getAttributeFilter() const=0;
124
125         /**
126          * Returns an AttributeResolver for use with this Application.
127          * 
128          * @return  an AttributeResolver, or NULL
129          */
130         virtual AttributeResolver* getAttributeResolver() const=0;
131
132         /**
133          * Returns the CredentialResolver instance associated with this Application.
134          * 
135          * @return  a CredentialResolver, or NULL
136          */
137         virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
138
139         /**
140          * Returns configuration properties governing security interactions with a peer.
141          * 
142          * @param provider  a peer entity's metadata
143          * @return  the applicable PropertySet
144          */
145         virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
146
147         /**
148          * Returns the set of audience values associated with this Application.
149          * 
150          * @return set of audience values associated with the Application
151          */
152         virtual const std::vector<const XMLCh*>& getAudiences() const=0;
153 #endif
154
155         /**
156          * Returns a set of attribute IDs to use as a REMOTE_USER value.
157          * <p>The first attribute with a value (and only a single value) will be used.
158          *
159          * @return  a set of attribute IDs, or an empty set
160          */
161         virtual const std::set<std::string>& getRemoteUserAttributeIds() const=0;
162
163         /**
164          * Clears any headers that may be used to hold attributes after export.
165          *
166          * @param request   SP request to clear
167          */
168         virtual void clearAttributeHeaders(SPRequest& request) const=0;
169
170         /**
171          * Returns the default SessionInitiator when automatically requesting a session.
172          * 
173          * @return the default SessionInitiator, or NULL
174          */
175         virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
176         
177         /**
178          * Returns a SessionInitiator with a particular ID when automatically requesting a session.
179          * 
180          * @param id    an identifier unique to the Application
181          * @return the designated SessionInitiator, or NULL
182          */
183         virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
184
185         /**
186          * Returns the default AssertionConsumerService Handler
187          * for use in AuthnRequest messages.
188          * 
189          * @return the default AssertionConsumerService, or NULL
190          */
191         virtual const Handler* getDefaultAssertionConsumerService() const=0;
192
193         /**
194          * Returns an AssertionConsumerService Handler with a particular index
195          * for use in AuthnRequest messages.
196          * 
197          * @param index an index unique to an application
198          * @return the designated AssertionConsumerService, or NULL
199          */
200         virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
201
202         /**
203          * Returns one or more AssertionConsumerService Handlers that support
204          * a particular protocol binding.
205          * 
206          * @param binding   a protocol binding identifier
207          * @return a set of qualifying AssertionConsumerServices
208          */
209         virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
210         
211         /**
212          * Returns the Handler associated with a particular path/location.
213          * 
214          * @param path  the PATH_INFO appended to the end of a base Handler location
215          *              that invokes the Handler
216          * @return the mapped Handler, or NULL 
217          */
218         virtual const Handler* getHandler(const char* path) const=0;
219     };
220 };
221
222 #endif /* __shibsp_app_h__ */