-/*
- * Copyright 2001-2010 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
*/
/**
#ifdef WIN32
# if (OPENSSL_VERSION_NUMBER >= 0x00908000)
-# define XMLTOOLING_OPENSSL_HAVE_SHA2
+# define XMLTOOLING_OPENSSL_HAVE_SHA2 1
# endif
#endif
{
}
+#ifndef XMLTOOLING_LITE
+const KeyInfoResolver* XMLToolingConfig::getKeyInfoResolver() const
+{
+ return m_keyInfoResolver;
+}
+
+ReplayCache* XMLToolingConfig::getReplayCache() const
+{
+ return m_replayCache;
+}
+
+void XMLToolingConfig::setKeyInfoResolver(xmltooling::KeyInfoResolver *keyInfoResolver)
+{
+ delete m_keyInfoResolver;
+ m_keyInfoResolver = keyInfoResolver;
+}
+
+void XMLToolingConfig::setReplayCache(ReplayCache* replayCache)
+{
+ delete m_replayCache;
+ m_replayCache = replayCache;
+}
+#endif
+
+PathResolver* XMLToolingConfig::getPathResolver() const
+{
+ return m_pathResolver;
+}
+
+TemplateEngine* XMLToolingConfig::getTemplateEngine() const
+{
+ return m_templateEngine;
+}
+
+const URLEncoder* XMLToolingConfig::getURLEncoder() const
+{
+ return m_urlEncoder;
+}
+
+void XMLToolingConfig::setPathResolver(PathResolver* pathResolver)
+{
+ delete m_pathResolver;
+ m_pathResolver = pathResolver;
+}
+
+void XMLToolingConfig::setTemplateEngine(TemplateEngine* templateEngine)
+{
+ delete m_templateEngine;
+ m_templateEngine = templateEngine;
+}
+
+void XMLToolingConfig::setURLEncoder(URLEncoder* urlEncoder)
+{
+ delete m_urlEncoder;
+ m_urlEncoder = urlEncoder;
+}
+
+XMLToolingInternalConfig::XMLToolingInternalConfig() :
+#ifndef XMLTOOLING_NO_XMLSEC
+ m_xsecProvider(nullptr),
+#endif
+ m_initCount(0), m_lock(Mutex::create()), m_parserPool(nullptr), m_validatingPool(nullptr)
+{
+}
+
+XMLToolingInternalConfig::~XMLToolingInternalConfig()
+{
+ delete m_lock;
+}
+
bool XMLToolingInternalConfig::log_config(const char* config)
{
try {
string path(config);
PropertyConfigurator::configure(m_pathResolver ? m_pathResolver->resolve(path, PathResolver::XMLTOOLING_CFG_FILE) : path);
}
- }
+
+#ifndef XMLTOOLING_NO_XMLSEC
+ Category::getInstance(XMLTOOLING_LOGCAT".Signature.Debugger").setAdditivity(false);
+#endif
+ }
catch (const ConfigureFailure& e) {
string msg = string("failed to configure logging: ") + e.what();
Category::getInstance(XMLTOOLING_LOGCAT".Logging").crit(msg);
return true;
}
-#ifndef XMLTOOLING_LITE
-const KeyInfoResolver* XMLToolingConfig::getKeyInfoResolver() const
-{
- return m_keyInfoResolver;
-}
-
-ReplayCache* XMLToolingConfig::getReplayCache() const
-{
- return m_replayCache;
-}
-
-void XMLToolingConfig::setKeyInfoResolver(xmltooling::KeyInfoResolver *keyInfoResolver)
-{
- delete m_keyInfoResolver;
- m_keyInfoResolver = keyInfoResolver;
-}
-
-void XMLToolingConfig::setReplayCache(ReplayCache* replayCache)
+bool XMLToolingInternalConfig::init()
{
- delete m_replayCache;
- m_replayCache = replayCache;
-}
+#ifdef _DEBUG
+ xmltooling::NDC ndc("init");
#endif
+ Category& log=Category::getInstance(XMLTOOLING_LOGCAT".Config");
-PathResolver* XMLToolingConfig::getPathResolver() const
-{
- return m_pathResolver;
-}
-
-TemplateEngine* XMLToolingConfig::getTemplateEngine() const
-{
- return m_templateEngine;
-}
-
-const URLEncoder* XMLToolingConfig::getURLEncoder() const
-{
- return m_urlEncoder;
-}
+ Lock initLock(m_lock);
-void XMLToolingConfig::setPathResolver(PathResolver* pathResolver)
-{
- delete m_pathResolver;
- m_pathResolver = pathResolver;
-}
-
-void XMLToolingConfig::setTemplateEngine(TemplateEngine* templateEngine)
-{
- delete m_templateEngine;
- m_templateEngine = templateEngine;
-}
+ if (m_initCount == INT_MAX) {
+ log.crit("library initialized too many times");
+ return false;
+ }
-void XMLToolingConfig::setURLEncoder(URLEncoder* urlEncoder)
-{
- delete m_urlEncoder;
- m_urlEncoder = urlEncoder;
-}
+ if (m_initCount >= 1) {
+ ++m_initCount;
+ return true;
+ }
-bool XMLToolingInternalConfig::init()
-{
-#ifdef _DEBUG
- xmltooling::NDC ndc("init");
-#endif
- Category& log=Category::getInstance(XMLTOOLING_LOGCAT".XMLToolingConfig");
try {
log.debug("library initialization started");
log.fatal("failed to initialize libcurl, OpenSSL, or Winsock");
return false;
}
- log.debug("libcurl %s initialization complete", LIBCURL_VERSION);
+ curl_version_info_data* curlver = curl_version_info(CURLVERSION_NOW);
+ if (curlver) {
+ log.debug("libcurl %s initialization complete", curlver->version);
+ if (!(curlver->features & CURL_VERSION_SSL)) {
+ log.warn("libcurl lacks TLS/SSL support, this will greatly limit functionality");
+ }
+ }
+ else {
+ log.debug("libcurl %s initialization complete", LIBCURL_VERSION);
+ }
#endif
XMLPlatformUtils::Initialize();
m_parserPool=new ParserPool();
m_validatingPool=new ParserPool(true,true);
- m_lock=XMLPlatformUtils::makeMutex();
// Load catalogs from path.
if (!catalog_path.empty()) {
#endif
log.info("%s library initialization complete", PACKAGE_STRING);
+ ++m_initCount;
return true;
}
void XMLToolingInternalConfig::term()
{
+#ifdef _DEBUG
+ xmltooling::NDC ndc("term");
+#endif
+
+ Lock initLock(m_lock);
+ if (m_initCount == 0) {
+ Category::getInstance(XMLTOOLING_LOGCAT".Config").crit("term without corresponding init");
+ return;
+ }
+ else if (--m_initCount > 0) {
+ return;
+ }
+
#ifndef XMLTOOLING_NO_XMLSEC
CRYPTO_set_locking_callback(nullptr);
for_each(g_openssl_locks.begin(), g_openssl_locks.end(), xmltooling::cleanup<Mutex>());
XSECPlatformUtils::Terminate();
#endif
- XMLPlatformUtils::closeMutex(m_lock);
- m_lock=nullptr;
XMLPlatformUtils::Terminate();
#ifndef XMLTOOLING_NO_XMLSEC
curl_global_cleanup();
#endif
-#ifdef _DEBUG
- xmltooling::NDC ndc("term");
-#endif
- Category::getInstance(XMLTOOLING_LOGCAT".XMLToolingConfig").info("%s library shutdown complete", PACKAGE_STRING);
+ Category::getInstance(XMLTOOLING_LOGCAT".Config").info("%s library shutdown complete", PACKAGE_STRING);
}
Lockable* XMLToolingInternalConfig::lock()
{
- xercesc::XMLPlatformUtils::lockMutex(m_lock);
+ m_lock->lock();
return this;
}
void XMLToolingInternalConfig::unlock()
{
- xercesc::XMLPlatformUtils::unlockMutex(m_lock);
+ m_lock->unlock();
}
bool XMLToolingInternalConfig::load_library(const char* path, void* context)
#ifdef _DEBUG
xmltooling::NDC ndc("LoadLibrary");
#endif
- Category& log=Category::getInstance(XMLTOOLING_LOGCAT".XMLToolingConfig");
+ Category& log=Category::getInstance(XMLTOOLING_LOGCAT".Config");
log.info("loading extension: %s", path);
Locker locker(this);