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"
29 #include "ServiceProvider.h"
32 #include <log4cpp/Category.hh>
33 #include <saml/SAMLConfig.h>
34 #include <xmltooling/util/NDC.h>
35 #include <xmltooling/util/TemplateEngine.h>
37 using namespace shibsp;
38 using namespace opensaml;
39 using namespace xmltooling;
40 using namespace log4cpp;
42 DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
43 DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
46 SPInternalConfig g_config;
49 SPConfig& SPConfig::getConfig()
54 SPInternalConfig& SPInternalConfig::getInternalConfig()
59 void SPConfig::setServiceProvider(ServiceProvider* serviceProvider)
61 //delete m_serviceProvider;
62 m_serviceProvider = serviceProvider;
65 bool SPInternalConfig::init(const char* catalog_path)
70 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
71 log.debug("library initialization started");
73 const char* loglevel=getenv("SHIBSP_LOGGING");
75 loglevel = SHIBSP_LOGGING;
76 XMLToolingConfig::getConfig().log_config(loglevel);
79 catalog_path = getenv("SHIBSP_SCHEMAS");
81 catalog_path = SHIBSP_SCHEMAS;
82 XMLToolingConfig::getConfig().catalog_path = catalog_path;
84 if (!SAMLConfig::getConfig().init()) {
85 log.fatal("failed to initialize OpenSAML library");
89 XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
90 XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
92 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
93 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
95 registerMetadataExtClasses();
96 registerPKIXTrustEngine();
97 registerListenerServices();
98 registerServiceProviders();
100 log.info("library initialization complete");
104 void SPInternalConfig::term()
109 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
110 log.info("shutting down the library");
112 delete m_serviceProvider;
113 m_serviceProvider = NULL;
115 ListenerServiceManager.deregisterFactories();
116 ServiceProviderManager.deregisterFactories();
118 SAMLConfig::getConfig().term();
119 log.info("library shutdown complete");