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/SPConfig.h
24 * Library configuration.
27 #ifndef __shibsp_config_h__
28 #define __shibsp_config_h__
30 #include <shibsp/base.h>
34 # include <shibsp/TransactionLog.h>
35 # include <saml/binding/MessageDecoder.h>
36 # include <saml/binding/MessageEncoder.h>
38 #include <xmltooling/PluginManager.h>
39 #include <xmltooling/QName.h>
40 #include <xercesc/dom/DOM.hpp>
44 * Shibboleth Service Provider Library
48 class SHIBSP_API AccessControl;
49 class SHIBSP_API Handler;
50 class SHIBSP_API ListenerService;
51 class SHIBSP_API RequestMapper;
52 class SHIBSP_API ProtocolProvider;
53 class SHIBSP_API ServiceProvider;
54 class SHIBSP_API SessionCache;
55 class SHIBSP_API SessionInitiator;
58 class SHIBSP_API AttributeDecoder;
59 class SHIBSP_API AttributeExtractor;
60 class SHIBSP_API AttributeFilter;
61 class SHIBSP_API AttributeResolver;
62 class SHIBSP_API FilterPolicyContext;
63 class SHIBSP_API MatchFunctor;
64 class SHIBSP_API SecurityPolicyProvider;
67 #if defined (_MSC_VER)
68 #pragma warning( push )
69 #pragma warning( disable : 4250 4251 )
73 * Singleton object that manages library startup/shutdown.
75 class SHIBSP_API SPConfig
77 MAKE_NONCOPYABLE(SPConfig);
84 * Returns the global configuration object for the library.
86 * @return reference to the global library configuration object
88 static SPConfig& getConfig();
91 * Bitmask values representing subsystems of the library.
100 AttributeResolution = 32,
110 * Set a bitmask of subsystems to activate.
112 * @param enabled bitmask of component constants
114 void setFeatures(unsigned long enabled);
118 * Gets the bitmask of subsystems being activated.
120 * @return bitmask of component constants
122 unsigned long getFeatures() const;
125 * Test whether a subsystem is enabled.
127 * @param feature subsystem/component to test
128 * @return true iff feature is enabled
130 bool isEnabled(components_t feature) const;
133 * Initializes library
135 * Each process using the library MUST call this function exactly once
136 * before using any library classes.
138 * @param catalog_path delimited set of schema catalog files to load
139 * @param inst_prefix installation prefix for software
140 * @return true iff initialization was successful
142 virtual bool init(const char* catalog_path=nullptr, const char* inst_prefix=nullptr);
147 * Each process using the library SHOULD call this function exactly once
148 * before terminating itself.
153 * Sets the global ServiceProvider instance.
154 * This method must be externally synchronized with any code that uses the object.
155 * Any previously set object is destroyed.
157 * @param serviceProvider new ServiceProvider instance to store
159 void setServiceProvider(ServiceProvider* serviceProvider);
162 * Returns the global ServiceProvider instance.
164 * @return global ServiceProvider or nullptr
166 ServiceProvider* getServiceProvider() const;
169 * Instantiates and installs a ServiceProvider instance based on an XML configuration string
170 * or a configuration pathname.
172 * @param config a snippet of XML to parse (it <strong>MUST</strong> contain a type attribute) or a pathname
173 * @param rethrow true iff caught exceptions should be rethrown instead of just returning the status
174 * @return true iff instantiation was successful
176 virtual bool instantiate(const char* config=nullptr, bool rethrow=false);
180 * Sets the global ArtifactResolver instance.
182 * <p>This method must be externally synchronized with any code that uses the object.
183 * Any previously set object is destroyed.
185 * @param artifactResolver new ArtifactResolver instance to store
187 void setArtifactResolver(opensaml::MessageDecoder::ArtifactResolver* artifactResolver);
190 * Returns the global ArtifactResolver instance.
192 * @return global ArtifactResolver or nullptr
194 const opensaml::MessageDecoder::ArtifactResolver* getArtifactResolver() const;
197 /** Separator for serialized values of multi-valued attributes. */
198 char attribute_value_delimeter;
201 * Manages factories for AccessControl plugins.
203 xmltooling::PluginManager<AccessControl,std::string,const xercesc::DOMElement*> AccessControlManager;
207 * Manages factories for AttributeDecoder plugins.
209 xmltooling::PluginManager<AttributeDecoder,xmltooling::QName,const xercesc::DOMElement*> AttributeDecoderManager;
212 * Manages factories for AttributeExtractor plugins.
214 xmltooling::PluginManager<AttributeExtractor,std::string,const xercesc::DOMElement*> AttributeExtractorManager;
217 * Manages factories for AttributeFilter plugins.
219 xmltooling::PluginManager<AttributeFilter,std::string,const xercesc::DOMElement*> AttributeFilterManager;
222 * Manages factories for AttributeResolver plugins.
224 xmltooling::PluginManager<AttributeResolver,std::string,const xercesc::DOMElement*> AttributeResolverManager;
227 * Manages factories for Event plugins.
229 xmltooling::PluginManager<TransactionLog::Event,std::string,void*> EventManager;
232 * Manages factories for MatchFunctor plugins.
234 xmltooling::PluginManager< MatchFunctor,xmltooling::QName,std::pair<const FilterPolicyContext*,const xercesc::DOMElement*> > MatchFunctorManager;
237 * Manages factories for SecurityPolicyProvider plugins.
239 xmltooling::PluginManager<SecurityPolicyProvider,std::string,const xercesc::DOMElement*> SecurityPolicyProviderManager;
243 * Manages factories for Handler plugins that implement ArtifactResolutionService functionality.
245 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > ArtifactResolutionServiceManager;
248 * Manages factories for Handler plugins that implement AssertionConsumerService functionality.
250 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > AssertionConsumerServiceManager;
253 * Manages factories for Handler plugins that implement customized functionality.
255 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > HandlerManager;
258 * Manages factories for ListenerService plugins.
260 xmltooling::PluginManager<ListenerService,std::string,const xercesc::DOMElement*> ListenerServiceManager;
263 * Manages factories for Handler plugins that implement LogoutInitiator functionality.
265 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > LogoutInitiatorManager;
268 * Manages factories for Handler plugins that implement ManageNameIDService functionality.
270 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > ManageNameIDServiceManager;
273 * Manages factories for ProtocolProvider plugins.
275 xmltooling::PluginManager<ProtocolProvider,std::string,const xercesc::DOMElement*> ProtocolProviderManager;
278 * Manages factories for RequestMapper plugins.
280 xmltooling::PluginManager<RequestMapper,std::string,const xercesc::DOMElement*> RequestMapperManager;
283 * Manages factories for ServiceProvider plugins.
285 xmltooling::PluginManager<ServiceProvider,std::string,const xercesc::DOMElement*> ServiceProviderManager;
288 * Manages factories for SessionCache plugins.
290 xmltooling::PluginManager<SessionCache,std::string,const xercesc::DOMElement*> SessionCacheManager;
293 * Manages factories for Handler plugins that implement SessionInitiator functionality.
295 xmltooling::PluginManager< SessionInitiator,std::string,std::pair<const xercesc::DOMElement*,const char*> > SessionInitiatorManager;
298 * Manages factories for Handler plugins that implement SingleLogoutService functionality.
300 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > SingleLogoutServiceManager;
304 * Determine whether messages should be digitally signed or encrypted based on the setting and endpoint.
306 * @param setting the applicable "signing" or "encryption" property in effect
307 * @param isUserAgentPresent true iff the user agent is mediating the exchange
308 * @param URL of endpoint to receive message
309 * @return whether requests should be digitally signed or encrypted
311 static bool shouldSignOrEncrypt(const char* setting, const char* endpoint, bool isUserAgentPresent);
315 /** Global ServiceProvider instance. */
316 ServiceProvider* m_serviceProvider;
319 /** Global ArtifactResolver instance. */
320 opensaml::MessageDecoder::ArtifactResolver* m_artifactResolver;
324 unsigned long m_features;
325 xercesc::DOMDocument* m_configDoc;
328 #if defined (_MSC_VER)
329 #pragma warning( pop )
334 #endif /* __shibsp_config_h__ */