-<?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
<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
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
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)
# 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])
pkgdocdir = $(datadir)/doc/@PACKAGE@
docfiles = \
+ README.txt \
LICENSE.txt \
NOTICE.txt \
OPENSSL.LICENSE \
--- /dev/null
+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
Name: xmltooling
Summary: Open source XMLTooling library
Version: @-VERSION-@
-Release: 6
+Release: 1
Group: System Environment/Libraries
Vendor: Internet2
License: Apache 2.0
%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
%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.
/*
* 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
/**
* AbstractXMLObject.cpp
- *
+ *
* An abstract implementation of XMLObject.
*/
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) {
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;
}
/*
* 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
/**
* @file xmltooling/AbstractXMLObject.h
- *
+ *
* An abstract implementation of XMLObject.
*/
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();
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())
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();
bool hasParent() const {
return m_parent != NULL;
}
-
+
XMLObject* getParent() const {
return m_parent;
}
-
+
void setParent(XMLObject* parent) {
m_parent = parent;
}
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
/** 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);
* 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);
* 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);
* Stores off xsi:noNamespaceSchemaLocation attribute.
*/
XMLCh* m_noNamespaceSchemaLocation;
-
+
/**
* Stores off xsi:nil attribute.
*/
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}
config_pub_win32.h\
resource.h\
xmltooling.rc \
- util\Win32Threads.cpp
+ util/Win32Threads.cpp
/*\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
\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
* 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
{\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
{\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
{\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
/**
* 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();
/*
* 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
/**
* @file xmltooling/security/Credential.h
- *
- * Wraps keys and related functionality.
+ *
+ * Wraps keys and related functionality.
*/
#if !defined(__xmltooling_cred_h__) && !defined(XMLTOOLING_NO_XMLSEC)
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,
};
/**
- * Bitmask of use cases for credentials.
+ * Bitmask of use cases for credentials.
*/
enum UsageTypes {
UNSPECIFIED_CREDENTIAL = 0,
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;
/**
* 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
*/
/**
* 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 {
};
/**
+ * 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.
*
/*
* 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
/**
* 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"
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());
}
BN_free(serialBN);
}
-
+
X509_NAME* subject=X509_get_subject_name(cert);
if (subject) {
memset(buf,0,sizeof(buf));
case XSECCryptoKey::KEY_DSA_PUBLIC:
case XSECCryptoKey::KEY_DSA_PAIR:
return "DSA";
-
+
case XSECCryptoKey::KEY_HMAC:
return "HMAC";
/*
* 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
/**
* FilesystemCredentialResolver.cpp
- *
+ *
* Supplies credentials from local files
*/
strcpy(buf,reinterpret_cast<char*>(passwd));
return strlen(buf);
}
- }
+ }
return 0;
}
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() {
}
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;
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);
}
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;
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);
#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);
}
e = dummy; // reset "root" to the dummy config element
}
-
+
const DOMElement* root=e;
const XMLCh* usage = root->getAttributeNS(NULL,_use);
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();
}
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();
BIO_free(in);
in = NULL;
}
-
+
// Load the key.
crl = loadCRL();
}
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");
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);
throw XMLSecurityException("FilesystemCredentialResolver configuration contains unknown certificate encoding format ($1)",params(1,unknown.get()));
}
}
-
+
try {
X509* x=NULL;
PKCS12* p12=NULL;
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)
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);
}
}
m_credential = new FilesystemCredential(this, key, xseccerts, crl);
m_credential->addKeyNames(keynode);
m_credential->setUsage(usage);
+ m_credential->initKeyInfo(mask);
}
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) {
}
if (in)
BIO_free(in);
-
+
// Now map it to an XSEC wrapper.
if (pkey) {
XSECCryptoKey* ret=NULL;
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");
}
}
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()
case PEM:
crl=PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
break;
-
+
case DER:
crl=d2i_X509_CRL_bio(in, NULL);
break;
}
if (in)
BIO_free(in);
-
+
// Now map it to an XSEC wrapper.
if (crl) {
XSECCryptoX509CRL* ret=new OpenSSLCryptoX509CRL(crl);
}
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
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 (...) {
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");
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) {
BIO_free(in);
}
}
-
+
if (ret!=1) {
log_openssl();
throw XMLSecurityException("Unable to attach private key to SSL context.");
/*
* 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
/**
* @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.
*/
/**
* 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.
*/
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
* 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
*/
/**
* 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
/**
* 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
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;
* 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
/*
* 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
/**
* CURLSOAPTransport.cpp
- *
+ *
* libcurl-based SOAPTransport implementation
*/
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;
Mutex* m_lock;
Category& m_log;
};
-
+
static XMLTOOL_DLLLOCAL CURLPool* g_CURLPool = NULL;
-
+
class XMLTOOL_DLLLOCAL CURLSOAPTransport : public HTTPSOAPTransport, public OpenSSLSOAPTransport
{
public:
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);
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);
m_cred = down;
return true;
}
-
+
bool setTrustEngine(
const X509TrustEngine* trustEngine=NULL,
const CredentialResolver* peerResolver=NULL,
m_mandatory = mandatory;
return true;
}
-
+
#endif
-
+
bool useChunkedEncoding(bool chunked=true) {
m_chunked = chunked;
return true;
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;
}
}
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;
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);
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();
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)
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.
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);
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))
#endif
return j->second;
}
-
+
return emptyVector;
}
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
// 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;
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) {
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;
#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;
}
* 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>
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);
+}
* 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>
~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 :
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
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
-
/*
* 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
/**
* PathResolver.cpp
- *
- * Resolves local filenames into absolute pathnames.
+ *
+ * Resolves local filenames into absolute pathnames.
*/
#include "internal.h"
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;
else
s = string("/etc/") + (pkgname ? pkgname : m_defaultPackage) + '/' + s;
break;
-
+
default:
throw XMLToolingException("Unknown file type to resolve.");
}
*/
#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 */
<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
//\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
#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
<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