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 "AccessControl.h"
26 #include "exceptions.h"
28 #include "RequestMapper.h"
29 #include "ServiceProvider.h"
30 #include "SessionCache.h"
32 #include "metadata/MetadataExt.h"
33 #include "remoting/ListenerService.h"
34 #include "security/PKIXTrustEngine.h"
36 #include <log4cpp/Category.hh>
37 #include <saml/SAMLConfig.h>
38 #include <xmltooling/util/NDC.h>
39 #include <xmltooling/util/TemplateEngine.h>
41 using namespace shibsp;
42 using namespace opensaml;
43 using namespace xmltooling;
44 using namespace log4cpp;
46 DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
47 DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
50 SPInternalConfig g_config;
53 SPConfig& SPConfig::getConfig()
58 SPInternalConfig& SPInternalConfig::getInternalConfig()
63 void SPConfig::setServiceProvider(ServiceProvider* serviceProvider)
65 //delete m_serviceProvider;
66 m_serviceProvider = serviceProvider;
69 bool SPInternalConfig::init(const char* catalog_path)
74 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
75 log.debug("library initialization started");
77 const char* loglevel=getenv("SHIBSP_LOGGING");
79 loglevel = SHIBSP_LOGGING;
80 XMLToolingConfig::getConfig().log_config(loglevel);
83 catalog_path = getenv("SHIBSP_SCHEMAS");
85 catalog_path = SHIBSP_SCHEMAS;
86 XMLToolingConfig::getConfig().catalog_path = catalog_path;
88 if (!SAMLConfig::getConfig().init()) {
89 log.fatal("failed to initialize OpenSAML library");
93 XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
94 XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
96 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
97 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
99 registerMetadataExtClasses();
100 registerPKIXTrustEngine();
101 registerAccessControls();
102 registerListenerServices();
103 registerRequestMappers();
104 registerSessionCaches();
105 registerServiceProviders();
107 log.info("library initialization complete");
111 void SPInternalConfig::term()
116 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
117 log.info("shutting down the library");
119 delete m_serviceProvider;
120 m_serviceProvider = NULL;
122 SingleLogoutServiceManager.deregisterFactories();
123 SessionInitiatorManager.deregisterFactories();
124 SessionCacheManager.deregisterFactories();
125 ServiceProviderManager.deregisterFactories();
126 RequestMapperManager.deregisterFactories();
127 ManageNameIDServiceManager.deregisterFactories();
128 ListenerServiceManager.deregisterFactories();
129 HandlerManager.deregisterFactories();
130 AssertionConsumerServiceManager.deregisterFactories();
131 AccessControlManager.deregisterFactories();
133 SAMLConfig::getConfig().term();
134 log.info("library shutdown complete");