Allow for use as XMLTooling extension, clean up some header use in tests.
authorScott Cantor <cantor.2@osu.edu>
Wed, 6 Sep 2006 18:03:44 +0000 (18:03 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 6 Sep 2006 18:03:44 +0000 (18:03 +0000)
13 files changed:
saml/SAMLConfig.cpp
saml/SAMLConfig.h
saml/internal.h
saml/saml.vcproj
samltest/SAMLArtifactCreationTest.h
samltest/SAMLArtifactType0001Test.h
samltest/SAMLArtifactType0002Test.h
samltest/SAMLArtifactType0004Test.h
samltest/internal.h
samltest/saml2/metadata/FilesystemMetadataProviderTest.h
samltest/samltest.h
samltest/security/AbstractPKIXTrustEngineTest.h
samltest/security/ExplicitKeyTrustEngineTest.h

index 6f4bf76..a842faf 100644 (file)
@@ -49,6 +49,20 @@ using namespace xmltooling;
 using namespace log4cpp;
 using namespace std;
 
+// Expose entry points when used as an extension library
+
+extern "C" int SAML_API xmltooling_extension_init(void*)
+{
+    if (SAMLConfig::getConfig().init(false))
+        return 0;
+    return -1;
+}
+
+extern "C" void SAML_API xmltooling_extension_term()
+{
+    SAMLConfig::getConfig().term(false);
+}
+
 DECL_EXCEPTION_FACTORY(ArtifactException,opensaml);
 DECL_EXCEPTION_FACTORY(MetadataFilterException,opensaml::saml2md);
 
@@ -66,7 +80,7 @@ SAMLInternalConfig& SAMLInternalConfig::getInternalConfig()
     return g_config;
 }
 
-bool SAMLInternalConfig::init()
+bool SAMLInternalConfig::init(bool initXMLTooling)
 {
 #ifdef _DEBUG
     xmltooling::NDC ndc("init");
@@ -74,8 +88,10 @@ bool SAMLInternalConfig::init()
     Category& log=Category::getInstance(SAML_LOGCAT".SAMLConfig");
     log.debug("library initialization started");
 
-    XMLToolingConfig::getConfig().init();
-    log.debug("XMLTooling library initialized");
+    if (initXMLTooling) {
+        XMLToolingConfig::getConfig().init();
+        log.debug("XMLTooling library initialized");
+    }
 
     REGISTER_EXCEPTION_FACTORY(ArtifactException,opensaml);
     REGISTER_EXCEPTION_FACTORY(MetadataFilterException,opensaml::saml2md);
@@ -94,11 +110,12 @@ bool SAMLInternalConfig::init()
     return true;
 }
 
-void SAMLInternalConfig::term()
+void SAMLInternalConfig::term(bool termXMLTooling)
 {
 #ifdef _DEBUG
     xmltooling::NDC ndc("term");
 #endif
+    Category& log=Category::getInstance(SAML_LOGCAT".SAMLConfig");
 
     saml1::AssertionSchemaValidators.destroyValidators();
     saml1p::ProtocolSchemaValidators.destroyValidators();
@@ -110,8 +127,11 @@ void SAMLInternalConfig::term()
     MetadataProviderManager.deregisterFactories();
     TrustEngineManager.deregisterFactories();
 
-    XMLToolingConfig::getConfig().term();
-    Category::getInstance(SAML_LOGCAT".SAMLConfig").info("library shutdown complete");
+    if (termXMLTooling) {
+        XMLToolingConfig::getConfig().term();
+        log.debug("XMLTooling library shut down");
+    }
+    log.info("library shutdown complete");
 }
 
 void SAMLInternalConfig::generateRandomBytes(void* buf, unsigned int len)
index b97bda0..0474707 100644 (file)
@@ -69,19 +69,26 @@ namespace opensaml {
          * Initializes library\r
          * \r
          * Each process using the library MUST call this function exactly once\r
-         * before using any library classes.\r
+         * before using any library classes. The flag controls whether this is the\r
+         * "dominant" library or not and can allow the SAML library to be loaded\r
+         * as an extension of XMLTooling rather than subsuming it.\r
          * \r
+         * @param initXMLTooling true iff this method should initialize the XMLTooling layer\r
          * @return true iff initialization was successful \r
          */\r
-        virtual bool init()=0;\r
+        virtual bool init(bool initXMLTooling=true)=0;\r
         \r
         /**\r
          * Shuts down library\r
          * \r
          * Each process using the library SHOULD call this function exactly once\r
-         * before terminating itself\r
+         * before terminating itself. The flag controls whether this is the\r
+         * "dominant" library or not and can allow the SAML library to be loaded\r
+         * as an extension of XMLTooling rather than subsuming it.\r
+         * \r
+         * @param termXMLTooling true iff this method should shutdown the XMLTooling layer\r
          */\r
-        virtual void term()=0;\r
+        virtual void term(bool termXMLTooling=true)=0;\r
         \r
         /**\r
          * Generate random information using the underlying security library\r
index 9be5928..72beb8e 100644 (file)
@@ -89,8 +89,8 @@ namespace opensaml {
         static SAMLInternalConfig& getInternalConfig();
 
         // global per-process setup and shutdown of runtime
-        bool init();
-        void term();
+        bool init(bool initXMLTooling=true);
+        void term(bool termXMLTooling=true);
 
         void generateRandomBytes(void* buf, unsigned int len);
         void generateRandomBytes(std::string& buf, unsigned int len);
index e5aa7c0..27b7e03 100644 (file)
                                                >\r
                                        </Filter>\r
                                </Filter>\r
+                               <Filter\r
+                                       Name="binding"\r
+                                       >\r
+                                       <Filter\r
+                                               Name="impl"\r
+                                               >\r
+                                       </Filter>\r
+                               </Filter>\r
                        </Filter>\r
                        <Filter\r
                                Name="signature"\r
                                                </File>\r
                                        </Filter>\r
                                </Filter>\r
+                               <Filter\r
+                                       Name="binding"\r
+                                       >\r
+                                       <Filter\r
+                                               Name="impl"\r
+                                               >\r
+                                       </Filter>\r
+                               </Filter>\r
                        </Filter>\r
                        <Filter\r
                                Name="encryption"\r
                                        Name="profile"\r
                                        >\r
                                </Filter>\r
+                               <Filter\r
+                                       Name="binding"\r
+                                       >\r
+                               </Filter>\r
                        </Filter>\r
                        <Filter\r
                                Name="signature"\r
                                                >\r
                                        </File>\r
                                </Filter>\r
+                               <Filter\r
+                                       Name="binding"\r
+                                       >\r
+                               </Filter>\r
                        </Filter>\r
                        <Filter\r
                                Name="encryption"\r
index 104e7b1..a62f4c5 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>\r
 #include <saml/saml1/core/SAMLArtifactType0001.h>\r
 #include <saml/saml1/core/SAMLArtifactType0002.h>\r
 #include <saml/saml2/core/SAML2ArtifactType0004.h>\r
index 48c8754..78ef996 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>\r
 #include <saml/saml1/core/SAMLArtifactType0001.h>\r
 \r
 using namespace opensaml::saml1p;\r
index 45365d8..545564a 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>\r
 #include <saml/saml1/core/SAMLArtifactType0002.h>\r
 \r
 using namespace opensaml::saml1p;\r
index e2f57d0..52273aa 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>\r
 #include <saml/saml2/core/SAML2ArtifactType0004.h>\r
 \r
 using namespace opensaml::saml2p;\r
index 4575bc4..b5e1bd5 100644 (file)
 
 #include <fstream>
 #include <saml/exceptions.h>
-#include <saml/SAMLConfig.h>
 #include <saml/util/SAMLConstants.h>
 #include <xmltooling/exceptions.h>
 #include <xmltooling/validation/Validator.h>
 #include <xmltooling/XMLObject.h>
 #include <xmltooling/XMLObjectBuilder.h>
+#include <xmltooling/XMLToolingConfig.h>
 
 using namespace opensaml;
 using namespace xmltooling;
index a6093b1..5358d3e 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>\r
 #include <saml/saml2/core/SAML2ArtifactType0004.h>\r
 #include <saml/saml2/metadata/Metadata.h>\r
 #include <saml/saml2/metadata/MetadataProvider.h>\r
index 4033914..92509d8 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>
 \r
 #include <fstream>\r
 #include <cxxtest/GlobalFixture.h>\r
index 3db7df2..346bade 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>\r
 #include <saml/security/AbstractPKIXTrustEngine.h>\r
 #include <saml/saml2/metadata/MetadataProvider.h>\r
 \r
index 53416e9..e531e8a 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 \r
 #include "internal.h"\r
+#include <saml/SAMLConfig.h>\r
 #include <saml/security/TrustEngine.h>\r
 #include <saml/saml2/metadata/MetadataProvider.h>\r
 \r