3 * Copyright 2001-2006 Internet2
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 * Library configuration
25 #include "exceptions.h"
26 #include "ListenerService.h"
27 #include "MetadataExt.h"
28 #include "PKIXTrustEngine.h"
31 #include <log4cpp/Category.hh>
32 #include <saml/SAMLConfig.h>
33 #include <xmltooling/util/NDC.h>
34 #include <xmltooling/util/TemplateEngine.h>
36 using namespace shibsp;
37 using namespace opensaml;
38 using namespace xmltooling;
39 using namespace log4cpp;
41 DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
42 DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
45 SPInternalConfig g_config;
48 SPConfig& SPConfig::getConfig()
53 SPInternalConfig& SPInternalConfig::getInternalConfig()
58 void SPConfig::setServiceProvider(ServiceProvider* serviceProvider)
60 //delete m_serviceProvider;
61 m_serviceProvider = serviceProvider;
64 bool SPInternalConfig::init(const char* catalog_path)
69 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
70 log.debug("library initialization started");
72 const char* loglevel=getenv("SHIBSP_LOGGING");
74 loglevel = SHIBSP_LOGGING;
75 XMLToolingConfig::getConfig().log_config(loglevel);
78 catalog_path = getenv("SHIBSP_SCHEMAS");
80 catalog_path = SHIBSP_SCHEMAS;
81 XMLToolingConfig::getConfig().catalog_path = catalog_path;
83 if (!SAMLConfig::getConfig().init()) {
84 log.fatal("failed to initialize OpenSAML library");
88 XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
89 XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
91 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
92 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
94 registerListenerServices();
95 registerMetadataExtClasses();
96 registerPKIXTrustEngine();
98 log.info("library initialization complete");
102 void SPInternalConfig::term()
107 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
108 log.info("shutting down the library");
110 //delete m_serviceProvider;
111 m_serviceProvider = NULL;
113 ListenerServiceManager.deregisterFactories();
115 SAMLConfig::getConfig().term();
116 log.info("library shutdown complete");