2 * Copyright 2001-2010 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file shibsp/Application.h
20 * Interface to a Shibboleth Application instance.
23 #ifndef __shibsp_app_h__
24 #define __shibsp_app_h__
26 #include <shibsp/util/PropertySet.h>
31 # include <saml/binding/MessageEncoder.h>
34 namespace xmltooling {
35 class XMLTOOL_API CredentialResolver;
36 class XMLTOOL_API RWLock;
37 class XMLTOOL_API SOAPTransport;
38 class XMLTOOL_API StorageService;
39 class XMLTOOL_API TrustEngine;
44 class SAML_API SecurityPolicyRule;
46 class SAML_API MetadataProvider;
54 class SHIBSP_API AttributeExtractor;
55 class SHIBSP_API AttributeFilter;
56 class SHIBSP_API AttributeResolver;
58 class SHIBSP_API Attribute;
59 class SHIBSP_API Handler;
60 class SHIBSP_API ServiceProvider;
61 class SHIBSP_API SessionInitiator;
62 class SHIBSP_API SPRequest;
64 #if defined (_MSC_VER)
65 #pragma warning( push )
66 #pragma warning( disable : 4251 )
70 * Interface to a Shibboleth Application instance.
72 * <p>An Application is a logical set of resources that act as a unit
73 * of session management and policy.
75 class SHIBSP_API Application : public virtual PropertySet
77 ,public virtual opensaml::MessageEncoder::ArtifactGenerator
80 MAKE_NONCOPYABLE(Application);
85 * @param sp parent ServiceProvider instance
87 Application(const ServiceProvider* sp);
89 /** Pointer to parent SP instance. */
90 const ServiceProvider* m_sp;
92 /** Shared lock for manipulating application state. */
93 mutable xmltooling::RWLock* m_lock;
95 /** Pairs of raw and normalized CGI header names to clear. */
96 mutable std::vector< std::pair<std::string,std::string> > m_unsetHeaders;
99 virtual ~Application();
102 * Returns the owning ServiceProvider instance.
104 * @return a locked ServiceProvider
106 const ServiceProvider& getServiceProvider() const;
109 * Returns the Application's ID.
113 virtual const char* getId() const;
116 * Returns a unique hash for the Application.
118 * @return a value resulting from a computation over the Application's configuration
120 virtual const char* getHash() const=0;
123 * Returns the name and cookie properties to use for this Application.
125 * @param prefix a value to prepend to the base cookie name
126 * @param lifetime if non-null, will be populated with a suggested lifetime for the cookie, or 0 if session-bound
127 * @return a pair containing the cookie name and the string to append to the cookie value
129 virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix, time_t* lifetime=nullptr) const;
133 * Returns a MetadataProvider for use with this Application.
135 * @param required true iff an exception should be thrown if no MetadataProvider is available
136 * @return a MetadataProvider instance, or nullptr
138 virtual opensaml::saml2md::MetadataProvider* getMetadataProvider(bool required=true) const=0;
141 * Returns a TrustEngine for use with this Application.
143 * @param required true iff an exception should be thrown if no TrustEngine is available
144 * @return a TrustEngine instance, or nullptr
146 virtual xmltooling::TrustEngine* getTrustEngine(bool required=true) const=0;
149 * Returns an AttributeExtractor for use with this Application.
151 * @return an AttributeExtractor, or nullptr
153 virtual AttributeExtractor* getAttributeExtractor() const=0;
156 * Returns an AttributeFilter for use with this Application.
158 * @return an AttributeFilter, or nullptr
160 virtual AttributeFilter* getAttributeFilter() const=0;
163 * Returns an AttributeResolver for use with this Application.
165 * @return an AttributeResolver, or nullptr
167 virtual AttributeResolver* getAttributeResolver() const=0;
170 * Returns the CredentialResolver instance associated with this Application.
172 * @return a CredentialResolver, or nullptr
174 virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
177 * Returns configuration properties governing security interactions with a peer.
179 * @param provider a peer entity's metadata
180 * @return the applicable PropertySet
182 virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
185 * Returns configuration properties governing security interactions with a named peer.
187 * @param entityID a peer name
188 * @return the applicable PropertySet
190 virtual const PropertySet* getRelyingParty(const XMLCh* entityID) const=0;
194 * Returns any additional audience values associated with this Application.
196 * @return additional audience values associated with the Application, or nullptr
198 virtual const std::vector<const XMLCh*>* getAudiences() const=0;
202 * Returns the designated notification URL, or an empty string if no more locations are specified.
204 * @param request requested URL to use to fill in missing pieces of notification URL
205 * @param front true iff front channel notification is desired, false iff back channel is desired
206 * @param index zero-based index of URL to return
207 * @return the designated URL, or an empty string
209 virtual std::string getNotificationURL(const char* request, bool front, unsigned int index) const=0;
212 * Returns an array of attribute IDs to use as a REMOTE_USER value, in order of preference.
214 * @return an array of attribute IDs, possibly empty
216 virtual const std::vector<std::string>& getRemoteUserAttributeIds() const=0;
219 * Ensures no value exists for a request header, allowing for application-specific customization.
221 * @param request SP request to modify
222 * @param rawname raw name of header to clear
223 * @param cginame CGI-equivalent name of header, <strong>MUST</strong> begin with "HTTP_".
225 virtual void clearHeader(SPRequest& request, const char* rawname, const char* cginame) const;
228 * Sets a value for a request header allowing for application-specific customization.
230 * @param request SP request to modify
231 * @param name name of header to set
232 * @param value value to set
234 virtual void setHeader(SPRequest& request, const char* name, const char* value) const;
237 * Returns a non-spoofable request header value allowing for application-specific customization.
239 * @param request SP request to access
240 * @param name the name of the secure header to return
241 * @return the header's value, or an empty string
243 virtual std::string getSecureHeader(const SPRequest& request, const char* name) const;
246 * Clears any headers that may be used to hold attributes after export.
248 * @param request SP request to clear
250 virtual void clearAttributeHeaders(SPRequest& request) const;
253 * Returns the default SessionInitiator when automatically requesting a session.
255 * @return the default SessionInitiator, or nullptr
257 virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
260 * Returns a SessionInitiator with a particular ID when automatically requesting a session.
262 * @param id an identifier unique to the Application
263 * @return the designated SessionInitiator, or nullptr
265 virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
268 * Returns the default AssertionConsumerService Handler
269 * for use in AuthnRequest messages.
271 * @return the default AssertionConsumerService, or nullptr
273 virtual const Handler* getDefaultAssertionConsumerService() const=0;
276 * Returns an AssertionConsumerService Handler with a particular index
277 * for use in AuthnRequest messages.
279 * @param index an index unique to an application
280 * @return the designated AssertionConsumerService, or nullptr
282 virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
285 * Returns an AssertionConsumerService Handler that supports
286 * a particular protocol "family" and optional binding.
288 * @param protocol a protocol identifier
289 * @param binding a binding identifier
290 * @return a matching AssertionConsumerService, or nullptr
292 virtual const Handler* getAssertionConsumerServiceByProtocol(const XMLCh* protocol, const char* binding=nullptr) const;
296 * Returns one or more AssertionConsumerService Handlers that support
297 * a particular protocol binding.
299 * @param binding a protocol binding identifier
300 * @return a set of qualifying AssertionConsumerServices
302 virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
305 * Returns the Handler associated with a particular path/location.
307 * @param path the PATH_INFO appended to the end of a base Handler location
308 * that invokes the Handler
309 * @return the mapped Handler, or nullptr
311 virtual const Handler* getHandler(const char* path) const=0;
314 * Returns all registered Handlers.
316 * @param handlers array to populate
318 virtual void getHandlers(std::vector<const Handler*>& handlers) const=0;
321 #if defined (_MSC_VER)
322 #pragma warning( pop )
327 #endif /* __shibsp_app_h__ */