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 XMLToolingConfig.h
20 * Library configuration
23 #ifndef __xmltooling_config_h__
24 #define __xmltooling_config_h__
26 #include <xmltooling/Lockable.h>
27 #include <xmltooling/PluginManager.h>
28 #include <xmltooling/util/ParserPool.h>
30 #ifndef XMLTOOLING_NO_XMLSEC
31 namespace xmltooling {
32 class XMLTOOL_API CredentialResolver;
33 class XMLTOOL_API KeyInfoSource;
34 class XMLTOOL_API KeyInfoResolver;
35 class XMLTOOL_API TrustEngine;
36 class XMLTOOL_API XSECCryptoX509CRL;
40 #if defined (_MSC_VER)
41 #pragma warning( push )
42 #pragma warning( disable : 4251 )
45 namespace xmltooling {
47 class XMLTOOL_API ReplayCache;
48 class XMLTOOL_API SOAPTransport;
49 class XMLTOOL_API StorageService;
50 class XMLTOOL_API TemplateEngine;
51 class XMLTOOL_API URLEncoder;
54 * Singleton object that manages library startup/shutdown.configuration.
56 * A locking interface is supplied as a convenience for code that wants to
57 * obtain a global system lock, but the actual configuration itself is not
60 class XMLTOOL_API XMLToolingConfig : public Lockable
62 MAKE_NONCOPYABLE(XMLToolingConfig);
64 XMLToolingConfig() : m_keyInfoResolver(NULL), m_replayCache(NULL), m_templateEngine(NULL), m_urlEncoder(NULL), clock_skew_secs(180) {}
66 /** Global KeyInfoResolver instance. */
67 KeyInfoResolver* m_keyInfoResolver;
69 /** Global ReplayCache instance. */
70 ReplayCache* m_replayCache;
72 /** Global TemplateEngine instance. */
73 TemplateEngine* m_templateEngine;
75 /** Global URLEncoder instance for use by URL-related functions. */
76 URLEncoder* m_urlEncoder;
79 virtual ~XMLToolingConfig() {}
82 * Returns the global configuration object for the library.
84 * @return reference to the global library configuration object
86 static XMLToolingConfig& getConfig();
91 * Each process using the library MUST call this function exactly once
92 * before using any library classes except for the LogConfig method.
94 * @return true iff initialization was successful
96 virtual bool init()=0;
101 * Each process using the library SHOULD call this function exactly once
102 * before terminating itself
104 virtual void term()=0;
107 * Loads a shared/dynamic library extension.
109 * Extension libraries are managed using a pair of "C" linkage functions:<br>
110 * extern "C" int xmltooling_extension_init(void* context);<br>
111 * extern "C" void xmltooling_extension_term();
113 * This method is internally synchronized.
115 * @param path pathname of shared library to load into process
116 * @param context arbitrary data to pass to library initialization hook
117 * @return true iff library was loaded successfully
119 virtual bool load_library(const char* path, void* context=NULL)=0;
122 * Configure logging system.
124 * May be called first, before initializing the library. Other calls to it
125 * must be externally synchronized.
127 * @param config either a logging configuration file, or a level from the set
128 * (DEBUG, INFO, NOTICE, WARN, ERROR, CRIT, ALERT, FATAL, EMERG)
129 * @return true iff configuration was successful
131 virtual bool log_config(const char* config=NULL)=0;
134 * Obtains a non-validating parser pool.
135 * Library must be initialized first.
137 * @return reference to a non-validating parser pool.
139 virtual ParserPool& getParser() const=0;
142 * Obtains a validating parser pool.
143 * Library must be initialized first. Schema/catalog registration must be
144 * externally synchronized.
146 * @return reference to a validating parser pool.
148 virtual ParserPool& getValidatingParser() const=0;
151 * Sets the global KeyInfoResolver instance.
152 * This method must be externally synchronized with any code that uses the object.
153 * Any previously set object is destroyed.
155 * @param keyInfoResolver new KeyInfoResolver instance to store
157 void setKeyInfoResolver(KeyInfoResolver* keyInfoResolver);
160 * Returns the global KeyInfoResolver instance.
162 * @return global KeyInfoResolver or NULL
164 const KeyInfoResolver* getKeyInfoResolver() const {
165 return m_keyInfoResolver;
169 * Sets the global ReplayCache instance.
170 * This method must be externally synchronized with any code that uses the object.
171 * Any previously set object is destroyed.
173 * @param replayCache new ReplayCache instance to store
175 void setReplayCache(ReplayCache* replayCache);
178 * Returns the global ReplayCache instance.
180 * @return global ReplayCache or NULL
182 ReplayCache* getReplayCache() const {
183 return m_replayCache;
187 * Sets the global URLEncoder instance.
188 * This method must be externally synchronized with any code that uses the object.
189 * Any previously set object is destroyed.
191 * @param urlEncoder new URLEncoder instance to store
193 void setURLEncoder(URLEncoder* urlEncoder);
196 * Returns the global URLEncoder instance.
198 * @return global URLEncoder or NULL
200 const URLEncoder* getURLEncoder() const {
205 * Sets the global TemplateEngine instance.
206 * This method must be externally synchronized with any code that uses the object.
207 * Any previously set object is destroyed.
209 * @param templateEngine new TemplateEngine instance to store
211 void setTemplateEngine(TemplateEngine* templateEngine);
214 * Returns the global TemplateEngine instance.
216 * @return global TemplateEngine or NULL
218 TemplateEngine* getTemplateEngine() const {
219 return m_templateEngine;
223 * List of catalog files to load into validating parser pool at initialization time.
224 * Like other path settings, the separator depends on the platform
225 * (semicolon on Windows, colon otherwise).
227 std::string catalog_path;
230 * Adjusts any clock comparisons to be more liberal/permissive by the
231 * indicated number of seconds.
233 unsigned int clock_skew_secs;
235 #ifndef XMLTOOLING_NO_XMLSEC
237 * Returns an X.509 CRL implementation object.
239 virtual XSECCryptoX509CRL* X509CRL() const=0;
242 * Manages factories for KeyInfoResolver plugins.
244 PluginManager<KeyInfoResolver,const DOMElement*> KeyInfoResolverManager;
247 * Manages factories for CredentialResolver plugins.
249 PluginManager<CredentialResolver,const DOMElement*> CredentialResolverManager;
252 * Manages factories for TrustEngine plugins.
254 PluginManager<TrustEngine,const DOMElement*> TrustEngineManager;
258 * Manages factories for SOAPTransport plugins.
260 * <p>The factory interface takes a peer name/endpoint pair.
262 PluginManager<SOAPTransport,std::pair<const char*,const char*> > SOAPTransportManager;
265 * Manages factories for StorageService plugins.
267 PluginManager<StorageService,const DOMElement*> StorageServiceManager;
272 #if defined (_MSC_VER)
273 #pragma warning( pop )
276 #endif /* __xmltooling_config_h__ */