2 * Copyright 2001-2006 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 xmlsignature {
32 class XMLTOOL_API CredentialResolver;
33 class XMLTOOL_API KeyResolver;
37 #if defined (_MSC_VER)
38 #pragma warning( push )
39 #pragma warning( disable : 4251 )
42 namespace xmltooling {
44 class XMLTOOL_API ReplayCache;
45 class XMLTOOL_API SOAPTransport;
46 class XMLTOOL_API StorageService;
47 class XMLTOOL_API TemplateEngine;
48 class XMLTOOL_API TrustEngine;
49 class XMLTOOL_API KeyInfoSource;
50 class XMLTOOL_API XSECCryptoX509CRL;
53 * Singleton object that manages library startup/shutdown.configuration.
55 * A locking interface is supplied as a convenience for code that wants to
56 * obtain a global system lock, but the actual configuration itself is not
59 class XMLTOOL_API XMLToolingConfig : public Lockable
61 MAKE_NONCOPYABLE(XMLToolingConfig);
63 XMLToolingConfig() : m_replayCache(NULL), m_templateEngine(NULL), clock_skew_secs(180) {}
65 /** Global ReplayCache instance. */
66 ReplayCache* m_replayCache;
68 /** Global TemplateEngine instance. */
69 TemplateEngine* m_templateEngine;
71 virtual ~XMLToolingConfig() {}
74 * Returns the global configuration object for the library.
76 * @return reference to the global library configuration object
78 static XMLToolingConfig& getConfig();
83 * Each process using the library MUST call this function exactly once
84 * before using any library classes except for the LogConfig method.
86 * @return true iff initialization was successful
88 virtual bool init()=0;
93 * Each process using the library SHOULD call this function exactly once
94 * before terminating itself
96 virtual void term()=0;
99 * Loads a shared/dynamic library extension.
101 * Extension libraries are managed using a pair of "C" linkage functions:<br>
102 * extern "C" int xmltooling_extension_init(void* context);<br>
103 * extern "C" void xmltooling_extension_term();
105 * This method is internally synchronized.
107 * @param path pathname of shared library to load into process
108 * @param context arbitrary data to pass to library initialization hook
109 * @return true iff library was loaded successfully
111 virtual bool load_library(const char* path, void* context=NULL)=0;
114 * Configure logging system.
116 * May be called first, before initializing the library. Other calls to it
117 * must be externally synchronized.
119 * @param config either a logging configuration file, or a level from the set
120 * (DEBUG, INFO, NOTICE, WARN, ERROR, CRIT, ALERT, FATAL, EMERG)
121 * @return true iff configuration was successful
123 virtual bool log_config(const char* config=NULL)=0;
126 * Obtains a non-validating parser pool.
127 * Library must be initialized first.
129 * @return reference to a non-validating parser pool.
131 virtual ParserPool& getParser() const=0;
134 * Obtains a validating parser pool.
135 * Library must be initialized first. Schema/catalog registration must be
136 * externally synchronized.
138 * @return reference to a validating parser pool.
140 virtual ParserPool& getValidatingParser() const=0;
143 * Sets the global ReplayCache instance.
144 * This method must be externally synchronized with any code that uses the object.
145 * Any previously set object is destroyed.
147 * @param replayCache new ReplayCache instance to store
149 void setReplayCache(ReplayCache* replayCache);
152 * Returns the global ReplayCache instance.
154 * @return global ReplayCache or NULL
156 ReplayCache* getReplayCache() const {
157 return m_replayCache;
161 * Sets the global TemplateEngine instance.
162 * This method must be externally synchronized with any code that uses the object.
163 * Any previously set object is destroyed.
165 * @param templateEngine new TemplateEngine instance to store
167 void setTemplateEngine(TemplateEngine* templateEngine);
170 * Returns the global TemplateEngine instance.
172 * @return global TemplateEngine or NULL
174 TemplateEngine* getTemplateEngine() const {
175 return m_templateEngine;
179 * List of catalog files to load into validating parser pool at initialization time.
180 * Like other path settings, the separator depends on the platform
181 * (semicolon on Windows, colon otherwise).
183 std::string catalog_path;
186 * Adjusts any clock comparisons to be more liberal/permissive by the
187 * indicated number of seconds.
189 unsigned int clock_skew_secs;
191 #ifndef XMLTOOLING_NO_XMLSEC
193 * Returns an X.509 CRL implementation object.
195 virtual XSECCryptoX509CRL* X509CRL() const=0;
198 * Manages factories for KeyResolver plugins.
200 PluginManager<xmlsignature::KeyResolver,const DOMElement*> KeyResolverManager;
203 * Manages factories for CredentialResolver plugins.
205 PluginManager<xmlsignature::CredentialResolver,const DOMElement*> CredentialResolverManager;
208 * Manages factories for TrustEngine plugins.
210 PluginManager<TrustEngine,const DOMElement*> TrustEngineManager;
214 * Manages factories for SOAPTransport plugins.
216 PluginManager<SOAPTransport,std::pair<const KeyInfoSource*,const char*> > SOAPTransportManager;
219 * Manages factories for StorageService plugins.
221 PluginManager<StorageService,const DOMElement*> StorageServiceManager;
226 #if defined (_MSC_VER)
227 #pragma warning( pop )
230 #endif /* __xmltooling_config_h__ */