Tagging 1.1 release. upstream/tags/1.1 tags/1.1
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Mon, 11 Aug 2008 04:09:07 +0000 (04:09 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Mon, 11 Aug 2008 04:09:07 +0000 (04:09 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/tags/1.1@517 de75baf8-a10c-0410-a50a-987c0e22f00f

24 files changed:
.cproject
Makefile.am
configure.ac
doc/Makefile.am
doc/README.txt [new file with mode: 0644]
xmltooling.spec.in
xmltooling/AbstractXMLObject.cpp
xmltooling/AbstractXMLObject.h
xmltooling/Makefile.am
xmltooling/base.h
xmltooling/security/BasicX509Credential.h
xmltooling/security/Credential.h
xmltooling/security/X509Credential.h
xmltooling/security/impl/BasicX509Credential.cpp
xmltooling/security/impl/FilesystemCredentialResolver.cpp
xmltooling/soap/SOAPTransport.h
xmltooling/soap/impl/CURLSOAPTransport.cpp
xmltooling/util/CurlURLInputStream.cpp
xmltooling/util/CurlURLInputStream.hpp
xmltooling/util/PathResolver.cpp
xmltooling/version.h
xmltooling/xmltooling-lite.vcproj
xmltooling/xmltooling.rc
xmltooling/xmltooling.vcproj

index 8cb2825..2473079 100644 (file)
--- a/.cproject
+++ b/.cproject
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><?fileVersion 4.0.0?><cproject>\r
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<?fileVersion 4.0.0?>\r
+\r
+<cproject>\r
 <storageModule moduleId="org.eclipse.cdt.core.settings">\r
 <cconfiguration id="converted.config.943130369">\r
 <storageModule moduleId="scannerConfiguration">\r
 <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>\r
 </extensions>\r
 </storageModule>\r
+\r
+<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>\r
+<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>\r
+<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>\r
+\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:/openssl-0.9.8h/inc32" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/curl-7.18.2/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 include="C:/Program Files/Microsoft Visual Studio 8/VC/include" 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
@@ -83,8 +92,6 @@
 <pathentry kind="src" path="xmltooling/validation"/>\r
 <pathentry kind="src" path="xmltoolingtest"/>\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 18e5312..89132b2 100644 (file)
@@ -21,8 +21,8 @@ all-local: xmltooling.spec pkginfo
 endif
 
 install-data-hook:
-       rm -rf $(DESTDIR)/$(datadir)/doc/@PACKAGE@/api
-       cp -r doc/api $(DESTDIR)/$(datadir)/doc/@PACKAGE@
+       rm -rf $(DESTDIR)$(datadir)/doc/@PACKAGE@/api
+       cp -r doc/api $(DESTDIR)$(datadir)/doc/@PACKAGE@
 
 xmltooling.spec: xmltooling.spec.in Makefile
        rm -f $@.tmp
index e17b5df..2edc85e 100644 (file)
@@ -1,8 +1,8 @@
 AC_PREREQ([2.50])
-AC_INIT([xmltooling], [1.0.1], [mace-opensaml-users@internet2.edu], [xmltooling])
+AC_INIT([xmltooling], [1.1], [mace-opensaml-users@internet2.edu], [xmltooling])
 AM_CONFIG_HEADER(config.h)
 AM_CONFIG_HEADER(xmltooling/config_pub.h)
-AM_INIT_AUTOMAKE([xmltooling], [1.0.1])
+AM_INIT_AUTOMAKE([xmltooling], [1.1])
 
 sinclude(doxygen.m4)
 sinclude(acx_pthread.m4)
@@ -61,6 +61,7 @@ AC_PROG_LIBTOOL
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_TYPE_SIZE_T
+AC_CHECK_SIZEOF([long])
 
 # Checks for library functions.
 AC_CHECK_FUNCS([strchr strdup strstr timegm strcasecmp])
index 06ac078..25d6f2d 100644 (file)
@@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS = foreign
 pkgdocdir = $(datadir)/doc/@PACKAGE@
 
 docfiles = \
+    README.txt \
        LICENSE.txt \
        NOTICE.txt \
        OPENSSL.LICENSE \
diff --git a/doc/README.txt b/doc/README.txt
new file mode 100644 (file)
index 0000000..1f9cd13
--- /dev/null
@@ -0,0 +1,20 @@
+VERSION 1.1\r
+\r
+Issues addressed by this release:\r
+---------------------------------\r
+https://bugs.internet2.edu/jira/secure/IssueNavigator.jspa?reset=true&&pid=10009&fixfor=10134&status=5&status=6&sorter/field=issuekey&sorter/order=ASC\r
+\r
+Documentation:\r
+--------------\r
+The OpenSAML wiki is the home for any documentation on the XMLTooling package.\r
+https://spaces.internet2.edu/display/OpenSAML/\r
+\r
+Reporting Bugs:\r
+---------------\r
+A Jira instance is available.\r
+https://bugs.internet2.edu/\r
+\r
+Support:\r
+--------\r
+A mailing list is available.\r
+https://spaces.internet2.edu/display/OpenSAML/MailingList\r
index 8cac0f4..3537821 100644 (file)
@@ -1,7 +1,7 @@
 Name:          xmltooling
 Summary:       Open source XMLTooling library
 Version:       @-VERSION-@
-Release:       6
+Release:       1
 Group:         System Environment/Libraries
 Vendor:                Internet2
 License:       Apache 2.0
@@ -80,6 +80,7 @@ find $RPM_BUILD_ROOT/%{_bindir} -type f |
 %dir %{_datadir}/xml/xmltooling
 %{_datadir}/xml/xmltooling
 %docdir %{_datadir}/doc/xmltooling
+%{_datadir}/doc/xmltooling/README.txt
 %{_datadir}/doc/xmltooling/LICENSE.txt
 %{_datadir}/doc/xmltooling/NOTICE.txt
 %{_datadir}/doc/xmltooling/CURL.LICENSE
@@ -97,6 +98,9 @@ find $RPM_BUILD_ROOT/%{_bindir} -type f |
 %doc %{_datadir}/doc/xmltooling/api
 
 %changelog
+* Tue Jul 1 2008  Scott Cantor  <cantor.2@osu.edu>  - 1.1-1
+- Bumping for minor update.
+
 * Mon Mar 17 2008  Scott Cantor  <cantor.2@osu.edu>  - 1.0-6
 - Official release.
 
index 6448856..a8461a4 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *  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
@@ -16,7 +16,7 @@
 
 /**
  * AbstractXMLObject.cpp
- * 
+ *
  * An abstract implementation of XMLObject.
  */
 
@@ -49,6 +49,13 @@ AbstractXMLObject::AbstractXMLObject(const AbstractXMLObject& src)
         m_typeQname=new QName(*src.m_typeQname);
 }
 
+AbstractXMLObject::~AbstractXMLObject()
+{
+    delete m_typeQname;
+    xercesc::XMLString::release(&m_schemaLocation);
+    xercesc::XMLString::release(&m_noNamespaceSchemaLocation);
+}
+
 void XMLObject::setNil(const XMLCh* value) {
     if (value) {
         switch (*value) {
@@ -121,21 +128,27 @@ DateTime* AbstractXMLObject::prepareForAssignment(DateTime* oldValue, const Date
     return newValue ? new DateTime(*newValue) : NULL;
 }
 
-DateTime* AbstractXMLObject::prepareForAssignment(DateTime* oldValue, time_t newValue)
+DateTime* AbstractXMLObject::prepareForAssignment(DateTime* oldValue, time_t newValue, bool duration)
 {
     delete oldValue;
     releaseThisandParentDOM();
     DateTime* ret = new DateTime(newValue);
-    ret->parseDateTime();
+    if (duration)
+        ret->parseDuration();
+    else
+        ret->parseDateTime();
     return ret;
 }
 
-DateTime* AbstractXMLObject::prepareForAssignment(DateTime* oldValue, const XMLCh* newValue)
+DateTime* AbstractXMLObject::prepareForAssignment(DateTime* oldValue, const XMLCh* newValue, bool duration)
 {
     delete oldValue;
     releaseThisandParentDOM();
     DateTime* ret = new DateTime(newValue);
-    ret->parseDateTime();
+    if (duration)
+        ret->parseDuration();
+    else
+        ret->parseDateTime();
     return ret;
 }
 
index 7767167..fc4c23b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *  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
@@ -16,7 +16,7 @@
 
 /**
  * @file xmltooling/AbstractXMLObject.h
- * 
+ *
  * An abstract implementation of XMLObject.
  */
 
@@ -44,11 +44,7 @@ namespace xmltooling {
     class XMLTOOL_API AbstractXMLObject : public virtual XMLObject
     {
     public:
-        virtual ~AbstractXMLObject() {
-            delete m_typeQname;
-            xercesc::XMLString::release(&m_schemaLocation);
-            xercesc::XMLString::release(&m_noNamespaceSchemaLocation);
-        }
+        virtual ~AbstractXMLObject();
 
         void detach();
 
@@ -59,7 +55,7 @@ namespace xmltooling {
         const std::set<Namespace>& getNamespaces() const {
             return m_namespaces;
         }
-    
+
         void addNamespace(const Namespace& ns) const {
             std::set<Namespace>::iterator i = m_namespaces.find(ns);
             if (i == m_namespaces.end())
@@ -67,23 +63,23 @@ namespace xmltooling {
             else if (ns.alwaysDeclare())
                 const_cast<Namespace&>(*i).setAlwaysDeclare(true);
         }
-    
+
         void removeNamespace(const Namespace& ns) {
             m_namespaces.erase(ns);
         }
-        
+
         const QName* getSchemaType() const {
             return m_typeQname;
         }
-        
+
         const XMLCh* getXMLID() const {
             return NULL;
         }
-        
+
         xmlconstants::xmltooling_bool_t getNil() const {
                return m_nil;
         }
-        
+
         void nil(xmlconstants::xmltooling_bool_t value) {
             if (m_nil != value) {
                releaseThisandParentDOM();
@@ -94,11 +90,11 @@ namespace xmltooling {
         bool hasParent() const {
             return m_parent != NULL;
         }
-     
+
         XMLObject* getParent() const {
             return m_parent;
         }
-    
+
         void setParent(XMLObject* parent) {
             m_parent = parent;
         }
@@ -106,7 +102,7 @@ namespace xmltooling {
      protected:
         /**
          * Constructor
-         * 
+         *
          * @param nsURI         the namespace of the element
          * @param localName     the local name of the XML element this Object represents
          * @param prefix        the namespace prefix to use
@@ -118,17 +114,17 @@ namespace xmltooling {
 
         /** Copy constructor. */
         AbstractXMLObject(const AbstractXMLObject& src);
-        
+
         /**
          * A helper function for derived classes, for assignment of strings.
          *
          * This 'normalizes' newString, and then if it is different from oldString,
          * it invalidates the DOM, frees the old string, and returns the new.
          * If not different, it frees the new string and just returns the old value.
-         * 
-         * @param oldValue the current value
-         * @param newValue the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value
+         *
          * @return the value that should be assigned
          */
         XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue);
@@ -137,10 +133,10 @@ namespace xmltooling {
          * A helper function for derived classes, for assignment of date/time data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue the current value
-         * @param newValue the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value
+         *
          * @return the value that should be assigned
          */
         DateTime* prepareForAssignment(DateTime* oldValue, const DateTime* newValue);
@@ -149,50 +145,52 @@ namespace xmltooling {
          * A helper function for derived classes, for assignment of date/time data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue - the current value
-         * @param newValue - the epoch to assign as the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the epoch to assign as the new value
+         * @param duration true iff the value is a duration rather than an absolute timestamp
+         *
          * @return the value that should be assigned
          */
-        DateTime* prepareForAssignment(DateTime* oldValue, time_t newValue);
+        DateTime* prepareForAssignment(DateTime* oldValue, time_t newValue, bool duration=false);
 
         /**
          * A helper function for derived classes, for assignment of date/time data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue - the current value
-         * @param newValue - the new value in string form
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value in string form
+         * @param duration true iff the value is a duration rather than an absolute timestamp
+         *
          * @return the value that should be assigned
          */
-        DateTime* prepareForAssignment(DateTime* oldValue, const XMLCh* newValue);
+        DateTime* prepareForAssignment(DateTime* oldValue, const XMLCh* newValue, bool duration=false);
 
         /**
          * A helper function for derived classes, for assignment of QName data.
          *
          * It invalidates the DOM, frees the old object, and returns the new.
-         * 
-         * @param oldValue the current value
-         * @param newValue the new value
-         * 
+         *
+         * @param oldValue the current value
+         * @param newValue the new value
+         *
          * @return the value that should be assigned
          */
         QName* prepareForAssignment(QName* oldValue, const QName* newValue);
 
         /**
          * A helper function for derived classes, for assignment of (singleton) XML objects.
-         * 
-         * It is indifferent to whether either the old or the new version of the value is null. 
+         *
+         * It is indifferent to whether either the old or the new version of the value is null.
          * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate.
          * Note that since the new value (even if NULL) is always returned, it may be more efficient
          * to discard the return value and just assign independently if a dynamic cast would be involved.
-         * 
-         * @param oldValue current value
-         * @param newValue proposed new value
-         * @return the new value 
-         * 
+         *
+         * @param oldValue current value
+         * @param newValue proposed new value
+         * @return the new value
+         *
          * @throws XMLObjectException if the new child already has a parent.
          */
         XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);
@@ -216,7 +214,7 @@ namespace xmltooling {
          * Stores off xsi:noNamespaceSchemaLocation attribute.
          */
         XMLCh* m_noNamespaceSchemaLocation;
-        
+
         /**
          * Stores off xsi:nil attribute.
          */
index a81af0b..a580e53 100644 (file)
@@ -195,10 +195,10 @@ common_sources = \
 libxmltooling_lite_la_SOURCES = \
        ${common_sources}
 libxmltooling_lite_la_CPPFLAGS = -DXMLTOOLING_LITE
-libxmltooling_lite_la_LDFLAGS = -version-info 1:0:0
+libxmltooling_lite_la_LDFLAGS = -version-info 2:0:0
 
 if BUILD_XMLSEC
-libxmltooling_la_LDFLAGS = $(XMLSEC_LIBS) -version-info 1:0:0
+libxmltooling_la_LDFLAGS = $(XMLSEC_LIBS) -version-info 2:0:0
 libxmltooling_la_SOURCES = \
        ${common_sources} \
        ${xmlsec_sources}
@@ -214,4 +214,4 @@ EXTRA_DIST = \
     config_pub_win32.h\
     resource.h\
     xmltooling.rc \
-    util\Win32Threads.cpp
+    util/Win32Threads.cpp
index 450c37f..05128dd 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  *  Copyright 2001-2007 Internet2\r
- * \r
+ *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -16,7 +16,7 @@
 \r
 /**\r
  * @file xmltooling/base.h\r
- * \r
+ *\r
  * Base header file definitions\r
  * Must be included prior to including any other header\r
  */\r
  * Begins the declaration of an XMLObject specialization for an abstract element/type.\r
  * Basic boilerplate includes a protected constructor, empty virtual destructor,\r
  * and Unicode constants for the default associated element's name and prefix.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the class to declare\r
  * @param base      the base class to derive from using public virtual inheritance\r
  * Begins the declaration of an XMLObject specialization.\r
  * Basic boilerplate includes a protected constructor, empty virtual destructor,\r
  * and Unicode constants for the default associated element's name and prefix.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the class to declare\r
  * @param base      the base class to derive from using public virtual inheritance\r
  * Begins the declaration of an XMLObject specialization with two base classes.\r
  * Basic boilerplate includes a protected constructor, empty virtual destructor,\r
  * and Unicode constants for the default associated element's name and prefix.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the class to declare\r
  * @param base      the first base class to derive from using public virtual inheritance\r
  * Begins the declaration of an XMLObject specialization with three base classes.\r
  * Basic boilerplate includes a protected constructor, empty virtual destructor,\r
  * and Unicode constants for the default associated element's name and prefix.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the class to declare\r
  * @param base      the first base class to derive from using public virtual inheritance\r
  * Begins the declaration of an XMLObject specialization with four base classes.\r
  * Basic boilerplate includes a protected constructor, empty virtual destructor,\r
  * and Unicode constants for the default associated element's name and prefix.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the class to declare\r
  * @param base      the first base class to derive from using public virtual inheritance\r
  * Begins the declaration of an XMLObject specialization with five base classes.\r
  * Basic boilerplate includes a protected constructor, empty virtual destructor,\r
  * and Unicode constants for the default associated element's name and prefix.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the class to declare\r
  * @param base      the first base class to derive from using public virtual inheritance\r
 \r
 /**\r
  * Implements a static variable holding an XMLObject's element QName.\r
- * \r
+ *\r
  * @param cname             the name of the XMLObject specialization\r
  * @param namespaceURI      the XML namespace of the default associated element\r
  * @param namespacePrefix   the XML namespace prefix of the default associated element\r
 \r
 /**\r
  * Implements a static variable holding an XMLObject's schema type QName.\r
- * \r
+ *\r
  * @param cname             the name of the XMLObject specialization\r
  * @param namespaceURI      the XML namespace of the default associated element\r
  * @param namespacePrefix   the XML namespace prefix of the default associated element\r
 /**\r
  * Declares abstract set method for a typed XML attribute.\r
  * The get method is omitted.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  * @param type      the attribute's data type\r
 \r
 /**\r
  * Declares abstract get/set methods for a typed XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  * @param type      the attribute's data type\r
 /**\r
  * Declares abstract set method for a string XML attribute.\r
  * The get method is omitted.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  */\r
 \r
 /**\r
  * Declares abstract get/set methods for a string XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  */\r
 /**\r
  * Declares abstract set method for a DateTime XML attribute.\r
  * The get method is omitted.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  */\r
 \r
 /**\r
  * Declares abstract get/set methods for a DateTime XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  */\r
 /**\r
  * Declares abstract set method for an integer XML attribute.\r
  * The get method is omitted.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  */\r
 \r
 /**\r
  * Declares abstract get/set methods for an integer XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  */\r
 \r
 /**\r
  * Declares abstract get/set methods for a boolean XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param upcased   the upcased name of the attribute\r
  * @param def       the default/presumed value, if no explicit value has been set\r
 \r
 /**\r
  * Implements get/set methods and a private member for a typed XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param type      the attribute's data type\r
  */\r
 \r
 /**\r
  * Implements get/set methods and a private member for a string XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  */\r
 #define IMPL_STRING_ATTRIB(proper) \\r
 /**\r
  * Implements get/set methods and a private member for a string XML attribute,\r
  * plus a getXMLID override.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  */\r
 #define IMPL_ID_ATTRIB(proper) \\r
 \r
 /**\r
  * Implements get/set methods and a private member for a DateTime XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  * @param fallback  epoch to return when attribute is NULL\r
  */\r
 #define IMPL_DATETIME_ATTRIB(proper,fallback) \\r
+    IMPL_DATETIME_ATTRIB_EX(proper,fallback,false)\r
+\r
+/**\r
+ * Implements get/set methods and a private member for a duration-valued DateTime XML attribute.\r
+ *\r
+ * @param proper    the proper name of the attribute\r
+ * @param fallback  epoch to return when attribute is NULL\r
+ */\r
+#define IMPL_DURATION_ATTRIB(proper,fallback) \\r
+    IMPL_DATETIME_ATTRIB_EX(proper,fallback,true)\r
+\r
+/**\r
+ * Implements get/set methods and a private member for a DateTime XML attribute.\r
+ *\r
+ * @param proper    the proper name of the attribute\r
+ * @param fallback  epoch to return when attribute is NULL\r
+ * @param duration  true iff the attribute should be handled as a duration\r
+ */\r
+#define IMPL_DATETIME_ATTRIB_EX(proper,fallback,duration) \\r
     protected: \\r
         DateTime* m_##proper; \\r
         time_t m_##proper##Epoch; \\r
                 m_##proper##Epoch=m_##proper->getEpoch(); \\r
         } \\r
         void set##proper(time_t proper) { \\r
-            m_##proper = prepareForAssignment(m_##proper,proper); \\r
+            m_##proper = prepareForAssignment(m_##proper,proper,duration); \\r
             m_##proper##Epoch = proper; \\r
         } \\r
         void set##proper(const XMLCh* proper) { \\r
-            m_##proper = prepareForAssignment(m_##proper,proper); \\r
+            m_##proper = prepareForAssignment(m_##proper,proper,duration); \\r
             if (m_##proper) \\r
                 m_##proper##Epoch=m_##proper->getEpoch(); \\r
         }\r
 \r
 /**\r
  * Implements get/set methods and a private member for an integer XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  */\r
 #define IMPL_INTEGER_ATTRIB(proper) \\r
 \r
 /**\r
  * Implements get/set methods and a private member for a boolean XML attribute.\r
- * \r
+ *\r
  * @param proper    the proper name of the attribute\r
  */\r
 #define IMPL_BOOLEAN_ATTRIB(proper) \\r
 /**\r
  * Declares abstract set method for a typed XML child object in a foreign namespace.\r
  * The get method is omitted.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  * @param ns        the C++ namespace for the type\r
  */\r
 \r
 /**\r
  * Declares abstract get/set methods for a typed XML child object in a foreign namespace.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  * @param ns        the C++ namespace for the type\r
  */\r
 /**\r
  * Declares abstract set method for a typed XML child object.\r
  * The get method is omitted.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  */\r
 #define DECL_INHERITED_TYPED_CHILD(proper) \\r
 \r
 /**\r
  * Declares abstract get/set methods for a typed XML child object.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  */\r
 #define DECL_TYPED_CHILD(proper) \\r
 \r
 /**\r
  * Declares abstract get/set methods for a generic XML child object.\r
- * \r
+ *\r
  * @param proper    the proper name of the child\r
  */\r
 #define DECL_XMLOBJECT_CHILD(proper) \\r
 \r
 /**\r
  * Implements get/set methods and a private list iterator member for a typed XML child object.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  */\r
 #define IMPL_TYPED_CHILD(proper) \\r
 /**\r
  * Implements get/set methods and a private list iterator member for\r
  * a typed XML child object in a foreign namespace\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  * @param ns        the C++ namespace for the type\r
  */\r
 \r
 /**\r
  * Implements get/set methods and a private list iterator member for a generic XML child object.\r
- * \r
+ *\r
  * @param proper    the proper name of the child\r
  */\r
 #define IMPL_XMLOBJECT_CHILD(proper) \\r
 \r
 /**\r
  * Declares abstract get/set methods for a typed XML child collection.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  */\r
 #define DECL_TYPED_CHILDREN(proper) \\r
 \r
 /**\r
  * Declares abstract get/set methods for a typed XML child collection in a foreign namespace.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  * @param ns        the C++ namespace for the type\r
  */\r
 \r
 /**\r
  * Declares abstract get/set methods for a generic XML child collection.\r
- * \r
+ *\r
  * @param proper    the proper name of the child\r
  */\r
 #define DECL_XMLOBJECT_CHILDREN(proper) \\r
 \r
 /**\r
  * Implements get method and a private vector member for a typed XML child collection.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  * @param fence     insertion fence for new objects of the child collection in backing list\r
  */\r
         } \\r
         const std::vector<proper*>& get##proper##s() const { \\r
             return m_##proper##s; \\r
-        } \r
+        }\r
 \r
 /**\r
  * Implements get method and a private vector member for a typed XML child collection\r
  * in a foreign namespace.\r
- * \r
+ *\r
  * @param proper    the proper name of the child type\r
  * @param ns        the C++ namespace for the type\r
  * @param fence     insertion fence for new objects of the child collection in backing list\r
         } \\r
         const std::vector<ns::proper*>& get##proper##s() const { \\r
             return m_##proper##s; \\r
-        } \r
+        }\r
 \r
 /**\r
  * Implements get method and a private vector member for a generic XML child collection.\r
- * \r
+ *\r
  * @param proper    the proper name of the child\r
  * @param fence     insertion fence for new objects of the child collection in backing list\r
  */\r
         } \\r
         const std::vector<xmltooling::XMLObject*>& get##proper##s() const { \\r
             return m_##proper##s; \\r
-        } \r
+        }\r
 \r
 /**\r
  * Implements marshalling for a string attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements marshalling for a DateTime attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements marshalling for an integer attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements marshalling for a boolean attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements marshalling for a QName attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements marshalling for an ID attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements unmarshalling process branch for a string attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements unmarshalling process branch for an ID attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements unmarshalling process branch for a DateTime attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements unmarshalling process branch for a DateTime attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements unmarshalling process branch for an integer attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements unmarshalling process branch for a boolean attribute\r
- * \r
+ *\r
  * @param proper        the proper name of the attribute\r
  * @param ucase         the upcased name of the attribute\r
  * @param namespaceURI  the XML namespace of the attribute\r
 \r
 /**\r
  * Implements unmarshalling process branch for typed child collection element\r
- * \r
+ *\r
  * @param proper        the proper name of the child type\r
  * @param namespaceURI  the XML namespace of the child element\r
  * @param force         bypass use of hint and just cast down to check child\r
 /**\r
  * Implements unmarshalling process branch for typed child collection element\r
  * in a foreign namespace.\r
- * \r
+ *\r
  * @param proper        the proper name of the child type\r
  * @param ns            the C++ namespace for the type\r
  * @param namespaceURI  the XML namespace of the child element\r
 \r
 /**\r
  * Implements unmarshalling process branch for typed child singleton element\r
- * \r
+ *\r
  * @param proper        the proper name of the child type\r
  * @param namespaceURI  the XML namespace of the child element\r
  * @param force         bypass use of hint and just cast down to check child\r
 /**\r
  * Implements unmarshalling process branch for typed child singleton element\r
  * in a foreign namespace.\r
- * \r
+ *\r
  * @param proper        the proper name of the child type\r
  * @param ns            the C++ namespace for the type\r
  * @param namespaceURI  the XML namespace of the child element\r
 \r
 /**\r
  * Implements unmarshalling process branch for a generic child singleton element\r
- * \r
+ *\r
  * @param proper        the proper name of the child type\r
  * @param namespaceURI  the XML namespace of the child element\r
  */\r
 \r
 /**\r
  * Declares aliased get/set methods for named XML element simple content.\r
- * \r
+ *\r
  * @param proper    the proper name to label the element's content\r
  */\r
 #define DECL_SIMPLE_CONTENT(proper) \\r
 \r
 /**\r
  * Declares aliased get/set methods for named integer XML element content.\r
- * \r
+ *\r
  * @param proper    the proper name to label the element's content\r
  */\r
 #define DECL_INTEGER_CONTENT(proper) \\r
 \r
 /**\r
  * Implements cloning methods for an XMLObject specialization implementation class.\r
- * \r
+ *\r
  * @param cname    the name of the XMLObject specialization\r
  */\r
 #define IMPL_XMLOBJECT_CLONE(cname) \\r
 /**\r
  * Declares an XMLObject specialization with a simple content model and type,\r
  * handling it as string data.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the XMLObject specialization\r
  * @param proper    the proper name to label the element's content\r
 /**\r
  * Declares and defines an implementation class for an XMLObject with\r
  * a simple content model and type, handling it as string data.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the XMLObject specialization\r
  */\r
  * Begins the declaration of an XMLObjectBuilder specialization.\r
  * Basic boilerplate includes an empty virtual destructor, and\r
  * a default builder that defaults the element name.\r
- * \r
+ *\r
  * @param linkage           linkage specifier for the class\r
  * @param cname             the name of the XMLObject specialization\r
  * @param namespaceURI      the XML namespace of the default associated element\r
 \r
 /**\r
  * Declares a generic XMLObjectBuilder specialization.\r
- * \r
+ *\r
  * @param linkage           linkage specifier for the class\r
  * @param cname             the name of the XMLObject specialization\r
  * @param namespaceURI      the XML namespace of the default associated element\r
     END_XMLOBJECTBUILDER\r
 \r
 /**\r
- * Implements the standard XMLObjectBuilder specialization function. \r
- * \r
+ * Implements the standard XMLObjectBuilder specialization function.\r
+ *\r
  * @param cname the name of the XMLObject specialization\r
  */\r
 #define IMPL_XMLOBJECTBUILDER(cname) \\r
  * Begins the declaration of an XMLObjectBuilder specialization.\r
  * Basic boilerplate includes an empty virtual destructor, and\r
  * a default builder that defaults the element name.\r
- * \r
+ *\r
  * @param linkage           linkage specifier for the class\r
  * @param cname             the name of the XMLObject specialization\r
  * @param namespaceURI      the XML namespace of the default associated element\r
 \r
 /**\r
  * Declares a generic XMLObjectBuilder specialization.\r
- * \r
+ *\r
  * @param linkage           linkage specifier for the class\r
  * @param cname             the name of the XMLObject specialization\r
  * @param namespaceURI      the XML namespace of the default associated element\r
     END_XMLOBJECTBUILDER\r
 \r
 /**\r
- * Implements the standard XMLObjectBuilder specialization function. \r
- * \r
+ * Implements the standard XMLObjectBuilder specialization function.\r
+ *\r
  * @param cname the name of the XMLObject specialization\r
  */\r
 #define IMPL_XMLOBJECTBUILDER(cname) \\r
 \r
 /**\r
  * Begins the declaration of a Schema Validator specialization.\r
- * \r
+ *\r
  * @param linkage           linkage specifier for the class\r
  * @param cname the base name of the Validator specialization\r
  */\r
 \r
 /**\r
  * Begins the declaration of a Schema Validator specialization subclass.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the base name of the Validator specialization\r
  * @param base      base class for the validator\r
 \r
 /**\r
  * Validator code that checks the object type.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
  */\r
 #define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \\r
 \r
 /**\r
  * Validator code that checks for a required attribute, content, or singleton.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
- * @param proper    the proper name of the attribute, content, or singleton member \r
+ * @param proper    the proper name of the attribute, content, or singleton member\r
  */\r
 #define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \\r
     if (!ptr->get##proper()) \\r
 \r
 /**\r
  * Validator code that checks for a required integer attribute\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
- * @param proper    the proper name of the attribute, content, or singleton member \r
+ * @param proper    the proper name of the attribute, content, or singleton member\r
  */\r
 #define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \\r
     if (!ptr->get##proper().first) \\r
 /**\r
  * Validator code that checks for one of a pair of\r
  * required attributes, content, or singletons.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
- * @param proper1   the proper name of the first attribute, content, or singleton member \r
- * @param proper2   the proper name of the second attribute, content, or singleton member \r
+ * @param proper1   the proper name of the first attribute, content, or singleton member\r
+ * @param proper2   the proper name of the second attribute, content, or singleton member\r
  */\r
 #define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \\r
     if (!ptr->get##proper1() && !ptr->get##proper2()) \\r
 /**\r
  * Validator code that checks for one of a pair of\r
  * required attributes, content, or singletons, but disallows both.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
- * @param proper1   the proper name of the first attribute, content, or singleton member \r
- * @param proper2   the proper name of the second attribute, content, or singleton member \r
+ * @param proper1   the proper name of the first attribute, content, or singleton member\r
+ * @param proper2   the proper name of the second attribute, content, or singleton member\r
  */\r
 #define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \\r
     if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \\r
 /**\r
  * Validator code that checks for one of a set of three\r
  * required attributes, content, or singletons.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
  * @param proper1   the proper name of the first attribute, content, or singleton member\r
  * @param proper2   the proper name of the second attribute, content, or singleton member\r
 /**\r
  * Validator code that checks for one of a set of three\r
  * required attributes, content, or singletons but disallows more than one.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
  * @param proper1   the proper name of the first attribute, content, or singleton member\r
  * @param proper2   the proper name of the second attribute, content, or singleton member\r
 /**\r
  * Validator code that checks a co-constraint (if one present, the other must be)\r
  * between a pair of attributes, content, or singletons.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
- * @param proper1   the proper name of the first attribute, content, or singleton member \r
- * @param proper2   the proper name of the second attribute, content, or singleton member \r
+ * @param proper1   the proper name of the first attribute, content, or singleton member\r
+ * @param proper2   the proper name of the second attribute, content, or singleton member\r
  */\r
 #define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \\r
     if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \\r
 \r
 /**\r
  * Validator code that checks for a non-empty collection.\r
- * \r
+ *\r
  * @param cname     the name of the XMLObject specialization\r
- * @param proper    the proper name of the collection item \r
+ * @param proper    the proper name of the collection item\r
  */\r
 #define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \\r
     if (ptr->get##proper##s().empty()) \\r
 /**\r
  * Declares/defines a Validator specialization that checks object type and\r
  * a non-empty simple content model.\r
- * \r
+ *\r
  * @param linkage   linkage specifier for the class\r
  * @param cname     the name of the XMLObject specialization\r
  */\r
@@ -1515,7 +1534,7 @@ namespace xmltooling {
      * Template function for cloning a sequence of XMLObjects.\r
      * Invokes the clone() member on each element of the input sequence and adds the copy to\r
      * the output sequence. Order is preserved.\r
-     * \r
+     *\r
      * @param in    input sequence to clone\r
      * @param out   output sequence to copy cloned pointers into\r
      */\r
@@ -1535,14 +1554,14 @@ namespace xmltooling {
     {\r
         /**\r
          * Function operator to delete an object.\r
-         * \r
+         *\r
          * @param ptr   object to delete\r
          */\r
         void operator()(T* ptr) {delete ptr;}\r
-        \r
+\r
         /**\r
          * Function operator to delete an object stored as const.\r
-         * \r
+         *\r
          * @param ptr   object to delete after casting away const\r
          */\r
         void operator()(const T* ptr) {delete const_cast<T*>(ptr);}\r
@@ -1555,7 +1574,7 @@ namespace xmltooling {
     {\r
         /**\r
          * Function operator to delete an object.\r
-         * \r
+         *\r
          * @param p   a pair in which the second component is the object to delete\r
          */\r
         void operator()(const std::pair<const A,B*>& p) {delete p.second;}\r
@@ -1568,7 +1587,7 @@ namespace xmltooling {
     {\r
         /**\r
          * Function operator to delete an object stored as const\r
-         * \r
+         *\r
          * @param p   a pair in which the second component is the const object to delete\r
          */\r
         void operator()(const std::pair<const A,const B*>& p) {delete const_cast<B*>(p.second);}\r
index e33e785..9241fd0 100644 (file)
@@ -87,8 +87,10 @@ namespace xmltooling {
 
         /**
          * Initializes (or reinitializes) a ds:KeyInfo to represent the Credential.
+         *
+         * @param types the kinds of KeyInfo content to include 
          */
-        void initKeyInfo();
+        void initKeyInfo(unsigned int types=0);
 
     public:
         virtual ~BasicX509Credential();
index 02d4999..ecd575a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -16,8 +16,8 @@
 
 /**
  * @file xmltooling/security/Credential.h
- * 
- * Wraps keys and related functionality. 
+ *
+ * Wraps keys and related functionality.
  */
 
 #if !defined(__xmltooling_cred_h__) && !defined(XMLTOOLING_NO_XMLSEC)
@@ -49,12 +49,12 @@ namespace xmltooling {
         MAKE_NONCOPYABLE(Credential);
     protected:
         Credential() {}
-        
+
     public:
         virtual ~Credential() {}
-        
+
         /**
-         * Bitmask constants for limiting resolution process inside a CredentialResolver. 
+         * Bitmask constants for limiting resolution process inside a CredentialResolver.
          */
         enum ResolveTypes {
             RESOLVE_KEYS = 1,
@@ -62,7 +62,7 @@ namespace xmltooling {
         };
 
         /**
-         * Bitmask of use cases for credentials. 
+         * Bitmask of use cases for credentials.
          */
         enum UsageTypes {
             UNSPECIFIED_CREDENTIAL = 0,
@@ -70,10 +70,18 @@ namespace xmltooling {
             TLS_CREDENTIAL = 2,
             ENCRYPTION_CREDENTIAL = 4
         };
-        
+
+        /**
+         * Bitmask of supported KeyInfo content to generate.
+         */
+        enum KeyInfoTypes {
+            KEYINFO_KEY_VALUE = 1,
+            KEYINFO_KEY_NAME = 2
+        };
+
         /**
          * Get credential usage types.
-         * 
+         *
          * @return the usage bitmask
          */
         virtual unsigned int getUsage() const=0;
@@ -94,32 +102,32 @@ namespace xmltooling {
 
         /**
          * Returns a secret or private key to use for signing or decryption operations.
-         * 
+         *
          * @return  a secret or private key
          */
         virtual XSECCryptoKey* getPrivateKey() const=0;
 
         /**
          * Returns a secret or public key to use for verification or encryption operations.
-         * 
+         *
          * @return  a secret or public key
          */
         virtual XSECCryptoKey* getPublicKey() const=0;
-        
+
         /**
          * Returns names representing the Credential.
          *
          * <p>Names should be unique in the context of the comparisons against CredentialCriteria
          * that deployments expect to see.
-         * 
+         *
          * @return  a sorted set of names
          */
         virtual const std::set<std::string>& getKeyNames() const=0;
-        
+
         /**
          * Returns a ds:KeyInfo object representing the Credential for use in
          * communicating with other entities.
-         * 
+         *
          * @param compact   true iff the communication medium is such that only compact forms should be included
          * @return a KeyInfo object, which must be freed by the caller
          */
@@ -128,7 +136,7 @@ namespace xmltooling {
         /**
          * Get the credential context information, which provides additional information
          * specific to the context in which the credential was resolved.
-         * 
+         *
          * @return resolution context of the credential
          */
         virtual const CredentialContext* getCredentalContext() const {
index a4d6e69..59dcd07 100644 (file)
@@ -50,6 +50,15 @@ namespace xmltooling {
         };
 
         /**
+         * Bitmask of supported KeyInfo content to generate. 
+         */
+        enum KeyInfoTypes {
+            KEYINFO_X509_CERTIFICATE = 4,
+            KEYINFO_X509_SUBJECTNAME = 8,
+            KEYINFO_X509_ISSUERSERIAL = 16
+        };
+
+        /**
          * Gets an immutable collection of certificates in the entity's trust chain. The entity certificate is contained
          * within this list. No specific ordering of the certificates is guaranteed.
          * 
index b9678ff..50da3ed 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -16,8 +16,8 @@
 
 /**
  * BasicX509Credential.cpp
- * 
- * Wraps an X.509-based Credential by storing key/cert objects inside. 
+ *
+ * Wraps an X.509-based Credential by storing key/cert objects inside.
  */
 
 #include "internal.h"
@@ -42,56 +42,61 @@ BasicX509Credential::~BasicX509Credential()
     delete m_compactKeyInfo;
 }
 
-void BasicX509Credential::initKeyInfo()
+void BasicX509Credential::initKeyInfo(unsigned int types)
 {
     delete m_keyInfo;
     m_keyInfo = NULL;
     delete m_compactKeyInfo;
     m_compactKeyInfo = NULL;
 
-    const set<string>& names = getKeyNames();
-    if (!names.empty()) {
-        m_compactKeyInfo = KeyInfoBuilder::buildKeyInfo();
-        VectorOf(KeyName) knames = m_compactKeyInfo->getKeyNames();
-        for (set<string>::const_iterator n = names.begin(); n!=names.end(); ++n) {
-            if (*n == m_subjectName)
-                continue;
-            auto_ptr_XMLCh wide(n->c_str());
-            KeyName* kname = KeyNameBuilder::buildKeyName();
-            kname->setName(wide.get());
-            knames.push_back(kname);
-        }
-    }
+    if (types == 0)
+        types = KEYINFO_KEY_VALUE | KEYINFO_KEY_NAME | KEYINFO_X509_CERTIFICATE | KEYINFO_X509_SUBJECTNAME | KEYINFO_X509_ISSUERSERIAL;
 
-//  if (!m_subjectName.empty() || (!m_issuerName.empty() && !m_serial.empty())) {
-    if (!m_subjectName.empty()) {
-        if (!m_compactKeyInfo)
+    if (types & KEYINFO_KEY_NAME) {
+        const set<string>& names = getKeyNames();
+        if (!names.empty()) {
             m_compactKeyInfo = KeyInfoBuilder::buildKeyInfo();
-        X509Data* x509Data=X509DataBuilder::buildX509Data();
-        m_compactKeyInfo->getX509Datas().push_back(x509Data);
-        if (!m_subjectName.empty()) {
-            X509SubjectName* sn = X509SubjectNameBuilder::buildX509SubjectName();
-            auto_ptr_XMLCh wide(m_subjectName.c_str());
-            sn->setName(wide.get());
-            x509Data->getX509SubjectNames().push_back(sn);
+            VectorOf(KeyName) knames = m_compactKeyInfo->getKeyNames();
+            for (set<string>::const_iterator n = names.begin(); n!=names.end(); ++n) {
+                if (*n == m_subjectName)
+                    continue;
+                auto_ptr_XMLCh wide(n->c_str());
+                KeyName* kname = KeyNameBuilder::buildKeyName();
+                kname->setName(wide.get());
+                knames.push_back(kname);
+            }
         }
-/*        
-        if (!m_issuerName.empty() && !m_serial.empty()) {
-            X509IssuerSerial* is = X509IssuerSerialBuilder::buildX509IssuerSerial();
-            X509IssuerName* in = X509IssuerNameBuilder::buildX509IssuerName();
-            auto_ptr_XMLCh wide(m_issuerName.c_str());
-            in->setName(wide.get());
-            is->setX509IssuerName(in);
-            X509SerialNumber* ser = X509SerialNumberBuilder::buildX509SerialNumber();
-            auto_ptr_XMLCh wide2(m_serial.c_str());
-            ser->setSerialNumber(wide2.get());
-            is->setX509SerialNumber(ser);
-            x509Data->getX509IssuerSerials().push_back(is);
+    }
+
+    if (types & KEYINFO_X509_SUBJECTNAME || types & KEYINFO_X509_ISSUERSERIAL) {
+        if (!m_subjectName.empty() || (!m_issuerName.empty() && !m_serial.empty())) {
+            if (!m_compactKeyInfo)
+                m_compactKeyInfo = KeyInfoBuilder::buildKeyInfo();
+            X509Data* x509Data=X509DataBuilder::buildX509Data();
+            m_compactKeyInfo->getX509Datas().push_back(x509Data);
+            if (types & KEYINFO_X509_SUBJECTNAME && !m_subjectName.empty()) {
+                X509SubjectName* sn = X509SubjectNameBuilder::buildX509SubjectName();
+                auto_ptr_XMLCh wide(m_subjectName.c_str());
+                sn->setName(wide.get());
+                x509Data->getX509SubjectNames().push_back(sn);
+            }
+
+            if (types & KEYINFO_X509_ISSUERSERIAL && !m_issuerName.empty() && !m_serial.empty()) {
+                X509IssuerSerial* is = X509IssuerSerialBuilder::buildX509IssuerSerial();
+                X509IssuerName* in = X509IssuerNameBuilder::buildX509IssuerName();
+                auto_ptr_XMLCh wide(m_issuerName.c_str());
+                in->setName(wide.get());
+                is->setX509IssuerName(in);
+                X509SerialNumber* ser = X509SerialNumberBuilder::buildX509SerialNumber();
+                auto_ptr_XMLCh wide2(m_serial.c_str());
+                ser->setSerialNumber(wide2.get());
+                is->setX509SerialNumber(ser);
+                x509Data->getX509IssuerSerials().push_back(is);
+            }
         }
-*/
     }
-    
-    if (!m_xseccerts.empty()) {
+
+    if (types & KEYINFO_X509_CERTIFICATE && !m_xseccerts.empty()) {
         m_keyInfo = m_compactKeyInfo ? m_compactKeyInfo->cloneKeyInfo() : KeyInfoBuilder::buildKeyInfo();
         if (m_keyInfo->getX509Datas().empty())
             m_keyInfo->getX509Datas().push_back(X509DataBuilder::buildX509Data());
@@ -142,7 +147,7 @@ void BasicX509Credential::extract()
         }
         BN_free(serialBN);
     }
-    
+
     X509_NAME* subject=X509_get_subject_name(cert);
     if (subject) {
         memset(buf,0,sizeof(buf));
@@ -196,7 +201,7 @@ const char* BasicX509Credential::getAlgorithm() const
             case XSECCryptoKey::KEY_DSA_PUBLIC:
             case XSECCryptoKey::KEY_DSA_PAIR:
                 return "DSA";
-            
+
             case XSECCryptoKey::KEY_HMAC:
                 return "HMAC";
 
index a4bef3c..b36eef0 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -16,7 +16,7 @@
 
 /**
  * FilesystemCredentialResolver.cpp
- * 
+ *
  * Supplies credentials from local files
  */
 
@@ -55,7 +55,7 @@ static int passwd_callback(char* buf, int len, int verify, void* passwd)
             strcpy(buf,reinterpret_cast<char*>(passwd));
             return strlen(buf);
         }
-    }  
+    }
     return 0;
 }
 
@@ -74,7 +74,6 @@ namespace xmltooling {
             FilesystemCredentialResolver* resolver, XSECCryptoKey* key, const std::vector<XSECCryptoX509*>& xseccerts, XSECCryptoX509CRL* crl=NULL
             ) : BasicX509Credential(key, xseccerts, crl), m_resolver(resolver), m_usage(UNSPECIFIED_CREDENTIAL) {
             extract();
-            initKeyInfo();
         }
         virtual ~FilesystemCredential() {
         }
@@ -97,8 +96,12 @@ namespace xmltooling {
 
         void addKeyNames(const DOMElement* e);
 
+        void initKeyInfo(unsigned int types=0) {
+            BasicX509Credential::initKeyInfo(types);
+        }
+
         void attach(SSL_CTX* ctx) const;
-    
+
     private:
         FilesystemCredentialResolver* m_resolver;
         unsigned int m_usage;
@@ -119,7 +122,7 @@ namespace xmltooling {
 
         Lockable* lock() { return this; }
         void unlock() {}
-        
+
         const Credential* resolve(const CredentialCriteria* criteria=NULL) const {
             return (criteria ? (criteria->matches(*m_credential) ? m_credential : NULL) : m_credential);
         }
@@ -139,13 +142,13 @@ namespace xmltooling {
     private:
         XSECCryptoKey* loadKey();
         XSECCryptoX509CRL* loadCRL();
-        
+
         enum format_t { PEM=SSL_FILETYPE_PEM, DER=SSL_FILETYPE_ASN1, _PKCS12, UNKNOWN };
-    
+
         format_t getEncodingFormat(BIO* in) const;
         string formatToString(format_t format) const;
         format_t xmlFormatToFormat(const XMLCh* format_xml) const;
-    
+
         format_t m_keyformat,m_crlformat;
         string m_keypath,m_keypass,m_crlpath;
         vector<X509*> m_certs;
@@ -165,6 +168,7 @@ namespace xmltooling {
     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 keyInfoMask[] =      UNICODE_LITERAL_11(k,e,y,I,n,f,o,M,a,s,k);
     static const XMLCh keyName[] =          UNICODE_LITERAL_7(k,e,y,N,a,m,e);
     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);
@@ -179,6 +183,15 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
 #endif
     Category& log=Category::getInstance(XMLTOOLING_LOGCAT".CredentialResolver."FILESYSTEM_CREDENTIAL_RESOLVER);
 
+    // Default to disable X509IssuerSerial due to schema validation issues.
+    unsigned int mask =
+        Credential::KEYINFO_KEY_NAME |
+        Credential::KEYINFO_KEY_VALUE |
+        X509Credential::KEYINFO_X509_CERTIFICATE |
+        X509Credential::KEYINFO_X509_SUBJECTNAME;
+    if (e && e->hasAttributeNS(NULL,keyInfoMask))
+        mask = XMLString::parseInt(e->getAttributeNS(NULL,keyInfoMask));
+
     if (e && (e->hasAttributeNS(NULL,_certificate) || e->hasAttributeNS(NULL,_key))) {
         // Dummy up a simple file resolver config using these attributes.
         DOMElement* dummy = e->getOwnerDocument()->createElementNS(NULL,_CredentialResolver);
@@ -207,7 +220,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
         }
         e = dummy;  // reset "root" to the dummy config element
     }
-    
+
     const DOMElement* root=e;
     const XMLCh* usage = root->getAttributeNS(NULL,_use);
 
@@ -218,20 +231,20 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
     format_t fformat;
     const XMLCh* format_xml=NULL;
     BIO* in = NULL;
-    
+
     // 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 
+        // 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);
-            
+
         const XMLCh* password_xml=keynode->getAttributeNS(NULL,password);
         if (password_xml) {
             auto_ptr_char kp(password_xml);
             m_keypass=kp.get();
         }
-        
+
         e=XMLHelper::getFirstChildElement(keynode,Path);
         if (e && e->hasChildNodes()) {
             const XMLCh* s=e->getFirstChild()->getNodeValue();
@@ -279,20 +292,20 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
             }
             if (in)
                 BIO_free(in);
-            in = NULL;    
+            in = NULL;
         }
-        
+
         // 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 
+        // 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();
@@ -342,7 +355,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
                 BIO_free(in);
             in = NULL;
         }
-        
+
         // Load the key.
         crl = loadCRL();
     }
@@ -353,10 +366,11 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
         m_credential = new FilesystemCredential(this,key,xseccerts,crl);
         m_credential->addKeyNames(keynode);
         m_credential->setUsage(usage);
+        m_credential->initKeyInfo(mask);
         return;
     }
     auto_ptr_char certpass(e->getAttributeNS(NULL,password));
-    
+
     const DOMElement* ep=XMLHelper::getFirstChildElement(e,Path);
     if (!ep || !ep->hasChildNodes()) {
         log.error("Path element missing inside Certificate element or is empty");
@@ -364,7 +378,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
         delete crl;
         throw XMLSecurityException("FilesystemCredentialResolver can't access certificate file, missing or empty Path element.");
     }
-    
+
     auto_ptr_char certpath2(ep->getFirstChild()->getNodeValue());
     string certpath(certpath2.get());
     XMLToolingConfig::getConfig().getPathResolver()->resolve(certpath, PathResolver::XMLTOOLING_CFG_FILE);
@@ -380,7 +394,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
             throw XMLSecurityException("FilesystemCredentialResolver configuration contains unknown certificate encoding format ($1)",params(1,unknown.get()));
         }
     }
-    
+
     try {
         X509* x=NULL;
         PKCS12* p12=NULL;
@@ -401,7 +415,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
                     while (x=PEM_read_bio_X509(in,NULL,passwd_callback,const_cast<char*>(certpass.get())))
                         m_certs.push_back(x);
                     break;
-                                
+
                 case DER:
                     x=d2i_X509_bio(in,NULL);
                     if (x)
@@ -515,7 +529,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
                 log.error("CA certificate file (%s) can't be opened", capath.c_str());
                 throw XMLSecurityException("FilesystemCredentialResolver can't open CA certificate file ($1)",params(1,capath.c_str()));
             }
-            
+
             extra = XMLHelper::getNextSiblingElement(extra,CAPath);
         }
     }
@@ -534,6 +548,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
     m_credential = new FilesystemCredential(this, key, xseccerts, crl);
     m_credential->addKeyNames(keynode);
     m_credential->setUsage(usage);
+    m_credential->initKeyInfo(mask);
 }
 
 XSECCryptoKey* FilesystemCredentialResolver::loadKey()
@@ -553,11 +568,11 @@ XSECCryptoKey* FilesystemCredentialResolver::loadKey()
             case PEM:
                 pkey=PEM_read_bio_PrivateKey(in, NULL, passwd_callback, const_cast<char*>(m_keypass.c_str()));
                 break;
-            
+
             case DER:
                 pkey=d2i_PrivateKey_bio(in, NULL);
                 break;
-                
+
             default: {
                 PKCS12* p12 = d2i_PKCS12_bio(in, NULL);
                 if (p12) {
@@ -569,7 +584,7 @@ XSECCryptoKey* FilesystemCredentialResolver::loadKey()
     }
     if (in)
         BIO_free(in);
-    
+
     // Now map it to an XSEC wrapper.
     if (pkey) {
         XSECCryptoKey* ret=NULL;
@@ -577,11 +592,11 @@ XSECCryptoKey* FilesystemCredentialResolver::loadKey()
             case EVP_PKEY_RSA:
                 ret=new OpenSSLCryptoKeyRSA(pkey);
                 break;
-                
+
             case EVP_PKEY_DSA:
                 ret=new OpenSSLCryptoKeyDSA(pkey);
                 break;
-            
+
             default:
                 Category::getInstance(XMLTOOLING_LOGCAT".CredentialResolver."FILESYSTEM_CREDENTIAL_RESOLVER).error("unsupported private key type");
         }
@@ -591,7 +606,7 @@ XSECCryptoKey* FilesystemCredentialResolver::loadKey()
     }
 
     log_openssl();
-    throw XMLSecurityException("FilesystemCredentialResolver unable to load private key from file."); 
+    throw XMLSecurityException("FilesystemCredentialResolver unable to load private key from file.");
 }
 
 XSECCryptoX509CRL* FilesystemCredentialResolver::loadCRL()
@@ -610,7 +625,7 @@ XSECCryptoX509CRL* FilesystemCredentialResolver::loadCRL()
             case PEM:
                 crl=PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
                 break;
-            
+
             case DER:
                 crl=d2i_X509_CRL_bio(in, NULL);
                 break;
@@ -618,7 +633,7 @@ XSECCryptoX509CRL* FilesystemCredentialResolver::loadCRL()
     }
     if (in)
         BIO_free(in);
-    
+
     // Now map it to an XSEC wrapper.
     if (crl) {
         XSECCryptoX509CRL* ret=new OpenSSLCryptoX509CRL(crl);
@@ -627,7 +642,7 @@ XSECCryptoX509CRL* FilesystemCredentialResolver::loadCRL()
     }
 
     log_openssl();
-    throw XMLSecurityException("FilesystemCredentialResolver unable to load CRL from file."); 
+    throw XMLSecurityException("FilesystemCredentialResolver unable to load CRL from file.");
 }
 
 // Used to determine the encoding format of credentials files
@@ -643,11 +658,11 @@ FilesystemCredentialResolver::format_t FilesystemCredentialResolver::getEncoding
     int mark;
 
     try {
-        if ( (mark = BIO_tell(in)) < 0 ) 
+        if ( (mark = BIO_tell(in)) < 0 )
             throw XMLSecurityException("getEncodingFormat: BIO_tell() can't get the file position");
-        if ( BIO_read(in, buf, READSIZE) <= 0 ) 
+        if ( BIO_read(in, buf, READSIZE) <= 0 )
             throw XMLSecurityException("getEncodingFormat: BIO_read() can't read from the stream");
-        if ( BIO_seek(in, mark) < 0 ) 
+        if ( BIO_seek(in, mark) < 0 )
             throw XMLSecurityException("getEncodingFormat: BIO_seek() can't reset the file position");
     }
     catch (...) {
@@ -674,7 +689,7 @@ FilesystemCredentialResolver::format_t FilesystemCredentialResolver::getEncoding
             format = _PKCS12;
         }
         if (p12)
-            PKCS12_free(p12);    
+            PKCS12_free(p12);
         if ( BIO_seek(in, mark) < 0 ) {
             log_openssl();
             throw XMLSecurityException("getEncodingFormat: BIO_seek() can't reset the file position");
@@ -737,11 +752,11 @@ void FilesystemCredentialResolver::attach(SSL_CTX* ctx) const
         case PEM:
             ret=SSL_CTX_use_PrivateKey_file(ctx, m_keypath.c_str(), m_keyformat);
             break;
-            
+
         case DER:
             ret=SSL_CTX_use_RSAPrivateKey_file(ctx, m_keypath.c_str(), m_keyformat);
             break;
-            
+
         default: {
             BIO* in=BIO_new(BIO_s_file_internal());
             if (in && BIO_read_filename(in,m_keypath.c_str())>0) {
@@ -760,7 +775,7 @@ void FilesystemCredentialResolver::attach(SSL_CTX* ctx) const
                 BIO_free(in);
         }
     }
-    
+
     if (ret!=1) {
         log_openssl();
         throw XMLSecurityException("Unable to attach private key to SSL context.");
index 55ec9e0..ec6ed9c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -16,7 +16,7 @@
 
 /**
  * @file xmltooling/soap/SOAPTransport.h
- * 
+ *
  * Encapsulates a transport layer protocol for sending/receiving messages.
  */
 
 #include <iostream>
 
 namespace xmltooling {
-    
+
     class XMLTOOL_API Credential;
     class XMLTOOL_API CredentialCriteria;
     class XMLTOOL_API CredentialResolver;
     class XMLTOOL_API X509TrustEngine;
-    
+
     /**
      * Encapsulates a transport layer protocol for sending/receiving messages.
-     * 
+     *
      * Most of the methods are const, meaning they don't affect the transport
      * layer until the data is sent.
      */
@@ -73,27 +73,27 @@ namespace xmltooling {
 
         /**
          * Indicates whether transport provides confidentiality.
-         * 
+         *
          * @return  true iff transport layer provides confidentiality
          */
         virtual bool isConfidential() const=0;
-        
+
         /**
          * Sets the connection timeout.
-         * 
+         *
          * @param timeout  time to wait for connection to server in seconds, or -1 for no timeout
          * @return  true iff the transport supports connection timeouts
          */
         virtual bool setConnectTimeout(long timeout)=0;
-        
+
         /**
          * Sets the request timeout.
-         * 
+         *
          * @param timeout  time to wait for a response in seconds, or -1 for no timeout
          * @return  true iff the transport supports request/response timeouts
          */
         virtual bool setTimeout(long timeout)=0;
-        
+
         /**
          * Common types of transport authentication that may be supported.
          */
@@ -104,10 +104,10 @@ namespace xmltooling {
             transport_auth_ntlm = 3,
             transport_auth_gss = 4
         };
-        
+
         /**
          * Sets a particular form of transport authentication and credentials.
-         * 
+         *
          * @param authType  type of transport authentication to use
          * @param username  username for transport authentication
          * @param password  simple password/credential for transport authentication
@@ -119,18 +119,18 @@ namespace xmltooling {
          * Determines whether TLS/SSL connections include a check of the server's certificate
          * against the expected hostname or address. Defaults to true, and has no effect for
          * insecure protocols.
-         * 
+         *
          * @param verify    true iff the hostname should be verified against the server's certificate
          * @return  true iff the transport supports hostname verification
          */
         virtual bool setVerifyHost(bool verify)=0;
-        
+
 #ifndef XMLTOOLING_NO_XMLSEC
         /**
          * Supplies transport credentials.
          *
          * <p>The lifetime of the credential must be longer than the lifetime of this object.
-         * 
+         *
          * @param credential  a Credential instance, or NULL
          * @return true iff the transport supports the use of the Credential
          */
@@ -139,7 +139,7 @@ namespace xmltooling {
         /**
          * Provides an X509TrustEngine to the transport to authenticate the transport peer.
          * The lifetime of the engine must be longer than the lifetime of this object.
-         * 
+         *
          * @param trustEngine   an X509TrustEngine instance, or NULL
          * @param credResolver  a CredentialResolver to supply the peer's trusted credentials, or NULL
          * @param criteria      optional criteria for selecting peer credentials
@@ -157,10 +157,10 @@ namespace xmltooling {
 
         /**
          * Sets an implementation-specific transport provider option.
-         * 
+         *
          * <p>Requires knowledge of the underlying SOAPTransport implementation.
          * Without the proper knowledge and inputs, crashes may result.
-         * 
+         *
          * @param provider  name of the SOAPTransport class the caller believes is in use
          * @param option    implementation-specific string containing the option to set
          * @param value     implementation- and option-specific string to use
@@ -169,33 +169,36 @@ namespace xmltooling {
         virtual bool setProviderOption(const char* provider, const char* option, const char* value) {
             return false;
         }
-        
+
         /**
          * Sends a stream of data over the transport. The function may return without
          * having received any data, depending on the nature of the transport.
-         * 
+         *
+         * <p>If the stream is empty, a request may be issued with no body if the transport
+         * supports that feature.
+         *
          * @param in    input stream to send
-         */        
+         */
         virtual void send(std::istream& in)=0;
-        
+
         /**
          * Returns reference to response stream.  The resulting stream must be
          * checked directly to determine whether data is available.
-         * 
+         *
          * @return  reference to a stream containing the response, if any
          */
         virtual std::istream& receive()=0;
-        
+
         /**
          * Returns result of authenticating transport peer.
-         * 
+         *
          * @return true iff TrustEngine or other mechanism successfully authenticated the peer
          */
         virtual bool isAuthenticated() const=0;
 
         /**
          * Returns the MIME type of the response, if any.
-         * 
+         *
          * @return  MIME type of response, or an empty string
          */
         virtual std::string getContentType() const=0;
@@ -206,14 +209,14 @@ namespace xmltooling {
      * Registers SOAPTransport classes into the runtime.
      */
     void XMLTOOL_API registerSOAPTransports();
-    
+
     /**
-     * Notifies transport infrastructure to initialize. 
+     * Notifies transport infrastructure to initialize.
      */
     void XMLTOOL_API initSOAPTransports();
-    
+
     /**
-     * Notifies transport infrastructure to shutdown. 
+     * Notifies transport infrastructure to shutdown.
      */
     void XMLTOOL_API termSOAPTransports();
 #endif
index 811bde5..0aca880 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -16,7 +16,7 @@
 
 /**
  * CURLSOAPTransport.cpp
- * 
+ *
  * libcurl-based SOAPTransport implementation
  */
 
@@ -48,11 +48,11 @@ namespace xmltooling {
         CURLPool() : m_size(0), m_lock(Mutex::create()),
             m_log(Category::getInstance(XMLTOOLING_LOGCAT".SOAPTransport.CURL")) {}
         ~CURLPool();
-        
+
         CURL* get(const SOAPTransport::Address& addr);
         void put(const char* from, const char* to, const char* endpoint, CURL* handle);
-    
-    private:    
+
+    private:
         typedef map<string,vector<CURL*> > poolmap_t;
         poolmap_t m_bindingMap;
         list< vector<CURL*>* > m_pools;
@@ -60,9 +60,9 @@ namespace xmltooling {
         Mutex* m_lock;
         Category& m_log;
     };
-    
+
     static XMLTOOL_DLLLOCAL CURLPool* g_CURLPool = NULL;
-    
+
     class XMLTOOL_DLLLOCAL CURLSOAPTransport : public HTTPSOAPTransport, public OpenSSLSOAPTransport
     {
     public:
@@ -83,7 +83,7 @@ namespace xmltooling {
             curl_easy_setopt(m_handle,CURLOPT_HEADERDATA,this);
             m_headers=curl_slist_append(m_headers,"Content-Type: text/xml");
         }
-        
+
         virtual ~CURLSOAPTransport() {
             curl_slist_free_all(m_headers);
             curl_easy_setopt(m_handle,CURLOPT_ERRORBUFFER,NULL);
@@ -98,17 +98,17 @@ namespace xmltooling {
         bool setConnectTimeout(long timeout) {
             return (curl_easy_setopt(m_handle,CURLOPT_CONNECTTIMEOUT,timeout)==CURLE_OK);
         }
-        
+
         bool setTimeout(long timeout) {
             return (curl_easy_setopt(m_handle,CURLOPT_TIMEOUT,timeout)==CURLE_OK);
         }
-        
+
         bool setAuth(transport_auth_t authType, const char* username=NULL, const char* password=NULL);
-        
+
         bool setVerifyHost(bool verify) {
             return (curl_easy_setopt(m_handle,CURLOPT_SSL_VERIFYHOST,verify ? 2 : 0)==CURLE_OK);
         }
-        
+
 #ifndef XMLTOOLING_NO_XMLSEC
         bool setCredential(const Credential* cred=NULL) {
             const OpenSSLCredential* down = dynamic_cast<const OpenSSLCredential*>(cred);
@@ -119,7 +119,7 @@ namespace xmltooling {
             m_cred = down;
             return true;
         }
-        
+
         bool setTrustEngine(
             const X509TrustEngine* trustEngine=NULL,
             const CredentialResolver* peerResolver=NULL,
@@ -139,9 +139,9 @@ namespace xmltooling {
             m_mandatory = mandatory;
             return true;
         }
-        
+
 #endif
-        
+
         bool useChunkedEncoding(bool chunked=true) {
             m_chunked = chunked;
             return true;
@@ -165,13 +165,13 @@ namespace xmltooling {
                 return (curl_easy_setopt(m_handle, opt, value) == CURLE_OK);
 #endif
         }
-        
+
         void send(istream& in);
-        
+
         istream& receive() {
             return m_stream;
         }
-        
+
         bool isAuthenticated() const {
             return m_authenticated;
         }
@@ -181,23 +181,23 @@ namespace xmltooling {
         }
 
         string getContentType() const;
-        
+
         bool setRequestHeader(const char* name, const char* val) {
             string temp(name);
             temp=temp + ": " + val;
             m_headers=curl_slist_append(m_headers,temp.c_str());
             return true;
         }
-        
+
         const vector<string>& getResponseHeader(const char* val) const;
-        
+
         bool setSSLCallback(ssl_ctx_callback_fn fn, void* userptr=NULL) {
             m_ssl_callback=fn;
             m_ssl_userptr=userptr;
             return true;
         }
 
-    private:        
+    private:
         // per-call state
         string m_sender,m_peerName,m_endpoint,m_simplecreds;
         CURL* m_handle;
@@ -215,7 +215,7 @@ namespace xmltooling {
         void* m_ssl_userptr;
         bool m_chunked;
         bool m_authenticated;
-        
+
         friend size_t XMLTOOL_DLLLOCAL curl_header_hook(void* ptr, size_t size, size_t nmemb, void* stream);
         friend CURLcode XMLTOOL_DLLLOCAL xml_ssl_ctx_callback(CURL* curl, SSL_CTX* ssl_ctx, void* userptr);
         friend int XMLTOOL_DLLLOCAL verify_callback(X509_STORE_CTX* x509_ctx, void* arg);
@@ -277,12 +277,12 @@ CURL* CURLPool::get(const SOAPTransport::Address& addr)
         key = key + '|' + addr.m_to;
     m_lock->lock();
     poolmap_t::iterator i=m_bindingMap.find(key);
-    
+
     if (i!=m_bindingMap.end()) {
         // Move this pool to the front of the list.
         m_pools.remove(&(i->second));
         m_pools.push_front(&(i->second));
-        
+
         // If a free connection exists, return it.
         if (!(i->second.empty())) {
             CURL* handle=i->second.back();
@@ -293,10 +293,10 @@ CURL* CURLPool::get(const SOAPTransport::Address& addr)
             return handle;
         }
     }
-    
+
     m_lock->unlock();
     m_log.debug("nothing free in pool, returning new connection handle");
-    
+
     // Create a new connection and set non-varying options.
     CURL* handle=curl_easy_init();
     if (!handle)
@@ -328,7 +328,7 @@ void CURLPool::put(const char* from, const char* to, const char* endpoint, CURL*
         m_pools.push_front(&(m_bindingMap.insert(poolmap_t::value_type(key,vector<CURL*>(1,handle))).first->second));
     else
         i->second.push_back(handle);
-    
+
     CURL* killit=NULL;
     if (++m_size > 256) {
         // Kick a handle out from the back of the bus.
@@ -340,7 +340,7 @@ void CURLPool::put(const char* from, const char* to, const char* endpoint, CURL*
                 m_size--;
                 break;
             }
-            
+
             // Move an empty pool up to the front so we don't keep hitting it.
             m_pools.pop_back();
             m_pools.push_front(corpse);
@@ -384,7 +384,7 @@ const vector<string>& CURLSOAPTransport::getResponseHeader(const char* name) con
     map<string,vector<string> >::const_iterator i=m_response_headers.find(name);
     if (i!=m_response_headers.end())
         return i->second;
-    
+
     for (map<string,vector<string> >::const_iterator j=m_response_headers.begin(); j!=m_response_headers.end(); j++) {
 #ifdef HAVE_STRCASECMP
         if (!strcasecmp(j->first.c_str(), name))
@@ -393,7 +393,7 @@ const vector<string>& CURLSOAPTransport::getResponseHeader(const char* name) con
 #endif
             return j->second;
     }
-    
+
     return emptyVector;
 }
 
@@ -412,6 +412,10 @@ void CURLSOAPTransport::send(istream& in)
     Category& log=Category::getInstance(XMLTOOLING_LOGCAT".SOAPTransport.CURL");
     Category& log_curl=Category::getInstance(XMLTOOLING_LOGCAT".libcurl");
 
+    // For this implementation, it's sufficient to check for https as a sign of transport security.
+    if (m_mandatory && !isConfidential())
+        throw IOException("Blocking unprotected HTTP request, transport authentication by server required.");
+
     string msg;
 
     // By this time, the handle has been prepared with the URL to use and the
@@ -420,22 +424,26 @@ void CURLSOAPTransport::send(istream& in)
     // Setup standard per-call curl properties.
     curl_easy_setopt(m_handle,CURLOPT_DEBUGDATA,&log_curl);
     curl_easy_setopt(m_handle,CURLOPT_FILE,&m_stream);
-    curl_easy_setopt(m_handle,CURLOPT_POST,1);
-    if (m_chunked) {
+    if (m_chunked && in) {
+        curl_easy_setopt(m_handle,CURLOPT_POST,1);
         m_headers=curl_slist_append(m_headers,"Transfer-Encoding: chunked");
         curl_easy_setopt(m_handle,CURLOPT_READFUNCTION,&curl_read_hook);
         curl_easy_setopt(m_handle,CURLOPT_READDATA,&in);
     }
-    else {
+    else if (in) {
         char buf[1024];
         while (in) {
             in.read(buf,1024);
             msg.append(buf,in.gcount());
         }
+        curl_easy_setopt(m_handle,CURLOPT_POST,1);
         curl_easy_setopt(m_handle,CURLOPT_READFUNCTION,NULL);
         curl_easy_setopt(m_handle,CURLOPT_POSTFIELDS,msg.c_str());
         curl_easy_setopt(m_handle,CURLOPT_POSTFIELDSIZE,msg.length());
     }
+    else {
+        curl_easy_setopt(m_handle,CURLOPT_HTTPGET,1);
+    }
 
     char curl_errorbuf[CURL_ERROR_SIZE];
     curl_errorbuf[0]=0;
@@ -465,7 +473,7 @@ void CURLSOAPTransport::send(istream& in)
         curl_easy_setopt(m_handle,CURLOPT_SSL_CTX_FUNCTION,NULL);
         curl_easy_setopt(m_handle,CURLOPT_SSL_CTX_DATA,NULL);
     }
-    
+
     // Make the call.
     log.debug("sending SOAP message to %s", m_endpoint.c_str());
     if (curl_easy_perform(m_handle) != CURLE_OK) {
@@ -562,14 +570,14 @@ int xmltooling::verify_callback(X509_STORE_CTX* x509_ctx, void* arg)
         cc.setUsage(Credential::TLS_CREDENTIAL);
         success = ctx->m_trustEngine->validate(x509_ctx->cert,x509_ctx->untrusted,*(ctx->m_peerResolver),&cc);
     }
-    
+
     if (!success) {
         log.error("supplied TrustEngine failed to validate SSL/TLS server certificate");
         x509_ctx->error=X509_V_ERR_APPLICATION_VERIFICATION;     // generic error, check log for plugin specifics
         ctx->setAuthenticated(false);
         return ctx->m_mandatory ? 0 : 1;
     }
-    
+
     // Signal success. Hopefully it doesn't matter what's actually in the structure now.
     ctx->setAuthenticated(true);
     return 1;
@@ -599,9 +607,9 @@ CURLcode xmltooling::xml_ssl_ctx_callback(CURL* curl, SSL_CTX* ssl_ctx, void* us
 #endif
     }
 #endif
-        
+
     if (conf->m_ssl_callback && !conf->m_ssl_callback(conf, ssl_ctx, conf->m_ssl_userptr))
         return CURLE_SSL_CERTPROBLEM;
-        
+
     return CURLE_OK;
 }
index ccf66a4..532d318 100644 (file)
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
 
 #include "internal.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-//#include <sys/types.h>
-//#include <sys/time.h>
+#include <curl/curl.h>
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/util/XMLNetAccessor.hpp>
@@ -47,218 +39,98 @@ using namespace xmltooling;
 
 
 CurlURLInputStream::CurlURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
-      : fMulti(0)
-      , fEasy(0)
-      , fMemoryManager(urlSource.getMemoryManager())
+      : fMemoryManager(urlSource.getMemoryManager())
       , fURLSource(urlSource)
       , fURL(0)
-      , fTotalBytesRead(0)
-      , fWritePtr(0)
-      , fBytesRead(0)
-      , fBytesToRead(0)
-      , fDataAvailable(false)
-      , fBufferHeadPtr(fBuffer)
-      , fBufferTailPtr(fBuffer)
+      , fInputStream(NULL)
       , m_log(logging::Category::getInstance(XMLTOOLING_LOGCAT".libcurl.NetAccessor"))
 {
-       // Allocate the curl multi handle
-       fMulti = curl_multi_init();
-       
-       // Allocate the curl easy handle
-       fEasy = curl_easy_init();
-       
        // Get the text of the URL we're going to use
        fURL.reset(XMLString::transcode(fURLSource.getURLText(), fMemoryManager), fMemoryManager);
-
-       m_log.debug("libcurl trying to fetch %s", fURL.get());
-
-       // Set URL option
-       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, 30);
-    curl_easy_setopt(fEasy, CURLOPT_TIMEOUT, 60);
-    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);
 }
 
 
 CurlURLInputStream::~CurlURLInputStream()
 {
-       // Remove the easy handle from the multi stack
-       curl_multi_remove_handle(fMulti, fEasy);
-       
-       // Cleanup the easy handle
-       curl_easy_cleanup(fEasy);
-       
-       // Cleanup the multi handle
-       curl_multi_cleanup(fMulti);
+    delete fInputStream;
 }
 
 
-size_t
-CurlURLInputStream::staticWriteCallback(char *buffer,
-                                      size_t size,
-                                      size_t nitems,
-                                      void *outstream)
+size_t CurlURLInputStream::staticWriteCallback(void* ptr, size_t size, size_t nmemb, void* stream)
 {
-       return ((CurlURLInputStream*)outstream)->writeCallback(buffer, size, nitems);
+    size_t len = size*nmemb;
+    reinterpret_cast<std::stringstream*>(stream)->write(reinterpret_cast<const char*>(ptr),len);
+    return len;
 }
 
 
-
-size_t
-CurlURLInputStream::writeCallback(char *buffer,
-                                      size_t size,
-                                      size_t nitems)
+unsigned int CurlURLInputStream::readBytes(XMLByte* const toFill, const unsigned int maxToRead)
 {
-       size_t cnt = size * nitems;
-       size_t totalConsumed = 0;
-               
-       // Consume as many bytes as possible immediately into the buffer
-       size_t consume = (cnt > fBytesToRead) ? fBytesToRead : cnt;
-       memcpy(fWritePtr, buffer, consume);
-       fWritePtr               += consume;
-       fBytesRead              += consume;
-       fTotalBytesRead += consume;
-       fBytesToRead    -= consume;
-
-       //m_log.debug("write callback consuming %d bytes", consume);
+    if (!fInputStream) {
+        // Allocate the curl easy handle.
+        CURL* fEasy = curl_easy_init();
+        if (!fEasy)
+            ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_InternalError, "unable to allocate libcurl handle", fMemoryManager);
+
+        m_log.debug("libcurl trying to fetch %s", fURL.get());
+
+        // Set URL option
+        curl_easy_setopt(fEasy, CURLOPT_URL, fURL.get());
+        curl_easy_setopt(fEasy, CURLOPT_WRITEDATA, &fUnderlyingStream);
+        curl_easy_setopt(fEasy, CURLOPT_WRITEFUNCTION, staticWriteCallback);
+        curl_easy_setopt(fEasy, CURLOPT_CONNECTTIMEOUT, 30);
+        curl_easy_setopt(fEasy, CURLOPT_TIMEOUT, 60);
+        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);
+
+        char curl_errorbuf[CURL_ERROR_SIZE];
+        curl_errorbuf[0]=0;
+        curl_easy_setopt(fEasy,CURLOPT_ERRORBUFFER,curl_errorbuf);
+
+        // Fetch the data.
+        if (curl_easy_perform(fEasy) != CURLE_OK) {
+            curl_easy_cleanup(fEasy);
+            ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_InternalError, curl_errorbuf, fMemoryManager);
+        }
 
-       // If bytes remain, rebuffer as many as possible into our holding buffer
-       buffer                  += consume;
-       totalConsumed   += consume;
-       cnt                             -= consume;
-       if (cnt > 0)
-       {
-               size_t bufAvail = sizeof(fBuffer) - (fBufferHeadPtr - fBuffer);
-               consume = (cnt > bufAvail) ? bufAvail : cnt;
-               memcpy(fBufferHeadPtr, buffer, consume);
-               fBufferHeadPtr  += consume;
-               buffer                  += consume;
-               totalConsumed   += consume;
-               //m_log.debug("write callback rebuffering %d bytes", consume);
-       }
-       
-       // Return the total amount we've consumed. If we don't consume all the bytes
-       // then an error will be generated. Since our buffer size is equal to the
-       // maximum size that curl will write, this should never happen unless there
-       // is a logic error somewhere here.
-       return totalConsumed;
-}
+        curl_easy_cleanup(fEasy);
 
+        /*
+        switch (msg->data.result)
+        {
+        case CURLE_OK:
+            // We completed successfully. runningHandles should have dropped to zero, so we'll bail out below...
+            break;
 
-unsigned int
-CurlURLInputStream::readBytes(XMLByte* const          toFill
-                                     , const unsigned int maxToRead)
-{
-       fBytesRead = 0;
-       fBytesToRead = maxToRead;
-       fWritePtr = toFill;
-       
-       for (bool tryAgain = true; fBytesToRead > 0 && (tryAgain || fBytesRead == 0); )
-       {
-               // First, any buffered data we have available
-               size_t bufCnt = fBufferHeadPtr - fBufferTailPtr;
-               bufCnt = (bufCnt > fBytesToRead) ? fBytesToRead : bufCnt;
-               if (bufCnt > 0)
-               {
-                       memcpy(fWritePtr, fBufferTailPtr, bufCnt);
-                       fWritePtr               += bufCnt;
-                       fBytesRead              += bufCnt;
-                       fTotalBytesRead += bufCnt;
-                       fBytesToRead    -= bufCnt;
-                       
-                       fBufferTailPtr  += bufCnt;
-                       if (fBufferTailPtr == fBufferHeadPtr)
-                               fBufferHeadPtr = fBufferTailPtr = fBuffer;
-                               
-                       //m_log.debug("consuming %d buffered bytes", bufCnt);
+        case CURLE_UNSUPPORTED_PROTOCOL:
+            ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_UnsupportedProto, fMemoryManager);
+            break;
 
-                       tryAgain = true;
-                       continue;
-               }
-       
-               // Ask the curl to do some work
-               int runningHandles = 0;
-               CURLMcode curlResult = curl_multi_perform(fMulti, &runningHandles);
-        //m_log.debug("curl_multi_perform returned %d", curlResult);
-               tryAgain = (curlResult == CURLM_CALL_MULTI_PERFORM);
-               
-               // Process messages from curl
-               int msgsInQueue = 0;
-               for (CURLMsg* msg = NULL; (msg = curl_multi_info_read(fMulti, &msgsInQueue)) != NULL; )
-               {
-                       m_log.debug("msg %d, %d from curl", msg->msg, msg->data.result);
+        case CURLE_COULDNT_RESOLVE_HOST:
+        case CURLE_COULDNT_RESOLVE_PROXY:
+            ThrowXMLwithMemMgr1(NetAccessorException,  XMLExcepts::NetAcc_TargetResolution, fURLSource.getHost(), fMemoryManager);
+            break;
 
-                       if (msg->msg != CURLMSG_DONE)
-                               continue;
-                               
-                       switch (msg->data.result)
-                       {
-                       case CURLE_OK:
-                               // We completed successfully. runningHandles should have dropped to zero, so we'll bail out below...
-                               break;
-                               
-                       case CURLE_UNSUPPORTED_PROTOCOL:
-                ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_UnsupportedProto, fMemoryManager);
-                break;
+        case CURLE_COULDNT_CONNECT:
+            ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ConnSocket, fURLSource.getURLText(), fMemoryManager);
 
-            case CURLE_COULDNT_RESOLVE_HOST:
-            case CURLE_COULDNT_RESOLVE_PROXY:
-                ThrowXMLwithMemMgr1(NetAccessorException,  XMLExcepts::NetAcc_TargetResolution, fURLSource.getHost(), fMemoryManager);
-                break;
-                
-            case CURLE_COULDNT_CONNECT:
-                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ConnSocket, fURLSource.getURLText(), fMemoryManager);
-               
-            case CURLE_RECV_ERROR:
-                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, fURLSource.getURLText(), fMemoryManager);
-                break;
+        case CURLE_RECV_ERROR:
+            ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, fURLSource.getURLText(), fMemoryManager);
+            break;
 
-            default:
-                m_log.error("curl NetAccessor encountered error from libcurl (%d)", msg->data.result);
-                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_InternalError, fURLSource.getURLText(), fMemoryManager);
-                               break;
-                       }
-               }
-               
-               // If nothing is running any longer, bail out
-        if (runningHandles == 0) {
-            //m_log.debug("libcurl indicated no running handles");
-                       break;
+        default:
+            m_log.error("curl NetAccessor encountered error from libcurl (%d)", msg->data.result);
+            ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_InternalError, fURLSource.getURLText(), fMemoryManager);
+            break;
         }
-               
-               // If there is no further data to read, and we haven't
-               // read any yet on this invocation, call select to wait for data
-               if (!tryAgain && fBytesRead == 0)
-               {
-                       fd_set readSet;
-                       fd_set writeSet;
-                       fd_set exceptSet;
-                       int fdcnt=0;
-                       
-                       // 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+1, &readSet, &writeSet, &exceptSet, &tv);
-               }
-       }
-       
-    //m_log.debug("returning with %d bytes to parser", fBytesRead);
-       return fBytesRead;
-}
+        */
 
+        fInputStream = new (fMemoryManager) StreamInputSource::StreamBinInputStream(fUnderlyingStream);
+    }
+
+    // Defer to the stream wrapper.
+    return fInputStream->readBytes(toFill, maxToRead);
+}
index 991f775..cd6106a 100644 (file)
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
 #define XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP
 
 #include <xmltooling/logging.h>
+#include <xmltooling/util/ParserPool.h>
 
-#include <curl/curl.h>
-#include <curl/multi.h>
-#include <curl/easy.h>
+#include <sstream>
 
 #include <xercesc/util/XMLURL.hpp>
 #include <xercesc/util/XMLExceptMsgs.hpp>
@@ -48,12 +47,7 @@ public :
     ~CurlURLInputStream();
 
     unsigned int curPos() const;
-    unsigned int readBytes
-    (
-                XMLByte* const  toFill
-        , const unsigned int       maxToRead
-    );
-
+    unsigned int readBytes(XMLByte* const toFill, const unsigned int maxToRead);
 
 private :
     // -----------------------------------------------------------------------
@@ -61,65 +55,24 @@ private :
     // -----------------------------------------------------------------------
     CurlURLInputStream(const CurlURLInputStream&);
     CurlURLInputStream& operator=(const CurlURLInputStream&);
-    
-    static size_t staticWriteCallback(char *buffer,
-                                      size_t size,
-                                      size_t nitems,
-                                      void *outstream);
-    size_t writeCallback(                        char *buffer,
-                                      size_t size,
-                                      size_t nitems);
 
+    static size_t staticWriteCallback(void* ptr, size_t size, size_t nmemb, void* stream);
 
-    // -----------------------------------------------------------------------
-    //  Private data members
-    //
-    //  fSocket
-    //      The socket representing the connection to the remote file.
-    //  fBytesProcessed
-    //      Its a rolling count of the number of bytes processed off this
-    //      input stream.
-    //  fBuffer
-    //      Holds the http header, plus the first part of the actual
-    //      data.  Filled at the time the stream is opened, data goes
-    //      out to user in response to readBytes().
-    //  fBufferPos, fBufferEnd
-    //      Pointers into fBuffer, showing start and end+1 of content
-    //      that readBytes must return.
-    // -----------------------------------------------------------------------
-       
-    CURLM*                             fMulti;
-    CURL*                              fEasy;
-    
+    std::stringstream   fUnderlyingStream;
     MemoryManager*      fMemoryManager;
-    
     XMLURL                             fURLSource;
     ArrayJanitor<char> fURL;
-    
-    unsigned long       fTotalBytesRead;
-    XMLByte*                   fWritePtr;
-    unsigned long              fBytesRead;
-    unsigned long              fBytesToRead;
-    bool                               fDataAvailable;
-    
-    // Overflow buffer for when curl writes more data to us
-    // than we've asked for.
-    XMLByte                            fBuffer[CURL_MAX_WRITE_SIZE];
-    XMLByte*                   fBufferHeadPtr;
-    XMLByte*                   fBufferTailPtr;
-
+    StreamInputSource::StreamBinInputStream* fInputStream;
     logging::Category&  m_log;
-    
+
 }; // CurlURLInputStream
 
 
-inline unsigned int
-CurlURLInputStream::curPos() const
+inline unsigned int CurlURLInputStream::curPos() const
 {
-    return fTotalBytesRead;
+    return fInputStream ? fInputStream->curPos() : 0;
 }
 
 };
 
 #endif // CURLURLINPUTSTREAM_HPP
-
index f894d2f..f4d4975 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -16,8 +16,8 @@
 
 /**
  * PathResolver.cpp
- * 
- * Resolves local filenames into absolute pathnames. 
+ *
+ * Resolves local filenames into absolute pathnames.
  */
 
 #include "internal.h"
@@ -32,9 +32,15 @@ const string& PathResolver::resolve(string& s, file_type_t filetype, const char*
     if (!isAbsolute(s.c_str())) {
         switch (filetype) {
             case XMLTOOLING_LIB_FILE:
-                s = string(prefix ? prefix : m_defaultPrefix) + "/lib/" + (pkgname ? pkgname : m_defaultPackage) + '/' + s;
+                s = string(prefix ? prefix : m_defaultPrefix) +
+#if (SIZEOF_LONG == 8)
+                    "/lib64/"
+#else
+                    "/lib/"
+#endif
+                    + (pkgname ? pkgname : m_defaultPackage) + '/' + s;
                 break;
-                
+
             case XMLTOOLING_LOG_FILE:
                 if (prefix || m_defaultPrefix != "/usr")
                     s = string(prefix ? prefix : m_defaultPrefix) + "/var/log/" + (pkgname ? pkgname : m_defaultPackage) + '/' + s;
@@ -59,7 +65,7 @@ const string& PathResolver::resolve(string& s, file_type_t filetype, const char*
                 else
                     s = string("/etc/") + (pkgname ? pkgname : m_defaultPackage) + '/' + s;
                 break;
-            
+
             default:
                 throw XMLToolingException("Unknown file type to resolve.");
         }
index 48ad3ca..b4f6957 100644 (file)
@@ -38,8 +38,8 @@
  */
 
 #define XMLTOOLING_VERSION_MAJOR 1
-#define XMLTOOLING_VERSION_MINOR 0
-#define XMLTOOLING_VERSION_REVISION 1
+#define XMLTOOLING_VERSION_MINOR 1
+#define XMLTOOLING_VERSION_REVISION 0
 
 /** DO NOT MODIFY BELOW THIS LINE */
 
index 136e4d4..d45dc86 100644 (file)
@@ -67,7 +67,7 @@
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1D.lib xerces-c_2D.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1.lib xerces-c_2.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OptimizeReferences="2"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1D.lib xerces-c_2D.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1.lib xerces-c_2.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OptimizeReferences="2"\r
index 4c09635..d1156c5 100644 (file)
@@ -28,8 +28,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 //\r
 \r
 VS_VERSION_INFO VERSIONINFO\r
- FILEVERSION 1,0,0,0\r
- PRODUCTVERSION 2,0,0,0\r
+ FILEVERSION 1,1,0,0\r
+ PRODUCTVERSION 2,1,0,0\r
  FILEFLAGSMASK 0x3fL\r
 #ifdef _DEBUG\r
  FILEFLAGS 0x1L\r
@@ -51,38 +51,38 @@ BEGIN
 #else\r
             VALUE "FileDescription", "OpenSAML XMLTooling Library\0"\r
 #endif\r
-            VALUE "FileVersion", "1, 0, 0, 0\0"\r
+            VALUE "FileVersion", "1, 1, 0, 0\0"\r
 #ifdef XMLTOOLING_LITE\r
 #ifdef _DEBUG\r
-            VALUE "InternalName", "xmltooling-lite1_0D\0"\r
+            VALUE "InternalName", "xmltooling-lite1_1D\0"\r
 #else\r
-            VALUE "InternalName", "xmltooling-lite1_0\0"\r
+            VALUE "InternalName", "xmltooling-lite1_1\0"\r
 #endif\r
 #else\r
 #ifdef _DEBUG\r
-            VALUE "InternalName", "xmltooling1_0D\0"\r
+            VALUE "InternalName", "xmltooling1_1D\0"\r
 #else\r
-            VALUE "InternalName", "xmltooling1_0\0"\r
+            VALUE "InternalName", "xmltooling1_1\0"\r
 #endif\r
 #endif\r
-            VALUE "LegalCopyright", "Copyright © 2007 Internet2\0"\r
+            VALUE "LegalCopyright", "Copyright © 2008 Internet2\0"\r
             VALUE "LegalTrademarks", "\0"\r
 #ifdef XMLTOOLING_LITE\r
 #ifdef _DEBUG\r
-            VALUE "OriginalFilename", "xmltooling-lite1_0D.dll\0"\r
+            VALUE "OriginalFilename", "xmltooling-lite1_1D.dll\0"\r
 #else\r
-            VALUE "OriginalFilename", "xmltooling-lite1_0.dll\0"\r
+            VALUE "OriginalFilename", "xmltooling-lite1_1.dll\0"\r
 #endif\r
 #else\r
 #ifdef _DEBUG\r
-            VALUE "OriginalFilename", "xmltooling1_0D.dll\0"\r
+            VALUE "OriginalFilename", "xmltooling1_1D.dll\0"\r
 #else\r
-            VALUE "OriginalFilename", "xmltooling1_0.dll\0"\r
+            VALUE "OriginalFilename", "xmltooling1_1.dll\0"\r
 #endif\r
 #endif\r
             VALUE "PrivateBuild", "\0"\r
-            VALUE "ProductName", "OpenSAML 2.0\0"\r
-            VALUE "ProductVersion", "2, 0, 0, 0\0"\r
+            VALUE "ProductName", "OpenSAML 2.1\0"\r
+            VALUE "ProductVersion", "2, 1, 0, 0\0"\r
             VALUE "SpecialBuild", "\0"\r
         END\r
     END\r
index 311a29b..ca39462 100644 (file)
@@ -67,7 +67,7 @@
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1D.lib xerces-c_2D.lib xsec_1D.lib libeay32D.lib ssleay32D.lib libcurld_imp.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1.lib xerces-c_2.lib xsec_1.lib libeay32.lib ssleay32.lib libcurl_imp.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OptimizeReferences="2"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1D.lib xerces-c_2D.lib xsec_1D.lib libeay32D.lib ssleay32D.lib libcurld_imp.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wsock32.lib log4shib1.lib xerces-c_2.lib xsec_1.lib libeay32.lib ssleay32.lib libcurl_imp.lib"\r
-                               OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
+                               OutputFile="$(OutDir)\$(ProjectName)1_1.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OptimizeReferences="2"\r