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 StorageService;
46 class XMLTOOL_API TemplateEngine;
47 class XMLTOOL_API TrustEngine;
48 class XMLTOOL_API XSECCryptoX509CRL;
51 * Singleton object that manages library startup/shutdown.configuration.
53 * A locking interface is supplied as a convenience for code that wants to
54 * obtain a global system lock, but the actual configuration itself is not
57 class XMLTOOL_API XMLToolingConfig : public Lockable
59 MAKE_NONCOPYABLE(XMLToolingConfig);
61 XMLToolingConfig() : m_replayCache(NULL), clock_skew_secs(180) {}
63 /** Global ReplayCache instance. */
64 ReplayCache* m_replayCache;
66 /** Global TemplateEngine instance. */
67 TemplateEngine* m_templateEngine;
69 virtual ~XMLToolingConfig() {}
72 * Returns the global configuration object for the library.
74 * @return reference to the global library configuration object
76 static XMLToolingConfig& getConfig();
81 * Each process using the library MUST call this function exactly once
82 * before using any library classes except for the LogConfig method.
84 * @return true iff initialization was successful
86 virtual bool init()=0;
91 * Each process using the library SHOULD call this function exactly once
92 * before terminating itself
94 virtual void term()=0;
97 * Loads a shared/dynamic library extension.
99 * Extension libraries are managed using a pair of "C" linkage functions:<br>
100 * extern "C" int xmltooling_extension_init(void* context);<br>
101 * extern "C" void xmltooling_extension_term();
103 * This method is internally synchronized.
105 * @param path pathname of shared library to load into process
106 * @param context arbitrary data to pass to library initialization hook
107 * @return true iff library was loaded successfully
109 virtual bool load_library(const char* path, void* context=NULL)=0;
112 * Configure logging system.
114 * May be called first, before initializing the library. Other calls to it
115 * must be externally synchronized.
117 * @param config either a logging configuration file, or a level from the set
118 * (DEBUG, INFO, NOTICE, WARN, ERROR, CRIT, ALERT, FATAL, EMERG)
119 * @return true iff configuration was successful
121 virtual bool log_config(const char* config=NULL)=0;
124 * Obtains a non-validating parser pool.
125 * Library must be initialized first.
127 * @return reference to a non-validating parser pool.
129 virtual ParserPool& getParser() const=0;
132 * Obtains a validating parser pool.
133 * Library must be initialized first. Schema/catalog registration must be
134 * externally synchronized.
136 * @return reference to a validating parser pool.
138 virtual ParserPool& getValidatingParser() const=0;
141 * Sets the global ReplayCache instance.
142 * This method must be externally synchronized with any code that uses the object.
143 * Any previously set object is destroyed.
145 * @param replayCache new ReplayCache instance to store
147 void setReplayCache(ReplayCache* replayCache);
150 * Returns the global ReplayCache instance.
152 * @return global ReplayCache or NULL
154 ReplayCache* getReplayCache() const {
155 return m_replayCache;
159 * Sets the global TemplateEngine instance.
160 * This method must be externally synchronized with any code that uses the object.
161 * Any previously set object is destroyed.
163 * @param templateEngine new TemplateEngine instance to store
165 void setTemplateEngine(TemplateEngine* templateEngine);
168 * Returns the global TemplateEngine instance.
170 * @return global TemplateEngine or NULL
172 TemplateEngine* getTemplateEngine() const {
173 return m_templateEngine;
177 * List of catalog files to load into validating parser pool at initialization time.
178 * Like other path settings, the separator depends on the platform
179 * (semicolon on Windows, colon otherwise).
181 std::string catalog_path;
184 * Adjusts any clock comparisons to be more liberal/permissive by the
185 * indicated number of seconds.
187 unsigned int clock_skew_secs;
189 #ifndef XMLTOOLING_NO_XMLSEC
191 * Returns an X.509 CRL implementation object.
193 virtual XSECCryptoX509CRL* X509CRL() const=0;
196 * Manages factories for KeyResolver plugins.
198 PluginManager<xmlsignature::KeyResolver,const DOMElement*> KeyResolverManager;
201 * Manages factories for CredentialResolver plugins.
203 PluginManager<xmlsignature::CredentialResolver,const DOMElement*> CredentialResolverManager;
206 * Manages factories for TrustEngine plugins.
208 PluginManager<TrustEngine,const DOMElement*> TrustEngineManager;
212 * Manages factories for StorageService plugins.
214 PluginManager<StorageService,const DOMElement*> StorageServiceManager;
219 #if defined (_MSC_VER)
220 #pragma warning( pop )
223 #endif /* __xmltooling_config_h__ */