First release candidate. upstream/tags/1.0-rc1 tags/1.0-rc1
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Thu, 24 Jan 2008 06:26:54 +0000 (06:26 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Thu, 24 Jan 2008 06:26:54 +0000 (06:26 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/tags/1.0-rc1@456 de75baf8-a10c-0410-a50a-987c0e22f00f

55 files changed:
.cproject
Makefile.am
acx_pthread.m4
checkinstall [deleted file]
config_win32.h
configure.ac
depend [new file with mode: 0644]
doc/Makefile.am
pkginfo.in
postinstall [new file with mode: 0644]
schemas/xmldsig-core-schema.xsd
xmltooling.spec.in
xmltooling/AbstractAttributeExtensibleXMLObject.cpp
xmltooling/Makefile.am
xmltooling/Namespace.cpp
xmltooling/QName.cpp
xmltooling/XMLToolingConfig.cpp
xmltooling/base.h
xmltooling/config_pub.h.in
xmltooling/config_pub_win32.h
xmltooling/encryption/Encrypter.h
xmltooling/encryption/impl/Decrypter.cpp
xmltooling/io/AbstractXMLObjectMarshaller.cpp
xmltooling/io/HTTPRequest.cpp [new file with mode: 0644]
xmltooling/io/HTTPRequest.h
xmltooling/io/HTTPResponse.h
xmltooling/security/BasicX509Credential.h
xmltooling/security/Credential.h
xmltooling/security/CredentialCriteria.h
xmltooling/security/impl/AbstractPKIXTrustEngine.cpp
xmltooling/security/impl/CredentialCriteria.cpp
xmltooling/security/impl/ExplicitKeyTrustEngine.cpp
xmltooling/security/impl/FilesystemCredentialResolver.cpp
xmltooling/security/impl/InlineKeyResolver.cpp
xmltooling/soap/SOAP.h
xmltooling/soap/impl/CURLSOAPTransport.cpp
xmltooling/soap/impl/SOAPClient.cpp
xmltooling/soap/impl/SOAPImpl.cpp
xmltooling/soap/impl/SOAPSchemaValidators.cpp
xmltooling/util/CurlNetAccessor.cpp
xmltooling/util/CurlNetAccessor.hpp
xmltooling/util/CurlURLInputStream.cpp
xmltooling/util/CurlURLInputStream.hpp
xmltooling/util/DateTime.cpp
xmltooling/util/ParserPool.cpp
xmltooling/util/ParserPool.h
xmltooling/util/Predicates.h [new file with mode: 0644]
xmltooling/util/ReloadableXMLFile.cpp
xmltooling/util/TemplateEngine.h
xmltooling/util/XMLObjectChildrenList.h
xmltooling/xmltooling-lite.vcproj
xmltooling/xmltooling.vcproj
xmltoolingtest/EncryptionTest.h
xmltoolingtest/SignatureTest.h
xmltoolingtest/data/SimpleXMLObjectWithContent.xml

index 38380e1..ad22b26 100644 (file)
--- a/.cproject
+++ b/.cproject
 </scannerInfoProvider>\r
 </profile>\r
 </storageModule>\r
+\r
+<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="converted.config.943130369" moduleId="org.eclipse.cdt.core.settings" name="convertedConfig">\r
+<externalSettings/>\r
+<extensions>\r
+<extension id="org.eclipse.cdt.core.nullindexer" point="org.eclipse.cdt.core.CIndexer"/>\r
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>\r
+<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>\r
+</extensions>\r
+</storageModule>\r
 <storageModule moduleId="org.eclipse.cdt.core.pathentry">\r
+<pathentry include="C:/log4shib-1.0/include" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/xerces-c_2_8_0-x86-windows-vc_8_0/include" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/xml-security-c-1.4.0/include" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/openssl-0.9.8g/inc32" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/curl-7.17.1/include" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/cxxtest" kind="inc" path="" system="true"/>\r
+<pathentry base-path="cpp-xmltooling" include="" kind="inc" path="" system="true"/>\r
+<pathentry base-path="cpp-xmltooling" include="xmltooling" kind="inc" path="" system="true"/>\r
+<pathentry kind="mac" name="_MSC_VER" path="" value=""/>\r
+<pathentry kind="mac" name="WIN32" path="" value=""/>\r
 <pathentry kind="out" path="xmltooling/Debug"/>\r
 <pathentry kind="out" path="xmltoolingtest/Debug"/>\r
 <pathentry kind="out" path="debug"/>\r
 <pathentry kind="src" path="xmltooling/util"/>\r
 <pathentry kind="src" path="xmltooling/validation"/>\r
 <pathentry kind="src" path="xmltoolingtest"/>\r
-<pathentry include="C:/log4cpp-0.3.5rc1/include" kind="inc" path="" system="true"/>\r
-<pathentry include="C:/xerces-c2_7_0-win32/include" kind="inc" path="" system="true"/>\r
-<pathentry include="C:/xml-security-c-1.2.0/include" kind="inc" path="" system="true"/>\r
-<pathentry include="C:/cxxtest" kind="inc" path="" system="true"/>\r
-<pathentry base-path="XMLTooling-C" include="" kind="inc" path="" system="true"/>\r
-<pathentry base-path="XMLTooling-C" include="xmltooling" kind="inc" path="" system="true"/>\r
-<pathentry kind="mac" name="_MSC_VER" path="" value=""/>\r
-<pathentry kind="mac" name="WIN32" path="" value=""/>\r
-</storageModule>\r
-<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="converted.config.943130369" moduleId="org.eclipse.cdt.core.settings" name="convertedConfig">\r
-<externalSettings/>\r
-<extensions>\r
-<extension id="org.eclipse.cdt.core.nullindexer" point="org.eclipse.cdt.core.CIndexer"/>\r
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>\r
-<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>\r
-</extensions>\r
 </storageModule>\r
+<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>\r
+<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>\r
 </cconfiguration>\r
 </storageModule>\r
 </cproject>\r
index 25be000..05bea16 100644 (file)
@@ -8,6 +8,7 @@ MOSTLYCLEANFILES = $(DX_CLEANFILES)
 
 dist-hook:
        rm -rf `find $(distdir)/xmltoolingtest/data -name .svn`
+       rm -rf `find $(distdir)/doc/api -name .svn`
 
 
 SUBDIRS = doc schemas xmltooling xmltoolingtest
@@ -48,6 +49,7 @@ EXTRA_DIST = $(DX_CONFIG) \
         xmltooling.spec \
         pkginfo.in \
         pkginfo \
-        checkinstall
+        depend \
+        postinstall
 
 DISTCLEANFILES = xmltooling.spec pkginfo
index 7ac8ffd..33f1d29 100644 (file)
@@ -243,8 +243,15 @@ if test "x$acx_pthread_ok" = xyes; then
         AC_MSG_CHECKING([if more special flags are required for pthreads])
         flag=no
         case "${host_cpu}-${host_os}" in
-            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
-            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+                *-aix* | *-freebsd*)     flag="-D_THREAD_SAFE";;
+                *-osf* | *-hpux*) flag="-D_REENTRANT";;
+                *solaris*)
+                if test "$GCC" = "yes"; then
+                    flag="-D_REENTRANT"
+                else
+                    flag="-mt -D_REENTRANT"
+                fi
+                ;;
         esac
         AC_MSG_RESULT(${flag})
         if test "x$flag" != xno; then
diff --git a/checkinstall b/checkinstall
deleted file mode 100644 (file)
index 6adfb56..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh\r
-\r
-expected_platform="sparc"\r
-platform=`uname -p`\r
-if [ ${platform} != ${expected_platform} ]; then\r
-       echo "This package must be installed on ${expected_platform}"\r
-       exit 1\r
-fi\r
-exit 0\r
index 63a1a56..2f9815a 100644 (file)
    specialization. */
 #define HAVE_GOOD_STL 1
 
+/* Define to 1 if you have an STL implementation that supports
+   std::iterator_traits. */
+#define HAVE_ITERATOR_TRAITS 1
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 /* #undef HAVE_INTTYPES_H */
 
index ae4acd6..d14baf6 100644 (file)
@@ -106,10 +106,11 @@ AC_ARG_WITH(log4shib,
 if test -f "${LOG4SHIB_CONFIG}"; then
     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
-       AC_CHECK_HEADER([log4shib/Category.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
+       AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
        AC_TRY_LINK(
-               [#include <log4shib/Category.hh>],
-               [log4shib::Category::getInstance("foo")],
+               [#include <log4shib/Category.hh>
+#include <log4shib/CategoryStream.hh>],
+               [log4shib::Category::getInstance("foo").errorStream() << log4shib::eol],
                [AC_DEFINE(XMLTOOLING_LOG4SHIB,1,[Define if log4shib library is used.])],
                [AC_MSG_ERROR([unable to link with log4shib])])
 else
@@ -130,13 +131,13 @@ else
                AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
            LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
            CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
-               AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
-               AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
+               AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
                AC_TRY_LINK(
-                       [#include <log4cpp/Category.hh>],
-                       [log4cpp::Category::getInstance("foo")],
+                       [#include <log4cpp/Category.hh>
+#include <log4cpp/CategoryStream.hh>],
+                       [log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol],
                        [AC_DEFINE(XMLTOOLING_LOG4CPP,1,[Define if log4cpp library is used.])],
-                       [AC_MSG_ERROR([unable to link with log4cpp])])
+                       [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
        else
            AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
        fi
@@ -188,23 +189,21 @@ if test x_$with_xmlsec != x_no; then
     AC_MSG_CHECKING([XML-Security version])
     AC_PREPROC_IFELSE(
            [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
-        [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3) || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM == 3 && XSEC_VERSION_MINOR > 0)
+        [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
 int i = 0;
 #else
-#error need version 1.3.1 or later
+#error need version 1.4.0 or later
 #endif])],
         [AC_MSG_RESULT(OK)],
-        [AC_MSG_FAILURE([XML-Security version 1.3.1 or greater is required.])])
+        [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
     AC_TRY_LINK(
             [#include <xsec/utils/XSECPlatformUtils.hpp>],
             [XSECPlatformUtils::Initialise()],,
-            [AC_MSG_ERROR([unable to link with XML-Sec])])
+            [AC_MSG_ERROR([unable to link with XML-Security])])
 
        # restore master libs
        LIBS="$save_LIBS"
 
-       AC_LANG(C)
-
        # libcurl settings
        AC_PATH_PROG(CURL_CONFIG,curl-config)
        AC_ARG_WITH(curl,
@@ -240,8 +239,10 @@ int i = 0;
        AC_ARG_WITH(openssl,
            AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
            [if test x_$with_openssl != x_/usr; then
-               SSLFLAGS="-I${with_openssl}/include"
+            SSLFLAGS="-I${with_openssl}/include"
                SSLLIBS="-L${with_openssl}/lib -lcrypto -lssl"
+        else
+            SSLLIBS="-lcrypto -lssl"
            fi])
        
        if test "x$SSLLIBS" = "x" ; then
@@ -282,8 +283,6 @@ int i = 0;
        LIBS="$save_LIBS"
 
        AC_SUBST(XMLSEC_LIBS)
-       
-       AC_LANG(C++)
 else
     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
@@ -298,6 +297,12 @@ AC_TRY_LINK(
         [AC_DEFINE(HAVE_GOOD_STL,1,
             [Define if you have an STL implementation that supports useful string specialization.])],
         )
+AC_TRY_LINK(
+        [#include <vector>],
+        [std::iterator_traits<std::vector<int>::iterator>::value_type foo=0],
+        [AC_DEFINE(HAVE_ITERATOR_TRAITS,1,
+            [Define to 1 if you have an STL implementation that supports std::iterator_traits.])],
+        )
 
 # Check for unit test support
 CXXTEST="/usr/bin/cxxtestgen.pl"
diff --git a/depend b/depend
new file mode 100644 (file)
index 0000000..b663e92
--- /dev/null
+++ b/depend
@@ -0,0 +1,6 @@
+P SHIBossl OpenSSL\r
+       0.9.8g\r
+P SHIBxerces xerces-c\r
+       2.8.0\r
+P SHIBxmlsec xml-security-c\r
+       1.4.0\r
index 893ebd9..06ac078 100644 (file)
@@ -11,4 +11,4 @@ docfiles = \
 
 pkgdoc_DATA = $(docfiles)
 
-EXTRA_DIST = $(docfiles)
+EXTRA_DIST = $(docfiles) api
index 653cc91..34a0393 100644 (file)
@@ -1,10 +1,12 @@
-ARCH=sparc\r
 PKG=SHIBxmltool\r
-NAME=XML Tooling Library for C++\r
+ARCH=sparc\r
 VERSION=@-VERSION-@\r
-CATEGORY=system\r
-VENDOR=http://www.opensaml.org/ packaged for Shibboleth by Scott Cantor\r
-HOTLINE=http://bugzilla.internet2.edu/\r
-EMAIL=cantor.2@osu.edu\r
-PSTAMP=1May2006\r
+BASEDIR=/usr/local\r
+NAME=xmltooling-c\r
+CATEGORY=application,textproc,security\r
+DESC=Library for DOM processing with Signature/Encryption for C++\r
+VENDOR=Internet2\r
+HOTLINE=https://bugs.internet2.edu/\r
 CLASSES=none\r
+PSTAMP=sunra.internet2.edu 2007-11-15\r
+EMAIL=cantor.2@osu.edu\r
diff --git a/postinstall b/postinstall
new file mode 100644 (file)
index 0000000..321de70
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh\r
+\r
+cd ${CLIENT_BASEDIR}/share/xml/xmltooling\r
+\r
+sed "s|uri=\".*${CLIENT_BASEDIR}|uri=\"${CLIENT_BASEDIR}|1" catalog.xml > catalog.xml.tmp\r
+mv catalog.xml.tmp catalog.xml\r
+chmod 644 catalog.xml\r
+\r
+exit 0\r
index 50c834f..3cb1daa 100644 (file)
@@ -66,7 +66,7 @@
   <element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/> \r
   <complexType name="CanonicalizationMethodType" mixed="true">\r
     <sequence>\r
-      <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>\r
+      <any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>\r
       <!-- (0,unbounded) elements from (1,1) namespace -->\r
     </sequence>\r
     <attribute name="Algorithm" type="anyURI" use="required"/> \r
@@ -76,7 +76,7 @@
   <complexType name="SignatureMethodType" mixed="true">\r
     <sequence>\r
       <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>\r
-      <any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>\r
+      <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>\r
       <!-- (0,unbounded) elements from (1,1) external namespace -->\r
     </sequence>\r
     <attribute name="Algorithm" type="anyURI" use="required"/> \r
index 481b7e2..2bf5b3d 100644 (file)
@@ -1,17 +1,17 @@
 Name:          xmltooling
 Summary:       Open source XMLTooling library
 Version:       @-VERSION-@
-Release:       3
+Release:       5
 Group:         System Environment/Libraries
 Vendor:                Internet2
 License:       Apache 2.0
 URL:           http://www.opensaml.org/
 Source0:       %{name}-%{version}.tar.gz
 BuildRoot:     %{_tmppath}/%{name}-%{version}-root
-BuildRequires: xerces%{?xercesver}-c-devel >= 2.6.1
+BuildRequires:  xerces%{?xercesver}-c-devel >= 2.8.0
 BuildRequires: xml-security-c-devel >= 1.4.0
-BuildRequires: openssl-devel, cxxtest
-%{?_with_log4cpp:BuildRequires:        log4cpp-devel >= 0.3.5}
+BuildRequires: openssl-devel, curl-devel >= 7.10.6
+%{?_with_log4cpp:BuildRequires:        log4cpp-devel >= 1.0}
 %{!?_with_log4cpp:BuildRequires: log4shib-devel}
 
 %description
@@ -56,6 +56,8 @@ XMLTooling Library API documentation generated by doxygen.
 %install
 [ "$RPM_BUILD_ROOT" != "/" ] && %{__rm} -rf $RPM_BUILD_ROOT
 %{__make} install DESTDIR=$RPM_BUILD_ROOT
+find $RPM_BUILD_ROOT/%{_bindir} -type f |
+  %{__sed} -e "s|$RPM_BUILD_ROOT||" | sort > rpm.binlist
 
 %check || :
 %{__make} check
@@ -71,13 +73,12 @@ XMLTooling Library API documentation generated by doxygen.
 %postun -p /sbin/ldconfig
 %endif
 
-%files
+%files -f rpm.binlist
 %defattr(-,root,root,-)
 %{_libdir}/libxmltooling.so.*
 %{_libdir}/libxmltooling-lite.so.*
 %dir %{_datadir}/xml/xmltooling
 %{_datadir}/xml/xmltooling
-%exclude %{_bindir}/xmltoolingtest
 %docdir %{_datadir}/doc/xmltooling
 %{_datadir}/doc/xmltooling/LICENSE.txt
 %{_datadir}/doc/xmltooling/NOTICE.txt
@@ -96,6 +97,12 @@ XMLTooling Library API documentation generated by doxygen.
 %doc %{_datadir}/doc/xmltooling/api
 
 %changelog
+* Fri Jan 18 2008  Scott Cantor  <cantor.2@osu.edu>  - 1.0-5
+- Release candidate 1.
+
+* Thu Nov 08 2007  Scott Cantor  <cantor.2@osu.edu>  - 1.0-4
+- Second public beta.
+
 * Thu Aug 16 2007  Scott Cantor  <cantor.2@osu.edu>  - 1.0-3
 - First public beta.
 
index 74c4a34..2efde22 100644 (file)
@@ -55,25 +55,22 @@ void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedNa
     if (i!=m_attributeMap.end()) {
         releaseThisandParentDOM();
         XMLString::release(&(i->second));
-        if (value) {
+        if (value && *value) {
             i->second=XMLString::replicate(value);
+            if (ID)
+                m_idAttribute=i;
         }
         else {
             if (m_idAttribute==i)
                 m_idAttribute=m_attributeMap.end();
             m_attributeMap.erase(i);
         }
-        
-        if (ID) {
-            m_idAttribute=i;
-        }
     }
-    else if (value) {
+    else if (value && *value) {
         releaseThisandParentDOM();
         m_attributeMap[qualifiedName]=XMLString::replicate(value);
-        if (ID) {
+        if (ID)
             m_idAttribute = m_attributeMap.find(qualifiedName);
-        } 
     }
 }
 
index 511bc26..efb133f 100644 (file)
@@ -98,9 +98,12 @@ soapinclude_HEADERS = \
        soap/OpenSSLSOAPTransport.h
 
 utilinclude_HEADERS = \
+    util/CurlNetAccessor.hpp \
+    util/CurlURLInputStream.hpp \
        util/DateTime.h \
        util/NDC.h \
        util/ParserPool.h \
+       util/Predicates.h \
        util/ReloadableXMLFile.h \
        util/ReplayCache.h \
        util/StorageService.h \
@@ -140,6 +143,8 @@ xmlsec_sources = \
        signature/impl/SignatureValidator.cpp \
        signature/impl/XMLSecSignatureImpl.cpp \
        soap/impl/CURLSOAPTransport.cpp \
+       util/CurlNetAccessor.cpp \
+       util/CurlURLInputStream.cpp \
        util/ReplayCache.cpp \
        util/StorageService.cpp
 
@@ -167,6 +172,7 @@ common_sources = \
        impl/UnknownElement.cpp \
        io/AbstractXMLObjectMarshaller.cpp \
        io/AbstractXMLObjectUnmarshaller.cpp \
+       io/HTTPRequest.cpp \
        signature/impl/KeyInfoImpl.cpp \
        signature/impl/KeyInfoSchemaValidators.cpp \
        soap/impl/SOAPClient.cpp \
index ca3f896..ec272c0 100644 (file)
@@ -88,6 +88,8 @@ Namespace& Namespace::operator=(const Namespace& src)
 
 bool xmltooling::operator==(const Namespace& op1, const Namespace& op2)
 {
+    if (&op1 == &op2)
+        return true;
     return (XMLString::equals(op1.getNamespaceURI(),op2.getNamespaceURI()) &&
             XMLString::equals(op1.getNamespacePrefix(),op2.getNamespacePrefix()));
 }
index 29f2714..b161da6 100644 (file)
@@ -164,6 +164,8 @@ QName& QName::operator=(const QName& src)
 
 bool xmltooling::operator==(const QName& op1, const QName& op2)
 {
+    if (&op1 == &op2)
+        return true;
     return (!XMLString::compareString(op1.getNamespaceURI(),op2.getNamespaceURI()) &&
             !XMLString::compareString(op1.getLocalPart(),op2.getLocalPart()));
 }
index 476f8f1..2c06eac 100644 (file)
@@ -215,12 +215,12 @@ bool XMLToolingInternalConfig::init()
 #endif
 
         XMLPlatformUtils::Initialize();
-        log.debug("Xerces initialization complete");
+        log.debug("Xerces %s initialization complete", XERCES_FULLVERSIONDOT);
 
 #ifndef XMLTOOLING_NO_XMLSEC
         XSECPlatformUtils::Initialise();
         m_xsecProvider=new XSECProvider();
-        log.debug("XMLSec initialization complete");
+        log.debug("XML-Security %s initialization complete", XSEC_FULLVERSIONDOT);
 #endif
 
         m_parserPool=new ParserPool();
@@ -298,7 +298,7 @@ bool XMLToolingInternalConfig::init()
 # endif
 #endif
 
-    log.info("library initialization complete");
+    log.info("%s library initialization complete", PACKAGE_STRING);
     return true;
 }
 
@@ -375,7 +375,7 @@ void XMLToolingInternalConfig::term()
 #ifdef _DEBUG
     xmltooling::NDC ndc("term");
 #endif
-   Category::getInstance(XMLTOOLING_LOGCAT".XMLToolingConfig").info("library shutdown complete");
+   Category::getInstance(XMLTOOLING_LOGCAT".XMLToolingConfig").info("%s library shutdown complete", PACKAGE_STRING);
 }
 
 Lockable* XMLToolingInternalConfig::lock()
@@ -475,9 +475,9 @@ void xmltooling::log_openssl()
     unsigned long code=ERR_get_error_line_data(&file,&line,&data,&flags);
     while (code) {
         Category& log=Category::getInstance("OpenSSL");
-        log.errorStream() << "error code: " << code << " in " << file << ", line " << line << CategoryStream::ENDLINE;
+        log.errorStream() << "error code: " << code << " in " << file << ", line " << line << logging::eol;
         if (data && (flags & ERR_TXT_STRING))
-            log.errorStream() << "error data: " << data << CategoryStream::ENDLINE;
+            log.errorStream() << "error data: " << data << logging::eol;
         code=ERR_get_error_line_data(&file,&line,&data,&flags);
     }
 }
index 237f798..76fdc50 100644 (file)
 #define END_XMLOBJECT }
 
 /**
+ * Declares a static variable holding the XMLObject's element QName.
+ */
+#define DECL_ELEMENT_QNAME \
+    public: \
+        XMLTOOLING_DOXYGEN(Element QName) \
+        static xmltooling::QName ELEMENT_QNAME
+
+/**
+ * Declares a static variable holding the XMLObject's schema type QName.
+ */
+#define DECL_TYPE_QNAME \
+    public: \
+        XMLTOOLING_DOXYGEN(Type QName) \
+        static xmltooling::QName TYPE_QNAME
+
+/**
+ * Implements a static variable holding an XMLObject's element QName.
+ * 
+ * @param cname             the name of the XMLObject specialization
+ * @param namespaceURI      the XML namespace of the default associated element
+ * @param namespacePrefix   the XML namespace prefix of the default associated element
+ */
+#define IMPL_ELEMENT_QNAME(cname,namespaceURI,namespacePrefix) \
+    xmltooling::QName cname::ELEMENT_QNAME(namespaceURI,cname::LOCAL_NAME,namespacePrefix)
+
+/**
+ * Implements a static variable holding an XMLObject's schema type QName.
+ * 
+ * @param cname             the name of the XMLObject specialization
+ * @param namespaceURI      the XML namespace of the default associated element
+ * @param namespacePrefix   the XML namespace prefix of the default associated element
+ */
+#define IMPL_TYPE_QNAME(cname,namespaceURI,namespacePrefix) \
+    xmltooling::QName cname::TYPE_QNAME(namespaceURI,cname::TYPE_NAME,namespacePrefix)
+
+/**
  * Declares abstract set method for a typed XML attribute.
  * The get method is omitted.
  * 
  * @param namespaceURI  the XML namespace of the attribute
  */
 #define MARSHALL_STRING_ATTRIB(proper,ucase,namespaceURI) \
-    if (m_##proper) { \
+    if (m_##proper && *m_##proper) { \
         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
     }
 
  * @param namespaceURI  the XML namespace of the attribute
  */
 #define MARSHALL_INTEGER_ATTRIB(proper,ucase,namespaceURI) \
-    if (m_##proper) { \
+    if (m_##proper && *m_##proper) { \
         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
     }
 
  * @param namespaceURI  the XML namespace of the attribute
  */
 #define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \
-    if (m_##proper) { \
+    if (m_##proper && *m_##proper) { \
         domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \
         domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \
     }
 #define PROC_TYPED_CHILD(proper,namespaceURI,force) \
     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
         proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
-        if (typesafe) { \
-            set##proper(typesafe); \
+        if (typesafe && !m_##proper) { \
+            typesafe->setParent(this); \
+            *m_pos_##proper = m_##proper = typesafe; \
             return; \
         } \
     }
 #define PROC_TYPED_FOREIGN_CHILD(proper,ns,namespaceURI,force) \
     if (force || xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,ns::proper::LOCAL_NAME)) { \
         ns::proper* typesafe=dynamic_cast<ns::proper*>(childXMLObject); \
-        if (typesafe) { \
-            set##proper(typesafe); \
+        if (typesafe && !m_##proper) { \
+            typesafe->setParent(this); \
+            *m_pos_##proper = m_##proper = typesafe; \
             return; \
         } \
     }
  */
 #define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
     if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
-        set##proper(childXMLObject); \
-        return; \
+        if (!m_##proper) { \
+            childXMLObject->setParent(this); \
+            *m_pos_##proper = m_##proper = childXMLObject; \
+            return; \
+        } \
     }
 
 /**
 #define DECL_INTEGER_CONTENT(proper) \
     XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \
     std::pair<bool,int> get##proper() const { \
-        return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? xercesc::XMLString::parseInt(getTextContent()) : NULL)); \
+        return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? xercesc::XMLString::parseInt(getTextContent()) : 0)); \
     } \
     XMLTOOLING_DOXYGEN(Sets proper.) \
     void set##proper(int proper) { \
index 144d787..1ae9290 100644 (file)
@@ -5,6 +5,10 @@
    specialization. */
 #undef HAVE_GOOD_STL
 
+/* Define to 1 if you have an STL implementation that supports
+   std::iterator_traits. */
+#undef HAVE_ITERATOR_TRAITS
+
 /* Define if log4shib library is used. */
 #undef XMLTOOLING_LOG4SHIB
 
index 0c13ee2..bf1053b 100644 (file)
@@ -5,6 +5,10 @@
    specialization. */
 #define HAVE_GOOD_STL 1
 
+/* Define to 1 if you have an STL implementation that supports
+   std::iterator_traits. */
+#define HAVE_ITERATOR_TRAITS 1
+
 /* Define if log4shib library is used. */
 #define XMLTOOLING_LOG4SHIB 1
 
index 1c85762..e01803a 100644 (file)
@@ -77,7 +77,7 @@ namespace xmlencryption {
              * @param compact       true iff the encrypted representation should be made as small as possible
              */
             EncryptionParams(
-                const XMLCh* algorithm=DSIGConstants::s_unicodeStrURIAES256_CBC,
+                const XMLCh* algorithm=DSIGConstants::s_unicodeStrURIAES128_CBC,
                 const unsigned char* keyBuffer=NULL,
                 unsigned int keyBufferSize=0,
                 const xmltooling::Credential* credential=NULL,
index 47ed588..c68d1cd 100644 (file)
@@ -92,7 +92,7 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
         CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES |
         CredentialCriteria::KEYINFO_EXTRACTION_IMPLICIT_KEYNAMES;
     if (m_criteria) {
-        m_criteria->setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        m_criteria->setUsage(Credential::ENCRYPTION_CREDENTIAL);
         m_criteria->setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -101,7 +101,7 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
     }
     else {
         CredentialCriteria criteria;
-        criteria.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        criteria.setUsage(Credential::ENCRYPTION_CREDENTIAL);
         criteria.setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -192,7 +192,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
         CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES |
         CredentialCriteria::KEYINFO_EXTRACTION_IMPLICIT_KEYNAMES;
     if (m_criteria) {
-        m_criteria->setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        m_criteria->setUsage(Credential::ENCRYPTION_CREDENTIAL);
         m_criteria->setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -201,7 +201,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
     }
     else {
         CredentialCriteria criteria;
-        criteria.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        criteria.setUsage(Credential::ENCRYPTION_CREDENTIAL);
         criteria.setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -276,7 +276,7 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
         CredentialCriteria::KEYINFO_EXTRACTION_IMPLICIT_KEYNAMES;
     vector<const Credential*> creds;
     if (m_criteria) {
-        m_criteria->setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        m_criteria->setUsage(Credential::ENCRYPTION_CREDENTIAL);
         m_criteria->setKeyInfo(encryptedKey.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedKey.getEncryptionMethod();
         if (meth)
@@ -285,7 +285,7 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
     }
     else {
         CredentialCriteria criteria;
-        criteria.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        criteria.setUsage(Credential::ENCRYPTION_CREDENTIAL);
         criteria.setKeyInfo(encryptedKey.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedKey.getEncryptionMethod();
         if (meth)
index 500f431..0c87aff 100644 (file)
@@ -316,23 +316,22 @@ void AbstractXMLObjectMarshaller::marshallContent(
 {
     m_log.debug("marshalling text and child elements for XMLObject");
     
-    const XMLCh* val;
     unsigned int pos=0;
+    const XMLCh* val = getTextContent(pos);
+    if (val && *val)
+        domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));
+    
     const list<XMLObject*>& children=getOrderedChildren();
     for (list<XMLObject*>::const_iterator i=children.begin(); i!=children.end(); ++i) {
-        val = getTextContent(pos);
-        if (val && *val)
-            domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));
         if (*i) {
 #ifndef XMLTOOLING_NO_XMLSEC
             (*i)->marshall(domElement,NULL,credential);
 #else
             (*i)->marshall(domElement);
 #endif
-            ++pos;
+            val = getTextContent(++pos);
+            if (val && *val)
+                domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));
         }
     }
-    val = getTextContent(pos);
-    if (val && *val)
-        domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));
 }
diff --git a/xmltooling/io/HTTPRequest.cpp b/xmltooling/io/HTTPRequest.cpp
new file mode 100644 (file)
index 0000000..ff73107
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  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.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * HTTPRequest.cpp
+ * 
+ * Interface to HTTP requests  
+ */
+
+#include "internal.h"
+#include "HTTPRequest.h"
+
+using namespace xmltooling;
+using namespace std;
+
+const char* HTTPRequest::getCookie(const char* name) const
+{
+    if (m_cookieMap.empty()) {
+        string cookies=getHeader("Cookie");
+
+        string::size_type pos=0,cname,namelen,val,vallen;
+        while (pos !=string::npos && pos < cookies.length()) {
+            while (isspace(cookies[pos])) pos++;
+            cname=pos;
+            pos=cookies.find_first_of("=",pos);
+            if (pos == string::npos)
+                break;
+            namelen=pos-cname;
+            pos++;
+            if (pos==cookies.length())
+                break;
+            val=pos;
+            pos=cookies.find_first_of(";",pos);
+            if (pos != string::npos) {
+                vallen=pos-val;
+                pos++;
+                m_cookieMap.insert(make_pair(cookies.substr(cname,namelen),cookies.substr(val,vallen)));
+            }
+            else
+                m_cookieMap.insert(make_pair(cookies.substr(cname,namelen),cookies.substr(val)));
+        }
+    }
+    map<string,string>::const_iterator lookup=m_cookieMap.find(name);
+    return (lookup==m_cookieMap.end()) ? NULL : lookup->second.c_str();
+}
index caee6d5..2a5abf7 100644 (file)
 
 #include <xmltooling/io/GenericRequest.h>
 
+#include <map>
+
 namespace xmltooling {
-    
+
+#if defined (_MSC_VER)
+    #pragma warning( push )
+    #pragma warning( disable : 4251 )
+#endif
+
     /**
      * Interface to HTTP requests.
      * 
@@ -83,7 +90,23 @@ namespace xmltooling {
          * @return the header's value, or an empty string
          */
         virtual std::string getHeader(const char* name) const=0;
+
+        /**
+         * Get a cookie value supplied by the client.
+         * 
+         * @param name  name of cookie
+         * @return  cookie value or NULL
+         */
+        virtual const char* getCookie(const char* name) const;
+
+    private:
+        mutable std::map<std::string,std::string> m_cookieMap;
     };
+
+#if defined (_MSC_VER)
+    #pragma warning( pop )
+#endif
+
 };
 
 #endif /* __xmltooling_httpreq_h__ */
index 63e1f4b..77aec51 100644 (file)
@@ -79,6 +79,7 @@ namespace xmltooling {
         enum status_t {
             XMLTOOLING_HTTP_STATUS_OK = 200,
             XMLTOOLING_HTTP_STATUS_MOVED = 302,
+            XMLTOOLING_HTTP_STATUS_UNAUTHORIZED = 401,
             XMLTOOLING_HTTP_STATUS_FORBIDDEN = 403,
             XMLTOOLING_HTTP_STATUS_NOTFOUND = 404,
             XMLTOOLING_HTTP_STATUS_ERROR = 500
index 6b4b486..b398133 100644 (file)
@@ -84,6 +84,9 @@ namespace xmltooling {
     public:
         virtual ~BasicX509Credential();
         
+        unsigned int getUsage() const {
+            return UNSPECIFIED_CREDENTIAL;
+        }
         const char* getAlgorithm() const;
         unsigned int getKeySize() const;
 
index 8fa7bb4..02d4999 100644 (file)
@@ -62,6 +62,23 @@ namespace xmltooling {
         };
 
         /**
+         * Bitmask of use cases for credentials. 
+         */
+        enum UsageTypes {
+            UNSPECIFIED_CREDENTIAL = 0,
+            SIGNING_CREDENTIAL = 1,
+            TLS_CREDENTIAL = 2,
+            ENCRYPTION_CREDENTIAL = 4
+        };
+        
+        /**
+         * Get credential usage types.
+         * 
+         * @return the usage bitmask
+         */
+        virtual unsigned int getUsage() const=0;
+
+        /**
          * Returns an algorithm identifier for the Credential.
          *
          * @return  the Credential algorithm, or NULL if indeterminate
index d331c89..8e40b9f 100644 (file)
@@ -42,7 +42,7 @@ namespace xmltooling {
     {
         MAKE_NONCOPYABLE(CredentialCriteria);
     public:
-        CredentialCriteria() : m_keyUsage(UNSPECIFIED_CREDENTIAL), m_keySize(0), m_key(NULL),
+        CredentialCriteria() : m_keyUsage(Credential::UNSPECIFIED_CREDENTIAL), m_keySize(0), m_key(NULL),
             m_keyInfo(NULL), m_nativeKeyInfo(NULL), m_credential(NULL) {
         }
         virtual ~CredentialCriteria() {
@@ -56,32 +56,22 @@ namespace xmltooling {
          * @return true iff the Credential is consistent with this criteria
          */
         virtual bool matches(const Credential& credential) const;
-
-        /**
-         * Enumeration of use cases for credentials. 
-         */
-        enum UsageType {
-            UNSPECIFIED_CREDENTIAL,
-            SIGNING_CREDENTIAL,
-            TLS_CREDENTIAL,
-            ENCRYPTION_CREDENTIAL
-        };
-        
+       
         /**
-         * Get the key usage criteria.
+         * Get key usage criteria.
          * 
-         * @return the usage.
+         * @return the usage mask
          */
-        UsageType getUsage() const {
+        unsigned int getUsage() const {
             return m_keyUsage;
         }
     
         /**
-         * Set the key usage criteria.
+         * Set key usage criteria.
          * 
-         * @param usage the usage to set
+         * @param usage the usage mask to set
          */
-        void setUsage(UsageType usage) {
+        void setUsage(unsigned int usage) {
             m_keyUsage = usage;
         }
 
@@ -301,7 +291,7 @@ namespace xmltooling {
         }
 
     private:
-        UsageType m_keyUsage;
+        unsigned int m_keyUsage;
         unsigned int m_keySize;
         std::string m_peerName,m_keyAlgorithm;
         std::set<std::string> m_keyNames;
index b98ce39..69e24f3 100644 (file)
@@ -169,7 +169,7 @@ bool AbstractPKIXTrustEngine::checkEntityNames(
             buf[len] = '\0';
             subjectstr+=buf;
         }
-        log.debugStream() << "certificate subject: " << subjectstr << CategoryStream::ENDLINE;
+        log.debugStream() << "certificate subject: " << subjectstr << logging::eol;
         // The flags give us LDAP order instead of X.500, with a comma plus space separator.
         len=X509_NAME_print_ex(b2,subject,0,XN_FLAG_RFC2253 + XN_FLAG_SEP_CPLUS_SPC - XN_FLAG_SEP_COMMA_PLUS);
         BIO_flush(b2);
@@ -262,8 +262,8 @@ bool AbstractPKIXTrustEngine::validate(
 
     if (criteria && criteria->getPeerName() && *(criteria->getPeerName())) {
         log.debug("checking that the certificate name is acceptable");
-        if (criteria->getUsage()==CredentialCriteria::UNSPECIFIED_CREDENTIAL)
-            criteria->setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        if (criteria->getUsage()==Credential::UNSPECIFIED_CREDENTIAL)
+            criteria->setUsage(Credential::SIGNING_CREDENTIAL);
         if (!checkEntityNames(certEE,credResolver,*criteria)) {
             log.error("certificate name was not acceptable");
             return false;
index e229a06..9d3cabd 100644 (file)
@@ -36,6 +36,13 @@ using namespace std;
 
 bool CredentialCriteria::matches(const Credential& credential) const
 {
+    // Usage check, if specified and we have one, compare masks.
+    if (getUsage() != Credential::UNSPECIFIED_CREDENTIAL) {
+        if (credential.getUsage() != Credential::UNSPECIFIED_CREDENTIAL)
+            if ((getUsage() & credential.getUsage()) == 0)
+                return false;
+    }
+
     // Algorithm check, if specified and we have one.
     const char* alg = getKeyAlgorithm();
     if (alg && *alg) {
@@ -65,11 +72,11 @@ bool CredentialCriteria::matches(const Credential& credential) const
     }
 
     // See if we have to match a specific key.
-    XSECCryptoKey* key1 = getPublicKey();
+    const XSECCryptoKey* key1 = getPublicKey();
     if (!key1)
         return true;    // no key to compare against, so we're done
 
-    XSECCryptoKey* key2 = credential.getPublicKey();
+    const XSECCryptoKey* key2 = credential.getPublicKey();
     if (!key2)
         return true;   // no key here, so we can't test it
 
@@ -82,16 +89,16 @@ bool CredentialCriteria::matches(const Credential& credential) const
     if (key1->getKeyType()==XSECCryptoKey::KEY_RSA_PUBLIC || key1->getKeyType()==XSECCryptoKey::KEY_RSA_PAIR) {
         if (key2->getKeyType()!=XSECCryptoKey::KEY_RSA_PUBLIC && key2->getKeyType()!=XSECCryptoKey::KEY_RSA_PAIR)
             return false;
-        RSA* rsa1 = static_cast<OpenSSLCryptoKeyRSA*>(key1)->getOpenSSLRSA();
-        RSA* rsa2 = static_cast<OpenSSLCryptoKeyRSA*>(key2)->getOpenSSLRSA();
+        const RSA* rsa1 = static_cast<const OpenSSLCryptoKeyRSA*>(key1)->getOpenSSLRSA();
+        const RSA* rsa2 = static_cast<const OpenSSLCryptoKeyRSA*>(key2)->getOpenSSLRSA();
         return (BN_cmp(rsa1->n,rsa2->n) == 0 && BN_cmp(rsa1->e,rsa2->e) == 0);
     }
 
     if (key1->getKeyType()==XSECCryptoKey::KEY_DSA_PUBLIC || key1->getKeyType()==XSECCryptoKey::KEY_DSA_PAIR) {
         if (key2->getKeyType()!=XSECCryptoKey::KEY_DSA_PUBLIC && key2->getKeyType()!=XSECCryptoKey::KEY_DSA_PAIR)
             return false;
-        DSA* dsa1 = static_cast<OpenSSLCryptoKeyDSA*>(key1)->getOpenSSLDSA();
-        DSA* dsa2 = static_cast<OpenSSLCryptoKeyDSA*>(key2)->getOpenSSLDSA();
+        const DSA* dsa1 = static_cast<const OpenSSLCryptoKeyDSA*>(key1)->getOpenSSLDSA();
+        const DSA* dsa2 = static_cast<const OpenSSLCryptoKeyDSA*>(key2)->getOpenSSLDSA();
         return (BN_cmp(dsa1->pub_key,dsa2->pub_key) == 0);
     }
     
index bed55d5..346c35f 100644 (file)
@@ -94,13 +94,13 @@ bool ExplicitKeyTrustEngine::validate(
 
     vector<const Credential*> credentials;
     if (criteria) {
-        criteria->setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        criteria->setUsage(Credential::SIGNING_CREDENTIAL);
         criteria->setSignature(sig, CredentialCriteria::KEYINFO_EXTRACTION_KEY);
         credResolver.resolve(credentials,criteria);
     }
     else {
         CredentialCriteria cc;
-        cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        cc.setUsage(Credential::SIGNING_CREDENTIAL);
         cc.setSignature(sig, CredentialCriteria::KEYINFO_EXTRACTION_KEY);
         credResolver.resolve(credentials,&cc);
     }
@@ -144,14 +144,14 @@ bool ExplicitKeyTrustEngine::validate(
     
     vector<const Credential*> credentials;
     if (criteria) {
-        criteria->setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        criteria->setUsage(Credential::SIGNING_CREDENTIAL);
         criteria->setKeyInfo(keyInfo, CredentialCriteria::KEYINFO_EXTRACTION_KEY);
         criteria->setXMLAlgorithm(sigAlgorithm);
         credResolver.resolve(credentials,criteria);
     }
     else {
         CredentialCriteria cc;
-        cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        cc.setUsage(Credential::SIGNING_CREDENTIAL);
         cc.setKeyInfo(keyInfo, CredentialCriteria::KEYINFO_EXTRACTION_KEY);
         cc.setXMLAlgorithm(sigAlgorithm);
         credResolver.resolve(credentials,&cc);
@@ -223,13 +223,13 @@ bool ExplicitKeyTrustEngine::validate(
 
     vector<const Credential*> credentials;
     if (criteria) {
-        if (criteria->getUsage()==CredentialCriteria::UNSPECIFIED_CREDENTIAL)
-            criteria->setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        if (criteria->getUsage()==Credential::UNSPECIFIED_CREDENTIAL)
+            criteria->setUsage(Credential::SIGNING_CREDENTIAL);
         credResolver.resolve(credentials,criteria);
     }
     else {
         CredentialCriteria cc;
-        cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        cc.setUsage(Credential::SIGNING_CREDENTIAL);
         credResolver.resolve(credentials,&cc);
     }
     if (credentials.empty()) {
index 7bf0d0e..9ccf160 100644 (file)
@@ -27,6 +27,7 @@
 #include "security/CredentialResolver.h"
 #include "security/KeyInfoResolver.h"
 #include "security/OpenSSLCredential.h"
+#include "security/OpenSSLCryptoX509CRL.h"
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
@@ -68,8 +69,9 @@ namespace xmltooling {
     class XMLTOOL_DLLLOCAL FilesystemCredential : public OpenSSLCredential, public BasicX509Credential
     {
     public:
-        FilesystemCredential(FilesystemCredentialResolver* resolver, XSECCryptoKey* key, const std::vector<XSECCryptoX509*>& xseccerts)
-                : BasicX509Credential(key, xseccerts), m_resolver(resolver) {
+        FilesystemCredential(
+            FilesystemCredentialResolver* resolver, XSECCryptoKey* key, const std::vector<XSECCryptoX509*>& xseccerts, XSECCryptoX509CRL* crl=NULL
+            ) : BasicX509Credential(key, xseccerts, crl), m_resolver(resolver), m_usage(UNSPECIFIED_CREDENTIAL) {
             if (!m_xseccerts.empty())
                 extractNames(m_xseccerts.front(), m_keyNames);
             initKeyInfo();
@@ -77,12 +79,29 @@ namespace xmltooling {
         virtual ~FilesystemCredential() {
         }
 
+        unsigned int getUsage() const {
+            return m_usage;
+        }
+
+        void setUsage(const XMLCh* usage) {
+            if (usage && *usage) {
+                auto_ptr_char u(usage);
+                if (!strcmp(u.get(), "signing"))
+                    m_usage = SIGNING_CREDENTIAL | TLS_CREDENTIAL;
+                else if (!strcmp(u.get(), "TLS"))
+                    m_usage = TLS_CREDENTIAL;
+                else if (!strcmp(u.get(), "encryption"))
+                    m_usage = ENCRYPTION_CREDENTIAL;
+            }
+        }
+
         void addKeyNames(const DOMElement* e);
 
         void attach(SSL_CTX* ctx) const;
     
     private:
         FilesystemCredentialResolver* m_resolver;
+        unsigned int m_usage;
     };
 
 #if defined (_MSC_VER)
@@ -119,6 +138,7 @@ namespace xmltooling {
 
     private:
         XSECCryptoKey* loadKey();
+        XSECCryptoX509CRL* loadCRL();
         
         enum format_t { PEM=SSL_FILETYPE_PEM, DER=SSL_FILETYPE_ASN1, _PKCS12, UNKNOWN };
     
@@ -126,8 +146,8 @@ namespace xmltooling {
         string formatToString(format_t format) const;
         format_t xmlFormatToFormat(const XMLCh* format_xml) const;
     
-        format_t m_keyformat;
-        string m_keypath,m_keypass;
+        format_t m_keyformat,m_certformat,m_crlformat;
+        string m_keypath,m_keypass,m_certpath,m_certpass,m_crlpath;
         vector<X509*> m_certs;
         FilesystemCredential* m_credential;
     };
@@ -141,12 +161,14 @@ namespace xmltooling {
     static const XMLCh CAPath[] =           UNICODE_LITERAL_6(C,A,P,a,t,h);
     static const XMLCh Certificate[] =      UNICODE_LITERAL_11(C,e,r,t,i,f,i,c,a,t,e);
     static const XMLCh _certificate[] =     UNICODE_LITERAL_11(c,e,r,t,i,f,i,c,a,t,e);
+    static const XMLCh CRL[] =              UNICODE_LITERAL_3(C,R,L);
     static const XMLCh format[] =           UNICODE_LITERAL_6(f,o,r,m,a,t);
     static const XMLCh Key[] =              UNICODE_LITERAL_3(K,e,y);
     static const XMLCh _key[] =             UNICODE_LITERAL_3(k,e,y);
     static const XMLCh Name[] =             UNICODE_LITERAL_4(N,a,m,e);
     static const XMLCh password[] =         UNICODE_LITERAL_8(p,a,s,s,w,o,r,d);
     static const XMLCh Path[] =             UNICODE_LITERAL_4(P,a,t,h);
+    static const XMLCh _use[] =             UNICODE_LITERAL_3(u,s,e);
 };
 
 FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e) : m_credential(NULL)
@@ -181,9 +203,11 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
     }
     
     const DOMElement* root=e;
+    const XMLCh* usage = root->getAttributeNS(NULL,_use);
 
     XSECCryptoKey* key=NULL;
     vector<XSECCryptoX509*> xseccerts;
+    XSECCryptoX509CRL* crl=NULL;
 
     format_t fformat;
     const XMLCh* format_xml=NULL;
@@ -192,7 +216,6 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
     // Move to Key
     const DOMElement* keynode=XMLHelper::getFirstChildElement(root,Key);
     if (keynode) {
-
         // Get raw format attrib value, but defer processing til later since may need to 
         // determine format dynamically, and we need the Path for that.
         format_xml=keynode->getAttributeNS(NULL,format);
@@ -255,12 +278,73 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
         // Load the key.
         key = loadKey();
     }
+    
+    // Check for CRL.
+    const DOMElement* crlnode=XMLHelper::getFirstChildElement(root,CRL);
+    if (crlnode) {
+        // Get raw format attrib value, but defer processing til later since may need to 
+        // determine format dynamically, and we need the Path for that.
+        format_xml=crlnode->getAttributeNS(NULL,format);
+            
+        e=XMLHelper::getFirstChildElement(crlnode,Path);
+        if (e && e->hasChildNodes()) {
+            const XMLCh* s=e->getFirstChild()->getNodeValue();
+            auto_ptr_char kpath(s);
+#ifdef WIN32
+            struct _stat stat_buf;
+            if (_stat(kpath.get(), &stat_buf) != 0)
+#else
+            struct stat stat_buf;
+            if (stat(kpath.get(), &stat_buf) != 0)
+#endif
+            {
+                log.error("CRL file (%s) can't be opened", kpath.get());
+                throw XMLSecurityException("FilesystemCredentialResolver can't access CRL file ($1)",params(1,kpath.get()));
+            }
+            m_crlpath=kpath.get();
+        }
+        else {
+            log.error("Path element missing inside CRL element");
+            throw XMLSecurityException("FilesystemCredentialResolver can't access CRL file, no Path element specified.");
+        }
+
+        // Determine the CRL encoding format dynamically, if not explicitly specified
+        if (format_xml && *format_xml) {
+            fformat = xmlFormatToFormat(format_xml);
+            if (fformat != UNKNOWN) {
+                m_crlformat = fformat;
+            }
+            else {
+                auto_ptr_char unknown(format_xml);
+                log.error("configuration specifies unknown CRL encoding format (%s)", unknown.get());
+                throw XMLSecurityException("FilesystemCredentialResolver configuration contains unknown CRL encoding format ($1)",params(1,unknown.get()));
+            }
+        }
+        else {
+            in=BIO_new(BIO_s_file_internal());
+            if (in && BIO_read_filename(in,m_crlpath.c_str())>0) {
+                m_crlformat = getEncodingFormat(in);
+                log.debug("CRL encoding format for (%s) dynamically resolved as (%s)", m_crlpath.c_str(), formatToString(m_crlformat).c_str());
+            }
+            else {
+                log.error("CRL file (%s) can't be read to determine encoding format", m_crlpath.c_str());
+                throw XMLSecurityException("FilesystemCredentialResolver can't read CRL file ($1) to determine encoding format",params(1,m_crlpath.c_str()));
+            }
+            if (in)
+                BIO_free(in);
+            in = NULL;
+        }
         
+        // Load the key.
+        crl = loadCRL();
+    }
+
     // Check for Certificate
     e=XMLHelper::getFirstChildElement(root,Certificate);
     if (!e) {
-        m_credential = new FilesystemCredential(this,key,xseccerts);
+        m_credential = new FilesystemCredential(this,key,xseccerts,crl);
         m_credential->addKeyNames(keynode);
+        m_credential->setUsage(usage);
         return;
     }
     auto_ptr_char certpass(e->getAttributeNS(NULL,password));
@@ -269,6 +353,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
     if (!ep || !ep->hasChildNodes()) {
         log.error("Path element missing inside Certificate element or is empty");
         delete key;
+        delete crl;
         throw XMLSecurityException("FilesystemCredentialResolver can't access certificate file, missing or empty Path element.");
     }
     
@@ -280,6 +365,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
             auto_ptr_char unknown(format_xml);
             log.error("configuration specifies unknown certificate encoding format (%s)", unknown.get());
             delete key;
+            delete crl;
             throw XMLSecurityException("FilesystemCredentialResolver configuration contains unknown certificate encoding format ($1)",params(1,unknown.get()));
         }
     }
@@ -414,6 +500,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
     }
     catch (XMLToolingException&) {
         delete key;
+        delete crl;
         for_each(m_certs.begin(), m_certs.end(), X509_free);
         throw;
     }
@@ -423,8 +510,9 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
         xseccerts.push_back(new OpenSSLCryptoX509(*j));
     if (!key && !xseccerts.empty())
         key = xseccerts.front()->clonePublicKey();
-    m_credential = new FilesystemCredential(this, key, xseccerts);
+    m_credential = new FilesystemCredential(this, key, xseccerts, crl);
     m_credential->addKeyNames(keynode);
+    m_credential->setUsage(usage);
 }
 
 XSECCryptoKey* FilesystemCredentialResolver::loadKey()
@@ -482,6 +570,39 @@ XSECCryptoKey* FilesystemCredentialResolver::loadKey()
     throw XMLSecurityException("FilesystemCredentialResolver unable to load private key from file."); 
 }
 
+XSECCryptoX509CRL* FilesystemCredentialResolver::loadCRL()
+{
+#ifdef _DEBUG
+    NDC ndc("loadCRL");
+#endif
+
+    X509_CRL* crl=NULL;
+    BIO* in=BIO_new(BIO_s_file_internal());
+    if (in && BIO_read_filename(in,m_crlpath.c_str())>0) {
+        switch (m_crlformat) {
+            case PEM:
+                crl=PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
+                break;
+            
+            case DER:
+                crl=d2i_X509_CRL_bio(in, NULL);
+                break;
+        }
+    }
+    if (in)
+        BIO_free(in);
+    
+    // Now map it to an XSEC wrapper.
+    if (crl) {
+        XSECCryptoX509CRL* ret=new OpenSSLCryptoX509CRL(crl);
+        X509_CRL_free(crl);
+        return ret;
+    }
+
+    log_openssl();
+    throw XMLSecurityException("FilesystemCredentialResolver unable to load CRL from file."); 
+}
+
 // Used to determine the encoding format of credentials files
 // dynamically. Supports: PEM, DER, PKCS12.
 FilesystemCredentialResolver::format_t FilesystemCredentialResolver::getEncodingFormat(BIO* in) const
index 126a6ea..deaf595 100644 (file)
@@ -239,32 +239,6 @@ bool InlineCredential::resolveKey(const KeyInfo* keyInfo)
         }
     }
 
-    // Check for RetrievalMethod.
-    const XMLCh* fragID=NULL;
-    const XMLObject* treeRoot=NULL;
-    const vector<RetrievalMethod*>& methods=keyInfo->getRetrievalMethods();
-    for (vector<RetrievalMethod*>::const_iterator m=methods.begin(); m!=methods.end(); ++m) {
-        if (!XMLString::equals((*m)->getType(),RetrievalMethod::TYPE_RSAKEYVALUE) &&
-            !XMLString::equals((*m)->getType(),RetrievalMethod::TYPE_DSAKEYVALUE))
-            continue;
-        fragID = (*m)->getURI();
-        if (!fragID || *fragID != chPound || !*(fragID+1)) {
-            log.warn("skipping ds:RetrievalMethod with an empty or non-local reference");
-            continue;
-        }
-        if (!treeRoot) {
-            treeRoot = keyInfo;
-            while (treeRoot->getParent())
-                treeRoot = treeRoot->getParent();
-        }
-        keyInfo = dynamic_cast<const KeyInfo*>(XMLHelper::getXMLObjectById(*treeRoot, fragID+1));
-        if (!keyInfo) {
-            log.warn("skipping ds:RetrievalMethod, local reference did not resolve to a ds:KeyInfo");
-            continue;
-        }
-        if (resolveKey(keyInfo))
-            return true;
-    }
     return false;
 }
 
@@ -298,35 +272,6 @@ bool InlineCredential::resolveCerts(const KeyInfo* keyInfo)
             }
         }
     }
-
-    if (m_xseccerts.empty()) {
-        // Check for RetrievalMethod.
-        const XMLCh* fragID=NULL;
-        const XMLObject* treeRoot=NULL;
-        const vector<RetrievalMethod*> methods=keyInfo->getRetrievalMethods();
-        for (vector<RetrievalMethod*>::const_iterator m=methods.begin(); m!=methods.end(); ++m) {
-            if (!XMLString::equals((*m)->getType(),RetrievalMethod::TYPE_X509DATA))
-                continue;
-            fragID = (*m)->getURI();
-            if (!fragID || *fragID != chPound || !*(fragID+1)) {
-                log.warn("skipping ds:RetrievalMethod with an empty or non-local reference");
-                continue;
-            }
-            if (!treeRoot) {
-                treeRoot = keyInfo;
-                while (treeRoot->getParent())
-                    treeRoot = treeRoot->getParent();
-            }
-            keyInfo = dynamic_cast<const KeyInfo*>(XMLHelper::getXMLObjectById(*treeRoot, fragID+1));
-            if (!keyInfo) {
-                log.warn("skipping ds:RetrievalMethod, local reference did not resolve to a ds:KeyInfo");
-                continue;
-            }
-            if (resolveCerts(keyInfo))
-                return true;
-        }
-        return false;
-    }
     
     log.debug("resolved %d certificate(s)", m_xseccerts.size());
     return !m_xseccerts.empty();
@@ -356,40 +301,14 @@ bool InlineCredential::resolveCRL(const KeyInfo* keyInfo)
             }
             catch(XSECException& e) {
                 auto_ptr_char temp(e.getMsg());
-                log.error("caught XML-Security exception loading certificate: %s", temp.get());
+                log.error("caught XML-Security exception loading CRL: %s", temp.get());
             }
             catch(XSECCryptoException& e) {
-                log.error("caught XML-Security exception loading certificate: %s", e.getMsg());
+                log.error("caught XML-Security exception loading CRL: %s", e.getMsg());
             }
         }
     }
 
-    // Check for RetrievalMethod.
-    const XMLCh* fragID=NULL;
-    const XMLObject* treeRoot=NULL;
-    const vector<RetrievalMethod*> methods=keyInfo->getRetrievalMethods();
-    for (vector<RetrievalMethod*>::const_iterator m=methods.begin(); m!=methods.end(); ++m) {
-        if (!XMLString::equals((*m)->getType(),RetrievalMethod::TYPE_X509DATA))
-            continue;
-        fragID = (*m)->getURI();
-        if (!fragID || *fragID != chPound || !*(fragID+1)) {
-            log.warn("skipping ds:RetrievalMethod with an empty or non-local reference");
-            continue;
-        }
-        if (!treeRoot) {
-            treeRoot = keyInfo;
-            while (treeRoot->getParent())
-                treeRoot = treeRoot->getParent();
-        }
-        keyInfo = dynamic_cast<const KeyInfo*>(XMLHelper::getXMLObjectById(*treeRoot, fragID+1));
-        if (!keyInfo) {
-            log.warn("skipping ds:RetrievalMethod, local reference did not resolve to a ds:KeyInfo");
-            continue;
-        }
-        if (resolveCRL(keyInfo))
-            return true;
-    }
-
     return false;
 }
 
index 8ef5de0..031599b 100644 (file)
@@ -81,8 +81,10 @@ namespace soap11 {
     END_XMLOBJECT;
 
     BEGIN_XMLOBJECT(XMLTOOL_API,Header,xmltooling::ElementProxy,SOAP 1.1 Header element);
-        DECL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,false);
-        DECL_STRING_ATTRIB(Actor,ACTOR);
+        /** Actor header block attribute name */
+        static const XMLCh ACTOR_ATTRIB_NAME[];
+        /** mustUnderstand header block attribute name */
+        static const XMLCh MUSTUNDERSTAND_ATTRIB_NAME[];
         /** Header (type) local name */
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
@@ -95,13 +97,13 @@ namespace soap11 {
     END_XMLOBJECT;
 
     DECL_SOAP11OBJECTBUILDER(Body);
-    DECL_SOAP11OBJECTBUILDER(Detail);
     DECL_SOAP11OBJECTBUILDER(Envelope);
     DECL_SOAP11OBJECTBUILDER(Fault);
-    DECL_SOAP11OBJECTBUILDER(Faultactor);
-    DECL_SOAP11OBJECTBUILDER(Faultcode);
-    DECL_SOAP11OBJECTBUILDER(Faultstring);
     DECL_SOAP11OBJECTBUILDER(Header);
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,Detail,NULL,NULL);
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,Faultactor,NULL,NULL);
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,Faultcode,NULL,NULL);
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,Faultstring,NULL,NULL);
 
     /**
      * Registers builders and validators for SOAP 1.1 classes into the runtime.
index 190d6a1..bde039d 100644 (file)
@@ -154,11 +154,16 @@ namespace xmltooling {
             CURLoption opt = static_cast<CURLoption>(strtol(option, NULL, 10));
             if (opt < CURLOPTTYPE_OBJECTPOINT)
                 return (curl_easy_setopt(m_handle, opt, strtol(value, NULL, 10)) == CURLE_OK);
+#ifdef CURLOPTTYPE_OFF_T
             else if (opt < CURLOPTTYPE_OFF_T)
                 return (curl_easy_setopt(m_handle, opt, value) == CURLE_OK);
             else if (sizeof(curl_off_t) == sizeof(long))
                 return (curl_easy_setopt(m_handle, opt, strtol(value, NULL, 10)) == CURLE_OK);
             return false;
+#else
+            else
+                return (curl_easy_setopt(m_handle, opt, value) == CURLE_OK);
+#endif
         }
         
         void send(istream& in);
@@ -546,7 +551,7 @@ int xmltooling::verify_callback(X509_STORE_CTX* x509_ctx, void* arg)
 
     bool success=false;
     if (ctx->m_criteria) {
-        ctx->m_criteria->setUsage(CredentialCriteria::TLS_CREDENTIAL);
+        ctx->m_criteria->setUsage(Credential::TLS_CREDENTIAL);
         // Bypass name check (handled for us by curl).
         ctx->m_criteria->setPeerName(NULL);
         success = ctx->m_trustEngine->validate(x509_ctx->cert,x509_ctx->untrusted,*(ctx->m_peerResolver),ctx->m_criteria);
@@ -554,7 +559,7 @@ int xmltooling::verify_callback(X509_STORE_CTX* x509_ctx, void* arg)
     else {
         // Bypass name check (handled for us by curl).
         CredentialCriteria cc;
-        cc.setUsage(CredentialCriteria::TLS_CREDENTIAL);
+        cc.setUsage(Credential::TLS_CREDENTIAL);
         success = ctx->m_trustEngine->validate(x509_ctx->cert,x509_ctx->untrusted,*(ctx->m_peerResolver),&cc);
     }
     
index fdca645..9120310 100644 (file)
@@ -56,6 +56,10 @@ void SOAPClient::send(const Envelope& env, const SOAPTransport::Address& addr)
     m_transport = XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), addr);
     prepareTransport(*m_transport);
     
+    Category& log = Category::getInstance(XMLTOOLING_LOGCAT".SOAPClient");
+    if (log.isDebugEnabled())
+        log.debugStream() << "marshalled envelope:" << logging::eol << env << logging::eol;
+    
     // Serialize envelope.
     stringstream s;
     s << env;
@@ -83,6 +87,11 @@ Envelope* SOAPClient::receive()
     DOMDocument* doc = (m_validate ? XMLToolingConfig::getConfig().getValidatingParser()
         : XMLToolingConfig::getConfig().getParser()).parse(out); 
     XercesJanitor<DOMDocument> janitor(doc);
+
+    Category& log = Category::getInstance(XMLTOOLING_LOGCAT".SOAPClient");
+    if (log.isDebugEnabled())
+        log.debugStream() << "received XML:" << logging::eol << *(doc->getDocumentElement()) << logging::eol;
+    
     auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));
     janitor.release();
     if (!m_validate)
index 57c7fde..e6fc4d6 100644 (file)
@@ -184,10 +184,10 @@ namespace {
 
     protected:
         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-            PROC_TYPED_CHILD(Faultcode,SOAP11ENV_NS,false);
-            PROC_TYPED_CHILD(Faultstring,SOAP11ENV_NS,false);
-            PROC_TYPED_CHILD(Faultactor,SOAP11ENV_NS,false);
-            PROC_TYPED_CHILD(Detail,SOAP11ENV_NS,false);
+            PROC_TYPED_CHILD(Faultcode,NULL,false);
+            PROC_TYPED_CHILD(Faultstring,NULL,false);
+            PROC_TYPED_CHILD(Faultactor,NULL,false);
+            PROC_TYPED_CHILD(Detail,NULL,false);
             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
         }
     };
@@ -228,6 +228,7 @@ namespace {
         IMPL_STRING_ATTRIB(EncodingStyle);
         IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
 
+        using AbstractAttributeExtensibleXMLObject::setAttribute;
         void setAttribute(QName& qualifiedName, const XMLCh* value, bool ID=false) {
             if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) {
                 if (XMLString::equals(qualifiedName.getLocalPart(),ENCODINGSTYLE_ATTRIB_NAME)) {
@@ -260,18 +261,12 @@ namespace {
         public AbstractXMLObjectMarshaller,
         public AbstractXMLObjectUnmarshaller
     {
-        void init() {
-            m_Actor=NULL;
-            m_MustUnderstand=xmlconstants::XML_BOOL_NULL;
-        }
     public:
         virtual ~HeaderImpl() {
-            XMLString::release(&m_Actor);
         }
 
         HeaderImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
-            init();
         }
             
         HeaderImpl(const HeaderImpl& src)
@@ -279,37 +274,16 @@ namespace {
                     AbstractAttributeExtensibleXMLObject(src),
                     AbstractComplexElement(src),
                     AbstractDOMCachingXMLObject(src) {
-            init();
-            setActor(src.getActor());
-            MustUnderstand(m_MustUnderstand);
             VectorOf(XMLObject) v=getUnknownXMLObjects();
             for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
                 v.push_back((*i)->clone());
         }
         
         IMPL_XMLOBJECT_CLONE(Header);
-        IMPL_STRING_ATTRIB(Actor);
-        IMPL_BOOLEAN_ATTRIB(MustUnderstand);
         IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
 
-        void setAttribute(QName& qualifiedName, const XMLCh* value, bool ID=false) {
-            if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) {
-                if (XMLString::equals(qualifiedName.getLocalPart(),MUSTUNDERSTAND_ATTRIB_NAME)) {
-                    setMustUnderstand(value);
-                    return;
-                }
-                else if (XMLString::equals(qualifiedName.getLocalPart(),ACTOR_ATTRIB_NAME)) {
-                    setActor(value);
-                    return;
-                }
-            }
-            AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
-        }
-
     protected:
         void marshallAttributes(DOMElement* domElement) const {
-            MARSHALL_STRING_ATTRIB(Actor,ACTOR,SOAP11ENV_NS);
-            MARSHALL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,SOAP11ENV_NS);
             marshallExtensionAttributes(domElement);
         }
 
index 405aaf8..be701b8 100644 (file)
@@ -72,12 +72,12 @@ void soap11::registerSOAPClasses()
 {
     QName q;
     REGISTER_ELEMENT_NOVAL(SOAP11ENV_NS,Body);
-    REGISTER_ELEMENT_NOVAL(SOAP11ENV_NS,Detail);
+    REGISTER_ELEMENT_NOVAL(NULL,Detail);
     REGISTER_ELEMENT(SOAP11ENV_NS,Envelope);
     REGISTER_ELEMENT(SOAP11ENV_NS,Fault);
-    REGISTER_ELEMENT(SOAP11ENV_NS,Faultactor);
-    REGISTER_ELEMENT(SOAP11ENV_NS,Faultcode);
-    REGISTER_ELEMENT(SOAP11ENV_NS,Faultstring);
+    REGISTER_ELEMENT(NULL,Faultactor);
+    REGISTER_ELEMENT(NULL,Faultcode);
+    REGISTER_ELEMENT(NULL,Faultstring);
     REGISTER_ELEMENT_NOVAL(SOAP11ENV_NS,Header);
     REGISTER_TYPE_NOVAL(SOAP11ENV_NS,Body);
     REGISTER_TYPE_NOVAL(SOAP11ENV_NS,Detail);
index 4e255b5..e09ffe5 100644 (file)
@@ -30,7 +30,7 @@
 
 using namespace xmltooling;
 
-const XMLCh CurlNetAccessor::fgMyName[] =
+const XMLCh xmltooling::CurlNetAccessor::fgMyName[] =
 {
     chLatin_C, chLatin_u, chLatin_r, chLatin_l, chLatin_N, chLatin_e,
     chLatin_t, chLatin_A, chLatin_c, chLatin_c, chLatin_e, chLatin_s,
index a032d57..a1ff700 100644 (file)
@@ -19,7 +19,7 @@
  * $Id$
  */
 
-#if !defined(XERCESC_INCLUDE_GUARD_CURLNETACCESSOR_HPP)
+#if !defined(XERCESC_INCLUDE_GUARD_CURLNETACCESSOR_HPP) && !defined(XMLTOOLING_LITE)
 #define XERCESC_INCLUDE_GUARD_CURLNETACCESSOR_HPP
 
 #include <xmltooling/base.h>
@@ -37,7 +37,7 @@ namespace xmltooling {
 // a HTTP or FTP URL.
 //
 
-class XMLTOOL_EXPORT CurlNetAccessor : public XMLNetAccessor
+class XMLTOOL_API CurlNetAccessor : public XMLNetAccessor
 {
 public :
     CurlNetAccessor();
index 4b4c9d2..bba89a3 100644 (file)
@@ -75,6 +75,14 @@ CurlURLInputStream::CurlURLInputStream(const XMLURL& urlSource, const XMLNetHTTP
        curl_easy_setopt(fEasy, CURLOPT_URL, fURL.get());
        curl_easy_setopt(fEasy, CURLOPT_WRITEDATA, this);                                               // Pass this pointer to write function
        curl_easy_setopt(fEasy, CURLOPT_WRITEFUNCTION, staticWriteCallback);    // Our static write function
+    curl_easy_setopt(fEasy, CURLOPT_CONNECTTIMEOUT, 15);
+    curl_easy_setopt(fEasy, CURLOPT_TIMEOUT, 30);
+    curl_easy_setopt(fEasy, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
+    curl_easy_setopt(fEasy, CURLOPT_SSL_VERIFYHOST, 0);
+    curl_easy_setopt(fEasy, CURLOPT_SSL_VERIFYPEER, 0);
+    curl_easy_setopt(fEasy, CURLOPT_NOPROGRESS, 1);
+    curl_easy_setopt(fEasy, CURLOPT_NOSIGNAL, 1);
+    curl_easy_setopt(fEasy, CURLOPT_FAILONERROR, 1);
        
        // Add easy handle to the multi stack
        curl_multi_add_handle(fMulti, fEasy);
@@ -227,19 +235,22 @@ CurlURLInputStream::readBytes(XMLByte* const          toFill
                // read any yet on this invocation, call select to wait for data
                if (!tryAgain && fBytesRead == 0)
                {
-                       fd_set readSet[16];
-                       fd_set writeSet[16];
-                       fd_set exceptSet[16];
-                       int fdcnt = 16;
+                       fd_set readSet;
+                       fd_set writeSet;
+                       fd_set exceptSet;
+                       int fdcnt=0;
                        
-                       // As curl for the file descriptors to wait on
-                       (void) curl_multi_fdset(fMulti, readSet, writeSet, exceptSet, &fdcnt);
+                       // Ask curl for the file descriptors to wait on
+            FD_ZERO(&readSet);
+            FD_ZERO(&writeSet);
+            FD_ZERO(&exceptSet);
+                       (void) curl_multi_fdset(fMulti, &readSet, &writeSet, &exceptSet, &fdcnt);
                        
                        // Wait on the file descriptors
                        timeval tv;
                        tv.tv_sec  = 2;
                        tv.tv_usec = 0;
-                       (void) select(fdcnt, readSet, writeSet, exceptSet, &tv);
+                       (void) select(fdcnt, &readSet, &writeSet, &exceptSet, &tv);
                }
        }
        
index 38e2391..a8bb925 100644 (file)
@@ -19,7 +19,7 @@
  * $Id$
  */
 
-#if !defined(XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP)
+#if !defined(XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP) && !defined(XMLTOOLING_LITE)
 #define XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP
 
 #include <xmltooling/base.h>
@@ -41,7 +41,7 @@ namespace xmltooling {
 // parser.
 //
 
-class XMLTOOL_EXPORT CurlURLInputStream : public BinInputStream
+class XMLTOOL_API CurlURLInputStream : public BinInputStream
 {
 public :
     CurlURLInputStream(const XMLURL&  urlSource, const XMLNetHTTPInfo* httpInfo=0);
index 10f698d..8e07608 100644 (file)
@@ -36,7 +36,6 @@
 #include <ctime>
 #include <assert.h>
 #include <xercesc/util/Janitor.hpp>
-#include <xercesc/util/NumberFormatException.hpp>
 
 using namespace xmltooling;
 using namespace std;
@@ -533,9 +532,7 @@ void DateTime::parseDateTime()
 
     //fStart is supposed to point to 'T'
     if (fBuffer[fStart++] != DATETIME_SEPARATOR)
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_gDay_invalid
-                , fBuffer);
+        throw XMLParserException("Invalid separator between date and time.");
 
     getTime();
     validateDateTime();
@@ -583,9 +580,7 @@ void DateTime::parseDay()
         fBuffer[1] != DATE_SEPARATOR ||
         fBuffer[2] != DATE_SEPARATOR  )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_gDay_invalid
-                , fBuffer);
+        throw XMLParserException("Invalid character in date.");
     }
 
     //initialize values
@@ -598,9 +593,7 @@ void DateTime::parseDay()
         int sign = findUTCSign(DAY_SIZE);
         if ( sign < 0 )
         {
-            ThrowXML1(SchemaDateTimeException
-                    , XMLExcepts::DateTime_gDay_invalid
-                    , fBuffer);
+            throw XMLParserException("Invalid character in date.");
         }
         else
         {
@@ -624,9 +617,7 @@ void DateTime::parseMonth()
     if (fBuffer[0] != DATE_SEPARATOR ||
         fBuffer[1] != DATE_SEPARATOR  )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_gMth_invalid
-                , fBuffer);
+        throw XMLParserException("Invalid character in date.");
     }
 
     //set constants
@@ -651,9 +642,7 @@ void DateTime::parseMonth()
         int sign = findUTCSign(fStart);
         if ( sign < 0 )
         {
-            ThrowXML1(SchemaDateTimeException
-                    , XMLExcepts::DateTime_gMth_invalid
-                    , fBuffer);
+            throw XMLParserException("Invalid character in date.");
         }
         else
         {
@@ -707,9 +696,7 @@ void DateTime::parseMonthDay()
         fBuffer[1] != DATE_SEPARATOR ||
         fBuffer[4] != DATE_SEPARATOR )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_gMthDay_invalid
-                , fBuffer);
+        throw XMLParserException("Invalid character in date.");
     }
 
 
@@ -723,9 +710,7 @@ void DateTime::parseMonthDay()
         int sign = findUTCSign(MONTHDAY_SIZE);
         if ( sign<0 )
         {
-            ThrowXML1(SchemaDateTimeException
-                    , XMLExcepts::DateTime_gMthDay_invalid
-                    , fBuffer);
+            throw XMLParserException("Invalid character in date.");
         }
         else
         {
@@ -768,18 +753,14 @@ void DateTime::parseDuration()
     if ( (c != DURATION_STARTER) &&
          (c != chDash)            )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_dur_Start_dashP
-                , fBuffer);
+        throw XMLParserException("Invalid character in time.");
     }
 
     // 'P' must ALWAYS be present in either case
     if ( (c == chDash) &&
          (fBuffer[fStart++]!= DURATION_STARTER ))
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_dur_noP
-                , fBuffer);
+        throw XMLParserException("Invalid character in time.");
     }
 
     // java code
@@ -796,9 +777,7 @@ void DateTime::parseDuration()
     //
     if (indexOf(fStart, fEnd, chDash) != NOT_FOUND)
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_dur_DashNotFirst
-                , fBuffer);
+        throw XMLParserException("Invalid character in time.");
     }
 
     //at least one number and designator must be seen after P
@@ -841,9 +820,7 @@ void DateTime::parseDuration()
     if ( (fEnd == endDate) &&   // 'T' absent
          (fStart != fEnd)   )   // something after Day
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_dur_inv_b4T
-                , fBuffer);
+        throw XMLParserException("Invalid character in time.");
     }
 
     if ( fEnd != endDate ) // 'T' present
@@ -889,9 +866,7 @@ void DateTime::parseDuration()
                  */
                 if ( mlsec+1 == end )
                 {
-                    ThrowXML1(SchemaDateTimeException
-                            , XMLExcepts::DateTime_dur_inv_seconds
-                            , fBuffer);
+                    throw XMLParserException("Invalid character in time.");
                 }
 
                 fValue[Second]     = negate * parseInt(fStart, mlsec);
@@ -911,17 +886,13 @@ void DateTime::parseDuration()
         if ( (fStart != fEnd) ||
               fBuffer[--fStart] == DATETIME_SEPARATOR )
         {
-            ThrowXML1(SchemaDateTimeException
-                    , XMLExcepts::DateTime_dur_NoTimeAfterT
-                    , fBuffer);
+            throw XMLParserException("Invalid character in time.");
         }
     }
 
     if ( !designator )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_dur_NoElementAtAll
-                , fBuffer);
+        throw XMLParserException("Invalid character in time.");
     }
 
 }
@@ -943,19 +914,14 @@ void DateTime::getDate()
 
     // Ensure enough chars in buffer
     if ( (fStart+YMD_MIN_SIZE) > fEnd)
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_date_incomplete
-                , fBuffer);
+        throw XMLParserException("Date/time string not complete.");
 
     getYearMonth();    // Scan YearMonth and
                        // fStart point to the next '-'
 
     if (fBuffer[fStart++] != DATE_SEPARATOR)
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_date_invalid
-                , fBuffer);
-        //("CCYY-MM must be followed by '-' sign");
+        throw XMLParserException("CCYY-MM must be followed by '-' sign.");
     }
 
     fValue[Day] = parseInt(fStart, fStart+2);
@@ -978,19 +944,13 @@ void DateTime::getTime()
 
     // Ensure enough chars in buffer
     if ( (fStart+TIME_MIN_SIZE) > fEnd)
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_time_incomplete
-                , fBuffer);
-        //"Imcomplete Time Format"
+        throw XMLParserException("Incomplete Time Format.");
 
     // check (fixed) format first
     if ((fBuffer[fStart + 2] != TIME_SEPARATOR) ||
         (fBuffer[fStart + 5] != TIME_SEPARATOR)  )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_time_invalid
-                , fBuffer);
-        //("Error in parsing time" );
+        throw XMLParserException("Error in parsing time.");
     }
 
     //
@@ -1016,10 +976,7 @@ void DateTime::getTime()
         // make sure we have some thing between the '.' and fEnd
         if (fStart >= fEnd)
         {
-            ThrowXML1(SchemaDateTimeException
-                    , XMLExcepts::DateTime_ms_noDigit
-                    , fBuffer);
-            //("ms shall be present once '.' is present" );
+            throw XMLParserException("ms should be present once '.' is present.");
         }
 
         if ( sign == NOT_FOUND )
@@ -1034,10 +991,7 @@ void DateTime::getTime()
        }
     else if(sign == 0 || sign != fStart)
     {
-        // seconds has more than 2 digits
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_min_invalid
-                , fBuffer);
+        throw XMLParserException("Seconds has more than 2 digits.");
     }
 
     //parse UTC time zone (hh:mm)
@@ -1058,10 +1012,7 @@ void DateTime::getYearMonth()
 
     // Ensure enough chars in buffer
     if ( (fStart+YMONTH_MIN_SIZE) > fEnd)
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_ym_incomplete
-                , fBuffer);
-        //"Imcomplete YearMonth Format";
+        throw XMLParserException("Incomplete YearMonth Format.");
 
     // skip the first leading '-'
     int start = ( fBuffer[0] == chDash ) ? fStart + 1 : fStart;
@@ -1071,10 +1022,7 @@ void DateTime::getYearMonth()
     //
     int yearSeparator = indexOf(start, fEnd, DATE_SEPARATOR);
     if ( yearSeparator == NOT_FOUND)
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_ym_invalid
-                , fBuffer);
-        //("Year separator is missing or misplaced");
+        throw XMLParserException("Year separator is missing or misplaced.");
 
     fValue[CentYear] = parseIntYear(yearSeparator);
     fStart = yearSeparator + 1;  //skip the '-' and point to the first M
@@ -1083,10 +1031,7 @@ void DateTime::getYearMonth()
     //gonna check we have enough byte for month
     //
     if ((fStart + 2) > fEnd )
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_ym_noMonth
-                , fBuffer);
-        //"no month in buffer"
+        throw XMLParserException("No month in buffer.");
 
     fValue[Month] = parseInt(fStart, yearSeparator + 3);
     fStart += 2;  //fStart points right after the MONTH
@@ -1101,10 +1046,7 @@ void DateTime::parseTimeZone()
         int sign = findUTCSign(fStart);
         if ( sign < 0 )
         {
-            ThrowXML1(SchemaDateTimeException
-                    , XMLExcepts::DateTime_tz_noUTCsign
-                    , fBuffer);
-            //("Error in month parsing");
+            throw XMLParserException("Error in month parsing.");
         }
         else
         {
@@ -1129,10 +1071,7 @@ void DateTime::getTimeZone(const int sign)
     {
         if ((sign + 1) != fEnd )
         {
-            ThrowXML1(SchemaDateTimeException
-                    , XMLExcepts::DateTime_tz_stuffAfterZ
-                    , fBuffer);
-            //"Error in parsing time zone");
+            throw XMLParserException("Error in parsing time zone.");
         }              
 
         return;        
@@ -1147,10 +1086,7 @@ void DateTime::getTimeZone(const int sign)
     if ( ( ( sign + TIMEZONE_SIZE + 1) != fEnd )      ||
          ( fBuffer[sign + 3] != TIMEZONE_SEPARATOR ) )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_tz_invalid
-                , fBuffer);
-        //("Error in parsing time zone");
+        throw XMLParserException("Error in parsing time zone.");
     }
 
     fTimeZone[hh] = parseInt(sign+1, sign+3);          
@@ -1226,29 +1162,20 @@ void DateTime::validateDateTime() const
     //          or reporting an error message should be sufficient?
     if ( fValue[CentYear] == 0 )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_year_zero
-                , fBuffer);
-        //"The year \"0000\" is an illegal year value");
+        throw XMLParserException("The year \"0000\" is an illegal year value");
     }
 
     if ( fValue[Month] < 1  ||
          fValue[Month] > 12  )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_mth_invalid
-                , fBuffer);
-               //"The month must have values 1 to 12");
+        throw XMLParserException("The month must have values 1 to 12");
     }
 
     //validate days
     if ( fValue[Day] > maxDayInMonthFor( fValue[CentYear], fValue[Month]) ||
          fValue[Day] == 0 )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_day_invalid
-                , fBuffer);
-        //"The day must have values 1 to 31");
+        throw XMLParserException("The day must have values 1 to 31");
     }
 
     //validate hours
@@ -1258,49 +1185,34 @@ void DateTime::validateDateTime() const
                                   (fValue[Second] !=0) ||
                                   (fMiliSecond    !=0))))
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_hour_invalid
-                , fBuffer);
-        //("Hour must have values 0-23");
+        throw XMLParserException("Hour must have values 0-23");
     }
 
     //validate minutes
     if ( fValue[Minute] < 0 ||
          fValue[Minute] > 59 )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_min_invalid
-                , fBuffer);
-        //"Minute must have values 0-59");
+        throw XMLParserException("Minute must have values 0-59");
     }
 
     //validate seconds
     if ( fValue[Second] < 0 ||
          fValue[Second] > 60 )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_second_invalid
-                , fBuffer);
-        //"Second must have values 0-60");
+        throw XMLParserException("Second must have values 0-60");
     }
 
     //validate time-zone hours
     if ( (abs(fTimeZone[hh]) > 14) ||
          ((abs(fTimeZone[hh]) == 14) && (fTimeZone[mm] != 0)) )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_tz_hh_invalid
-                , fBuffer);
-        //"Time zone should have range -14..+14");
+        throw XMLParserException("Time zone should have range -14..+14");
     }
 
     //validate time-zone minutes
     if ( abs(fTimeZone[mm]) > 59 )
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_min_invalid
-                , fBuffer);
-        //("Minute must have values 0-59");
+        throw XMLParserException("Minute must have values 0-59");
     }
        
     return;
@@ -1346,7 +1258,7 @@ int DateTime::parseInt(const int start, const int end) const
     for (int i=start; i < end; i++) {
 
         if (fBuffer[i] < chDigit_0 || fBuffer[i] > chDigit_9)
-            ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars);
+            throw XMLParserException("Invalid non-numeric characters.");
 
         retVal = (retVal * 10) + (unsigned int) (fBuffer[i] - chDigit_0);
     }
@@ -1381,7 +1293,7 @@ double DateTime::parseMiliSecond(const int start, const int end) const
 
     // check if all chars are valid char
     if ( (endptr - nptr) != strLen)
-        ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars);
+        throw XMLParserException("Invalid non-numeric characters.");
 
     // we don't check underflow occurs since
     // nothing we can do about it.
@@ -1403,19 +1315,12 @@ int DateTime::parseIntYear(const int end) const
     int length = end - start;
     if (length < 4)
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_year_tooShort
-                , fBuffer);
-        //"Year must have 'CCYY' format");
+        throw XMLParserException("Year must have 'CCYY' format");
     }
     else if (length > 4 &&
              fBuffer[start] == chDigit_0)
     {
-        ThrowXML1(SchemaDateTimeException
-                , XMLExcepts::DateTime_year_leadingZero
-                , fBuffer);
-        //"Leading zeros are required if the year value would otherwise have fewer than four digits;
-        // otherwise they are forbidden");
+        throw XMLParserException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden.");
     }
 
     bool negative = (fBuffer[0] == chDash);
index 18f27ea..17133b3 100644 (file)
@@ -43,7 +43,7 @@ using namespace xmltooling;
 using namespace std;
 
 ParserPool::ParserPool(bool namespaceAware, bool schemaAware)
-    : m_namespaceAware(namespaceAware), m_schemaAware(schemaAware), m_lock(Mutex::create()) {}
+    : m_namespaceAware(namespaceAware), m_schemaAware(schemaAware), m_lock(Mutex::create()), m_security(new SecurityManager()) {}
 
 ParserPool::~ParserPool()
 {
@@ -52,6 +52,7 @@ ParserPool::~ParserPool()
         m_pool.pop();
     }
     delete m_lock;
+    delete m_security;
 }
 
 DOMDocument* ParserPool::newDocument()
@@ -280,19 +281,19 @@ bool ParserPool::handleError(const DOMError& e)
         case DOMError::DOM_SEVERITY_WARNING:
             log.warnStream() << "warning on line " << locator->getLineNumber()
                 << ", column " << locator->getColumnNumber()
-                << ", message: " << temp.get() << CategoryStream::ENDLINE;
+                << ", message: " << temp.get() << logging::eol;
             return true;
 
         case DOMError::DOM_SEVERITY_ERROR:
             log.errorStream() << "error on line " << locator->getLineNumber()
                 << ", column " << locator->getColumnNumber()
-                << ", message: " << temp.get() << CategoryStream::ENDLINE;
+                << ", message: " << temp.get() << logging::eol;
             throw XMLParserException(string("error during XML parsing: ") + (temp.get() ? temp.get() : "no message"));
 
         case DOMError::DOM_SEVERITY_FATAL_ERROR:
-            log.critStream() << "fatal error on line " << locator->getLineNumber()
+            log.errorStream() << "fatal error on line " << locator->getLineNumber()
                 << ", column " << locator->getColumnNumber()
-                << ", message: " << temp.get() << CategoryStream::ENDLINE;
+                << ", message: " << temp.get() << logging::eol;
             throw XMLParserException(string("fatal error during XML parsing: ") + (temp.get() ? temp.get() : "no message"));
     }
     throw XMLParserException(string("unclassified error during XML parsing: ") + (temp.get() ? temp.get() : "no message"));
@@ -320,6 +321,7 @@ DOMBuilder* ParserPool::createBuilder()
         parser->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,const_cast<XMLCh*>(temp.get()));
 #endif
     }
+    parser->setProperty(XMLUni::fgXercesSecurityManager, m_security);
     parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument,true);
     parser->setEntityResolver(this);
     parser->setErrorHandler(this);
@@ -369,7 +371,7 @@ unsigned int StreamInputSource::StreamBinInputStream::readBytes(XMLByte* const t
         catch(ios_base::failure& e) {
             Category::getInstance(XMLTOOLING_LOGCAT".StreamInputSource").critStream()
                 << "XML::StreamInputSource::StreamBinInputStream::readBytes caught an exception: " << e.what()
-                << CategoryStream::ENDLINE;
+                << logging::eol;
             *toFill=0;
             return 0;
         }
index ebc7bf1..3dcdde6 100644 (file)
@@ -32,6 +32,7 @@
 #include <xercesc/dom/DOM.hpp>
 #include <xercesc/sax/InputSource.hpp>
 #include <xercesc/util/BinInputStream.hpp>
+#include <xercesc/util/SecurityManager.hpp>
 
 #if defined (_MSC_VER)
     #pragma warning( push )
@@ -130,6 +131,7 @@ namespace xmltooling {
         bool m_namespaceAware,m_schemaAware;
         std::stack<xercesc::DOMBuilder*> m_pool;
         Mutex* m_lock;
+        xercesc::SecurityManager* m_security;
     };
 
     /**
diff --git a/xmltooling/util/Predicates.h b/xmltooling/util/Predicates.h
new file mode 100644 (file)
index 0000000..b822862
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ *  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.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file xmltooling/util/Predicates.h
+ * 
+ * Useful XMLObject predicates for use with STL algorithms. 
+ */
+
+#ifndef __xmltooling_predicates_h__
+#define __xmltooling_predicates_h__
+
+#include <xmltooling/XMLObject.h>
+
+#include <functional>
+
+namespace xmltooling {
+
+    /**
+     * Predicate that checks the QName of an XMLObject.
+     */
+    class hasQName
+    {
+    public:
+        /**
+         * Constructor.
+         * 
+         * @param q the QName to check for
+         */
+        hasQName(const QName& q) : m_q(q) {
+        }
+        
+        /**
+         * Returns true iff the provided object's QName matches the constructor argument.
+         * 
+         * @param xmlObject the object to examine
+         */
+        bool operator()(const XMLObject* xmlObject) const {
+            return xmlObject ? (xmlObject->getElementQName() == m_q) : false;
+        }
+        
+    private:
+        const QName& m_q;
+    };
+
+    /**
+     * Predicate that checks the xsi:type of an XMLObject.
+     */
+    class hasSchemaType
+    {
+    public:
+        /**
+         * Constructor.
+         * 
+         * @param q the QName to check for
+         */
+        hasSchemaType(const QName& q) : m_q(q) {
+        }
+        
+        /**
+         * Returns true iff the provided object's xsi:type matches the constructor argument.
+         * 
+         * @param xmlObject the object to examine
+         */
+        bool operator()(const XMLObject* xmlObject) const {
+            const QName* xsitype = xmlObject ? xmlObject->getSchemaType() : NULL;
+            return xsitype ? (*xsitype == m_q) : false;
+        }
+        
+    private:
+        const QName& m_q;
+    };
+
+    /**
+     * Template algorithm returns first pointer element from a container that matches a predicate.
+     *
+     * @param c read-only container of pointer-based objects
+     * @param p a predicate function
+     * @return  the first object in the container matching the predicate, or NULL
+     */
+    template<typename Container, typename Predicate>
+    typename Container::value_type find_if(const Container& c, const Predicate& p) {
+        typename Container::const_iterator i = std::find_if(c.begin(), c.end(), p);
+        return (i!=c.end()) ? *i : NULL;
+    }
+
+    /**
+     * Template algorithm returns first pointer element from a container that matches a predicate.
+     *
+     * @param c read-only container of pointer-based objects
+     * @param p a predicate function
+     * @return  the first object in the container matching the predicate, or NULL
+     */
+    template<typename Container, typename Predicate>
+    typename Container::value_type find_if(Container& c, const Predicate& p) {
+        typename Container::iterator i = std::find_if(c.begin(), c.end(), p);
+        return (i!=c.end()) ? *i : NULL;
+    }
+
+};
+
+#endif /* __xmltooling_predicates_h__ */
index 5bdb545..fe7a54b 100644 (file)
@@ -170,7 +170,7 @@ pair<bool,DOMElement*> ReloadableXMLFile::load(bool backup)
                     doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);\r
             }\r
 \r
-            m_log.infoStream() << "loaded XML resource (" << (backup ? m_backing : m_source) << ")" << CategoryStream::ENDLINE;\r
+            m_log.infoStream() << "loaded XML resource (" << (backup ? m_backing : m_source) << ")" << logging::eol;\r
 \r
             if (!backup && !m_backing.empty()) {\r
                 m_log.debug("backing up remote resource to (%s)", m_backing.c_str());\r
@@ -188,15 +188,15 @@ pair<bool,DOMElement*> ReloadableXMLFile::load(bool backup)
     }\r
     catch (XMLException& e) {\r
         auto_ptr_char msg(e.getMessage());\r
-        m_log.critStream() << "Xerces error while loading resource (" << (backup ? m_backing : m_source) << "): "\r
-            << msg.get() << CategoryStream::ENDLINE;\r
+        m_log.errorStream() << "Xerces error while loading resource (" << (backup ? m_backing : m_source) << "): "\r
+            << msg.get() << logging::eol;\r
         if (!backup && !m_backing.empty())\r
             return load(true);\r
         throw XMLParserException(msg.get());\r
     }\r
     catch (exception& e) {\r
-        m_log.critStream() << "error while loading configuration from ("\r
-            << (m_source.empty() ? "inline" : (backup ? m_backing : m_source)) << "): " << e.what() << CategoryStream::ENDLINE;\r
+        m_log.errorStream() << "error while loading configuration from ("\r
+            << (m_source.empty() ? "inline" : (backup ? m_backing : m_source)) << "): " << e.what() << logging::eol;\r
         if (!backup && !m_backing.empty())\r
             return load(true);\r
         throw;\r
index 35f589d..bbbcf18 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef __xmltooling_template_h__
 #define __xmltooling_template_h__
 
-#include <xmltooling/base.h>
+#include <xmltooling/io/GenericRequest.h>
 
 #include <map>
 #include <string>
@@ -72,12 +72,15 @@ namespace xmltooling {
         class XMLTOOL_API TemplateParameters {
             MAKE_NONCOPYABLE(TemplateParameters);
         public:
-            TemplateParameters() {}
+            TemplateParameters() : m_request(NULL) {}
             virtual ~TemplateParameters() {}
             
             /** Map of known parameters to supply to template. */
             std::map<std::string,std::string> m_map;
             
+            /** Request from client that resulted in template being processed. */
+            const GenericRequest* m_request;
+            
             /**
              * Returns the value of a parameter to plug into the template.
              * 
@@ -86,7 +89,7 @@ namespace xmltooling {
              */
             virtual const char* getParameter(const char* name) const {
                 std::map<std::string,std::string>::const_iterator i=m_map.find(name);
-                return (i!=m_map.end() ? i->second.c_str() : NULL); 
+                return (i!=m_map.end() ? i->second.c_str() : (m_request ? m_request->getParameter(name) : NULL));
             }
         };
         
index df6b860..c0b6575 100644 (file)
@@ -81,27 +81,150 @@ namespace xmltooling {
 
     /**
      * STL iterator that mediates access to an iterator over typed XML children.
-     * @param _Ty   a bidrectional sequence of the subtype to iterate over
+     *
+     * @param Container type of container
+     * @param _Ty       a bidrectional iterator to guard
      */
-    template <class _Ty>
+    template <class Container, typename _Ty>
     class XMLObjectChildrenIterator
     {
         /// @cond OFF
-        typename _Ty::iterator m_iter;
+        _Ty m_iter;
         template <class _Tx, class _Tz> friend class XMLObjectChildrenList;
         template <class _Tx, class _Tz> friend class XMLObjectPairList;
     public:
+#ifdef HAVE_ITERATOR_TRAITS
+        typedef typename std::iterator_traits<_Ty>::iterator_category iterator_category;
+        typedef typename std::iterator_traits<_Ty>::value_type value_type;
+        typedef typename std::iterator_traits<_Ty>::difference_type difference_type;
+        typedef typename std::iterator_traits<_Ty>::pointer pointer;
+        typedef typename std::iterator_traits<_Ty>::reference reference;
+#else
+        typedef typename _Ty::iterator_category iterator_category;
         typedef typename _Ty::value_type value_type;
-        typedef typename _Ty::reference reference;
-        typedef typename _Ty::pointer pointer;
-        typedef typename _Ty::const_reference const_reference;
-        typedef typename _Ty::const_pointer const_pointer;
         typedef typename _Ty::difference_type difference_type;
+        typedef typename _Ty::pointer pointer;
+        typedef typename _Ty::reference reference;
+#endif
+        typedef typename Container::const_reference const_reference;
+        typedef typename Container::const_pointer const_pointer;
+
+        XMLObjectChildrenIterator() {
+        }
+
+        XMLObjectChildrenIterator(_Ty iter) {
+            m_iter=iter;
+        }
+
+        const_reference operator*() const {
+            return *m_iter;
+        }
+
+        const_reference operator->() const {
+            return *m_iter;
+        }
+
+        XMLObjectChildrenIterator& operator++() {
+            // preincrement
+            ++m_iter;
+            return (*this);
+        }
+
+        XMLObjectChildrenIterator& operator--() {
+            // predecrement
+            --m_iter;
+            return (*this);
+        }
+
+        XMLObjectChildrenIterator operator++(int) {
+            // postincrement
+            XMLObjectChildrenIterator _Tmp = *this;
+            ++*this;
+            return (_Tmp);
+        }
+
+        XMLObjectChildrenIterator operator--(int) {
+            // postdecrement
+            XMLObjectChildrenIterator _Tmp = *this;
+            --*this;
+            return (_Tmp);
+        }
+
+        XMLObjectChildrenIterator& operator+=(difference_type _Off) {
+            // increment by integer
+            m_iter += _Off;
+            return (*this);
+        }
+
+        XMLObjectChildrenIterator operator+(difference_type _Off) const {
+            // return this + integer
+            return m_iter + _Off;
+        }
+
+        XMLObjectChildrenIterator& operator-=(difference_type _Off) {
+            // decrement by integer
+            return (*this += -_Off);
+        }
+
+        XMLObjectChildrenIterator operator-(difference_type _Off) const {
+            // return this - integer
+            XMLObjectChildrenIterator _Tmp = *this;
+            return (_Tmp -= _Off);
+        }
+
+        difference_type operator-(const XMLObjectChildrenIterator& _Right) const {
+            // return difference of iterators
+            return m_iter - _Right.m_iter;
+        }
+
+        const_reference operator[](difference_type _Off) const {
+            // subscript
+            return (*(*this + _Off));
+        }
+
+        bool operator==(const XMLObjectChildrenIterator &_Right) const {
+                   // test for iterator equality
+                   return (m_iter == _Right.m_iter);
+           }
+
+           bool operator!=(const XMLObjectChildrenIterator &_Right) const {
+                   // test for iterator inequality
+                   return (!(m_iter == _Right.m_iter));
+           }
+           
+           bool operator<(const XMLObjectChildrenIterator &_Right) const {
+               return (m_iter < _Right.m_iter);
+           }
+        /// @endcond
+    };
+
+#ifndef HAVE_ITERATOR_TRAITS
+    /**
+     * STL iterator that mediates access to an iterator that's a pointer.
+     *
+     * @param Container type of container
+     * @param _Ty       the type of object being referenced
+     */
+    template <class Container, typename _Ty>
+    class XMLObjectChildrenIterator<Container, _Ty*>
+    {
+        /// @cond OFF
+        typename _Ty* m_iter;
+        template <class _Tx, class _Tz> friend class XMLObjectChildrenList;
+        template <class _Tx, class _Tz> friend class XMLObjectPairList;
+    public:
+        typedef std::random_access_iterator_tag iterator_category;
+        typedef _Ty value_type;
+        typedef ptrdiff_t difference_type;
+        typedef _Ty* pointer;
+        typedef _Ty& reference;
+        typedef const _Ty& const_reference;
+        typedef const _Ty* const_pointer;
 
         XMLObjectChildrenIterator() {
         }
 
-        XMLObjectChildrenIterator(typename _Ty::iterator iter) {
+        XMLObjectChildrenIterator(_Ty* iter) {
             m_iter=iter;
         }
 
@@ -180,8 +303,124 @@ namespace xmltooling {
                    // test for iterator inequality
                    return (!(m_iter == _Right.m_iter));
            }
+           
+           bool operator<(const XMLObjectChildrenIterator &_Right) const {
+               return (m_iter < _Right.m_iter);
+           }
+        /// @endcond
+    };
+
+    /**
+     * STL iterator that mediates access to an iterator that's a const pointer.
+     *
+     * @param Container type of container
+     * @param _Ty       the type of object being referenced
+     */
+    template <class Container, typename _Ty>
+    class XMLObjectChildrenIterator<Container, const _Ty*>
+    {
+        /// @cond OFF
+        typename const _Ty* m_iter;
+        template <class _Tx, class _Tz> friend class XMLObjectChildrenList;
+        template <class _Tx, class _Tz> friend class XMLObjectPairList;
+    public:
+        typedef std::random_access_iterator_tag iterator_category;
+        typedef _Ty value_type;
+        typedef ptrdiff_t difference_type;
+        typedef const _Ty* pointer;
+        typedef const _Ty& reference;
+        typedef const _Ty& const_reference;
+        typedef const _Ty* const_pointer;
+
+        XMLObjectChildrenIterator() {
+        }
+
+        XMLObjectChildrenIterator(_Ty* iter) {
+            m_iter=iter;
+        }
+
+        const_reference operator*() const {
+            return *m_iter;
+        }
+
+        const_reference operator->() const {
+            return *m_iter;
+        }
+
+        XMLObjectChildrenIterator& operator++() {
+            // preincrement
+            ++m_iter;
+            return (*this);
+        }
+
+        XMLObjectChildrenIterator& operator--() {
+            // predecrement
+            --m_iter;
+            return (*this);
+        }
+
+        XMLObjectChildrenIterator operator++(int) {
+            // postincrement
+            XMLObjectChildrenIterator _Tmp = *this;
+            ++*this;
+            return (_Tmp);
+        }
+
+        XMLObjectChildrenIterator operator--(int) {
+            // postdecrement
+            XMLObjectChildrenIterator _Tmp = *this;
+            --*this;
+            return (_Tmp);
+        }
+
+        XMLObjectChildrenIterator& operator+=(difference_type _Off) {
+            // increment by integer
+            m_iter += _Off;
+            return (*this);
+        }
+
+        XMLObjectChildrenIterator operator+(difference_type _Off) const {
+            // return this + integer
+            return m_iter + _Off;
+        }
+
+        XMLObjectChildrenIterator& operator-=(difference_type _Off) {
+            // decrement by integer
+            return (*this += -_Off);
+        }
+
+        XMLObjectChildrenIterator operator-(difference_type _Off) const {
+            // return this - integer
+            XMLObjectChildrenIterator _Tmp = *this;
+            return (_Tmp -= _Off);
+        }
+
+        difference_type operator-(const XMLObjectChildrenIterator& _Right) const {
+            // return difference of iterators
+            return m_iter - _Right.m_iter;
+        }
+
+        const_reference operator[](difference_type _Off) const {
+            // subscript
+            return (*(*this + _Off));
+        }
+
+        bool operator==(const XMLObjectChildrenIterator &_Right) const {
+                   // test for iterator equality
+                   return (m_iter == _Right.m_iter);
+           }
+
+           bool operator!=(const XMLObjectChildrenIterator &_Right) const {
+                   // test for iterator inequality
+                   return (!(m_iter == _Right.m_iter));
+           }
+           
+           bool operator<(const XMLObjectChildrenIterator &_Right) const {
+               return (m_iter < _Right.m_iter);
+           }
         /// @endcond
     };
+#endif
 
     /**
      * STL-compatible container that mediates access to underlying lists of typed XML children.
@@ -205,8 +444,8 @@ namespace xmltooling {
         typedef typename Container::size_type size_type;
 
         // We override the iterator types with our constrained wrapper.
-        typedef XMLObjectChildrenIterator<Container> iterator;
-        typedef XMLObjectChildrenIterator<Container> const_iterator;
+        typedef XMLObjectChildrenIterator<Container, typename Container::iterator> iterator;
+        typedef XMLObjectChildrenIterator<Container, typename Container::const_iterator> const_iterator;
         /// @endcond
 
         /**
@@ -249,12 +488,12 @@ namespace xmltooling {
 
         const_iterator begin() const {
             // return iterator for beginning of const sequence
-            return m_container.begin();
+            return const_cast<const Container&>(m_container).begin();
         }
 
         const_iterator end() const {
             // return iterator for end of const sequence
-            return m_container.end();
+            return const_cast<const Container&>(m_container).end();
         }
 
         const_reference at(size_type _Pos) const {
@@ -359,8 +598,8 @@ namespace xmltooling {
         typedef typename Container::size_type size_type;
 
         // We override the iterator types with our constrained wrapper.
-        typedef XMLObjectChildrenIterator<Container> iterator;
-        typedef XMLObjectChildrenIterator<Container> const_iterator;
+        typedef XMLObjectChildrenIterator<Container, typename Container::iterator> iterator;
+        typedef XMLObjectChildrenIterator<Container, typename Container::const_iterator> const_iterator;
         /// @endcond
 
         /**
@@ -403,12 +642,12 @@ namespace xmltooling {
 
         const_iterator begin() const {
             // return iterator for beginning of const sequence
-            return m_container.begin();
+            return const_cast<const Container&>(m_container).begin();
         }
 
         const_iterator end() const {
             // return iterator for end of const sequence
-            return m_container.end();
+            return const_cast<const Container&>(m_container).end();
         }
 
         const_reference at(size_type _Pos) const {
index cb1a9d7..489992b 100644 (file)
                                        RelativePath=".\io\AbstractXMLObjectUnmarshaller.cpp"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath=".\io\HTTPRequest.cpp"\r
+                                       >\r
+                               </File>\r
                        </Filter>\r
                        <Filter\r
                                Name="impl"\r
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath=".\util\Predicates.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath=".\util\ReloadableXMLFile.h"\r
                                        >\r
                                </File>\r
index 070fba3..9b148c4 100644 (file)
                                        RelativePath=".\io\AbstractXMLObjectUnmarshaller.cpp"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath=".\io\HTTPRequest.cpp"\r
+                                       >\r
+                               </File>\r
                        </Filter>\r
                        <Filter\r
                                Name="impl"\r
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath=".\util\Predicates.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath=".\util\ReloadableXMLFile.h"\r
                                        >\r
                                </File>\r
index 3d6c79a..7cd05e6 100644 (file)
@@ -56,7 +56,7 @@ public:
 
         try {
             CredentialCriteria cc;
-            cc.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+            cc.setUsage(Credential::ENCRYPTION_CREDENTIAL);
             Locker locker(m_resolver);
             const Credential* cred=m_resolver->resolve(&cc);
             TSM_ASSERT("Retrieved credential was null", cred!=NULL);
index 8e05cce..fc682e1 100644 (file)
@@ -119,7 +119,7 @@ public:
         sig->setContentReference(new TestContext(&chNull));
 
         CredentialCriteria cc;
-        cc.setUsage(CredentialCriteria::SIGNING_CREDENTIAL);
+        cc.setUsage(Credential::SIGNING_CREDENTIAL);
         Locker locker(m_resolver);
         const Credential* cred = m_resolver->resolve(&cc);
         TSM_ASSERT("Retrieved credential was null", cred!=NULL);
index d6df345..3bf4dcf 100644 (file)
Binary files a/xmltoolingtest/data/SimpleXMLObjectWithContent.xml and b/xmltoolingtest/data/SimpleXMLObjectWithContent.xml differ