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 "AccessControl.h"
27 #include "RequestMapper.h"
28 #include "ServiceProvider.h"
30 #include "metadata/MetadataExt.h"
31 #include "remoting/ListenerService.h"
32 #include "security/PKIXTrustEngine.h"
34 #include <log4cpp/Category.hh>
35 #include <saml/SAMLConfig.h>
36 #include <xmltooling/util/NDC.h>
37 #include <xmltooling/util/TemplateEngine.h>
39 using namespace shibsp;
40 using namespace opensaml;
41 using namespace xmltooling;
42 using namespace log4cpp;
44 DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
45 DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
48 SPInternalConfig g_config;
51 SPConfig& SPConfig::getConfig()
56 SPInternalConfig& SPInternalConfig::getInternalConfig()
61 void SPConfig::setServiceProvider(ServiceProvider* serviceProvider)
63 //delete m_serviceProvider;
64 m_serviceProvider = serviceProvider;
67 bool SPInternalConfig::init(const char* catalog_path)
72 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
73 log.debug("library initialization started");
75 const char* loglevel=getenv("SHIBSP_LOGGING");
77 loglevel = SHIBSP_LOGGING;
78 XMLToolingConfig::getConfig().log_config(loglevel);
81 catalog_path = getenv("SHIBSP_SCHEMAS");
83 catalog_path = SHIBSP_SCHEMAS;
84 XMLToolingConfig::getConfig().catalog_path = catalog_path;
86 if (!SAMLConfig::getConfig().init()) {
87 log.fatal("failed to initialize OpenSAML library");
91 XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
92 XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
94 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
95 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
97 registerMetadataExtClasses();
98 registerPKIXTrustEngine();
99 registerAccessControls();
100 registerListenerServices();
101 registerRequestMappers();
102 registerServiceProviders();
104 log.info("library initialization complete");
108 void SPInternalConfig::term()
113 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
114 log.info("shutting down the library");
116 delete m_serviceProvider;
117 m_serviceProvider = NULL;
119 ServiceProviderManager.deregisterFactories();
120 RequestMapperManager.deregisterFactories();
121 ListenerServiceManager.deregisterFactories();
122 AccessControlManager.deregisterFactories();
124 SAMLConfig::getConfig().term();
125 log.info("library shutdown complete");