Conditional xmlsec support
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Tue, 14 Mar 2006 03:03:46 +0000 (03:03 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Tue, 14 Mar 2006 03:03:46 +0000 (03:03 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/trunk@51 de75baf8-a10c-0410-a50a-987c0e22f00f

configure.ac
xmltooling/Makefile.am
xmltooling/config_pub.h.in
xmltooling/config_pub_win32.h
xmltooling/signature/KeyInfo.h [deleted file]
xmltooling/signature/Signature.h
xmltooling/signature/impl/XMLSecSignature.cpp
xmltooling/signature/impl/XMLSecSignature.h
xmltoolingtest/Makefile.am

index a08e631..6786afc 100644 (file)
@@ -65,8 +65,8 @@ if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
     AC_ARG_WITH(openssl, 
             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
             [if test x_$with_openssl != x_/usr; then
-           SSLLIBS="-L${with_openssl}/lib"
-           SSLFLAGS="-I${with_openssl}/include"
+                SSLLIBS="-L${with_openssl}/lib"
+                SSLFLAGS="-I${with_openssl}/include"
             fi])
     SSLLIBS="$SSLLIBS -lssl -lcrypto"
 else
@@ -139,18 +139,17 @@ AC_ARG_WITH(xerces,
                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
             fi])
 LIBS="-lxerces-c $LIBS"
-AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
-                AC_MSG_ERROR([unable to find xerces header files]))
+AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
 AC_MSG_CHECKING([Xerces version])
 AC_PREPROC_IFELSE(
-       [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
+    [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
 [#if  _XERCES_VERSION != 20600
 int i = 0;
 #else
 #error cannot use version 2.6.0
 #endif])],
-       [AC_MSG_RESULT(OK)],
-       [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use special 2.6.1 tarball provided by Shibboleth Project])])
+    [AC_MSG_RESULT(OK)],
+    [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use special 2.6.1 tarball provided by Shibboleth Project])])
 AC_TRY_LINK(
         [#include <xercesc/util/PlatformUtils.hpp>],
         [xercesc::XMLPlatformUtils::Initialize()],
@@ -165,13 +164,34 @@ AC_ARG_WITH(xmlsec,
                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
             fi])
-LIBS="-lxml-security-c $LIBS"
-AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xsec header files]))
-AC_TRY_LINK(
-        [#include <xsec/utils/XSECPlatformUtils.hpp>],
-        [XSECPlatformUtils::Initialise()],
-        [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
-        [AC_MSG_ERROR([unable to link with XML-Sec])])
+
+if test x_$with_xmlsec != x_no; then
+    if test x_$with_xmlsec != x_/usr; then
+        LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
+        CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
+    fi        
+    LIBS="-lxml-security-c $LIBS"
+    AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
+    AC_MSG_CHECKING([XML-Security version])
+    AC_PREPROC_IFELSE(
+           [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
+        [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
+int i = 0;
+#else
+#error need version 1.3 or later
+#endif])],
+        [AC_MSG_RESULT(OK)],
+        [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
+    AC_TRY_LINK(
+            [#include <xsec/utils/XSECPlatformUtils.hpp>],
+            [XSECPlatformUtils::Initialise()],,
+            [AC_MSG_ERROR([unable to link with XML-Sec])])
+else
+    AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
+    [AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
+        [Define if you wish to disable XML-Security-dependent features.])]
+fi
+AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
 
 # Does the STL in use help or screw us?
 AC_TRY_LINK(
@@ -186,7 +206,7 @@ CXXTEST="/usr/bin/cxxtestgen.pl"
 CXXTESTFLAGS=""
 AC_ARG_WITH(cxxtest,
             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
-            [if test x_$with_xerces != x_/usr; then
+            [if test x_$with_cxxtest != x_/usr; then
                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
                 CXXTESTFLAGS="-I${with_cxxtest}"
             fi])
index 2796597..a26eb12 100644 (file)
@@ -38,7 +38,6 @@ ioinclude_HEADERS = \
     io/Unmarshaller.h
 
 siginclude_HEADERS = \
-    signature/KeyInfo.h \
     signature/Signature.h \
     signature/SigningContext.h
 
@@ -57,6 +56,13 @@ noinst_HEADERS = \
     impl/UnknownElement.h \
     signature/impl/XMLSecSignature.h
 
+if BUILD_XMLSEC
+xmlsec_sources = \
+    signature/impl/XMLSecSignature.cpp
+else
+xmlsec_sources =
+endif
+
 libxmltooling_la_SOURCES = \
     AbstractAttributeExtensibleXMLObject.cpp \
     AbstractDOMCachingXMLObject.cpp \
@@ -71,12 +77,12 @@ libxmltooling_la_SOURCES = \
     io/AbstractXMLObjectUnmarshaller.cpp \
     io/Marshaller.cpp \
     io/Unmarshaller.cpp \
-    signature/impl/XMLSecSignature.cpp \
     util/NDC.cpp \
     util/ParserPool.cpp \
     util/XMLConstants.cpp \
     util/XMLHelper.cpp \
-    validation/Validator.cpp
+    validation/Validator.cpp \
+    ${xmlsec_sources}
 
 # this is different from the project version
 # http://sources.redhat.com/autobook/autobook/autobook_91.html
index 8ff76d9..4b790f1 100644 (file)
@@ -2,3 +2,5 @@
    specialization. */
 #undef HAVE_GOOD_STL
 
+/* Define to 1 to disable XML-Security-dependent features. */
+#undef XMLTOOLING_NO_XMLSEC
index 9ba556a..a99e87b 100644 (file)
@@ -1,3 +1,6 @@
 /* Define to 1 if you have an STL implementation that supports useful string\r
    specialization. */\r
 #define HAVE_GOOD_STL 1\r
+\r
+/* Define to 1 to disable XML-Security-dependent features. */\r
+#undef XMLTOOLING_NO_XMLSEC\r
diff --git a/xmltooling/signature/KeyInfo.h b/xmltooling/signature/KeyInfo.h
deleted file mode 100644 (file)
index 9648a3c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*\r
- *  Copyright 2001-2006 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * @file KeyInfo.h\r
- * \r
- * XMLObject representing XML Digital Signature, version 20020212, KeyInfo element. \r
- */\r
-\r
-#if !defined(__xmltooling_keyinfo_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
-#define __xmltooling_keyinfo_h__\r
-\r
-#include <xmltooling/XMLObject.h>\r
-#include <xsec/dsig/DSIGKeyInfoList.hpp>\r
-\r
-namespace xmltooling {\r
-\r
-    /**\r
-     * XMLObject representing XML Digital Signature, version 20020212, KeyInfo element.\r
-     */\r
-    class XMLTOOL_API KeyInfo : public virtual XMLObject\r
-    {\r
-    public:\r
-        virtual ~KeyInfo() {}\r
-\r
-        /** Element local name */\r
-        static const XMLCh LOCAL_NAME[];\r
-\r
-        /**\r
-         * Returns immutable ds:KeyInfo information.\r
-         * \r
-         * @return the ds:KeyInfo information\r
-         */\r
-        virtual const DSIGKeyInfoList* getKeyInfo() const=0; \r
-\r
-        /**\r
-         * Returns mutable ds:KeyInfo information.\r
-         * \r
-         * @return the ds:KeyInfo information\r
-         */\r
-        virtual DSIGKeyInfoList* getKeyInfo()=0; \r
-        \r
-    protected:\r
-        KeyInfo() {}\r
-    };\r
-\r
-};\r
-\r
-#endif /* __xmltooling_keyinfo_h__ */\r
index fd219d6..9a8838a 100644 (file)
@@ -61,10 +61,11 @@ namespace xmltooling {
         /**\r
          * Returns the ds:KeyInfo information attached to the signature.\r
          * The Signature object must be marshalled before this will return anything.\r
+         * The caller MUST NOT mutate the information through the provided pointer.\r
          * \r
          * @return the ds:KeyInfo information\r
          */\r
-        virtual const DSIGKeyInfoList* getKeyInfo() const=0; \r
+        virtual DSIGKeyInfoList* getKeyInfo() const=0; \r
 \r
         /**\r
          * Sets the canonicalization method for the ds:SignedInfo element\r
index 1462ba6..5221329 100644 (file)
@@ -84,7 +84,7 @@ XMLObject* XMLSecSignatureImpl::clone() const
     return ret;\r
 }\r
 \r
-const DSIGKeyInfoList* XMLSecSignatureImpl::getKeyInfo() const\r
+DSIGKeyInfoList* XMLSecSignatureImpl::getKeyInfo() const\r
 {\r
     return m_signature ? m_signature->getKeyInfoList() : NULL;\r
 }\r
index 1bc0c1f..c196be5 100644 (file)
@@ -54,7 +54,7 @@ namespace xmltooling {
         // Getters\r
         const XMLCh* getCanonicalizationMethod() const { return m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC; }\r
         const XMLCh* getSignatureAlgorithm() const { return m_sm ? m_sm : DSIGConstants::s_unicodeStrURIRSA_SHA1; }\r
-        const DSIGKeyInfoList* getKeyInfo() const;\r
+        DSIGKeyInfoList* getKeyInfo() const;\r
 \r
         // Setters\r
         void setCanonicalizationMethod(const XMLCh* c14n) { m_c14n = prepareForAssignment(m_c14n,c14n); }\r
index 92f35d3..0e26bc0 100644 (file)
@@ -7,13 +7,20 @@ else
 bin_PROGRAMS = 
 endif
 
+if BUILD_XMLSEC
+xmlsec_sources = \
+    Signature.h
+else
+xmlsec_sources =
+endif
+
 xmltoolingtest_h = \
     ComplexXMLObjectTest.h \
     MarshallingTest.h \
-    Signature.h \
     UnknownTest.h \
     UnmarshallingTest.h \
-    xmltoolingtest.h
+    xmltoolingtest.h \
+    ${xmlsec_sources}
 
 noinst_HEADERS = \
     XMLObjectBaseTestCase.h