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 KeyResolver;
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_replayCache(NULL), m_templateEngine(NULL), m_urlEncoder(NULL), clock_skew_secs(180) {}
66 /** Global ReplayCache instance. */
67 ReplayCache* m_replayCache;
69 /** Global TemplateEngine instance. */
70 TemplateEngine* m_templateEngine;
72 /** Global URLEncoder instance for use by URL-related functions. */
73 URLEncoder* m_urlEncoder;
76 virtual ~XMLToolingConfig() {}
79 * Returns the global configuration object for the library.
81 * @return reference to the global library configuration object
83 static XMLToolingConfig& getConfig();
88 * Each process using the library MUST call this function exactly once
89 * before using any library classes except for the LogConfig method.
91 * @return true iff initialization was successful
93 virtual bool init()=0;
98 * Each process using the library SHOULD call this function exactly once
99 * before terminating itself
101 virtual void term()=0;
104 * Loads a shared/dynamic library extension.
106 * Extension libraries are managed using a pair of "C" linkage functions:<br>
107 * extern "C" int xmltooling_extension_init(void* context);<br>
108 * extern "C" void xmltooling_extension_term();
110 * This method is internally synchronized.
112 * @param path pathname of shared library to load into process
113 * @param context arbitrary data to pass to library initialization hook
114 * @return true iff library was loaded successfully
116 virtual bool load_library(const char* path, void* context=NULL)=0;
119 * Configure logging system.
121 * May be called first, before initializing the library. Other calls to it
122 * must be externally synchronized.
124 * @param config either a logging configuration file, or a level from the set
125 * (DEBUG, INFO, NOTICE, WARN, ERROR, CRIT, ALERT, FATAL, EMERG)
126 * @return true iff configuration was successful
128 virtual bool log_config(const char* config=NULL)=0;
131 * Obtains a non-validating parser pool.
132 * Library must be initialized first.
134 * @return reference to a non-validating parser pool.
136 virtual ParserPool& getParser() const=0;
139 * Obtains a validating parser pool.
140 * Library must be initialized first. Schema/catalog registration must be
141 * externally synchronized.
143 * @return reference to a validating parser pool.
145 virtual ParserPool& getValidatingParser() const=0;
148 * Sets the global ReplayCache instance.
149 * This method must be externally synchronized with any code that uses the object.
150 * Any previously set object is destroyed.
152 * @param replayCache new ReplayCache instance to store
154 void setReplayCache(ReplayCache* replayCache);
157 * Returns the global ReplayCache instance.
159 * @return global ReplayCache or NULL
161 ReplayCache* getReplayCache() const {
162 return m_replayCache;
166 * Sets the global URLEncoder instance.
167 * This method must be externally synchronized with any code that uses the object.
168 * Any previously set object is destroyed.
170 * @param urlEncoder new URLEncoder instance to store
172 void setURLEncoder(URLEncoder* urlEncoder);
175 * Returns the global URLEncoder instance.
177 * @return global URLEncoder or NULL
179 const URLEncoder* getURLEncoder() const {
184 * Sets the global TemplateEngine instance.
185 * This method must be externally synchronized with any code that uses the object.
186 * Any previously set object is destroyed.
188 * @param templateEngine new TemplateEngine instance to store
190 void setTemplateEngine(TemplateEngine* templateEngine);
193 * Returns the global TemplateEngine instance.
195 * @return global TemplateEngine or NULL
197 TemplateEngine* getTemplateEngine() const {
198 return m_templateEngine;
202 * List of catalog files to load into validating parser pool at initialization time.
203 * Like other path settings, the separator depends on the platform
204 * (semicolon on Windows, colon otherwise).
206 std::string catalog_path;
209 * Adjusts any clock comparisons to be more liberal/permissive by the
210 * indicated number of seconds.
212 unsigned int clock_skew_secs;
214 #ifndef XMLTOOLING_NO_XMLSEC
216 * Returns an X.509 CRL implementation object.
218 virtual XSECCryptoX509CRL* X509CRL() const=0;
221 * Manages factories for KeyResolver plugins.
223 PluginManager<KeyResolver,const DOMElement*> KeyResolverManager;
226 * Manages factories for CredentialResolver plugins.
228 PluginManager<CredentialResolver,const DOMElement*> CredentialResolverManager;
231 * Manages factories for TrustEngine plugins.
233 PluginManager<TrustEngine,const DOMElement*> TrustEngineManager;
237 * Manages factories for SOAPTransport plugins.
239 PluginManager<SOAPTransport,std::pair<const KeyInfoSource*,const char*> > SOAPTransportManager;
242 * Manages factories for StorageService plugins.
244 PluginManager<StorageService,const DOMElement*> StorageServiceManager;
249 #if defined (_MSC_VER)
250 #pragma warning( pop )
253 #endif /* __xmltooling_config_h__ */