Add method to test for algorithm support.
authorScott Cantor <cantor.2@osu.edu>
Tue, 31 Aug 2010 17:48:11 +0000 (17:48 +0000)
committerScott Cantor <cantor.2@osu.edu>
Tue, 31 Aug 2010 17:48:11 +0000 (17:48 +0000)
xmltooling/XMLToolingConfig.cpp
xmltooling/XMLToolingConfig.h
xmltooling/internal.h

index c9821ee..5dcfaaf 100644 (file)
@@ -61,6 +61,7 @@
 #ifndef XMLTOOLING_NO_XMLSEC
 # include <curl/curl.h>
 # include <openssl/err.h>
+# include <xsec/framework/XSECAlgorithmMapper.hpp>
 # include <xsec/framework/XSECException.hpp>
 # include <xsec/framework/XSECProvider.hpp>
 # include <xsec/transformers/TXFMBase.hpp>
@@ -605,6 +606,7 @@ bool XMLToolingInternalConfig::load_library(const char* path, void* context)
 }
 
 #ifndef XMLTOOLING_NO_XMLSEC
+
 void xmltooling::log_openssl()
 {
     const char* file;
@@ -626,6 +628,17 @@ XSECCryptoX509CRL* XMLToolingInternalConfig::X509CRL() const
     return new OpenSSLCryptoX509CRL();
 }
 
+bool XMLToolingInternalConfig::isXMLAlgorithmSupported(const XMLCh* xmlAlgorithm)
+{
+    try {
+        if (XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(xmlAlgorithm))
+            return true;
+    }
+    catch (XSECException&) {
+    }
+    return false;
+}
+
 void XMLToolingInternalConfig::registerXMLAlgorithms()
 {
     registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_MD5, "RSA", 0);
@@ -663,6 +676,7 @@ void XMLToolingInternalConfig::registerXMLAlgorithms()
     registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIAES256_CBC, "AES", 256);
     registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIKW_AES256, "AES", 256);
 }
+
 #endif
 
 #ifdef WIN32
index f23f62c..56beaf0 100644 (file)
@@ -294,6 +294,13 @@ namespace xmltooling {
          * @param size          a key size (or 0 if the size is irrelevant)
          */
         virtual void registerXMLAlgorithm(const XMLCh* xmlAlgorithm, const char* keyAlgorithm, unsigned int size=0)=0;
+
+        /**
+         * Checks for implementation support of a particular XML security algorithm.
+         *
+         * @return  true iff the algorithm is supported by the underlying libraries
+         */
+        virtual bool isXMLAlgorithmSupported(const XMLCh* xmlAlgorithm)=0;
 #endif
 
         /**
index 189617e..f4f8bea 100644 (file)
@@ -131,6 +131,7 @@ namespace xmltooling {
 # endif
         }
 
+        bool isXMLAlgorithmSupported(const XMLCh* xmlAlgorithm);
         void registerXMLAlgorithms();
 
         XSECProvider* m_xsecProvider;