2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file shibsp/Application.h
24 * Interface to a Shibboleth Application instance.
27 #ifndef __shibsp_app_h__
28 #define __shibsp_app_h__
30 #include <shibsp/util/PropertySet.h>
35 # include <saml/binding/MessageEncoder.h>
38 namespace xmltooling {
39 class XMLTOOL_API CredentialResolver;
40 class XMLTOOL_API RWLock;
41 class XMLTOOL_API SOAPTransport;
42 class XMLTOOL_API StorageService;
43 class XMLTOOL_API TrustEngine;
48 class SAML_API SecurityPolicyRule;
50 class SAML_API MetadataProvider;
58 class SHIBSP_API AttributeExtractor;
59 class SHIBSP_API AttributeFilter;
60 class SHIBSP_API AttributeResolver;
62 class SHIBSP_API Attribute;
63 class SHIBSP_API Handler;
64 class SHIBSP_API ServiceProvider;
65 class SHIBSP_API SessionInitiator;
66 class SHIBSP_API SPRequest;
68 #if defined (_MSC_VER)
69 #pragma warning( push )
70 #pragma warning( disable : 4251 )
74 * Interface to a Shibboleth Application instance.
76 * <p>An Application is a logical set of resources that act as a unit
77 * of session management and policy.
79 class SHIBSP_API Application : public virtual PropertySet
81 ,public virtual opensaml::MessageEncoder::ArtifactGenerator
84 MAKE_NONCOPYABLE(Application);
89 * @param sp parent ServiceProvider instance
91 Application(const ServiceProvider* sp);
93 /** Pointer to parent SP instance. */
94 const ServiceProvider* m_sp;
96 /** Shared lock for manipulating application state. */
97 mutable xmltooling::RWLock* m_lock;
99 /** Pairs of raw and normalized CGI header names to clear. */
100 mutable std::vector< std::pair<std::string,std::string> > m_unsetHeaders;
103 virtual ~Application();
106 * Returns the owning ServiceProvider instance.
108 * @return a locked ServiceProvider
110 const ServiceProvider& getServiceProvider() const;
113 * Returns the Application's ID.
117 virtual const char* getId() const;
120 * Returns a unique hash for the Application.
122 * @return a value resulting from a computation over the Application's configuration
124 virtual const char* getHash() const=0;
127 * Returns the name and cookie properties to use for this Application.
129 * @param prefix a value to prepend to the base cookie name
130 * @param lifetime if non-null, will be populated with a suggested lifetime for the cookie, or 0 if session-bound
131 * @return a pair containing the cookie name and the string to append to the cookie value
133 virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix, time_t* lifetime=nullptr) const;
137 * Returns a MetadataProvider for use with this Application.
139 * @param required true iff an exception should be thrown if no MetadataProvider is available
140 * @return a MetadataProvider instance, or nullptr
142 virtual opensaml::saml2md::MetadataProvider* getMetadataProvider(bool required=true) const=0;
145 * Returns a TrustEngine for use with this Application.
147 * @param required true iff an exception should be thrown if no TrustEngine is available
148 * @return a TrustEngine instance, or nullptr
150 virtual xmltooling::TrustEngine* getTrustEngine(bool required=true) const=0;
153 * Returns an AttributeExtractor for use with this Application.
155 * @return an AttributeExtractor, or nullptr
157 virtual AttributeExtractor* getAttributeExtractor() const=0;
160 * Returns an AttributeFilter for use with this Application.
162 * @return an AttributeFilter, or nullptr
164 virtual AttributeFilter* getAttributeFilter() const=0;
167 * Returns an AttributeResolver for use with this Application.
169 * @return an AttributeResolver, or nullptr
171 virtual AttributeResolver* getAttributeResolver() const=0;
174 * Returns the CredentialResolver instance associated with this Application.
176 * @return a CredentialResolver, or nullptr
178 virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
181 * Returns configuration properties governing security interactions with a peer.
183 * @param provider a peer entity's metadata
184 * @return the applicable PropertySet
186 virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
189 * Returns configuration properties governing security interactions with a named peer.
191 * @param entityID a peer name
192 * @return the applicable PropertySet
194 virtual const PropertySet* getRelyingParty(const XMLCh* entityID) const=0;
198 * Returns any additional audience values associated with this Application.
200 * @return additional audience values associated with the Application, or nullptr
202 virtual const std::vector<const XMLCh*>* getAudiences() const=0;
206 * Returns the designated notification URL, or an empty string if no more locations are specified.
208 * @param request requested URL to use to fill in missing pieces of notification URL
209 * @param front true iff front channel notification is desired, false iff back channel is desired
210 * @param index zero-based index of URL to return
211 * @return the designated URL, or an empty string
213 virtual std::string getNotificationURL(const char* request, bool front, unsigned int index) const=0;
216 * Returns an array of attribute IDs to use as a REMOTE_USER value, in order of preference.
218 * @return an array of attribute IDs, possibly empty
220 virtual const std::vector<std::string>& getRemoteUserAttributeIds() const=0;
223 * Ensures no value exists for a request header, allowing for application-specific customization.
225 * @param request SP request to modify
226 * @param rawname raw name of header to clear
227 * @param cginame CGI-equivalent name of header, <strong>MUST</strong> begin with "HTTP_".
229 virtual void clearHeader(SPRequest& request, const char* rawname, const char* cginame) const;
232 * Sets a value for a request header allowing for application-specific customization.
234 * @param request SP request to modify
235 * @param name name of header to set
236 * @param value value to set
238 virtual void setHeader(SPRequest& request, const char* name, const char* value) const;
241 * Returns a non-spoofable request header value allowing for application-specific customization.
243 * @param request SP request to access
244 * @param name the name of the secure header to return
245 * @return the header's value, or an empty string
247 virtual std::string getSecureHeader(const SPRequest& request, const char* name) const;
250 * Clears any headers that may be used to hold attributes after export.
252 * @param request SP request to clear
254 virtual void clearAttributeHeaders(SPRequest& request) const;
257 * Returns the default SessionInitiator when automatically requesting a session.
259 * @return the default SessionInitiator, or nullptr
261 virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
264 * Returns a SessionInitiator with a particular ID when automatically requesting a session.
266 * @param id an identifier unique to the Application
267 * @return the designated SessionInitiator, or nullptr
269 virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
272 * Returns the default AssertionConsumerService Handler
273 * for use in AuthnRequest messages.
275 * @return the default AssertionConsumerService, or nullptr
277 virtual const Handler* getDefaultAssertionConsumerService() const=0;
280 * Returns an AssertionConsumerService Handler with a particular index
281 * for use in AuthnRequest messages.
283 * @param index an index unique to an application
284 * @return the designated AssertionConsumerService, or nullptr
286 virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
289 * Returns an AssertionConsumerService Handler that supports
290 * a particular protocol "family" and optional binding.
292 * @param protocol a protocol identifier
293 * @param binding a binding identifier
294 * @return a matching AssertionConsumerService, or nullptr
296 virtual const Handler* getAssertionConsumerServiceByProtocol(const XMLCh* protocol, const char* binding=nullptr) const;
300 * Returns one or more AssertionConsumerService Handlers that support
301 * a particular protocol binding.
303 * @param binding a protocol binding identifier
304 * @return a set of qualifying AssertionConsumerServices
306 virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
309 * Returns the Handler associated with a particular path/location.
311 * @param path the PATH_INFO appended to the end of a base Handler location
312 * that invokes the Handler
313 * @return the mapped Handler, or nullptr
315 virtual const Handler* getHandler(const char* path) const=0;
318 * Returns all registered Handlers.
320 * @param handlers array to populate
322 virtual void getHandlers(std::vector<const Handler*>& handlers) const=0;
325 #if defined (_MSC_VER)
326 #pragma warning( pop )
331 #endif /* __shibsp_app_h__ */