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/SPConfig.h
20 * Library configuration.
23 #ifndef __shibsp_config_h__
24 #define __shibsp_config_h__
26 #include <shibsp/base.h>
30 # include <saml/binding/MessageDecoder.h>
31 # include <saml/binding/MessageEncoder.h>
33 #include <xmltooling/PluginManager.h>
34 #include <xmltooling/QName.h>
35 #include <xercesc/dom/DOM.hpp>
39 * Shibboleth Service Provider Library
43 class SHIBSP_API AccessControl;
44 class SHIBSP_API Handler;
45 class SHIBSP_API ListenerService;
46 class SHIBSP_API RequestMapper;
47 class SHIBSP_API ProtocolProvider;
48 class SHIBSP_API ServiceProvider;
49 class SHIBSP_API SessionCache;
50 class SHIBSP_API SessionInitiator;
53 class SHIBSP_API AttributeDecoder;
54 class SHIBSP_API AttributeExtractor;
55 class SHIBSP_API AttributeFilter;
56 class SHIBSP_API AttributeResolver;
57 class SHIBSP_API FilterPolicyContext;
58 class SHIBSP_API MatchFunctor;
59 class SHIBSP_API SecurityPolicyProvider;
62 #if defined (_MSC_VER)
63 #pragma warning( push )
64 #pragma warning( disable : 4250 4251 )
68 * Singleton object that manages library startup/shutdown.
70 class SHIBSP_API SPConfig
72 MAKE_NONCOPYABLE(SPConfig);
79 * Returns the global configuration object for the library.
81 * @return reference to the global library configuration object
83 static SPConfig& getConfig();
86 * Bitmask values representing subsystems of the library.
95 AttributeResolution = 32,
105 * Set a bitmask of subsystems to activate.
107 * @param enabled bitmask of component constants
109 void setFeatures(unsigned long enabled);
112 * Test whether a subsystem is enabled.
114 * @param feature subsystem/component to test
115 * @return true iff feature is enabled
117 bool isEnabled(components_t feature);
120 * Initializes library
122 * Each process using the library MUST call this function exactly once
123 * before using any library classes.
125 * @param catalog_path delimited set of schema catalog files to load
126 * @param inst_prefix installation prefix for software
127 * @return true iff initialization was successful
129 virtual bool init(const char* catalog_path=nullptr, const char* inst_prefix=nullptr);
134 * Each process using the library SHOULD call this function exactly once
135 * before terminating itself.
140 * Sets the global ServiceProvider instance.
141 * This method must be externally synchronized with any code that uses the object.
142 * Any previously set object is destroyed.
144 * @param serviceProvider new ServiceProvider instance to store
146 void setServiceProvider(ServiceProvider* serviceProvider);
149 * Returns the global ServiceProvider instance.
151 * @return global ServiceProvider or nullptr
153 ServiceProvider* getServiceProvider() const;
156 * Instantiates and installs a ServiceProvider instance based on an XML configuration string
157 * or a configuration pathname.
159 * @param config a snippet of XML to parse (it <strong>MUST</strong> contain a type attribute) or a pathname
160 * @param rethrow true iff caught exceptions should be rethrown instead of just returning the status
161 * @return true iff instantiation was successful
163 virtual bool instantiate(const char* config=nullptr, bool rethrow=false);
167 * Sets the global ArtifactResolver instance.
169 * <p>This method must be externally synchronized with any code that uses the object.
170 * Any previously set object is destroyed.
172 * @param artifactResolver new ArtifactResolver instance to store
174 void setArtifactResolver(opensaml::MessageDecoder::ArtifactResolver* artifactResolver);
177 * Returns the global ArtifactResolver instance.
179 * @return global ArtifactResolver or nullptr
181 const opensaml::MessageDecoder::ArtifactResolver* getArtifactResolver() const;
184 /** Separator for serialized values of multi-valued attributes. */
185 char attribute_value_delimeter;
188 * Manages factories for AccessControl plugins.
190 xmltooling::PluginManager<AccessControl,std::string,const xercesc::DOMElement*> AccessControlManager;
194 * Manages factories for AttributeDecoder plugins.
196 xmltooling::PluginManager<AttributeDecoder,xmltooling::QName,const xercesc::DOMElement*> AttributeDecoderManager;
199 * Manages factories for AttributeExtractor plugins.
201 xmltooling::PluginManager<AttributeExtractor,std::string,const xercesc::DOMElement*> AttributeExtractorManager;
204 * Manages factories for AttributeFilter plugins.
206 xmltooling::PluginManager<AttributeFilter,std::string,const xercesc::DOMElement*> AttributeFilterManager;
209 * Manages factories for AttributeResolver plugins.
211 xmltooling::PluginManager<AttributeResolver,std::string,const xercesc::DOMElement*> AttributeResolverManager;
214 * Manages factories for MatchFunctor plugins.
216 xmltooling::PluginManager< MatchFunctor,xmltooling::QName,std::pair<const FilterPolicyContext*,const xercesc::DOMElement*> > MatchFunctorManager;
219 * Manages factories for SecurityPolicyProvider plugins.
221 xmltooling::PluginManager<SecurityPolicyProvider,std::string,const xercesc::DOMElement*> SecurityPolicyProviderManager;
225 * Manages factories for Handler plugins that implement ArtifactResolutionService functionality.
227 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > ArtifactResolutionServiceManager;
230 * Manages factories for Handler plugins that implement AssertionConsumerService functionality.
232 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > AssertionConsumerServiceManager;
235 * Manages factories for Handler plugins that implement customized functionality.
237 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > HandlerManager;
240 * Manages factories for ListenerService plugins.
242 xmltooling::PluginManager<ListenerService,std::string,const xercesc::DOMElement*> ListenerServiceManager;
245 * Manages factories for Handler plugins that implement LogoutInitiator functionality.
247 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > LogoutInitiatorManager;
250 * Manages factories for Handler plugins that implement ManageNameIDService functionality.
252 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > ManageNameIDServiceManager;
255 * Manages factories for ProtocolProvider plugins.
257 xmltooling::PluginManager<ProtocolProvider,std::string,const xercesc::DOMElement*> ProtocolProviderManager;
260 * Manages factories for RequestMapper plugins.
262 xmltooling::PluginManager<RequestMapper,std::string,const xercesc::DOMElement*> RequestMapperManager;
265 * Manages factories for ServiceProvider plugins.
267 xmltooling::PluginManager<ServiceProvider,std::string,const xercesc::DOMElement*> ServiceProviderManager;
270 * Manages factories for SessionCache plugins.
272 xmltooling::PluginManager<SessionCache,std::string,const xercesc::DOMElement*> SessionCacheManager;
275 * Manages factories for Handler plugins that implement SessionInitiator functionality.
277 xmltooling::PluginManager< SessionInitiator,std::string,std::pair<const xercesc::DOMElement*,const char*> > SessionInitiatorManager;
280 * Manages factories for Handler plugins that implement SingleLogoutService functionality.
282 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > SingleLogoutServiceManager;
285 /** Global ServiceProvider instance. */
286 ServiceProvider* m_serviceProvider;
289 /** Global ArtifactResolver instance. */
290 opensaml::MessageDecoder::ArtifactResolver* m_artifactResolver;
294 unsigned long m_features;
295 xercesc::DOMDocument* m_configDoc;
298 #if defined (_MSC_VER)
299 #pragma warning( pop )
304 #endif /* __shibsp_config_h__ */