2 * Copyright 2001-2007 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/ServiceProvider.h
20 * Interface to a Shibboleth ServiceProvider instance.
23 #ifndef __shibsp_sp_h__
24 #define __shibsp_sp_h__
26 #include <shibsp/util/PropertySet.h>
28 # include <saml/binding/SecurityPolicyRule.h>
29 # include <xmltooling/soap/SOAPTransport.h>
30 # include <xmltooling/util/StorageService.h>
32 #include <xmltooling/Lockable.h>
36 class SHIBSP_API Application;
37 class SHIBSP_API Handler;
38 class SHIBSP_API ListenerService;
39 class SHIBSP_API RequestMapper;
40 class SHIBSP_API SessionCache;
41 class SHIBSP_API SPRequest;
42 class SHIBSP_API TemplateParameters;
44 class SHIBSP_API TransactionLog;
48 * Interface to a Shibboleth ServiceProvider instance.
50 * <p>A ServiceProvider exposes configuration and infrastructure services required
51 * by the SP implementation, allowing a flexible configuration format.
53 class SHIBSP_API ServiceProvider : public virtual xmltooling::Lockable, public virtual PropertySet
55 MAKE_NONCOPYABLE(ServiceProvider);
59 virtual ~ServiceProvider() {}
62 * Loads a configuration and prepares the instance for use.
64 * <p>Implemented as a separate method so that services can rely on
65 * other services while they initialize by accessing the ServiceProvider
66 * from the SPConfig singleton.
68 virtual void init()=0;
72 * Returns a TransactionLog instance.
74 * @return a TransactionLog instance
76 virtual TransactionLog* getTransactionLog() const=0;
79 * Returns a StorageService instance based on an ID.
81 * @param id a NULL-terminated key identifying the StorageService to the configuration
82 * @return a StorageService if available, or NULL
84 virtual xmltooling::StorageService* getStorageService(const char* id) const=0;
88 * Returns a SessionCache instance.
90 * @param required true iff an exception should be thrown if no SessionCache is available
91 * @return a SessionCache
93 virtual SessionCache* getSessionCache(bool required=true) const=0;
96 * Returns a ListenerService instance.
98 * @param required true iff an exception should be thrown if no ListenerService is available
99 * @return a ListenerService
101 virtual ListenerService* getListenerService(bool required=true) const=0;
105 * Returns the security policy settings for an identified policy.
107 * @param id identifies the policy to return
108 * @return a PropertySet
110 virtual const PropertySet* getPolicySettings(const char* id) const=0;
113 * Returns the security policy rules for an identified policy.
115 * @param id identifies the policy to return
116 * @return an array of policy rules
118 virtual const std::vector<const opensaml::SecurityPolicyRule*>& getPolicyRules(const char* id) const=0;
121 * Sets implementation-specific transport options for an identified policy.
123 * @param id identifies the policy to return
124 * @param transport a SOAPTransport object
125 * @return true iff all options were successfully set
127 virtual bool setTransportOptions(const char* id, xmltooling::SOAPTransport& transport) const=0;
131 * Returns a RequestMapper instance.
133 * @param required true iff an exception should be thrown if no RequestMapper is available
134 * @return a RequestMapper
136 virtual RequestMapper* getRequestMapper(bool required=true) const=0;
139 * Returns an Application instance matching the specified ID.
141 * @param applicationId the ID of the application
142 * @return pointer to the application, or NULL
144 virtual const Application* getApplication(const char* applicationId) const=0;
147 * Enforces requirements for an authenticated session.
149 * <p>If the return value's first member is true, then request processing should terminate
150 * with the second member as a status value. If false, processing can continue.
152 * @param request SP request interface
153 * @param handler true iff a request to a registered Handler location can be directly executed
154 * @return a pair containing a "request completed" indicator and a server-specific response code
156 virtual std::pair<bool,long> doAuthentication(SPRequest& request, bool handler=false) const;
159 * Enforces authorization requirements based on the authenticated session.
161 * <p>If the return value's first member is true, then request processing should terminate
162 * with the second member as a status value. If false, processing can continue.
164 * @param request SP request interface
165 * @return a pair containing a "request completed" indicator and a server-specific response code
167 virtual std::pair<bool,long> doAuthorization(SPRequest& request) const;
170 * Publishes session contents to the request in the form of headers or environment variables.
172 * <p>If the return value's first member is true, then request processing should terminate
173 * with the second member as a status value. If false, processing can continue.
175 * @param request SP request interface
176 * @param requireSession set to true iff an error should result if no session exists
177 * @return a pair containing a "request completed" indicator and a server-specific response code
179 virtual std::pair<bool,long> doExport(SPRequest& request, bool requireSession=true) const;
182 * Services requests for registered Handler locations.
184 * <p>If the return value's first member is true, then request processing should terminate
185 * with the second member as a status value. If false, processing can continue.
187 * @param request SP request interface
188 * @return a pair containing a "request completed" indicator and a server-specific response code
190 virtual std::pair<bool,long> doHandler(SPRequest& request) const;
194 * Registers ServiceProvider classes into the runtime.
196 void SHIBSP_API registerServiceProviders();
198 /** SP based on integrated XML and native server configuration. */
199 #define XML_SERVICE_PROVIDER "XML"
202 #endif /* __shibsp_sp_h__ */