A "simple" attribute resolver, and token validation.
[shibboleth/sp.git] / shibsp / SPConfig.cpp
index 125c995..cefcc17 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- *  Copyright 2001-2006 Internet2
+ *  Copyright 2001-2007 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 #include "internal.h"
+#include "AccessControl.h"
 #include "exceptions.h"
+#include "Handler.h"
+#include "RequestMapper.h"
+#include "ServiceProvider.h"
+#include "SessionCache.h"
 #include "SPConfig.h"
+#include "attribute/AttributeDecoder.h"
+#include "attribute/resolver/AttributeResolver.h"
+#include "metadata/MetadataExt.h"
+#include "remoting/ListenerService.h"
+#include "security/PKIXTrustEngine.h"
 
 #include <log4cpp/Category.hh>
 #include <saml/SAMLConfig.h>
@@ -35,6 +45,8 @@ using namespace opensaml;
 using namespace xmltooling;
 using namespace log4cpp;
 
+DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
+DECL_XMLTOOLING_EXCEPTION_FACTORY(AttributeResolutionException,shibsp);
 DECL_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
 DECL_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
 
@@ -54,7 +66,7 @@ SPInternalConfig& SPInternalConfig::getInternalConfig()
 
 void SPConfig::setServiceProvider(ServiceProvider* serviceProvider)
 {
-    //delete m_serviceProvider;
+    delete m_serviceProvider;
     m_serviceProvider = serviceProvider;
 }
 
@@ -71,8 +83,11 @@ bool SPInternalConfig::init(const char* catalog_path)
         loglevel = SHIBSP_LOGGING;
     XMLToolingConfig::getConfig().log_config(loglevel);
 
-    if (catalog_path)
-        XMLToolingConfig::getConfig().catalog_path = catalog_path;
+    if (!catalog_path)
+        catalog_path = getenv("SHIBSP_SCHEMAS");
+    if (!catalog_path)
+        catalog_path = SHIBSP_SCHEMAS;
+    XMLToolingConfig::getConfig().catalog_path = catalog_path;
 
     if (!SAMLConfig::getConfig().init()) {
         log.fatal("failed to initialize OpenSAML library");
@@ -82,9 +97,23 @@ bool SPInternalConfig::init(const char* catalog_path)
     XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
     XMLToolingConfig::getConfig().getTemplateEngine()->setTagPrefix("shibmlp");
     
+    REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeException,shibsp);
+    REGISTER_XMLTOOLING_EXCEPTION_FACTORY(AttributeResolutionException,shibsp);
     REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ConfigurationException,shibsp);
     REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ListenerException,shibsp);
-
+    
+    registerMetadataExtClasses();
+    registerPKIXTrustEngine();
+
+    registerAccessControls();
+    registerAttributeDecoders();
+    registerAttributeFactories();
+    registerAttributeResolvers();
+    registerListenerServices();
+    registerRequestMappers();
+    registerSessionCaches();
+    registerServiceProviders();
+    
     log.info("library initialization complete");
     return true;
 }
@@ -97,9 +126,24 @@ void SPInternalConfig::term()
     Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
     log.info("shutting down the library");
 
-    //delete m_serviceProvider;
+    delete m_serviceProvider;
     m_serviceProvider = NULL;
 
+    AssertionConsumerServiceManager.deregisterFactories();
+    ManageNameIDServiceManager.deregisterFactories();
+    SessionInitiatorManager.deregisterFactories();
+    SingleLogoutServiceManager.deregisterFactories();
+    
+    ServiceProviderManager.deregisterFactories();
+    SessionCacheManager.deregisterFactories();
+    RequestMapperManager.deregisterFactories();
+    ListenerServiceManager.deregisterFactories();
+    HandlerManager.deregisterFactories();
+    AttributeResolverManager.deregisterFactories();
+    AttributeDecoderManager.deregisterFactories();
+    Attribute::deregisterFactories();
+    AccessControlManager.deregisterFactories();
+
     SAMLConfig::getConfig().term();
     log.info("library shutdown complete");
 }