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 TrustEngine;
47 class XMLTOOL_API XSECCryptoX509CRL;
50 * Singleton object that manages library startup/shutdown.configuration.
52 * A locking interface is supplied as a convenience for code that wants to
53 * obtain a global system lock, but the actual configuration itself is not
56 class XMLTOOL_API XMLToolingConfig : public Lockable
58 MAKE_NONCOPYABLE(XMLToolingConfig);
60 XMLToolingConfig() : m_replayCache(NULL), clock_skew_secs(180) {}
62 /** Global ReplayCache instance. */
63 ReplayCache* m_replayCache;
65 virtual ~XMLToolingConfig() {}
68 * Returns the global configuration object for the library.
70 * @return reference to the global library configuration object
72 static XMLToolingConfig& getConfig();
77 * Each process using the library MUST call this function exactly once
78 * before using any library classes except for the LogConfig method.
80 * @return true iff initialization was successful
82 virtual bool init()=0;
87 * Each process using the library SHOULD call this function exactly once
88 * before terminating itself
90 virtual void term()=0;
93 * Loads a shared/dynamic library extension.
95 * Extension libraries are managed using a pair of "C" linkage functions:<br>
96 * extern "C" int xmltooling_extension_init(void* context);<br>
97 * extern "C" void xmltooling_extension_term();
99 * This method is internally synchronized.
101 * @param path pathname of shared library to load into process
102 * @param context arbitrary data to pass to library initialization hook
103 * @return true iff library was loaded successfully
105 virtual bool load_library(const char* path, void* context=NULL)=0;
108 * Configure logging system.
110 * May be called first, before initializing the library. Other calls to it
111 * must be externally synchronized.
113 * @param config either a logging configuration file, or a level from the set
114 * (DEBUG, INFO, NOTICE, WARN, ERROR, CRIT, ALERT, FATAL, EMERG)
115 * @return true iff configuration was successful
117 virtual bool log_config(const char* config=NULL)=0;
120 * Obtains a non-validating parser pool.
121 * Library must be initialized first.
123 * @return reference to a non-validating parser pool.
125 virtual ParserPool& getParser() const=0;
128 * Obtains a validating parser pool.
129 * Library must be initialized first. Schema/catalog registration must be
130 * externally synchronized.
132 * @return reference to a validating parser pool.
134 virtual ParserPool& getValidatingParser() const=0;
137 * Sets the global ReplayCache instance.
138 * This method must be externally synchronized with any code that uses the object.
139 * Any previously set object is destroyed.
141 * @param replayCache new ReplayCache instance to store
143 void setReplayCache(ReplayCache* replayCache);
146 * Returns the global ReplayCache instance.
148 * @return global ReplayCache or NULL
150 ReplayCache* getReplayCache() const {
151 return m_replayCache;
155 * List of catalog files to load into validating parser pool at initialization time.
156 * Like other path settings, the separator depends on the platform
157 * (semicolon on Windows, colon otherwise).
159 std::string catalog_path;
162 * Adjusts any clock comparisons to be more liberal/permissive by the
163 * indicated number of seconds.
165 unsigned int clock_skew_secs;
167 #ifndef XMLTOOLING_NO_XMLSEC
169 * Returns an X.509 CRL implementation object.
171 virtual XSECCryptoX509CRL* X509CRL() const=0;
174 * Manages factories for KeyResolver plugins.
176 PluginManager<xmlsignature::KeyResolver,const DOMElement*> KeyResolverManager;
179 * Manages factories for CredentialResolver plugins.
181 PluginManager<xmlsignature::CredentialResolver,const DOMElement*> CredentialResolverManager;
184 * Manages factories for TrustEngine plugins.
186 PluginManager<TrustEngine,const DOMElement*> TrustEngineManager;
190 * Manages factories for StorageService plugins.
192 PluginManager<StorageService,const DOMElement*> StorageServiceManager;
197 #if defined (_MSC_VER)
198 #pragma warning( pop )
201 #endif /* __xmltooling_config_h__ */