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 <saml/binding/MessageDecoder.h>
35 # include <saml/binding/MessageEncoder.h>
37 #include <xmltooling/PluginManager.h>
38 #include <xmltooling/QName.h>
39 #include <xercesc/dom/DOM.hpp>
43 * Shibboleth Service Provider Library
47 class SHIBSP_API AccessControl;
48 class SHIBSP_API Handler;
49 class SHIBSP_API ListenerService;
50 class SHIBSP_API RequestMapper;
51 class SHIBSP_API ProtocolProvider;
52 class SHIBSP_API ServiceProvider;
53 class SHIBSP_API SessionCache;
54 class SHIBSP_API SessionInitiator;
57 class SHIBSP_API AttributeDecoder;
58 class SHIBSP_API AttributeExtractor;
59 class SHIBSP_API AttributeFilter;
60 class SHIBSP_API AttributeResolver;
61 class SHIBSP_API FilterPolicyContext;
62 class SHIBSP_API MatchFunctor;
63 class SHIBSP_API SecurityPolicyProvider;
66 #if defined (_MSC_VER)
67 #pragma warning( push )
68 #pragma warning( disable : 4250 4251 )
72 * Singleton object that manages library startup/shutdown.
74 class SHIBSP_API SPConfig
76 MAKE_NONCOPYABLE(SPConfig);
83 * Returns the global configuration object for the library.
85 * @return reference to the global library configuration object
87 static SPConfig& getConfig();
90 * Bitmask values representing subsystems of the library.
99 AttributeResolution = 32,
109 * Set a bitmask of subsystems to activate.
111 * @param enabled bitmask of component constants
113 void setFeatures(unsigned long enabled);
117 * Gets the bitmask of subsystems being activated.
119 * @return bitmask of component constants
121 unsigned long getFeatures() const;
124 * Test whether a subsystem is enabled.
126 * @param feature subsystem/component to test
127 * @return true iff feature is enabled
129 bool isEnabled(components_t feature) const;
132 * Initializes library
134 * Each process using the library MUST call this function exactly once
135 * before using any library classes.
137 * @param catalog_path delimited set of schema catalog files to load
138 * @param inst_prefix installation prefix for software
139 * @return true iff initialization was successful
141 virtual bool init(const char* catalog_path=nullptr, const char* inst_prefix=nullptr);
146 * Each process using the library SHOULD call this function exactly once
147 * before terminating itself.
152 * Sets the global ServiceProvider instance.
153 * This method must be externally synchronized with any code that uses the object.
154 * Any previously set object is destroyed.
156 * @param serviceProvider new ServiceProvider instance to store
158 void setServiceProvider(ServiceProvider* serviceProvider);
161 * Returns the global ServiceProvider instance.
163 * @return global ServiceProvider or nullptr
165 ServiceProvider* getServiceProvider() const;
168 * Instantiates and installs a ServiceProvider instance based on an XML configuration string
169 * or a configuration pathname.
171 * @param config a snippet of XML to parse (it <strong>MUST</strong> contain a type attribute) or a pathname
172 * @param rethrow true iff caught exceptions should be rethrown instead of just returning the status
173 * @return true iff instantiation was successful
175 virtual bool instantiate(const char* config=nullptr, bool rethrow=false);
179 * Sets the global ArtifactResolver instance.
181 * <p>This method must be externally synchronized with any code that uses the object.
182 * Any previously set object is destroyed.
184 * @param artifactResolver new ArtifactResolver instance to store
186 void setArtifactResolver(opensaml::MessageDecoder::ArtifactResolver* artifactResolver);
189 * Returns the global ArtifactResolver instance.
191 * @return global ArtifactResolver or nullptr
193 const opensaml::MessageDecoder::ArtifactResolver* getArtifactResolver() const;
196 /** Separator for serialized values of multi-valued attributes. */
197 char attribute_value_delimeter;
200 * Manages factories for AccessControl plugins.
202 xmltooling::PluginManager<AccessControl,std::string,const xercesc::DOMElement*> AccessControlManager;
206 * Manages factories for AttributeDecoder plugins.
208 xmltooling::PluginManager<AttributeDecoder,xmltooling::QName,const xercesc::DOMElement*> AttributeDecoderManager;
211 * Manages factories for AttributeExtractor plugins.
213 xmltooling::PluginManager<AttributeExtractor,std::string,const xercesc::DOMElement*> AttributeExtractorManager;
216 * Manages factories for AttributeFilter plugins.
218 xmltooling::PluginManager<AttributeFilter,std::string,const xercesc::DOMElement*> AttributeFilterManager;
221 * Manages factories for AttributeResolver plugins.
223 xmltooling::PluginManager<AttributeResolver,std::string,const xercesc::DOMElement*> AttributeResolverManager;
226 * Manages factories for MatchFunctor plugins.
228 xmltooling::PluginManager< MatchFunctor,xmltooling::QName,std::pair<const FilterPolicyContext*,const xercesc::DOMElement*> > MatchFunctorManager;
231 * Manages factories for SecurityPolicyProvider plugins.
233 xmltooling::PluginManager<SecurityPolicyProvider,std::string,const xercesc::DOMElement*> SecurityPolicyProviderManager;
237 * Manages factories for Handler plugins that implement ArtifactResolutionService functionality.
239 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > ArtifactResolutionServiceManager;
242 * Manages factories for Handler plugins that implement AssertionConsumerService functionality.
244 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > AssertionConsumerServiceManager;
247 * Manages factories for Handler plugins that implement customized functionality.
249 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > HandlerManager;
252 * Manages factories for ListenerService plugins.
254 xmltooling::PluginManager<ListenerService,std::string,const xercesc::DOMElement*> ListenerServiceManager;
257 * Manages factories for Handler plugins that implement LogoutInitiator functionality.
259 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > LogoutInitiatorManager;
262 * Manages factories for Handler plugins that implement ManageNameIDService functionality.
264 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > ManageNameIDServiceManager;
267 * Manages factories for ProtocolProvider plugins.
269 xmltooling::PluginManager<ProtocolProvider,std::string,const xercesc::DOMElement*> ProtocolProviderManager;
272 * Manages factories for RequestMapper plugins.
274 xmltooling::PluginManager<RequestMapper,std::string,const xercesc::DOMElement*> RequestMapperManager;
277 * Manages factories for ServiceProvider plugins.
279 xmltooling::PluginManager<ServiceProvider,std::string,const xercesc::DOMElement*> ServiceProviderManager;
282 * Manages factories for SessionCache plugins.
284 xmltooling::PluginManager<SessionCache,std::string,const xercesc::DOMElement*> SessionCacheManager;
287 * Manages factories for Handler plugins that implement SessionInitiator functionality.
289 xmltooling::PluginManager< SessionInitiator,std::string,std::pair<const xercesc::DOMElement*,const char*> > SessionInitiatorManager;
292 * Manages factories for Handler plugins that implement SingleLogoutService functionality.
294 xmltooling::PluginManager< Handler,std::string,std::pair<const xercesc::DOMElement*,const char*> > SingleLogoutServiceManager;
297 /** Global ServiceProvider instance. */
298 ServiceProvider* m_serviceProvider;
301 /** Global ArtifactResolver instance. */
302 opensaml::MessageDecoder::ArtifactResolver* m_artifactResolver;
306 unsigned long m_features;
307 xercesc::DOMDocument* m_configDoc;
310 #if defined (_MSC_VER)
311 #pragma warning( pop )
316 #endif /* __shibsp_config_h__ */