From 2ab456c7ddadf9acb54c41ec49b6e535b3970363 Mon Sep 17 00:00:00 2001 From: cantor Date: Tue, 31 Aug 2010 17:48:11 +0000 Subject: [PATCH] Add method to test for algorithm support. git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@778 de75baf8-a10c-0410-a50a-987c0e22f00f --- xmltooling/XMLToolingConfig.cpp | 14 ++++++++++++++ xmltooling/XMLToolingConfig.h | 7 +++++++ xmltooling/internal.h | 1 + 3 files changed, 22 insertions(+) diff --git a/xmltooling/XMLToolingConfig.cpp b/xmltooling/XMLToolingConfig.cpp index c9821ee..5dcfaaf 100644 --- a/xmltooling/XMLToolingConfig.cpp +++ b/xmltooling/XMLToolingConfig.cpp @@ -61,6 +61,7 @@ #ifndef XMLTOOLING_NO_XMLSEC # include # include +# include # include # include # include @@ -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 diff --git a/xmltooling/XMLToolingConfig.h b/xmltooling/XMLToolingConfig.h index f23f62c..56beaf0 100644 --- a/xmltooling/XMLToolingConfig.h +++ b/xmltooling/XMLToolingConfig.h @@ -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 /** diff --git a/xmltooling/internal.h b/xmltooling/internal.h index 189617e..f4f8bea 100644 --- a/xmltooling/internal.h +++ b/xmltooling/internal.h @@ -131,6 +131,7 @@ namespace xmltooling { # endif } + bool isXMLAlgorithmSupported(const XMLCh* xmlAlgorithm); void registerXMLAlgorithms(); XSECProvider* m_xsecProvider; -- 2.1.4