3 * Copyright 2001-2007 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 "attribute/SimpleAttribute.h"
37 #include "attribute/ScopedAttribute.h"
38 #include "attribute/NameIDAttribute.h"
40 #include <log4cpp/Category.hh>
41 #include <saml/SAMLConfig.h>
42 #include <xmltooling/util/NDC.h>
43 #include <xmltooling/util/TemplateEngine.h>
45 using namespace shibsp;
46 using namespace opensaml;
47 using namespace xmltooling;
48 using namespace log4cpp;
50 DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
51 DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
54 SPInternalConfig g_config;
57 SPConfig& SPConfig::getConfig()
62 SPInternalConfig& SPInternalConfig::getInternalConfig()
67 void SPConfig::setServiceProvider(ServiceProvider* serviceProvider)
69 //delete m_serviceProvider;
70 m_serviceProvider = serviceProvider;
73 bool SPInternalConfig::init(const char* catalog_path)
78 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
79 log.debug("library initialization started");
81 const char* loglevel=getenv("SHIBSP_LOGGING");
83 loglevel = SHIBSP_LOGGING;
84 XMLToolingConfig::getConfig().log_config(loglevel);
87 catalog_path = getenv("SHIBSP_SCHEMAS");
89 catalog_path = SHIBSP_SCHEMAS;
90 XMLToolingConfig::getConfig().catalog_path = catalog_path;
92 if (!SAMLConfig::getConfig().init()) {
93 log.fatal("failed to initialize OpenSAML library");
97 XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
98 XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
100 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
101 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
103 registerMetadataExtClasses();
104 registerPKIXTrustEngine();
105 registerAccessControls();
106 registerListenerServices();
107 registerRequestMappers();
108 registerSessionCaches();
109 registerServiceProviders();
110 registerAttributeFactories();
112 log.info("library initialization complete");
116 void SPInternalConfig::term()
121 Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
122 log.info("shutting down the library");
124 delete m_serviceProvider;
125 m_serviceProvider = NULL;
127 Attribute::deregisterFactories();
129 SingleLogoutServiceManager.deregisterFactories();
130 SessionInitiatorManager.deregisterFactories();
131 SessionCacheManager.deregisterFactories();
132 ServiceProviderManager.deregisterFactories();
133 RequestMapperManager.deregisterFactories();
134 ManageNameIDServiceManager.deregisterFactories();
135 ListenerServiceManager.deregisterFactories();
136 HandlerManager.deregisterFactories();
137 AssertionConsumerServiceManager.deregisterFactories();
138 AccessControlManager.deregisterFactories();
140 SAMLConfig::getConfig().term();
141 log.info("library shutdown complete");