-<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
-<?fileVersion 4.0.0?>\r
-\r
-<cproject>\r
+<?xml version="1.0" encoding="UTF-8"?><?fileVersion 4.0.0?><cproject>\r
<storageModule moduleId="org.eclipse.cdt.core.settings">\r
<cconfiguration id="converted.config.943130369">\r
<storageModule moduleId="scannerConfiguration">\r
<storageModule moduleId="org.eclipse.cdt.core.pathentry">\r
<pathentry include="C:/log4shib-1.0.2/include" kind="inc" path="" system="true"/>\r
<pathentry include="C:/xerces-c-3.0.1-x86-windows-vc-9.0/include" kind="inc" path="" system="true"/>\r
-<pathentry include="C:/xml-security-c-1.5.0/include" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/xml-security-c-1.5.1/include" kind="inc" path="" system="true"/>\r
<pathentry include="C:/openssl-0.9.8k/inc32" kind="inc" path="" system="true"/>\r
<pathentry include="C:/curl-7.19.5/include" kind="inc" path="" system="true"/>\r
<pathentry include="C:/cxxtest" kind="inc" path="" system="true"/>\r
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "AbstractAttributeExtensibleXMLObject.h"
+#include "ElementExtensibleXMLObject.h"
+#include "ElementProxy.h"
#include <algorithm>
#include <functional>
using xercesc::DOMElement;
using xercesc::XMLString;
+ElementExtensibleXMLObject::ElementExtensibleXMLObject()
+{
+}
+
+ElementExtensibleXMLObject::~ElementExtensibleXMLObject()
+{
+}
+
+ElementProxy::ElementProxy()
+{
+}
+
+ElementProxy::~ElementProxy()
+{
+}
+
set<QName> AttributeExtensibleXMLObject::m_idAttributeSet;
-AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject()
+AttributeExtensibleXMLObject::AttributeExtensibleXMLObject()
{
- for (map<QName,XMLCh*>::iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++)
- XMLString::release(&(i->second));
+}
+
+AttributeExtensibleXMLObject::~AttributeExtensibleXMLObject()
+{
+}
+
+const set<QName>& AttributeExtensibleXMLObject::getRegisteredIDAttributes()
+{
+ return m_idAttributeSet;
+}
+
+bool AttributeExtensibleXMLObject::isRegisteredIDAttribute(const QName& name)
+{
+ return m_idAttributeSet.find(name)!=m_idAttributeSet.end();
+}
+
+void AttributeExtensibleXMLObject::registerIDAttribute(const QName& name)
+{
+ m_idAttributeSet.insert(name);
+}
+
+void AttributeExtensibleXMLObject::deregisterIDAttribute(const QName& name)
+{
+ m_idAttributeSet.erase(name);
+}
+
+void AttributeExtensibleXMLObject::deregisterIDAttributes()
+{
+ m_idAttributeSet.clear();
+}
+
+AbstractAttributeExtensibleXMLObject::AbstractAttributeExtensibleXMLObject()
+{
+ m_idAttribute = m_attributeMap.end();
}
AbstractAttributeExtensibleXMLObject::AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src)
}
}
+AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject()
+{
+ for (map<QName,XMLCh*>::iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++)
+ XMLString::release(&(i->second));
+}
+
+const XMLCh* AbstractAttributeExtensibleXMLObject::getAttribute(const QName& qualifiedName) const
+{
+ map<QName,XMLCh*>::const_iterator i=m_attributeMap.find(qualifiedName);
+ return (i==m_attributeMap.end()) ? NULL : i->second;
+}
+
void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID)
{
map<QName,XMLCh*>::iterator i=m_attributeMap.find(qualifiedName);
}
}
+const map<QName,XMLCh*>& AbstractAttributeExtensibleXMLObject::getExtensionAttributes() const
+{
+ return m_attributeMap;
+}
+const XMLCh* AbstractAttributeExtensibleXMLObject::getXMLID() const
+{
+ return (m_idAttribute == m_attributeMap.end()) ? NULL : m_idAttribute->second;
+}
+
void AbstractAttributeExtensibleXMLObject::unmarshallExtensionAttribute(const DOMAttr* attribute)
{
QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix());
public:
virtual ~AbstractAttributeExtensibleXMLObject();
- const XMLCh* getAttribute(const QName& qualifiedName) const {
- std::map<QName,XMLCh*>::const_iterator i=m_attributeMap.find(qualifiedName);
- return (i==m_attributeMap.end()) ? NULL : i->second;
- }
-
+ // Virtual function overrides.
+ const XMLCh* getAttribute(const QName& qualifiedName) const;
void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false);
-
- const std::map<QName,XMLCh*>& getExtensionAttributes() const {
- return m_attributeMap;
- }
-
- const XMLCh* getXMLID() const {
- return (m_idAttribute == m_attributeMap.end()) ? NULL : m_idAttribute->second;
- }
+ const std::map<QName,XMLCh*>& getExtensionAttributes() const;
+ const XMLCh* getXMLID() const;
protected:
- AbstractAttributeExtensibleXMLObject() {
- m_idAttribute = m_attributeMap.end();
- }
+ AbstractAttributeExtensibleXMLObject();
/** Copy constructor. */
AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src);
}
}
+AbstractComplexElement::AbstractComplexElement()
+{
+}
+
+AbstractComplexElement::AbstractComplexElement(const AbstractComplexElement& src)
+{
+ for (vector<XMLCh*>::const_iterator i=src.m_text.begin(); i!=src.m_text.end(); ++i)
+ m_text.push_back(XMLString::replicate(*i));
+}
+
AbstractComplexElement::~AbstractComplexElement() {
for_each(m_children.begin(), m_children.end(), cleanup<XMLObject>());
for (vector<XMLCh*>::iterator i=m_text.begin(); i!=m_text.end(); ++i)
return (find_if(m_children.begin(), m_children.end(), _nonnull) != m_children.end());
}
+const list<XMLObject*>& AbstractComplexElement::getOrderedChildren() const
+{
+ return m_children;
+}
+
void AbstractComplexElement::removeChild(XMLObject* child)
{
m_children.erase(remove(m_children.begin(), m_children.end(), child), m_children.end());
}
-AbstractComplexElement::AbstractComplexElement(const AbstractComplexElement& src)
+const XMLCh* AbstractComplexElement::getTextContent(unsigned int position) const
{
- for (vector<XMLCh*>::const_iterator i=src.m_text.begin(); i!=src.m_text.end(); ++i)
- m_text.push_back(XMLString::replicate(*i));
+ return (m_text.size() > position) ? m_text[position] : NULL;
}
void AbstractComplexElement::setTextContent(const XMLCh* value, unsigned int position)
{
public:
virtual ~AbstractComplexElement();
-
- bool hasChildren() const;
-
- const std::list<XMLObject*>& getOrderedChildren() const {
- return m_children;
- }
+ // Virtual function overrides.
+ bool hasChildren() const;
+ const std::list<XMLObject*>& getOrderedChildren() const;
void removeChild(XMLObject* child);
-
- const XMLCh* getTextContent(unsigned int position=0) const {
- return (m_text.size() > position) ? m_text[position] : NULL;
- }
-
+ const XMLCh* getTextContent(unsigned int position=0) const;
void setTextContent(const XMLCh* value, unsigned int position=0);
protected:
- AbstractComplexElement() {}
+ AbstractComplexElement();
/** Copy constructor. */
AbstractComplexElement(const AbstractComplexElement& src);
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using namespace xercesc;
using namespace std;
+AbstractDOMCachingXMLObject::AbstractDOMCachingXMLObject() : m_dom(NULL), m_document(NULL)
+{
+}
+
+AbstractDOMCachingXMLObject::AbstractDOMCachingXMLObject(const AbstractDOMCachingXMLObject& src)
+ : AbstractXMLObject(src), m_dom(NULL), m_document(NULL)
+{
+}
+
AbstractDOMCachingXMLObject::~AbstractDOMCachingXMLObject()
{
if (m_document)
m_document->release();
}
+DOMElement* AbstractDOMCachingXMLObject::getDOM() const
+{
+ return m_dom;
+}
+
void AbstractDOMCachingXMLObject::setDOM(DOMElement* dom, bool bindDocument) const
{
m_dom=dom;
}
}
+void AbstractDOMCachingXMLObject::setDocument(DOMDocument* doc) const
+{
+ if (m_document)
+ m_document->release();
+ m_document=doc;
+}
+
void AbstractDOMCachingXMLObject::releaseDOM() const
{
if (m_dom) {
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
public:
virtual ~AbstractDOMCachingXMLObject();
-
- xercesc::DOMElement* getDOM() const {
- return m_dom;
- }
-
+
+ // Virtual function overrides.
+ xercesc::DOMElement* getDOM() const;
void setDOM(xercesc::DOMElement* dom, bool bindDocument=false) const;
-
- void setDocument(xercesc::DOMDocument* doc) const {
- if (m_document)
- m_document->release();
- m_document=doc;
- }
-
- virtual void releaseDOM() const;
-
- virtual void releaseParentDOM(bool propagateRelease=true) const;
-
- virtual void releaseChildrenDOM(bool propagateRelease=true) const;
-
+ void setDocument(xercesc::DOMDocument* doc) const;
+ void releaseDOM() const;
+ void releaseParentDOM(bool propagateRelease=true) const;
+ void releaseChildrenDOM(bool propagateRelease=true) const;
XMLObject* clone() const;
-
void detach();
protected:
- AbstractDOMCachingXMLObject() : m_dom(NULL), m_document(NULL) {}
+ AbstractDOMCachingXMLObject();
/** Copy constructor. */
- AbstractDOMCachingXMLObject(const AbstractDOMCachingXMLObject& src)
- : AbstractXMLObject(src), m_dom(NULL), m_document(NULL) {}
+ AbstractDOMCachingXMLObject(const AbstractDOMCachingXMLObject& src);
/**
* If a DOM representation exists, this clones it into a new document.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "AbstractSimpleElement.h"
using namespace xmltooling;
+using xercesc::XMLString;
using namespace std;
// shared "empty" list of children for childless objects
list<XMLObject*> AbstractSimpleElement::m_no_children;
+AbstractSimpleElement::AbstractSimpleElement() : m_value(NULL)
+{
+}
+
+AbstractSimpleElement::AbstractSimpleElement(const AbstractSimpleElement& src)
+ : AbstractXMLObject(src), m_value(XMLString::replicate(src.m_value))
+{
+}
+
+AbstractSimpleElement::~AbstractSimpleElement()
+{
+ XMLString::release(&m_value);
+}
+
+bool AbstractSimpleElement::hasChildren() const
+{
+ return false;
+}
+
+const list<XMLObject*>& AbstractSimpleElement::getOrderedChildren() const
+{
+ return m_no_children;
+}
+
void AbstractSimpleElement::removeChild(XMLObject* child)
{
throw XMLObjectException("Cannot remove child from a childless object.");
}
+
+const XMLCh* AbstractSimpleElement::getTextContent(unsigned int position) const
+{
+ return (position==0) ? m_value : NULL;
+}
+
+void AbstractSimpleElement::setTextContent(const XMLCh* value, unsigned int position)
+{
+ if (position > 0)
+ throw XMLObjectException("Cannot set text content in simple element at position > 0.");
+ m_value=prepareForAssignment(m_value,value);
+}
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API AbstractSimpleElement : public virtual AbstractXMLObject
{
public:
- virtual ~AbstractSimpleElement() {
- xercesc::XMLString::release(&m_value);
- }
+ virtual ~AbstractSimpleElement();
- bool hasChildren() const {
- return false;
- }
-
- const std::list<XMLObject*>& getOrderedChildren() const {
- return m_no_children;
- }
-
+ // Virtual function overrides.
+ bool hasChildren() const;
+ const std::list<XMLObject*>& getOrderedChildren() const;
void removeChild(XMLObject* child);
-
- virtual const XMLCh* getTextContent(unsigned int position=0) const {
- return (position==0) ? m_value : NULL;
- }
-
- virtual void setTextContent(const XMLCh* value, unsigned int position=0) {
- if (position > 0)
- throw XMLObjectException("Cannot set text content in simple element at position > 0.");
- m_value=prepareForAssignment(m_value,value);
- }
+ const XMLCh* getTextContent(unsigned int position=0) const;
+ void setTextContent(const XMLCh* value, unsigned int position=0);
protected:
- AbstractSimpleElement() : m_value(NULL) {}
+ AbstractSimpleElement();
/** Copy constructor. */
- AbstractSimpleElement(const AbstractSimpleElement& src)
- : AbstractXMLObject(src), m_value(xercesc::XMLString::replicate(src.m_value)) {}
+ AbstractSimpleElement(const AbstractSimpleElement& src);
private:
XMLCh* m_value;
*/
#include "internal.h"
-#include "AbstractXMLObject.h"
#include "exceptions.h"
+#include "AbstractXMLObject.h"
+#include "util/DateTime.h"
#include <algorithm>
using namespace xmltooling;
+using std::set;
using xercesc::XMLString;
+XMLObject::XMLObject()
+{
+}
+
+XMLObject::~XMLObject()
+{
+}
+
+void XMLObject::releaseThisandParentDOM() const
+{
+ if (getDOM()) {
+ releaseDOM();
+ releaseParentDOM(true);
+ }
+}
+
+void XMLObject::releaseThisAndChildrenDOM() const
+{
+ if (getDOM()) {
+ releaseChildrenDOM(true);
+ releaseDOM();
+ }
+}
+
AbstractXMLObject::AbstractXMLObject(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
: m_log(logging::Category::getInstance(XMLTOOLING_LOGCAT".XMLObject")),
m_schemaLocation(NULL), m_noNamespaceSchemaLocation(NULL), m_nil(xmlconstants::XML_BOOL_NULL),
xercesc::XMLString::release(&m_noNamespaceSchemaLocation);
}
+void AbstractXMLObject::detach()
+{
+ if (!getParent())
+ return;
+ else if (getParent()->hasParent())
+ throw XMLObjectException("Cannot detach an object whose parent is itself a child.");
+
+ // Pull ourselves out of the parent and then blast him.
+ getParent()->removeChild(this);
+ delete m_parent;
+ m_parent = NULL;
+}
+
+const QName& AbstractXMLObject::getElementQName() const
+{
+ return m_elementQname;
+}
+
+const set<Namespace>& AbstractXMLObject::getNamespaces() const
+{
+ return m_namespaces;
+}
+
void XMLObject::setNil(const XMLCh* value)
{
if (value) {
const_cast<Namespace&>(*i).setAlwaysDeclare(true);
}
+void AbstractXMLObject::removeNamespace(const Namespace& ns)
+{
+ m_namespaces.erase(ns);
+}
+
+const QName* AbstractXMLObject::getSchemaType() const
+{
+ return m_typeQname;
+}
+
+const XMLCh* AbstractXMLObject::getXMLID() const
+{
+ return NULL;
+}
+
+xmlconstants::xmltooling_bool_t AbstractXMLObject::getNil() const
+{
+ return m_nil;
+}
+
+void AbstractXMLObject::nil(xmlconstants::xmltooling_bool_t value)
+{
+ if (m_nil != value) {
+ releaseThisandParentDOM();
+ m_nil = value;
+ }
+}
+
+bool AbstractXMLObject::hasParent() const
+{
+ return m_parent != NULL;
+}
+
+XMLObject* AbstractXMLObject::getParent() const
+{
+ return m_parent;
+}
+
+void AbstractXMLObject::setParent(XMLObject* parent)
+{
+ m_parent = parent;
+}
+
XMLCh* AbstractXMLObject::prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue)
{
if (!XMLString::equals(oldValue,newValue)) {
return newValue;
}
-
-void AbstractXMLObject::detach()
-{
- if (!getParent())
- return;
- else if (getParent()->hasParent())
- throw XMLObjectException("Cannot detach an object whose parent is itself a child.");
-
- // Pull ourselves out of the parent and then blast him.
- getParent()->removeChild(this);
- delete m_parent;
- m_parent = NULL;
-}
#define __xmltooling_abstractxmlobj_h__
#include <xmltooling/logging.h>
+#include <xmltooling/QName.h>
#include <xmltooling/XMLObject.h>
-#include <xmltooling/util/DateTime.h>
#if defined (_MSC_VER)
#pragma warning( push )
namespace xmltooling {
+ class XMLTOOL_API DateTime;
+
/**
* An abstract implementation of XMLObject.
* This is the primary concrete base class, and supplies basic namespace,
public:
virtual ~AbstractXMLObject();
+ // Virtual function overrides.
void detach();
-
- const QName& getElementQName() const {
- return m_elementQname;
- }
-
- const std::set<Namespace>& getNamespaces() const {
- return m_namespaces;
- }
-
+ const QName& getElementQName() const;
+ const std::set<Namespace>& getNamespaces() const;
void addNamespace(const Namespace& ns) const;
-
- 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();
- m_nil = value;
- }
- }
-
- bool hasParent() const {
- return m_parent != NULL;
- }
-
- XMLObject* getParent() const {
- return m_parent;
- }
-
- void setParent(XMLObject* parent) {
- m_parent = parent;
- }
+ void removeNamespace(const Namespace& ns);
+ const QName* getSchemaType() const;
+ const XMLCh* getXMLID() const;
+ xmlconstants::xmltooling_bool_t getNil() const;
+ void nil(xmlconstants::xmltooling_bool_t value);
+ bool hasParent() const;
+ XMLObject* getParent() const;
+ void setParent(XMLObject* parent);
protected:
/**
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API AttributeExtensibleXMLObject : public virtual XMLObject
{
protected:
- AttributeExtensibleXMLObject() {}
+ AttributeExtensibleXMLObject();
public:
- virtual ~AttributeExtensibleXMLObject() {}
+ virtual ~AttributeExtensibleXMLObject();
/**
* Gets the value of an XML attribute of the object.
*
* @return list of all the ID attributes currently registered
*/
- static const std::set<QName>& getRegisteredIDAttributes() {
- return m_idAttributeSet;
- }
+ static const std::set<QName>& getRegisteredIDAttributes();
/**
* Tests whether an XML attribute is registered as an XML ID.
*
* @return true iff the attribute name matches a registered XML ID attribute
*/
- static bool isRegisteredIDAttribute(const QName& name) {
- return m_idAttributeSet.find(name)!=m_idAttributeSet.end();
- }
+ static bool isRegisteredIDAttribute(const QName& name);
/**
* Registers a new attribute as being of XML ID type.
*
* @param name the qualified attribute name
*/
- static void registerIDAttribute(const QName& name) {
- m_idAttributeSet.insert(name);
- }
+ static void registerIDAttribute(const QName& name);
/**
* Deregisters an ID attribute.
*
* @param name the qualified attribute name
*/
- static void deregisterIDAttribute(const QName& name) {
- m_idAttributeSet.erase(name);
- }
+ static void deregisterIDAttribute(const QName& name);
/**
* Deregisters all ID attributes.
*/
- static void deregisterIDAttributes() {
- m_idAttributeSet.clear();
- }
+ static void deregisterIDAttributes();
private:
/** Set of attributes to treat as XML IDs. */
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API ConcreteXMLObjectBuilder : public XMLObjectBuilder
{
public:
- virtual ~ConcreteXMLObjectBuilder() {}
+ virtual ~ConcreteXMLObjectBuilder();
using XMLObjectBuilder::buildObject;
virtual XMLObject* buildObject() const=0;
protected:
- ConcreteXMLObjectBuilder() {}
+ ConcreteXMLObjectBuilder();
};
};
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API ElementExtensibleXMLObject : public virtual XMLObject
{
protected:
- ElementExtensibleXMLObject() {}
+ ElementExtensibleXMLObject();
public:
- virtual ~ElementExtensibleXMLObject() {}
+ virtual ~ElementExtensibleXMLObject();
/**
* Gets a mutable list of child objects
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API ElementProxy : public virtual AttributeExtensibleXMLObject, public virtual ElementExtensibleXMLObject
{
protected:
- ElementProxy() {}
+ ElementProxy();
public:
- virtual ~ElementProxy() {}
+ virtual ~ElementProxy();
};
};
--- /dev/null
+/*
+ * Copyright 2009 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Lockable.cpp
+ *
+ * Locking abstraction.
+ */
+
+#include "internal.h"
+#include "Lockable.h"
+
+using namespace xmltooling;
+
+Lockable::Lockable()
+{
+}
+
+Lockable::~Lockable()
+{
+}
+
+Locker::Locker(Lockable* lockee, bool lock)
+{
+ if (lockee && lock)
+ m_lockee=lockee->lock();
+ else
+ m_lockee=lockee;
+}
+
+void Locker::assign(Lockable* lockee, bool lock)
+{
+ if (m_lockee)
+ m_lockee->unlock();
+ m_lockee=NULL;
+ if (lockee && lock)
+ m_lockee=lockee->lock();
+ else
+ m_lockee=lockee;
+}
+
+Locker::~Locker()
+{
+ if (m_lockee)
+ m_lockee->unlock();
+}
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @file xmltooling/Lockable.h
*
- * Locking abstraction
+ * Locking abstraction.
*/
#ifndef __xmltooling_lockable_h__
/**
* Abstract mixin interface for interfaces that support locking
*/
- struct XMLTOOL_API Lockable
+ class XMLTOOL_API Lockable
{
- virtual ~Lockable() {}
+ protected:
+ Lockable();
+ public:
+ virtual ~Lockable();
/**
* Lock the associated object for exclusive access.
* @param lockee pointer to an object to hold, and optionally lock
* @param lock true iff object is not yet locked
*/
- Locker(Lockable* lockee=NULL, bool lock=true) {
- if (lockee && lock)
- m_lockee=lockee->lock();
- else
- m_lockee=lockee;
- }
+ Locker(Lockable* lockee=NULL, bool lock=true);
/**
* Optionally locks an object and stores it for later release.
* @param lockee pointer to an object to hold, and optionally lock
* @param lock true iff object is not yet locked
*/
- void assign(Lockable* lockee=NULL, bool lock=true) {
- if (m_lockee)
- m_lockee->unlock();
- m_lockee=NULL;
- if (lockee && lock)
- m_lockee=lockee->lock();
- else
- m_lockee=lockee;
- }
+ void assign(Lockable* lockee=NULL, bool lock=true);
/**
* Destructor releases lock on held pointer, if any.
*/
- ~Locker() {
- if (m_lockee)
- m_lockee->unlock();
- }
+ ~Locker();
private:
Lockable* m_lockee;
AbstractSimpleElement.cpp \
AbstractXMLObject.cpp \
exceptions.cpp \
+ Lockable.cpp \
Namespace.cpp \
QName.cpp \
unicode.cpp \
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#ifndef __xmltooling_xmlobj_h__
#define __xmltooling_xmlobj_h__
-#include <xmltooling/QName.h>
#include <xmltooling/Namespace.h>
#include <xmltooling/util/XMLConstants.h>
#ifndef XMLTOOLING_NO_XMLSEC
class XMLTOOL_API Credential;
#endif
+ class XMLTOOL_API QName;
/**
* Object that represents an XML Element that has been unmarshalled into this C++ object.
class XMLTOOL_API XMLObject
{
public:
- virtual ~XMLObject() {}
+ virtual ~XMLObject();
/**
* Creates a copy of the object, along with all of its children.
/**
* A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).
*/
- void releaseThisandParentDOM() const {
- if (getDOM()) {
- releaseDOM();
- releaseParentDOM(true);
- }
- }
+ void releaseThisandParentDOM() const;
/**
* A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().
*/
- void releaseThisAndChildrenDOM() const {
- if (getDOM()) {
- releaseChildrenDOM(true);
- releaseDOM();
- }
- }
+ void releaseThisAndChildrenDOM() const;
/**
* Marshalls the XMLObject, and its children, into a DOM element.
virtual XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false)=0;
protected:
- XMLObject() {}
+ XMLObject();
private:
XMLObject& operator=(const XMLObject& src);
};
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "logging.h"
-#include "XMLObjectBuilder.h"
+#include "ConcreteXMLObjectBuilder.h"
#include "util/NDC.h"
#include "util/XMLHelper.h"
using namespace xmltooling;
using namespace std;
+using xercesc::DOMDocument;
using xercesc::DOMElement;
map<QName,XMLObjectBuilder*> XMLObjectBuilder::m_map;
XMLObjectBuilder* XMLObjectBuilder::m_default=NULL;
+XMLObjectBuilder::XMLObjectBuilder()
+{
+}
+
+XMLObjectBuilder::~XMLObjectBuilder()
+{
+}
+
+XMLObject* XMLObjectBuilder::buildFromQName(const QName& q) const
+{
+ return buildObject(q.getNamespaceURI(),q.getLocalPart(),q.getPrefix());
+}
+
+XMLObject* XMLObjectBuilder::buildFromElement(DOMElement* element, bool bindDocument) const
+{
+ auto_ptr<XMLObject> ret(
+ buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),XMLHelper::getXSIType(element))
+ );
+ ret->unmarshall(element,bindDocument);
+ return ret.release();
+}
+
+XMLObject* XMLObjectBuilder::buildFromDocument(DOMDocument* doc, bool bindDocument) const
+{
+ return buildFromElement(doc->getDocumentElement(),bindDocument);
+}
+
+XMLObject* XMLObjectBuilder::buildOneFromElement(xercesc::DOMElement* element, bool bindDocument)
+{
+ const XMLObjectBuilder* b=getBuilder(element);
+ return b ? b->buildFromElement(element,bindDocument) : NULL;
+}
+
+const XMLObjectBuilder* XMLObjectBuilder::getBuilder(const QName& key)
+{
+ map<QName,XMLObjectBuilder*>::const_iterator i=m_map.find(key);
+ return (i==m_map.end()) ? NULL : i->second;
+}
+
const XMLObjectBuilder* XMLObjectBuilder::getBuilder(const DOMElement* domElement)
{
#ifdef _DEBUG
return m_default;
}
+const XMLObjectBuilder* XMLObjectBuilder::getDefaultBuilder()
+{
+ return m_default;
+}
+
+const map<QName,XMLObjectBuilder*>& XMLObjectBuilder::getBuilders()
+{
+ return m_map;
+}
+
+void XMLObjectBuilder::registerBuilder(const QName& builderKey, XMLObjectBuilder* builder)
+{
+ deregisterBuilder(builderKey);
+ m_map[builderKey]=builder;
+}
+
+void XMLObjectBuilder::registerDefaultBuilder(XMLObjectBuilder* builder)
+{
+ deregisterDefaultBuilder();
+ m_default=builder;
+}
+
+void XMLObjectBuilder::deregisterBuilder(const QName& builderKey)
+{
+ delete getBuilder(builderKey);
+ m_map.erase(builderKey);
+}
+
+void XMLObjectBuilder::deregisterDefaultBuilder()
+{
+ delete m_default;
+ m_default=NULL;
+}
+
void XMLObjectBuilder::destroyBuilders()
{
for_each(m_map.begin(),m_map.end(),cleanup_pair<QName,XMLObjectBuilder>());
m_map.clear();
deregisterDefaultBuilder();
}
+
+ConcreteXMLObjectBuilder::ConcreteXMLObjectBuilder()
+{
+}
+
+ConcreteXMLObjectBuilder::~ConcreteXMLObjectBuilder()
+{
+}
{\r
MAKE_NONCOPYABLE(XMLObjectBuilder);\r
public:\r
- virtual ~XMLObjectBuilder() {}\r
+ virtual ~XMLObjectBuilder();\r
\r
/**\r
* Creates an empty XMLObject with a particular element name.\r
* @param q QName of element for object\r
* @return the empty XMLObject\r
*/\r
- XMLObject* buildFromQName(const QName& q) const {\r
- return buildObject(q.getNamespaceURI(),q.getLocalPart(),q.getPrefix());\r
- }\r
+ XMLObject* buildFromQName(const QName& q) const;\r
\r
/**\r
* Creates an unmarshalled XMLObject from a DOM Element.\r
* @param bindDocument true iff the XMLObject should take ownership of the DOM Document\r
* @return the unmarshalled XMLObject\r
*/\r
- XMLObject* buildFromElement(xercesc::DOMElement* element, bool bindDocument=false) const {\r
- std::auto_ptr<XMLObject> ret(\r
- buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),XMLHelper::getXSIType(element))\r
- );\r
- ret->unmarshall(element,bindDocument);\r
- return ret.release();\r
- }\r
+ XMLObject* buildFromElement(xercesc::DOMElement* element, bool bindDocument=false) const;\r
\r
/**\r
* Creates an unmarshalled XMLObject from the root of a DOM Document.\r
* @param bindDocument true iff the XMLObject should take ownership of the DOM Document\r
* @return the unmarshalled XMLObject\r
*/\r
- XMLObject* buildFromDocument(xercesc::DOMDocument* doc, bool bindDocument=true) const {\r
- return buildFromElement(doc->getDocumentElement(),bindDocument);\r
- }\r
+ XMLObject* buildFromDocument(xercesc::DOMDocument* doc, bool bindDocument=true) const;\r
\r
/**\r
* Creates an unmarshalled XMLObject using the default build method, if a builder can be found.\r
* @param bindDocument true iff the new XMLObject should take ownership of the DOM Document\r
* @return the unmarshalled object or NULL if no builder is available \r
*/\r
- static XMLObject* buildOneFromElement(xercesc::DOMElement* element, bool bindDocument=false) {\r
- const XMLObjectBuilder* b=getBuilder(element);\r
- return b ? b->buildFromElement(element,bindDocument) : NULL;\r
- }\r
+ static XMLObject* buildOneFromElement(xercesc::DOMElement* element, bool bindDocument=false);\r
\r
/**\r
* Retrieves an XMLObjectBuilder using the key it was registered with.\r
* @param key the key used to register the builder\r
* @return the builder or NULL\r
*/\r
- static const XMLObjectBuilder* getBuilder(const QName& key) {\r
- std::map<QName,XMLObjectBuilder*>::const_iterator i=m_map.find(key);\r
- return (i==m_map.end()) ? NULL : i->second;\r
- }\r
+ static const XMLObjectBuilder* getBuilder(const QName& key);\r
\r
/**\r
* Retrieves an XMLObjectBuilder for a given DOM element.\r
* \r
* @return the default builder or NULL\r
*/\r
- static const XMLObjectBuilder* getDefaultBuilder() {\r
- return m_default;\r
- }\r
+ static const XMLObjectBuilder* getDefaultBuilder();\r
\r
/**\r
* Gets an immutable list of all the builders currently registered.\r
* \r
* @return list of all the builders currently registered\r
*/\r
- static const std::map<QName,XMLObjectBuilder*>& getBuilders() {\r
- return m_map;\r
- }\r
+ static const std::map<QName,XMLObjectBuilder*>& getBuilders();\r
\r
/**\r
* Registers a new builder for the given key.\r
* @param builderKey the key used to retrieve this builder later\r
* @param builder the builder\r
*/\r
- static void registerBuilder(const QName& builderKey, XMLObjectBuilder* builder) {\r
- deregisterBuilder(builderKey);\r
- m_map[builderKey]=builder;\r
- }\r
+ static void registerBuilder(const QName& builderKey, XMLObjectBuilder* builder);\r
\r
/**\r
* Registers a default builder\r
* \r
* @param builder the default builder\r
*/\r
- static void registerDefaultBuilder(XMLObjectBuilder* builder) {\r
- deregisterDefaultBuilder();\r
- m_default=builder;\r
- }\r
+ static void registerDefaultBuilder(XMLObjectBuilder* builder);\r
\r
/**\r
* Deregisters a builder.\r
* \r
* @param builderKey the key for the builder to be deregistered\r
*/\r
- static void deregisterBuilder(const QName& builderKey) {\r
- delete getBuilder(builderKey);\r
- m_map.erase(builderKey);\r
- }\r
+ static void deregisterBuilder(const QName& builderKey);\r
\r
/**\r
* Deregisters default builder.\r
*/\r
- static void deregisterDefaultBuilder() {\r
- delete m_default;\r
- m_default=NULL;\r
- }\r
+ static void deregisterDefaultBuilder();\r
\r
/**\r
* Unregisters and destroys all registered builders. \r
static void destroyBuilders();\r
\r
protected:\r
- XMLObjectBuilder() {}\r
+ XMLObjectBuilder();\r
\r
private:\r
static std::map<QName,XMLObjectBuilder*> m_map;\r
#include "security/OpenSSLCryptoX509CRL.h"
#include "security/CredentialResolver.h"
#include "security/KeyInfoResolver.h"
+#include "signature/KeyInfo.h"
#include "signature/Signature.h"
#include "soap/SOAP.h"
#include "soap/SOAPTransport.h"
#include "util/ReplayCache.h"
#include "util/StorageService.h"
#include "util/TemplateEngine.h"
+#include "util/Threads.h"
#include "util/URLEncoder.h"
#include "util/XMLConstants.h"
#include "validation/ValidatorSuite.h"
}
#ifndef XMLTOOLING_LITE
-void XMLToolingConfig::setReplayCache(ReplayCache* replayCache)
+const KeyInfoResolver* XMLToolingConfig::getKeyInfoResolver() const
{
- delete m_replayCache;
- m_replayCache = replayCache;
+ return m_keyInfoResolver;
+}
+
+ReplayCache* XMLToolingConfig::getReplayCache() const
+{
+ return m_replayCache;
}
void XMLToolingConfig::setKeyInfoResolver(xmltooling::KeyInfoResolver *keyInfoResolver)
delete m_keyInfoResolver;
m_keyInfoResolver = keyInfoResolver;
}
+
+void XMLToolingConfig::setReplayCache(ReplayCache* replayCache)
+{
+ delete m_replayCache;
+ m_replayCache = replayCache;
+}
#endif
+PathResolver* XMLToolingConfig::getPathResolver() const
+{
+ return m_pathResolver;
+}
+
+TemplateEngine* XMLToolingConfig::getTemplateEngine() const
+{
+ return m_templateEngine;
+}
+
+const URLEncoder* XMLToolingConfig::getURLEncoder() const
+{
+ return m_urlEncoder;
+}
+
void XMLToolingConfig::setPathResolver(PathResolver* pathResolver)
{
delete m_pathResolver;
*
* @return global KeyInfoResolver or NULL
*/
- const KeyInfoResolver* getKeyInfoResolver() const {
- return m_keyInfoResolver;
- }
+ const KeyInfoResolver* getKeyInfoResolver() const;
/**
* Returns the global ReplayCache instance.
*
* @return global ReplayCache or NULL
*/
- ReplayCache* getReplayCache() const {
- return m_replayCache;
- }
+ ReplayCache* getReplayCache() const;
/**
* Sets the global KeyInfoResolver instance.
*
* @return global PathResolver or NULL
*/
- PathResolver* getPathResolver() const {
- return m_pathResolver;
- }
+ PathResolver* getPathResolver() const;
/**
* Returns the global TemplateEngine instance.
*
* @return global TemplateEngine or NULL
*/
- TemplateEngine* getTemplateEngine() const {
- return m_templateEngine;
- }
+ TemplateEngine* getTemplateEngine() const;
/**
* Returns the global URLEncoder instance.
*
* @return global URLEncoder or NULL
*/
- const URLEncoder* getURLEncoder() const {
- return m_urlEncoder;
- }
+ const URLEncoder* getURLEncoder() const;
/**
* Sets the global PathResolver instance.
#if !defined(__xmltooling_decrypter_h__) && !defined(XMLTOOLING_NO_XMLSEC)
#define __xmltooling_decrypter_h__
-#include <xmltooling/encryption/Encryption.h>
+#include <xmltooling/exceptions.h>
-#include <xsec/xenc/XENCCipher.hpp>
+class XENCCipher;
namespace xmltooling {
class XMLTOOL_API CredentialCriteria;
namespace xmlencryption {
+ class XMLTOOL_API EncryptedData;
+ class XMLTOOL_API EncryptedKey;
class XMLTOOL_API EncryptedKeyResolver;
/**
const xmltooling::CredentialResolver* credResolver=NULL,
xmltooling::CredentialCriteria* criteria=NULL,
const EncryptedKeyResolver* EKResolver=NULL
- ) : m_cipher(NULL), m_credResolver(credResolver), m_criteria(criteria), m_EKResolver(EKResolver) {
- }
+ );
virtual ~Decrypter();
*
* @param EKResolver the EncryptedKeyResolver to attach
*/
- void setEncryptedKeyResolver(const EncryptedKeyResolver* EKResolver) {
- m_EKResolver=EKResolver;
- }
+ void setEncryptedKeyResolver(const EncryptedKeyResolver* EKResolver);
/**
* Replace the current CredentialResolver interface, if any, with a new one.
* @param resolver the locked CredentialResolver to attach, or NULL to clear
* @param criteria optional external criteria to use with resolver
*/
- void setKEKResolver(const xmltooling::CredentialResolver* resolver, xmltooling::CredentialCriteria* criteria) {
- m_credResolver=resolver;
- m_criteria=criteria;
- }
+ void setKEKResolver(const xmltooling::CredentialResolver* resolver, xmltooling::CredentialCriteria* criteria);
/**
* Decrypts the supplied information using the supplied key, and returns
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API EncryptedKeyResolver {
MAKE_NONCOPYABLE(EncryptedKeyResolver);
public:
- EncryptedKeyResolver() {}
- virtual ~EncryptedKeyResolver() {}
+ EncryptedKeyResolver();
+ virtual ~EncryptedKeyResolver();
/**
* Returns an encrypted key based on the supplied object's KeyInfo information.
#if !defined(__xmltooling_encrypter_h__) && !defined(XMLTOOLING_NO_XMLSEC)
#define __xmltooling_encrypter_h__
-#include <xmltooling/encryption/Encryption.h>
+#include <xmltooling/exceptions.h>
-#include <xsec/enc/XSECCryptoKey.hpp>
-#include <xsec/xenc/XENCCipher.hpp>
+#include <xsec/dsig/DSIGConstants.hpp>
+
+class XENCCipher;
namespace xmltooling {
class XMLTOOL_API Credential;
namespace xmlencryption {
+ class XMLTOOL_API EncryptedData;
+ class XMLTOOL_API EncryptedKey;
+
/**
* Wrapper API for XML Encryption functionality.
* Designed to allow both external and internal key generation as follows:
unsigned int keyBufferSize=0,
const xmltooling::Credential* credential=NULL,
bool compact=false
- ) : m_algorithm(algorithm), m_keyBuffer(keyBuffer), m_keyBufferSize(keyBufferSize),
- m_credential(credential), m_compact(compact) {
- }
+ );
- ~EncryptionParams() {}
+ ~EncryptionParams();
/** Data encryption algorithm. */
const XMLCh* m_algorithm;
* @param recipient optional name of recipient of encrypted key
*/
KeyEncryptionParams(
- const xmltooling::Credential& credential,
- const XMLCh* algorithm=NULL,
- const XMLCh* recipient=NULL
- ) : m_credential(credential), m_algorithm(algorithm), m_recipient(recipient) {
- }
+ const xmltooling::Credential& credential, const XMLCh* algorithm=NULL, const XMLCh* recipient=NULL
+ );
- ~KeyEncryptionParams() {}
+ ~KeyEncryptionParams();
/** Credential containing key encryption key. */
const xmltooling::Credential& m_credential;
const XMLCh* m_recipient;
};
- Encrypter() : m_cipher(NULL) {}
+ Encrypter();
virtual ~Encrypter();
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#if !defined(__xmltooling_encryption_h__) && !defined(XMLTOOLING_NO_XMLSEC)
#define __xmltooling_encryption_h__
-#include <xmltooling/signature/KeyInfo.h>
+#include <xmltooling/ConcreteXMLObjectBuilder.h>
+#include <xmltooling/ElementProxy.h>
+#include <xmltooling/util/XMLConstants.h>
+
#include <cstdio>
+namespace xmlsignature {
+ class XMLTOOL_API KeyInfo;
+ class XMLTOOL_API Transform;
+};
+
/**
* Macro for declaring encryption builders.
*
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "logging.h"
#include "encryption/Decrypter.h"
#include "encryption/EncryptedKeyResolver.h"
+#include "encryption/Encryption.h"
#include "security/Credential.h"
#include "security/CredentialCriteria.h"
#include "security/CredentialResolver.h"
#include <xsec/framework/XSECAlgorithmMapper.hpp>
#include <xsec/framework/XSECAlgorithmHandler.hpp>
#include <xsec/utils/XSECBinTXFMInputStream.hpp>
+#include <xsec/xenc/XENCCipher.hpp>
#include <xsec/xenc/XENCEncryptedData.hpp>
#include <xsec/xenc/XENCEncryptedKey.hpp>
using namespace xercesc;
using namespace std;
+Decrypter::Decrypter(const CredentialResolver* credResolver, CredentialCriteria* criteria, const EncryptedKeyResolver* EKResolver)
+ : m_cipher(NULL), m_credResolver(credResolver), m_criteria(criteria), m_EKResolver(EKResolver)
+{
+}
+
Decrypter::~Decrypter()
{
if (m_cipher)
XMLToolingInternalConfig::getInternalConfig().m_xsecProvider->releaseCipher(m_cipher);
}
+void Decrypter::setEncryptedKeyResolver(const EncryptedKeyResolver* EKResolver)
+{
+ m_EKResolver=EKResolver;
+}
+
+void Decrypter::setKEKResolver(const CredentialResolver* resolver, CredentialCriteria* criteria)
+{
+ m_credResolver=resolver;
+ m_criteria=criteria;
+}
+
DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData, XSECCryptoKey* key)
{
if (encryptedData.getDOM()==NULL)
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "encryption/EncryptedKeyResolver.h"
+#include "signature/KeyInfo.h"
using namespace xmlencryption;
using namespace xmlsignature;
using namespace xmltooling;
using namespace std;
+EncryptedKeyResolver::EncryptedKeyResolver()
+{
+}
+
+EncryptedKeyResolver::~EncryptedKeyResolver()
+{
+}
+
const EncryptedKey* EncryptedKeyResolver::resolveKey(const EncryptedData& encryptedData, const XMLCh* recipient) const
{
if (!encryptedData.getKeyInfo())
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "encryption/Encrypter.h"
+#include "encryption/Encryption.h"
#include "security/Credential.h"
+#include "signature/KeyInfo.h"
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/framework/XSECAlgorithmMapper.hpp>
#include <xsec/framework/XSECAlgorithmHandler.hpp>
+#include <xsec/xenc/XENCCipher.hpp>
#include <xsec/xenc/XENCEncryptedData.hpp>
#include <xsec/xenc/XENCEncryptedKey.hpp>
using namespace xercesc;
using namespace std;
+Encrypter::EncryptionParams::EncryptionParams(
+ const XMLCh* algorithm, const unsigned char* keyBuffer, unsigned int keyBufferSize, const Credential* credential, bool compact
+ ) : m_algorithm(algorithm), m_keyBuffer(keyBuffer), m_keyBufferSize(keyBufferSize), m_credential(credential), m_compact(compact)
+{
+}
+
+Encrypter::EncryptionParams::~EncryptionParams()
+{
+}
+
+Encrypter::KeyEncryptionParams::KeyEncryptionParams(const Credential& credential, const XMLCh* algorithm, const XMLCh* recipient)
+ : m_credential(credential), m_algorithm(algorithm), m_recipient(recipient)
+{
+}
+
+Encrypter::KeyEncryptionParams::~KeyEncryptionParams()
+{
+}
+
+Encrypter::Encrypter() : m_cipher(NULL)
+{
+}
+
Encrypter::~Encrypter()
{
XMLToolingInternalConfig::getInternalConfig().m_xsecProvider->releaseCipher(m_cipher);
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "encryption/Encryption.h"
#include "io/AbstractXMLObjectMarshaller.h"
#include "io/AbstractXMLObjectUnmarshaller.h"
+#include "signature/KeyInfo.h"
#include "util/XMLHelper.h"
#include <xercesc/util/XMLUniDefs.hpp>
/*
-* Copyright 2001-2007 Internet2
+* Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "exceptions.h"
#include "encryption/Encryption.h"
+#include "validation/Validator.h"
#include "validation/ValidatorSuite.h"
using namespace xmlencryption;
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using namespace xercesc;
using namespace std;
+AnyElementImpl::AnyElementImpl()
+{
+}
+
+AnyElementImpl::AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
+ : AbstractXMLObject(nsURI, localName, prefix, schemaType)
+{
+}
+
+AnyElementImpl::~AnyElementImpl()
+{
+}
+
XMLObject* AnyElementImpl::clone() const {
auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
AnyElementImpl* ret=dynamic_cast<AnyElementImpl*>(domClone.get());
return new AnyElementImpl(*this);
}
-AnyElementImpl::AnyElementImpl(const AnyElementImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),
- AbstractComplexElement(src), AbstractAttributeExtensibleXMLObject(src) {
+AnyElementImpl::AnyElementImpl(const AnyElementImpl& src)
+ : AbstractXMLObject(src),
+ AbstractDOMCachingXMLObject(src),
+ AbstractComplexElement(src),
+ AbstractAttributeExtensibleXMLObject(src) {
const vector<XMLObject*>& children = src.getUnknownXMLObjects();
for (vector<XMLObject*>::const_iterator i=children.begin(); i!=children.end(); ++i)
getUnknownXMLObjects().push_back((*i)->clone());
}
-void AnyElementImpl::marshallAttributes(DOMElement* domElement) const {
+void AnyElementImpl::marshallAttributes(DOMElement* domElement) const
+{
marshallExtensionAttributes(domElement);
}
-void AnyElementImpl::processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+void AnyElementImpl::processChildElement(XMLObject* childXMLObject, const DOMElement* root)
+{
getUnknownXMLObjects().push_back(childXMLObject);
}
-void AnyElementImpl::processAttribute(const DOMAttr* attribute) {
+void AnyElementImpl::processAttribute(const DOMAttr* attribute)
+{
unmarshallExtensionAttribute(attribute);
}
XMLObject* AnyElementBuilder::buildObject(
const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType
- ) const {
+ ) const
+{
return new AnyElementImpl(nsURI, localName, prefix, schemaType);
}
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
/// @cond OFF
public:
- virtual ~AnyElementImpl() {}
+ virtual ~AnyElementImpl();
- AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL)
- : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
+ AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL);
XMLObject* clone() const;
protected:
- AnyElementImpl() {}
+ AnyElementImpl();
AnyElementImpl(const AnyElementImpl& src);
IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
/*
-* Copyright 2001-2007 Internet2
+* Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* UnknownElement.cpp
*
- * Basic implementation suitable for use as default for unrecognized content
+ * Basic implementation suitable for use as default for unrecognized content.
*/
#include "internal.h"
using xmlsignature::Signature;
#endif
+UnknownElementImpl::UnknownElementImpl(const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix)
+ : AbstractXMLObject(namespaceURI, elementLocalName, namespacePrefix)
+{
+}
+
+UnknownElementImpl::~UnknownElementImpl()
+{
+}
+
void UnknownElementImpl::releaseDOM() const
{
#ifdef _DEBUG
return ret;
}
+const XMLCh* UnknownElementImpl::getTextContent(unsigned int position) const
+{
+ throw XMLObjectException("Direct access to content is not permitted.");
+}
+
+void UnknownElementImpl::setTextContent(const XMLCh*, unsigned int position)
+{
+ throw XMLObjectException("Direct access to content is not permitted.");
+}
+
+void UnknownElementImpl::setDocumentElement(DOMDocument* document, DOMElement* element) const
+{
+ DOMElement* documentRoot = document->getDocumentElement();
+ if (documentRoot)
+ document->replaceChild(element, documentRoot);
+ else
+ document->appendChild(element);
+}
+
void UnknownElementImpl::serialize(string& s) const
{
if (getDOM())
XMLObject* UnknownElementBuilder::buildObject(
const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType
- ) const {
+ ) const
+{
return new UnknownElementImpl(nsURI,localName,prefix);
}
/*
-* Copyright 2001-2007 Internet2
+* Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @file xmltooling/impl/UnknownElement.h
*
- * Basic implementation suitable for use as default for unrecognized content
+ * Basic implementation suitable for use as default for unrecognized content.
*/
#ifndef __xmltooling_unkelement_h__
class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractSimpleElement, public AbstractDOMCachingXMLObject
{
public:
- UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL)
- : AbstractXMLObject(namespaceURI, elementLocalName, namespacePrefix) {}
+ UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL);
- void releaseDOM() const;
+ virtual ~UnknownElementImpl();
+ void releaseDOM() const;
XMLObject* clone() const;
-
- const XMLCh* getTextContent(unsigned int position=0) const {
- throw XMLObjectException("Direct access to content is not permitted.");
- }
-
- void setTextContent(const XMLCh*, unsigned int position=0) {
- throw XMLObjectException("Direct access to content is not permitted.");
- }
+ const XMLCh* getTextContent(unsigned int position=0) const;
+ void setTextContent(const XMLCh*, unsigned int position=0);
xercesc::DOMElement* marshall(
xercesc::DOMDocument* document=NULL
XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false);
protected:
- void setDocumentElement(xercesc::DOMDocument* document, xercesc::DOMElement* element) const {
- xercesc::DOMElement* documentRoot = document->getDocumentElement();
- if (documentRoot)
- document->replaceChild(element, documentRoot);
- else
- document->appendChild(element);
- }
+ void setDocumentElement(xercesc::DOMDocument* document, xercesc::DOMElement* element) const;
mutable std::string m_xml;
using namespace xercesc;
using namespace std;
+AbstractXMLObjectMarshaller::AbstractXMLObjectMarshaller()
+{
+}
+
+AbstractXMLObjectMarshaller::~AbstractXMLObjectMarshaller()
+{
+}
+
+void AbstractXMLObjectMarshaller::setDocumentElement(DOMDocument* document, DOMElement* element) const
+{
+ DOMElement* documentRoot = document->getDocumentElement();
+ if (documentRoot)
+ document->replaceChild(element, documentRoot);
+ else
+ document->appendChild(element);
+}
+
DOMElement* AbstractXMLObjectMarshaller::marshall(
DOMDocument* document
#ifndef XMLTOOLING_NO_XMLSEC
}
}
}
+
+void AbstractXMLObjectMarshaller::marshallAttributes(DOMElement* domElement) const
+{
+}
/*
-* Copyright 2001-2007 Internet2
+* Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API AbstractXMLObjectMarshaller : public virtual AbstractXMLObject
{
public:
- virtual ~AbstractXMLObjectMarshaller() {}
+ virtual ~AbstractXMLObjectMarshaller();
xercesc::DOMElement* marshall(
xercesc::DOMDocument* document=NULL
) const;
protected:
- AbstractXMLObjectMarshaller() {}
+ AbstractXMLObjectMarshaller();
/**
* Sets the given element as the Document Element of the given Document.
* @param document the document
* @param element the Element that will serve as the Document Element
*/
- void setDocumentElement(xercesc::DOMDocument* document, xercesc::DOMElement* element) const {
- xercesc::DOMElement* documentRoot = document->getDocumentElement();
- if (documentRoot)
- document->replaceChild(element, documentRoot);
- else
- document->appendChild(element);
- }
+ void setDocumentElement(xercesc::DOMDocument* document, xercesc::DOMElement* element) const;
#ifndef XMLTOOLING_NO_XMLSEC
/**
*
* @throws MarshallingException thrown if there is a problem marshalling an attribute
*/
- virtual void marshallAttributes(xercesc::DOMElement* domElement) const {}
+ virtual void marshallAttributes(xercesc::DOMElement* domElement) const;
};
};
using namespace xercesc;
using namespace std;
+AbstractXMLObjectUnmarshaller::AbstractXMLObjectUnmarshaller()
+{
+}
+
+AbstractXMLObjectUnmarshaller::~AbstractXMLObjectUnmarshaller()
+{
+}
XMLObject* AbstractXMLObjectUnmarshaller::unmarshall(DOMElement* element, bool bindDocument)
{
/*
-* Copyright 2001-2007 Internet2
+* Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual AbstractXMLObject
{
public:
- virtual ~AbstractXMLObjectUnmarshaller() {}
+ virtual ~AbstractXMLObjectUnmarshaller();
XMLObject* unmarshall(xercesc::DOMElement* element, bool bindDocument=false);
protected:
- AbstractXMLObjectUnmarshaller() {}
+ AbstractXMLObjectUnmarshaller();
/**
* Unmarshalls the attributes from the given DOM Element into the XMLObject. If the attribute
class XMLTOOL_API GenericRequest {
MAKE_NONCOPYABLE(GenericRequest);
protected:
- GenericRequest() {}
+ GenericRequest();
public:
- virtual ~GenericRequest() {}
+ virtual ~GenericRequest();
/**
* Returns the URL scheme of the request (http, https, ftp, ldap, etc.)
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API GenericResponse {
MAKE_NONCOPYABLE(GenericResponse);
protected:
- GenericResponse() {}
+ GenericResponse();
public:
- virtual ~GenericResponse() {}
+ virtual ~GenericResponse();
/**
* Sets or clears the MIME type of the response.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* HTTPRequest.cpp
*
- * Interface to HTTP requests
+ * Interface to HTTP requests.
*/
#include "internal.h"
using namespace xmltooling;
using namespace std;
+GenericRequest::GenericRequest()
+{
+}
+
+GenericRequest::~GenericRequest()
+{
+}
+
+HTTPRequest::HTTPRequest()
+{
+}
+
+HTTPRequest::~HTTPRequest()
+{
+}
+
+bool HTTPRequest::isSecure() const
+{
+ return strcmp(getScheme(),"https")==0;
+}
+
const char* HTTPRequest::getCookie(const char* name) const
{
if (m_cookieMap.empty()) {
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @file xmltooling/io/HTTPRequest.h
*
- * Interface to HTTP requests
+ * Interface to HTTP requests.
*/
#ifndef __xmltooling_httpreq_h__
*/
class XMLTOOL_API HTTPRequest : public GenericRequest {
protected:
- HTTPRequest() {}
+ HTTPRequest();
public:
- virtual ~HTTPRequest() {}
+ virtual ~HTTPRequest();
- bool isSecure() const {
- return strcmp(getScheme(),"https")==0;
- }
+ bool isSecure() const;
/**
* Returns the HTTP method of the request (GET, POST, etc.)
#include "HTTPResponse.h"
using namespace xmltooling;
+using std::istream;
+
+GenericResponse::GenericResponse()
+{
+}
+
+GenericResponse::~GenericResponse()
+{
+}
+
+HTTPResponse::HTTPResponse()
+{
+}
+
+HTTPResponse::~HTTPResponse()
+{
+}
+
+void HTTPResponse::setContentType(const char* type)
+{
+ setResponseHeader("Content-Type", type);
+}
void HTTPResponse::setCookie(const char* name, const char* value)
{
cookie = cookie + '=' + value;
setResponseHeader("Set-Cookie", cookie.c_str());
}
+
+long HTTPResponse::sendError(istream& inputStream)
+{
+ return sendResponse(inputStream, XMLTOOLING_HTTP_STATUS_ERROR);
+}
+
+long HTTPResponse::sendResponse(istream& inputStream)
+{
+ return sendResponse(inputStream, XMLTOOLING_HTTP_STATUS_OK);
+}
*/
class XMLTOOL_API HTTPResponse : public GenericResponse {
protected:
- HTTPResponse() {}
+ HTTPResponse();
public:
- virtual ~HTTPResponse() {}
+ virtual ~HTTPResponse();
- void setContentType(const char* type) {
- setResponseHeader("Content-Type", type);
- }
+ void setContentType(const char* type);
/**
* Sets or clears a response header.
XMLTOOLING_HTTP_STATUS_ERROR = 500
};
- using GenericResponse::sendResponse;
-
- long sendError(std::istream& inputStream) {
- return sendResponse(inputStream, XMLTOOLING_HTTP_STATUS_ERROR);
- }
+ long sendError(std::istream& inputStream);
- long sendResponse(std::istream& inputStream) {
- return sendResponse(inputStream, XMLTOOLING_HTTP_STATUS_OK);
- }
+ using GenericResponse::sendResponse;
+ long sendResponse(std::istream& inputStream);
};
};
#include <xmltooling/security/OpenSSLTrustEngine.h>
#include <xmltooling/security/SignatureTrustEngine.h>
-#include <xmltooling/security/XSECCryptoX509CRL.h>
namespace xmltooling {
+ class XMLTOOL_API XSECCryptoX509CRL;
+
/**
* A trust engine that uses X.509 trust anchors and CRLs associated with a peer
* to perform PKIX validation of signatures and credentials.
bool checkEntityNames(X509* certEE, const CredentialResolver& credResolver, const CredentialCriteria& criteria) const;
public:
- virtual ~AbstractPKIXTrustEngine() {}
+ virtual ~AbstractPKIXTrustEngine();
bool validate(
xmlsignature::Signature& sig,
class XMLTOOL_API PKIXValidationInfoIterator {
MAKE_NONCOPYABLE(PKIXValidationInfoIterator);
protected:
- PKIXValidationInfoIterator() {}
+ PKIXValidationInfoIterator();
public:
- virtual ~PKIXValidationInfoIterator() {}
+ virtual ~PKIXValidationInfoIterator();
/**
* Advances to the next set of information, if any.
#define __xmltooling_basicx509cred_h__
#include <xmltooling/security/X509Credential.h>
-#include <xmltooling/signature/KeyInfo.h>
-#include <algorithm>
+#include <set>
+#include <vector>
+#include <string>
+
+namespace xmlsignature {
+ class XMLTOOL_API KeyInfo;
+};
namespace xmltooling {
public:
virtual ~BasicX509Credential();
- // Virtual overrides.
+ // Virtual function overrides.
unsigned int getUsage() const;
const char* getAlgorithm() const;
unsigned int getKeySize() const;
#include <xmltooling/security/OpenSSLTrustEngine.h>
#include <xmltooling/security/SignatureTrustEngine.h>
+#include <vector>
+
namespace xmltooling {
/**
#define __xmltooling_cred_h__
#include <xmltooling/base.h>
-#include <xsec/enc/XSECCryptoKey.hpp>
#include <set>
#include <string>
+class XSECCryptoKey;
+
namespace xmlsignature {
class XMLTOOL_API KeyInfo;
};
{
MAKE_NONCOPYABLE(Credential);
protected:
- Credential() {}
+ Credential();
public:
- virtual ~Credential() {}
+ virtual ~Credential();
/**
* Bitmask constants for limiting resolution process inside a CredentialResolver.
*
* @return resolution context of the credential
*/
- virtual const CredentialContext* getCredentalContext() const {
- return NULL;
- }
+ virtual const CredentialContext* getCredentalContext() const;
};
};
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
MAKE_NONCOPYABLE(CredentialContext);
protected:
- CredentialContext() {}
+ CredentialContext();
public:
- virtual ~CredentialContext() {}
+ virtual ~CredentialContext();
};
};
*
* @return the usage mask
*/
- unsigned int getUsage() const {
- return m_keyUsage;
- }
+ unsigned int getUsage() const;
/**
* Set key usage criteria.
*
* @param usage the usage mask to set
*/
- void setUsage(unsigned int usage) {
- m_keyUsage = usage;
- }
+ void setUsage(unsigned int usage);
/**
* Get the peer name criteria.
*
* @return the peer name
*/
- const char* getPeerName() const {
- return m_peerName.c_str();
- }
+ const char* getPeerName() const;
/**
* Set the peer name criteria.
*
* @param peerName peer name to set
*/
- void setPeerName(const char* peerName) {
- m_peerName.erase();
- if (peerName)
- m_peerName = peerName;
- }
+ void setPeerName(const char* peerName);
/**
* Get the key algorithm criteria.
*
* @return the key algorithm
*/
- const char* getKeyAlgorithm() const {
- return m_keyAlgorithm.c_str();
- }
+ const char* getKeyAlgorithm() const;
/**
* Set the key algorithm criteria.
*
* @param keyAlgorithm The key algorithm to set
*/
- void setKeyAlgorithm(const char* keyAlgorithm) {
- m_keyAlgorithm.erase();
- if (keyAlgorithm)
- m_keyAlgorithm = keyAlgorithm;
- }
+ void setKeyAlgorithm(const char* keyAlgorithm);
/**
* Get the key size criteria.
*
* @return the key size, or 0
*/
- unsigned int getKeySize() const {
- return m_keySize;
- }
+ unsigned int getKeySize() const;
/**
* Set the key size criteria.
*
* @param keySize Key size to set
*/
- void setKeySize(unsigned int keySize) {
- m_keySize = keySize;
- }
+ void setKeySize(unsigned int keySize);
/**
* Set the key algorithm and size criteria based on an XML algorithm specifier.
*
* @return an immutable set of key names
*/
- const std::set<std::string>& getKeyNames() const {
- return m_keyNames;
- }
+ const std::set<std::string>& getKeyNames() const;
/**
* Gets key name criteria.
*
* @return a mutable set of key names
*/
- std::set<std::string>& getKeyNames() {
- return m_keyNames;
- }
+ std::set<std::string>& getKeyNames();
/**
* Returns the public key criteria.
*
* @return a public key
*/
- virtual XSECCryptoKey* getPublicKey() const {
- return m_key;
- }
+ virtual XSECCryptoKey* getPublicKey() const;
/**
* Sets the public key criteria.
*
* @param key a public key
*/
- void setPublicKey(XSECCryptoKey* key) {
- m_key = key;
- }
+ void setPublicKey(XSECCryptoKey* key);
/**
* Bitmask constants controlling the kinds of criteria set automatically
*
* @return the KeyInfo criteria
*/
- const xmlsignature::KeyInfo* getKeyInfo() const {
- return m_keyInfo;
- }
+ const xmlsignature::KeyInfo* getKeyInfo() const;
/**
* Sets the KeyInfo criteria.
*
* @return the native KeyInfo criteria
*/
- DSIGKeyInfoList* getNativeKeyInfo() const {
- return m_nativeKeyInfo;
- }
+ DSIGKeyInfoList* getNativeKeyInfo() const;
/**
* Sets the KeyInfo criteria.
{
MAKE_NONCOPYABLE(CredentialResolver);
protected:
- CredentialResolver() {}
+ CredentialResolver();
public:
- virtual ~CredentialResolver() {}
+ virtual ~CredentialResolver();
/**
* Returns a single Credential according to the supplied criteria.
*
* @param keyInfo surrounding KeyInfo context object
*/
- KeyInfoCredentialContext(const xmlsignature::KeyInfo* keyInfo=NULL) : m_keyInfo(keyInfo), m_nativeKeyInfo(NULL) {
- }
+ KeyInfoCredentialContext(const xmlsignature::KeyInfo* keyInfo=NULL);
/**
* Constructor
*
* @param keyInfo surrounding native KeyInfo context object
*/
- KeyInfoCredentialContext(DSIGKeyInfoList* keyInfo) : m_keyInfo(NULL), m_nativeKeyInfo(keyInfo) {
- }
+ KeyInfoCredentialContext(DSIGKeyInfoList* keyInfo);
- virtual ~KeyInfoCredentialContext() {}
+ virtual ~KeyInfoCredentialContext();
/**
* Gets the KeyInfo context.
*
* @return the KeyInfo context
*/
- const xmlsignature::KeyInfo* getKeyInfo() const {
- return m_keyInfo;
- }
+ const xmlsignature::KeyInfo* getKeyInfo() const;
/**
* Gets the native KeyInfo context.
*
* @return the native KeyInfo context
*/
- DSIGKeyInfoList* getNativeKeyInfo() const {
- return m_nativeKeyInfo;
- }
+ DSIGKeyInfoList* getNativeKeyInfo() const;
private:
const xmlsignature::KeyInfo* m_keyInfo;
class XMLTOOL_API KeyInfoResolver {
MAKE_NONCOPYABLE(KeyInfoResolver);
protected:
- KeyInfoResolver() {}
+ KeyInfoResolver();
public:
- virtual ~KeyInfoResolver() {}
+ virtual ~KeyInfoResolver();
/**
* Returns a credential based on the supplied KeyInfo information.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API OpenSSLCredential : public virtual X509Credential
{
protected:
- OpenSSLCredential() {}
+ OpenSSLCredential();
public:
- virtual ~OpenSSLCredential() {}
+ virtual ~OpenSSLCredential();
/**
* Attaches credential to an OpenSSL SSL context object.
class XMLTOOL_API OpenSSLCryptoX509CRL : public XSECCryptoX509CRL {
public:
/** Default constructor. */
- OpenSSLCryptoX509CRL() : mp_X509CRL(NULL), m_DERX509CRL("") {}
+ OpenSSLCryptoX509CRL();
virtual ~OpenSSLCryptoX509CRL();
- const XMLCh* getProviderName() const {
- return DSIGConstants::s_unicodeStrPROVOpenSSL;
- }
+ const XMLCh* getProviderName() const;
void loadX509CRLBase64Bin(const char* buf, unsigned int len);
- safeBuffer& getDEREncodingSB(void) {
- return m_DERX509CRL;
- }
+ safeBuffer& getDEREncodingSB();
/**
* Constructor
*
* @return native CRL object, or NULL
*/
- X509_CRL* getOpenSSLX509CRL() {
- return mp_X509CRL;
- }
+ X509_CRL* getOpenSSLX509CRL();
XSECCryptoX509CRL* clone() const;
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* @param e DOM to supply configuration for provider
*/
- OpenSSLTrustEngine(const xercesc::DOMElement* e=NULL) : X509TrustEngine(e) {}
+ OpenSSLTrustEngine(const xercesc::DOMElement* e=NULL);
public:
- virtual ~OpenSSLTrustEngine() {}
+ virtual ~OpenSSLTrustEngine();
using X509TrustEngine::validate;
#include <xmltooling/base.h>
+#include <string>
#include <vector>
class XSECCryptoKey;
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* @param e DOM to supply configuration for provider
*/
- SignatureTrustEngine(const xercesc::DOMElement* e=NULL) : TrustEngine(e) {}
+ SignatureTrustEngine(const xercesc::DOMElement* e=NULL);
public:
- virtual ~SignatureTrustEngine() {}
+ virtual ~SignatureTrustEngine();
/**
* Determines whether an XML signature is correct and valid with respect to
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define __xmltooling_x509cred_h__
#include <xmltooling/security/Credential.h>
-#include <xmltooling/security/XSECCryptoX509CRL.h>
-#include <xsec/enc/XSECCryptoX509.hpp>
+class XSECCryptoX509;
namespace xmltooling {
+ class XMLTOOL_API XSECCryptoX509CRL;
+
/**
* Wraps an X.509-based Credential.
*/
class XMLTOOL_API X509Credential : public virtual Credential
{
protected:
- X509Credential() {}
+ X509Credential();
public:
- virtual ~X509Credential() {}
+ virtual ~X509Credential();
/**
* Bitmask constants for limiting resolution process inside a CredentialResolver.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <xmltooling/security/TrustEngine.h>
#include <vector>
-#include <xsec/enc/XSECCryptoX509.hpp>
+
+class XSECCryptoX509;
namespace xmltooling {
*
* @param e DOM to supply configuration for provider
*/
- X509TrustEngine(const xercesc::DOMElement* e=NULL) : TrustEngine(e) {}
+ X509TrustEngine(const xercesc::DOMElement* e=NULL);
public:
- virtual ~X509TrustEngine() {}
+ virtual ~X509TrustEngine();
/**
* Determines whether an X.509 credential is valid with respect to the
class XMLTOOL_API XSECCryptoX509CRL {
MAKE_NONCOPYABLE(XSECCryptoX509CRL);
protected:
- XSECCryptoX509CRL() {}
+ XSECCryptoX509CRL();
public:
- virtual ~XSECCryptoX509CRL() {}
+ virtual ~XSECCryptoX509CRL();
/**
* Returns a string that identifies the crypto owner of this library.
}
};
+AbstractPKIXTrustEngine::PKIXValidationInfoIterator::PKIXValidationInfoIterator()
+{
+}
+
+AbstractPKIXTrustEngine::PKIXValidationInfoIterator::~PKIXValidationInfoIterator()
+{
+}
+
AbstractPKIXTrustEngine::AbstractPKIXTrustEngine(const xercesc::DOMElement* e) : TrustEngine(e), m_fullCRLChain(false)
{
static XMLCh fullCRLChain[] = UNICODE_LITERAL_12(f,u,l,l,C,R,L,C,h,a,i,n);
m_fullCRLChain = (flag && (*flag == xercesc::chLatin_t || *flag == xercesc::chDigit_1));
}
+AbstractPKIXTrustEngine::~AbstractPKIXTrustEngine()
+{
+}
+
bool AbstractPKIXTrustEngine::checkEntityNames(
X509* certEE, const CredentialResolver& credResolver, const CredentialCriteria& criteria
) const
#include "internal.h"
#include "security/BasicX509Credential.h"
+#include "security/KeyInfoCredentialContext.h"
+#include "security/OpenSSLCredential.h"
+#include "security/XSECCryptoX509CRL.h"
#include "signature/KeyInfo.h"
#include <algorithm>
using namespace xmltooling;
using namespace std;
+Credential::Credential()
+{
+}
+
+Credential::~Credential()
+{
+}
+
+const CredentialContext* Credential::getCredentalContext() const
+{
+ return NULL;
+}
+
+X509Credential::X509Credential()
+{
+}
+
+X509Credential::~X509Credential()
+{
+}
+
+OpenSSLCredential::OpenSSLCredential()
+{
+}
+
+OpenSSLCredential::~OpenSSLCredential()
+{
+}
+
+CredentialContext::CredentialContext()
+{
+}
+
+CredentialContext::~CredentialContext()
+{
+}
+
+KeyInfoCredentialContext::KeyInfoCredentialContext(const KeyInfo* keyInfo) : m_keyInfo(keyInfo), m_nativeKeyInfo(NULL)
+{
+}
+
+KeyInfoCredentialContext::KeyInfoCredentialContext(DSIGKeyInfoList* keyInfo) : m_keyInfo(NULL), m_nativeKeyInfo(keyInfo)
+{
+}
+
+KeyInfoCredentialContext::~KeyInfoCredentialContext()
+{
+}
+
+const KeyInfo* KeyInfoCredentialContext::getKeyInfo() const
+{
+ return m_keyInfo;
+}
+
+DSIGKeyInfoList* KeyInfoCredentialContext::getNativeKeyInfo() const
+{
+ return m_nativeKeyInfo;
+}
+
BasicX509Credential::BasicX509Credential(bool ownCerts) : m_key(NULL), m_ownCerts(ownCerts), m_keyInfo(NULL), m_compactKeyInfo(NULL)
{
}
#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
+using xmlsignature::KeyInfo;
+using xmlsignature::Signature;
using namespace xmltooling;
using namespace std;
delete m_credential;
}
+unsigned int CredentialCriteria::getUsage() const
+{
+ return m_keyUsage;
+}
+
+void CredentialCriteria::setUsage(unsigned int usage)
+{
+ m_keyUsage = usage;
+}
+
+const char* CredentialCriteria::getPeerName() const
+{
+ return m_peerName.c_str();
+}
+
+void CredentialCriteria::setPeerName(const char* peerName)
+{
+ m_peerName.erase();
+ if (peerName)
+ m_peerName = peerName;
+}
+
+const char* CredentialCriteria::getKeyAlgorithm() const
+{
+ return m_keyAlgorithm.c_str();
+}
+
+void CredentialCriteria::setKeyAlgorithm(const char* keyAlgorithm)
+{
+ m_keyAlgorithm.erase();
+ if (keyAlgorithm)
+ m_keyAlgorithm = keyAlgorithm;
+}
+
+unsigned int CredentialCriteria::getKeySize() const
+{
+ return m_keySize;
+}
+
+void CredentialCriteria::setKeySize(unsigned int keySize)
+{
+ m_keySize = keySize;
+}
+
void CredentialCriteria::setXMLAlgorithm(const XMLCh* algorithm)
{
if (algorithm) {
}
}
-void CredentialCriteria::setKeyInfo(const xmlsignature::KeyInfo* keyInfo, int extraction)
+const set<string>& CredentialCriteria::getKeyNames() const
+{
+ return m_keyNames;
+}
+
+set<string>& CredentialCriteria::getKeyNames()
+{
+ return m_keyNames;
+}
+
+XSECCryptoKey* CredentialCriteria::getPublicKey() const
+{
+ return m_key;
+}
+
+void CredentialCriteria::setPublicKey(XSECCryptoKey* key)
+{
+ m_key = key;
+}
+
+const KeyInfo* CredentialCriteria::getKeyInfo() const
+{
+ return m_keyInfo;
+}
+
+void CredentialCriteria::setKeyInfo(const KeyInfo* keyInfo, int extraction)
{
delete m_credential;
m_credential = NULL;
if (xcred)
xcred->extract();
}
-}
+}
+
+DSIGKeyInfoList* CredentialCriteria::getNativeKeyInfo() const
+{
+ return m_nativeKeyInfo;
+}
void CredentialCriteria::setNativeKeyInfo(DSIGKeyInfoList* keyInfo, int extraction)
{
}
}
-void CredentialCriteria::setSignature(const xmlsignature::Signature& sig, int extraction)
+void CredentialCriteria::setSignature(const Signature& sig, int extraction)
{
setXMLAlgorithm(sig.getSignatureAlgorithm());
- xmlsignature::KeyInfo* k = sig.getKeyInfo();
+ KeyInfo* k = sig.getKeyInfo();
if (k)
return setKeyInfo(k, extraction);
DSIGSignature* dsig = sig.getXMLSignature();
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* CredentialResolver.cpp
*
- * Registration of factories for built-in resolvers
+ * An API for resolving keys and certificates based on application criteria.
*/
#include "internal.h"
conf.CredentialResolverManager.registerFactory(FILESYSTEM_CREDENTIAL_RESOLVER, FilesystemCredentialResolverFactory);
conf.CredentialResolverManager.registerFactory(CHAINING_CREDENTIAL_RESOLVER, ChainingCredentialResolverFactory);
}
+
+CredentialResolver::CredentialResolver()
+{
+}
+
+CredentialResolver::~CredentialResolver()
+{
+}
/*
- * Copyright 2001-2008 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* FilesystemCredentialResolver.cpp
*
- * Supplies credentials from local files
+ * Supplies credentials from local files.
*/
#include "internal.h"
#include "security/KeyInfoResolver.h"
#include "security/OpenSSLCredential.h"
#include "security/SecurityHelper.h"
+#include "security/XSECCryptoX509CRL.h"
#include "util/NDC.h"
#include "util/PathResolver.h"
+#include "util/Threads.h"
#include "util/XMLHelper.h"
+#include <algorithm>
#include <sys/types.h>
#include <sys/stat.h>
#include <openssl/pkcs12.h>
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "security/BasicX509Credential.h"
#include "security/KeyInfoCredentialContext.h"
#include "security/KeyInfoResolver.h"
+#include "security/XSECCryptoX509CRL.h"
#include "signature/KeyInfo.h"
#include "signature/Signature.h"
#include "util/NDC.h"
/**
* KeyInfoResolver.cpp
*
- * Registration of factories for built-in resolvers
+ * Resolves credentials from KeyInfo information.
*/
#include "internal.h"
conf.KeyInfoResolverManager.registerFactory(INLINE_KEYINFO_RESOLVER, InlineKeyInfoResolverFactory);
}
+KeyInfoResolver::KeyInfoResolver()
+{
+}
+
+KeyInfoResolver::~KeyInfoResolver()
+{
+}
+
Credential* KeyInfoResolver::resolve(const Signature* sig, int types) const
{
const KeyInfo* keyInfo = sig->getKeyInfo();
using namespace xmltooling;
+OpenSSLCryptoX509CRL::OpenSSLCryptoX509CRL() : mp_X509CRL(NULL), m_DERX509CRL("")
+{
+}
+
OpenSSLCryptoX509CRL::~OpenSSLCryptoX509CRL()
{
if (mp_X509CRL)
BIO_free_all(b64);
}
-void OpenSSLCryptoX509CRL::loadX509CRLBase64Bin(const char* buf, unsigned int len) {
+const XMLCh* OpenSSLCryptoX509CRL::getProviderName() const
+{
+ return DSIGConstants::s_unicodeStrPROVOpenSSL;
+}
+
+void OpenSSLCryptoX509CRL::loadX509CRLBase64Bin(const char* buf, unsigned int len)
+{
// Free anything currently held.
}
+safeBuffer& OpenSSLCryptoX509CRL::getDEREncodingSB()
+{
+ return m_DERX509CRL;
+}
+
+X509_CRL* OpenSSLCryptoX509CRL::getOpenSSLX509CRL()
+{
+ return mp_X509CRL;
+}
+
XSECCryptoX509CRL* OpenSSLCryptoX509CRL::clone() const
{
OpenSSLCryptoX509CRL* copy = new OpenSSLCryptoX509CRL();
#include "internal.h"
#include "security/KeyInfoResolver.h"
-#include "security/TrustEngine.h"
+#include "security/SignatureTrustEngine.h"
+#include "security/OpenSSLTrustEngine.h"
#include "util/XMLHelper.h"
#include <xercesc/util/XMLUniDefs.hpp>
{
delete m_keyInfoResolver;
}
+
+SignatureTrustEngine::SignatureTrustEngine(const DOMElement* e) : TrustEngine(e)
+{
+}
+
+SignatureTrustEngine::~SignatureTrustEngine()
+{
+}
+
+X509TrustEngine::X509TrustEngine(const DOMElement* e) : TrustEngine(e)
+{
+}
+
+X509TrustEngine::~X509TrustEngine()
+{
+}
+
+OpenSSLTrustEngine::OpenSSLTrustEngine(const DOMElement* e) : X509TrustEngine(e)
+{
+}
+
+OpenSSLTrustEngine::~OpenSSLTrustEngine()
+{
+}
/*
- * Copyright 2001-2007 The Apache Software Foundation.
+ * Copyright 2001-2009 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using namespace xmltooling;
+XSECCryptoX509CRL::XSECCryptoX509CRL()
+{
+}
+
+XSECCryptoX509CRL::~XSECCryptoX509CRL()
+{
+}
+
void XSECCryptoX509CRL::loadX509CRLPEM(const char* buf, unsigned int len)
{
const char * b;
{
MAKE_NONCOPYABLE(ContentReference);
public:
- virtual ~ContentReference() {}
+ virtual ~ContentReference();
/**
* Given a native signature, asks the object to create the reference(s).
protected:
/** Default constructor. */
- ContentReference() {}
+ ContentReference();
};
};
#if !defined(__xmltooling_sig_h__) && !defined(XMLTOOLING_NO_XMLSEC)
#define __xmltooling_sig_h__
-#include <xmltooling/ConcreteXMLObjectBuilder.h>
#include <xmltooling/exceptions.h>
+#include <xmltooling/ConcreteXMLObjectBuilder.h>
class DSIGSignature;
class XSECCryptoKey;
class XMLTOOL_API Signature : public virtual xmltooling::XMLObject
{
public:
- virtual ~Signature() {}
+ virtual ~Signature();
/** Element local name */
static const XMLCh LOCAL_NAME[];
protected:
/** Default constructor. */
- Signature() {}
+ Signature();
};
/**
/**
* @file xmltooling/signature/SignatureValidator.h
*
- * Validator for signatures based on an externally-supplied key
+ * Validator for signatures based on an externally-supplied key.
*/
#if !defined(__xmltooling_sigval_h__) && !defined(XMLTOOLING_NO_XMLSEC)
*/
SignatureValidator(const xmltooling::Credential* credential);
- virtual ~SignatureValidator() {}
+ virtual ~SignatureValidator();
void validate(const xmltooling::XMLObject* xmlObject) const;
/*
-* Copyright 2001-2007 Internet2
+* Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "exceptions.h"
#include "signature/KeyInfo.h"
+#include "validation/Validator.h"
#include "validation/ValidatorSuite.h"
using namespace xmlsignature;
{
}
+SignatureValidator::~SignatureValidator()
+{
+}
+
void SignatureValidator::setKey(XSECCryptoKey* key)
{
m_key = key;
using xmlconstants::XMLSIG_NS;
using xmlconstants::XMLSIG_PREFIX;
+namespace xmlsignature {
+
#if defined (_MSC_VER)
#pragma warning( push )
#pragma warning( disable : 4250 4251 )
#endif
-
-namespace xmlsignature {
class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature
{
mutable KeyInfo* m_keyInfo;
ContentReference* m_reference;
};
-
-};
#if defined (_MSC_VER)
#pragma warning( pop )
#endif
+};
+
+ContentReference::ContentReference()
+{
+}
+
+ContentReference::~ContentReference()
+{
+}
+
+Signature::Signature()
+{
+}
+
+Signature::~Signature()
+{
+}
XMLSecSignatureImpl::~XMLSecSignatureImpl()
{
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API HTTPSOAPTransport : public virtual SOAPTransport
{
protected:
- HTTPSOAPTransport() {}
+ HTTPSOAPTransport();
public:
- virtual ~HTTPSOAPTransport() {}
+ virtual ~HTTPSOAPTransport();
/**
* Indicate whether content should be sent using HTTP 1.1 and
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class XMLTOOL_API OpenSSLSOAPTransport : public virtual SOAPTransport
{
protected:
- OpenSSLSOAPTransport() {}
+ OpenSSLSOAPTransport();
public:
- virtual ~OpenSSLSOAPTransport() {}
+ virtual ~OpenSSLSOAPTransport();
/** OpenSSL context callback for manipulating credentials and validation behavior. */
typedef bool (*ssl_ctx_callback_fn)(OpenSSLSOAPTransport* transport, SSL_CTX* ssl_ctx, void* userptr);
/*
- * Copyright 2001-2008 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <xmltooling/ConcreteXMLObjectBuilder.h>
#include <xmltooling/ElementProxy.h>
#include <xmltooling/util/XMLConstants.h>
-#include <xercesc/util/XMLUniDefs.hpp>
/**
* Macro for declaring SOAP builders.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#ifndef __xmltooling_soap11client_h__
#define __xmltooling_soap11client_h__
-#include <xmltooling/security/CredentialResolver.h>
#include <xmltooling/soap/SOAPTransport.h>
namespace soap11 {
*
* @param validate true iff schema validation should be used
*/
- SOAPClient(bool validate=false) : m_validate(validate), m_transport(NULL) {}
+ SOAPClient(bool validate=false);
virtual ~SOAPClient();
*
* @param validate true iff the client should use a validating XML parser
*/
- void setValidating(bool validate=true) {
- m_validate = validate;
- }
+ void setValidating(bool validate=true);
/**
* Sends the supplied envelope to the identified recipient/endpoint.
*
* @param transport reference to transport layer
*/
- virtual void prepareTransport(xmltooling::SOAPTransport& transport) {}
+ virtual void prepareTransport(xmltooling::SOAPTransport& transport);
/**
* Handling of SOAP faults.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
MAKE_NONCOPYABLE(SOAPTransport);
protected:
- SOAPTransport() {}
+ SOAPTransport();
public:
- virtual ~SOAPTransport() {}
+ virtual ~SOAPTransport();
/**
* A simple structure to capture SOAP addressing information.
* @param value implementation- and option-specific string to use
* @return true iff the transport supports the option and value supplied
*/
- virtual bool setProviderOption(const char* provider, const char* option, const char* value) {
- return false;
- }
+ virtual bool setProviderOption(const char* provider, const char* option, const char* value);
/**
* Sends a stream of data over the transport. The function may return without
g_CURLPool = NULL;
}
+SOAPTransport::SOAPTransport()
+{
+}
+
+SOAPTransport::~SOAPTransport()
+{
+}
+
+bool SOAPTransport::setProviderOption(const char* provider, const char* option, const char* value)
+{
+ return false;
+}
+
+HTTPSOAPTransport::HTTPSOAPTransport()
+{
+}
+
+HTTPSOAPTransport::~HTTPSOAPTransport()
+{
+}
+
+OpenSSLSOAPTransport::OpenSSLSOAPTransport()
+{
+}
+
+OpenSSLSOAPTransport::~OpenSSLSOAPTransport()
+{
+}
+
CURLPool::~CURLPool()
{
for (poolmap_t::iterator i=m_bindingMap.begin(); i!=m_bindingMap.end(); i++) {
using namespace xercesc;
using namespace std;
-void SOAPTransport::send(istream* in)
+SOAPClient::SOAPClient(bool validate) : m_validate(validate), m_transport(NULL)
{
- if (!in)
- throw IOException("SOAP transport does not support an empty request body.");
- return send(*in);
}
SOAPClient::~SOAPClient()
delete m_transport;
}
+void SOAPClient::setValidating(bool validate)
+{
+ m_validate = validate;
+}
+
void SOAPClient::reset()
{
delete m_transport;
m_transport=NULL;
}
+void SOAPTransport::send(istream* in)
+{
+ if (!in)
+ throw IOException("SOAP transport does not support an empty request body.");
+ return send(*in);
+}
+
void SOAPClient::send(const Envelope& env, const SOAPTransport::Address& addr)
{
// Prepare a transport object.
return env;
}
+void SOAPClient::prepareTransport(SOAPTransport& transport)
+{
+}
+
bool SOAPClient::handleFault(const Fault& fault)
{
const xmltooling::QName* code = (fault.getFaultcode() ? fault.getFaultcode()->getCode() : NULL);
/*
-* Copyright 2001-2007 Internet2
+* Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* SOAPSchemaValidators.cpp
*
- * Schema validators for SOAP schema
+ * Schema validators for SOAP schema.
*/
#include "internal.h"
#include "exceptions.h"
#include "soap/SOAP.h"
+#include "validation/Validator.h"
#include "validation/ValidatorSuite.h"
using namespace soap11;
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return;
}
+void DateTime::setBuffer(const XMLCh* const aString)
+{
+ reset();
+ fEnd = (int) xercesc::XMLString::stringLen(aString);
+ if (fEnd > 0) {
+ if (fEnd > fBufferMaxLen) {
+ delete[] fBuffer;
+ fBufferMaxLen = fEnd + 8;
+ fBuffer = new XMLCh[fBufferMaxLen+1];
+ }
+ memcpy(fBuffer, aString, (fEnd+1) * sizeof(XMLCh));
+ }
+}
+
+void DateTime::reset()
+{
+ for ( int i=0; i < xercesc::XMLDateTime::TOTAL_SIZE; i++ )
+ fValue[i] = 0;
+
+ fMiliSecond = 0;
+ fHasTime = false;
+ fTimeZone[hh] = fTimeZone[mm] = 0;
+ fStart = fEnd = 0;
+
+ if (fBuffer)
+ *fBuffer = 0;
+}
+
+void DateTime::copy(const DateTime& rhs)
+{
+ for ( int i = 0; i < xercesc::XMLDateTime::TOTAL_SIZE; i++ )
+ fValue[i] = rhs.fValue[i];
+
+ fMiliSecond = rhs.fMiliSecond;
+ fHasTime = rhs.fHasTime;
+ fTimeZone[hh] = rhs.fTimeZone[hh];
+ fTimeZone[mm] = rhs.fTimeZone[mm];
+ fStart = rhs.fStart;
+ fEnd = rhs.fEnd;
+
+ if (fEnd > 0) {
+ if (fEnd > fBufferMaxLen) {
+ delete[] fBuffer;
+ fBufferMaxLen = rhs.fBufferMaxLen;
+ fBuffer = new XMLCh[fBufferMaxLen+1];
+ }
+ memcpy(fBuffer, rhs.fBuffer, (fEnd+1) * sizeof(XMLCh));
+ }
+}
+
+void DateTime::initParser()
+{
+ fStart = 0; // to ensure scan from the very first beginning
+ // in case the pointer is updated accidentally by someone else.
+}
+
+bool DateTime::isNormalized() const
+{
+ return (fValue[xercesc::XMLDateTime::utc] == xercesc::XMLDateTime::UTC_STD ? true : false);
+}
+
+int DateTime::getRetVal(int c1, int c2)
+{
+ if ((c1 == xercesc::XMLDateTime::LESS_THAN && c2 == xercesc::XMLDateTime::GREATER_THAN) ||
+ (c1 == xercesc::XMLDateTime::GREATER_THAN && c2 == xercesc::XMLDateTime::LESS_THAN))
+ return xercesc::XMLDateTime::INDETERMINATE;
+
+ return (c1 != xercesc::XMLDateTime::INDETERMINATE) ? c1 : c2;
+}
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DateTime& operator=(const DateTime&);
~DateTime();
- inline void setBuffer(const XMLCh* const);
+ void setBuffer(const XMLCh* const);
const XMLCh* getRawData() const;
const XMLCh* getFormattedString() const;
static int compareResult(int, int, bool);
static void addDuration(DateTime* pDuration, const DateTime* const pBaseDate, int index);
static int compareResult(const DateTime* const, const DateTime* const, bool, int);
- static inline int getRetVal(int, int);
+ static int getRetVal(int, int);
- inline void reset();
+ void reset();
//inline void assertBuffer() const;
- inline void copy(const DateTime&);
+ void copy(const DateTime&);
- inline void initParser();
- inline bool isNormalized() const;
+ void initParser();
+ bool isNormalized() const;
void getDate();
void getTime();
double fMiliSecond;
bool fHasTime;
};
-
- inline void DateTime::setBuffer(const XMLCh* const aString)
- {
- reset();
- fEnd = (int) xercesc::XMLString::stringLen(aString);
- if (fEnd > 0) {
- if (fEnd > fBufferMaxLen) {
- delete[] fBuffer;
- fBufferMaxLen = fEnd + 8;
- fBuffer = new XMLCh[fBufferMaxLen+1];
- }
- memcpy(fBuffer, aString, (fEnd+1) * sizeof(XMLCh));
- }
- }
-
- inline void DateTime::reset()
- {
- for ( int i=0; i < xercesc::XMLDateTime::TOTAL_SIZE; i++ )
- fValue[i] = 0;
-
- fMiliSecond = 0;
- fHasTime = false;
- fTimeZone[hh] = fTimeZone[mm] = 0;
- fStart = fEnd = 0;
-
- if (fBuffer)
- *fBuffer = 0;
- }
-
- inline void DateTime::copy(const DateTime& rhs)
- {
- for ( int i = 0; i < xercesc::XMLDateTime::TOTAL_SIZE; i++ )
- fValue[i] = rhs.fValue[i];
-
- fMiliSecond = rhs.fMiliSecond;
- fHasTime = rhs.fHasTime;
- fTimeZone[hh] = rhs.fTimeZone[hh];
- fTimeZone[mm] = rhs.fTimeZone[mm];
- fStart = rhs.fStart;
- fEnd = rhs.fEnd;
-
- if (fEnd > 0) {
- if (fEnd > fBufferMaxLen) {
- delete[] fBuffer;
- fBufferMaxLen = rhs.fBufferMaxLen;
- fBuffer = new XMLCh[fBufferMaxLen+1];
- }
- memcpy(fBuffer, rhs.fBuffer, (fEnd+1) * sizeof(XMLCh));
- }
- }
-
- inline void DateTime::initParser()
- {
- fStart = 0; // to ensure scan from the very first beginning
- // in case the pointer is updated accidentally by someone else.
- }
-
- inline bool DateTime::isNormalized() const
- {
- return (fValue[xercesc::XMLDateTime::utc] == xercesc::XMLDateTime::UTC_STD ? true : false);
- }
-
- inline int DateTime::getRetVal(int c1, int c2)
- {
- if ((c1 == xercesc::XMLDateTime::LESS_THAN && c2 == xercesc::XMLDateTime::GREATER_THAN) ||
- (c1 == xercesc::XMLDateTime::GREATER_THAN && c2 == xercesc::XMLDateTime::LESS_THAN))
- return xercesc::XMLDateTime::INDETERMINATE;
-
- return (c1 != xercesc::XMLDateTime::INDETERMINATE) ? c1 : c2;
- }
-
}
#endif /* __xmltool_datetime_h__ */
/*
- * Copyright 2001-2008 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "util/CurlURLInputStream.h"
#include "util/NDC.h"
#include "util/ParserPool.h"
+#include "util/Threads.h"
#include "util/XMLHelper.h"
#include <algorithm>
#endif
+StreamInputSource::StreamInputSource(istream& is, const char* systemId) : InputSource(systemId), m_is(is)
+{
+}
+
+BinInputStream* StreamInputSource::makeStream() const
+{
+ return new StreamBinInputStream(m_is);
+}
+
+StreamInputSource::StreamBinInputStream::StreamBinInputStream(istream& is) : m_is(is), m_pos(0)
+{
+}
+
+#ifdef XMLTOOLING_XERCESC_64BITSAFE
+XMLFilePos
+#else
+unsigned int
+#endif
+StreamInputSource::StreamBinInputStream::curPos() const
+{
+ return m_pos;
+}
+
+#ifdef XMLTOOLING_XERCESC_64BITSAFE
+const XMLCh* StreamInputSource::StreamBinInputStream::getContentType() const
+{
+ return NULL;
+}
+#endif
+
xsecsize_t StreamInputSource::StreamBinInputStream::readBytes(XMLByte* const toFill, const xsecsize_t maxToRead)
{
XMLByte* target=toFill;
/*
- * Copyright 2001-2008 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define __xmltooling_pool_h__
#include <xmltooling/unicode.h>
-#include <xmltooling/util/Threads.h>
#include <map>
#include <stack>
namespace xmltooling {
+ class XMLTOOL_API Mutex;
+
/**
* A thread-safe pool of DOMBuilders that share characteristics.
*/
* @param is reference to an input stream
* @param systemId optional system identifier to attach to the stream
*/
- StreamInputSource(std::istream& is, const char* systemId=NULL) : xercesc::InputSource(systemId), m_is(is) {}
+ StreamInputSource(std::istream& is, const char* systemId=NULL);
/// @cond off
- virtual xercesc::BinInputStream* makeStream() const { return new StreamBinInputStream(m_is); }
+ xercesc::BinInputStream* makeStream() const;
/// @endcond
/**
*
* @param is reference to an input stream
*/
- StreamBinInputStream(std::istream& is) : m_is(is), m_pos(0) {}
+ StreamBinInputStream(std::istream& is);
/// @cond off
#ifdef XMLTOOLING_XERCESC_64BITSAFE
- XMLFilePos
+ XMLFilePos curPos() const;
+ const XMLCh* getContentType() const;
#else
- unsigned int
+ unsigned int curPos() const;
#endif
- curPos() const { return m_pos; }
xsecsize_t readBytes(XMLByte* const toFill, const xsecsize_t maxToRead);
-#ifdef XMLTOOLING_XERCESC_64BITSAFE
- const XMLCh* getContentType() const { return NULL; }
-#endif
/// @endcond
private:
std::istream& m_is;
setCfgDir("/etc");
}
+PathResolver::~PathResolver()
+{
+}
+
+void PathResolver::setDefaultPackageName(const char* pkgname)
+{
+ m_defaultPackage = pkgname;
+}
+
+void PathResolver::setDefaultPrefix(const char* prefix)
+{
+ m_defaultPrefix = prefix;
+}
+
+void PathResolver::setLibDir(const char* dir)
+{
+ m_lib = dir;
+}
+
+void PathResolver::setLogDir(const char* dir)
+{
+ m_log = dir;
+}
+
+void PathResolver::setXMLDir(const char* dir)
+{
+ m_xml = dir;
+}
+
+void PathResolver::setRunDir(const char* dir)
+{
+ m_run = dir;
+}
+
+void PathResolver::setCfgDir(const char* dir)
+{
+ m_cfg = dir;
+}
+
bool PathResolver::isAbsolute(const char* s) const
{
switch (*s) {
MAKE_NONCOPYABLE(PathResolver);
public:
PathResolver();
- virtual ~PathResolver() {}
+ virtual ~PathResolver();
/** Types of file resources to resolve. */
enum file_type_t {
*
* @param pkgname name of default package to use
*/
- virtual void setDefaultPackageName(const char* pkgname) {
- m_defaultPackage = pkgname;
- }
+ virtual void setDefaultPackageName(const char* pkgname);
/**
* Set the default installation prefix to use when resolving files.
*
* @param prefix name of default prefix to use
*/
- virtual void setDefaultPrefix(const char* prefix) {
- m_defaultPrefix = prefix;
- }
+ virtual void setDefaultPrefix(const char* prefix);
/**
* Set the lib directory to use when resolving files.
*
* @param dir the library directory to use
*/
- virtual void setLibDir(const char* dir) {
- m_lib = dir;
- }
+ virtual void setLibDir(const char* dir);
/**
* Set the log directory to use when resolving files.
*
* @param dir the log directory to use
*/
- virtual void setLogDir(const char* dir) {
- m_log = dir;
- }
+ virtual void setLogDir(const char* dir);
/**
* Set the XML directory to use when resolving files.
*
* @param dir the XML directory to use
*/
- virtual void setXMLDir(const char* dir) {
- m_xml = dir;
- }
+ virtual void setXMLDir(const char* dir);
/**
* Set the run directory to use when resolving files.
*
* @param dir the run directory to use
*/
- virtual void setRunDir(const char* dir) {
- m_run = dir;
- }
+ virtual void setRunDir(const char* dir);
/**
* Set the config directory to use when resolving files.
*
* @param dir the config directory to use
*/
- virtual void setCfgDir(const char* dir) {
- m_cfg = dir;
- }
+ virtual void setCfgDir(const char* dir);
/**
* Changes the input filename into an absolute pathname to the same file.
-/*\r
- * Copyright 2001-2009 Internet2\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * @file ReloadableXMLFile.cpp\r
- *\r
- * Base class for file-based XML configuration.\r
- */\r
-\r
-#include "internal.h"\r
-#include "util/NDC.h"\r
-#include "util/PathResolver.h"\r
-#include "util/ReloadableXMLFile.h"\r
-#include "util/XMLConstants.h"\r
-#include "util/XMLHelper.h"\r
-\r
-#include <fstream>\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-\r
-#include <xercesc/framework/LocalFileInputSource.hpp>\r
-#include <xercesc/framework/Wrapper4InputSource.hpp>\r
-#include <xercesc/util/XMLUniDefs.hpp>\r
-\r
-using namespace xmltooling::logging;\r
-using namespace xmltooling;\r
-using namespace xercesc;\r
-using namespace std;\r
-\r
-static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i);\r
-static const XMLCh url[] = UNICODE_LITERAL_3(u,r,l);\r
-static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h);\r
-static const XMLCh pathname[] = UNICODE_LITERAL_8(p,a,t,h,n,a,m,e);\r
-static const XMLCh file[] = UNICODE_LITERAL_4(f,i,l,e);\r
-static const XMLCh filename[] = UNICODE_LITERAL_8(f,i,l,e,n,a,m,e);\r
-static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);\r
-static const XMLCh reloadChanges[] = UNICODE_LITERAL_13(r,e,l,o,a,d,C,h,a,n,g,e,s);\r
-static const XMLCh reloadInterval[] = UNICODE_LITERAL_14(r,e,l,o,a,d,I,n,t,e,r,v,a,l);\r
-static const XMLCh backingFilePath[] = UNICODE_LITERAL_15(b,a,c,k,i,n,g,F,i,l,e,P,a,t,h);\r
-\r
+/*
+ * Copyright 2001-2009 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ReloadableXMLFile.cpp
+ *
+ * Base class for file-based XML configuration.
+ */
+
+#include "internal.h"
+#include "util/NDC.h"
+#include "util/PathResolver.h"
+#include "util/ReloadableXMLFile.h"
+#include "util/Threads.h"
+#include "util/XMLConstants.h"
+#include "util/XMLHelper.h"
+
+#include <fstream>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <xercesc/framework/LocalFileInputSource.hpp>
+#include <xercesc/framework/Wrapper4InputSource.hpp>
+#include <xercesc/util/XMLUniDefs.hpp>
+
+using namespace xmltooling::logging;
+using namespace xmltooling;
+using namespace xercesc;
+using namespace std;
+
+static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i);
+static const XMLCh url[] = UNICODE_LITERAL_3(u,r,l);
+static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h);
+static const XMLCh pathname[] = UNICODE_LITERAL_8(p,a,t,h,n,a,m,e);
+static const XMLCh file[] = UNICODE_LITERAL_4(f,i,l,e);
+static const XMLCh filename[] = UNICODE_LITERAL_8(f,i,l,e,n,a,m,e);
+static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);
+static const XMLCh reloadChanges[] = UNICODE_LITERAL_13(r,e,l,o,a,d,C,h,a,n,g,e,s);
+static const XMLCh reloadInterval[] = UNICODE_LITERAL_14(r,e,l,o,a,d,I,n,t,e,r,v,a,l);
+static const XMLCh backingFilePath[] = UNICODE_LITERAL_15(b,a,c,k,i,n,g,F,i,l,e,P,a,t,h);
+
ReloadableXMLFile::~ReloadableXMLFile()
{
delete m_lock;
}
-\r
-ReloadableXMLFile::ReloadableXMLFile(const DOMElement* e, Category& log)\r
- : m_root(e), m_local(true), m_validate(false), m_filestamp(0), m_reloadInterval(0), m_lock(NULL), m_log(log)\r
-{\r
-#ifdef _DEBUG\r
- NDC ndc("ReloadableXMLFile");\r
-#endif\r
-\r
- // Establish source of data...\r
- const XMLCh* source=e->getAttributeNS(NULL,uri);\r
- if (!source || !*source) {\r
- source=e->getAttributeNS(NULL,url);\r
- if (!source || !*source) {\r
- source=e->getAttributeNS(NULL,path);\r
- if (!source || !*source) {\r
- source=e->getAttributeNS(NULL,pathname);\r
- if (!source || !*source) {\r
- source=e->getAttributeNS(NULL,file);\r
- if (!source || !*source) {\r
- source=e->getAttributeNS(NULL,filename);\r
- }\r
- }\r
- }\r
- }\r
- else\r
- m_local=false;\r
- }\r
- else\r
- m_local=false;\r
-\r
- if (source && *source) {\r
- const XMLCh* flag=e->getAttributeNS(NULL,validate);\r
- m_validate=(XMLString::equals(flag,xmlconstants::XML_TRUE) || XMLString::equals(flag,xmlconstants::XML_ONE));\r
-\r
- auto_ptr_char temp(source);\r
- m_source=temp.get();\r
-\r
- if (!m_local && !strstr(m_source.c_str(),"://")) {\r
- log.warn("deprecated usage of uri/url attribute for a local resource, use path instead");\r
- m_local=true;\r
- }\r
-\r
- if (m_local) {\r
- XMLToolingConfig::getConfig().getPathResolver()->resolve(m_source, PathResolver::XMLTOOLING_CFG_FILE);\r
-\r
- flag=e->getAttributeNS(NULL,reloadChanges);\r
- if (!XMLString::equals(flag,xmlconstants::XML_FALSE) && !XMLString::equals(flag,xmlconstants::XML_ZERO)) {\r
-#ifdef WIN32\r
- struct _stat stat_buf;\r
- if (_stat(m_source.c_str(), &stat_buf) == 0)\r
-#else\r
- struct stat stat_buf;\r
- if (stat(m_source.c_str(), &stat_buf) == 0)\r
-#endif\r
- m_filestamp=stat_buf.st_mtime;\r
- else\r
- throw IOException("Unable to access local file ($1)", params(1,m_source.c_str()));\r
- m_lock=RWLock::create();\r
- }\r
- log.debug("using local resource (%s), will %smonitor for changes", m_source.c_str(), m_lock ? "" : "not ");\r
- }\r
- else {\r
- log.debug("using remote resource (%s)", m_source.c_str());\r
- source = e->getAttributeNS(NULL,backingFilePath);\r
- if (source && *source) {\r
- auto_ptr_char temp2(source);\r
- m_backing=temp2.get();\r
- XMLToolingConfig::getConfig().getPathResolver()->resolve(m_backing, PathResolver::XMLTOOLING_RUN_FILE);\r
- log.debug("backup remote resource with (%s)", m_backing.c_str());\r
- }\r
- source = e->getAttributeNS(NULL,reloadInterval);\r
- if (source && *source) {\r
- m_reloadInterval = XMLString::parseInt(source);\r
- if (m_reloadInterval > 0) {\r
- m_log.debug("will reload remote resource at most every %d seconds", m_reloadInterval);\r
- m_lock=RWLock::create();\r
- }\r
- }\r
- m_filestamp = time(NULL); // assume it gets loaded initially\r
- }\r
- }\r
- else {\r
- log.debug("no resource uri/path/name supplied, will load inline configuration");\r
- }\r
-}\r
-\r
-pair<bool,DOMElement*> ReloadableXMLFile::load(bool backup)\r
-{\r
-#ifdef _DEBUG\r
- NDC ndc("init");\r
-#endif\r
-\r
- try {\r
- if (m_source.empty()) {\r
- // Data comes from the DOM we were handed.\r
- m_log.debug("loading inline configuration...");\r
- return make_pair(false,XMLHelper::getFirstChildElement(m_root));\r
- }\r
- else {\r
- // Data comes from a file we have to parse.\r
- if (backup)\r
- m_log.warn("using local backup of remote resource");\r
- else\r
- m_log.debug("loading configuration from external resource...");\r
-\r
- DOMDocument* doc=NULL;\r
- if (m_local || backup) {\r
- auto_ptr_XMLCh widenit(backup ? m_backing.c_str() : m_source.c_str());\r
- LocalFileInputSource src(widenit.get());\r
- Wrapper4InputSource dsrc(&src,false);\r
- if (m_validate)\r
- doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc);\r
- else\r
- doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);\r
- }\r
- else {\r
- URLInputSource src(m_root);\r
- Wrapper4InputSource dsrc(&src,false);\r
- if (m_validate)\r
- doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc);\r
- else\r
- doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);\r
- }\r
-\r
- m_log.infoStream() << "loaded XML resource (" << (backup ? m_backing : m_source) << ")" << logging::eol;\r
-\r
- if (!backup && !m_backing.empty()) {\r
- m_log.debug("backing up remote resource to (%s)", m_backing.c_str());\r
- try {\r
- ofstream backer(m_backing.c_str());\r
- backer << *doc;\r
- }\r
- catch (exception& ex) {\r
- m_log.crit("exception while backing up resource: %s", ex.what());\r
- }\r
- }\r
-\r
- return make_pair(true,doc->getDocumentElement());\r
- }\r
- }\r
- catch (XMLException& e) {\r
- auto_ptr_char msg(e.getMessage());\r
- m_log.errorStream() << "Xerces error while loading resource (" << (backup ? m_backing : m_source) << "): "\r
- << msg.get() << logging::eol;\r
- if (!backup && !m_backing.empty())\r
- return load(true);\r
- throw XMLParserException(msg.get());\r
- }\r
- catch (exception& e) {\r
- m_log.errorStream() << "error while loading configuration from ("\r
- << (m_source.empty() ? "inline" : (backup ? m_backing : m_source)) << "): " << e.what() << logging::eol;\r
- if (!backup && !m_backing.empty())\r
- return load(true);\r
- throw;\r
- }\r
-}\r
-\r
-Lockable* ReloadableXMLFile::lock()\r
-{\r
- if (!m_lock)\r
- return this;\r
-\r
- m_lock->rdlock();\r
-\r
- // Check if we need to refresh.\r
- if (m_local) {\r
-#ifdef WIN32\r
- struct _stat stat_buf;\r
- if (_stat(m_source.c_str(), &stat_buf) != 0)\r
- return this;\r
-#else\r
- struct stat stat_buf;\r
- if (stat(m_source.c_str(), &stat_buf) != 0)\r
- return this;\r
-#endif\r
- if (m_filestamp>=stat_buf.st_mtime)\r
- return this;\r
-\r
- // Elevate lock and recheck.\r
- m_log.debug("timestamp of local resource changed, elevating to a write lock");\r
- m_lock->unlock();\r
- m_lock->wrlock();\r
- if (m_filestamp>=stat_buf.st_mtime) {\r
- // Somebody else handled it, just downgrade.\r
- m_log.debug("update of local resource handled by another thread, downgrading lock");\r
- m_lock->unlock();\r
- m_lock->rdlock();\r
- return this;\r
- }\r
-\r
- // Update the timestamp regardless. No point in repeatedly trying.\r
- m_filestamp=stat_buf.st_mtime;\r
- m_log.info("change detected, reloading local resource...");\r
- }\r
- else {\r
- time_t now = time(NULL);\r
-\r
- // Time to reload? If we have no data, filestamp is zero\r
- // and there's no way current time is less than the interval.\r
- if (now - m_filestamp < m_reloadInterval)\r
- return this;\r
-\r
- // Elevate lock and recheck.\r
- m_log.debug("reload interval for remote resource elapsed, elevating to a write lock");\r
- m_lock->unlock();\r
- m_lock->wrlock();\r
- if (now - m_filestamp < m_reloadInterval) {\r
- // Somebody else handled it, just downgrade.\r
- m_log.debug("update of remote resource handled by another thread, downgrading lock");\r
- m_lock->unlock();\r
- m_lock->rdlock();\r
- return this;\r
- }\r
-\r
- m_filestamp = now;\r
- m_log.info("reloading remote resource...");\r
- }\r
-\r
- // Do this once...\r
- try {\r
- // At this point we're holding the write lock, so make sure we pop it.\r
- SharedLock lockwrap(m_lock,false);\r
- pair<bool,DOMElement*> ret=load();\r
- if (ret.first)\r
- ret.second->getOwnerDocument()->release();\r
- } catch (exception& ex) {\r
- m_log.crit("maintaining existing configuration, error reloading resource (%s): %s", m_source.c_str(), ex.what());\r
- }\r
-\r
- // If we made it here, the swap may or may not have worked, but we need to relock.\r
- m_log.debug("attempt to update resource complete, relocking");\r
- m_lock->rdlock();\r
- return this;\r
-}\r
-\r
+
+ReloadableXMLFile::ReloadableXMLFile(const DOMElement* e, Category& log)
+ : m_root(e), m_local(true), m_validate(false), m_filestamp(0), m_reloadInterval(0), m_lock(NULL), m_log(log)
+{
+#ifdef _DEBUG
+ NDC ndc("ReloadableXMLFile");
+#endif
+
+ // Establish source of data...
+ const XMLCh* source=e->getAttributeNS(NULL,uri);
+ if (!source || !*source) {
+ source=e->getAttributeNS(NULL,url);
+ if (!source || !*source) {
+ source=e->getAttributeNS(NULL,path);
+ if (!source || !*source) {
+ source=e->getAttributeNS(NULL,pathname);
+ if (!source || !*source) {
+ source=e->getAttributeNS(NULL,file);
+ if (!source || !*source) {
+ source=e->getAttributeNS(NULL,filename);
+ }
+ }
+ }
+ }
+ else
+ m_local=false;
+ }
+ else
+ m_local=false;
+
+ if (source && *source) {
+ const XMLCh* flag=e->getAttributeNS(NULL,validate);
+ m_validate=(XMLString::equals(flag,xmlconstants::XML_TRUE) || XMLString::equals(flag,xmlconstants::XML_ONE));
+
+ auto_ptr_char temp(source);
+ m_source=temp.get();
+
+ if (!m_local && !strstr(m_source.c_str(),"://")) {
+ log.warn("deprecated usage of uri/url attribute for a local resource, use path instead");
+ m_local=true;
+ }
+
+ if (m_local) {
+ XMLToolingConfig::getConfig().getPathResolver()->resolve(m_source, PathResolver::XMLTOOLING_CFG_FILE);
+
+ flag=e->getAttributeNS(NULL,reloadChanges);
+ if (!XMLString::equals(flag,xmlconstants::XML_FALSE) && !XMLString::equals(flag,xmlconstants::XML_ZERO)) {
+#ifdef WIN32
+ struct _stat stat_buf;
+ if (_stat(m_source.c_str(), &stat_buf) == 0)
+#else
+ struct stat stat_buf;
+ if (stat(m_source.c_str(), &stat_buf) == 0)
+#endif
+ m_filestamp=stat_buf.st_mtime;
+ else
+ throw IOException("Unable to access local file ($1)", params(1,m_source.c_str()));
+ m_lock=RWLock::create();
+ }
+ log.debug("using local resource (%s), will %smonitor for changes", m_source.c_str(), m_lock ? "" : "not ");
+ }
+ else {
+ log.debug("using remote resource (%s)", m_source.c_str());
+ source = e->getAttributeNS(NULL,backingFilePath);
+ if (source && *source) {
+ auto_ptr_char temp2(source);
+ m_backing=temp2.get();
+ XMLToolingConfig::getConfig().getPathResolver()->resolve(m_backing, PathResolver::XMLTOOLING_RUN_FILE);
+ log.debug("backup remote resource with (%s)", m_backing.c_str());
+ }
+ source = e->getAttributeNS(NULL,reloadInterval);
+ if (source && *source) {
+ m_reloadInterval = XMLString::parseInt(source);
+ if (m_reloadInterval > 0) {
+ m_log.debug("will reload remote resource at most every %d seconds", m_reloadInterval);
+ m_lock=RWLock::create();
+ }
+ }
+ m_filestamp = time(NULL); // assume it gets loaded initially
+ }
+ }
+ else {
+ log.debug("no resource uri/path/name supplied, will load inline configuration");
+ }
+}
+
+pair<bool,DOMElement*> ReloadableXMLFile::load(bool backup)
+{
+#ifdef _DEBUG
+ NDC ndc("init");
+#endif
+
+ try {
+ if (m_source.empty()) {
+ // Data comes from the DOM we were handed.
+ m_log.debug("loading inline configuration...");
+ return make_pair(false,XMLHelper::getFirstChildElement(m_root));
+ }
+ else {
+ // Data comes from a file we have to parse.
+ if (backup)
+ m_log.warn("using local backup of remote resource");
+ else
+ m_log.debug("loading configuration from external resource...");
+
+ DOMDocument* doc=NULL;
+ if (m_local || backup) {
+ auto_ptr_XMLCh widenit(backup ? m_backing.c_str() : m_source.c_str());
+ LocalFileInputSource src(widenit.get());
+ Wrapper4InputSource dsrc(&src,false);
+ if (m_validate)
+ doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc);
+ else
+ doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);
+ }
+ else {
+ URLInputSource src(m_root);
+ Wrapper4InputSource dsrc(&src,false);
+ if (m_validate)
+ doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc);
+ else
+ doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);
+ }
+
+ m_log.infoStream() << "loaded XML resource (" << (backup ? m_backing : m_source) << ")" << logging::eol;
+
+ if (!backup && !m_backing.empty()) {
+ m_log.debug("backing up remote resource to (%s)", m_backing.c_str());
+ try {
+ ofstream backer(m_backing.c_str());
+ backer << *doc;
+ }
+ catch (exception& ex) {
+ m_log.crit("exception while backing up resource: %s", ex.what());
+ }
+ }
+
+ return make_pair(true,doc->getDocumentElement());
+ }
+ }
+ catch (XMLException& e) {
+ auto_ptr_char msg(e.getMessage());
+ m_log.errorStream() << "Xerces error while loading resource (" << (backup ? m_backing : m_source) << "): "
+ << msg.get() << logging::eol;
+ if (!backup && !m_backing.empty())
+ return load(true);
+ throw XMLParserException(msg.get());
+ }
+ catch (exception& e) {
+ m_log.errorStream() << "error while loading configuration from ("
+ << (m_source.empty() ? "inline" : (backup ? m_backing : m_source)) << "): " << e.what() << logging::eol;
+ if (!backup && !m_backing.empty())
+ return load(true);
+ throw;
+ }
+}
+
+Lockable* ReloadableXMLFile::lock()
+{
+ if (!m_lock)
+ return this;
+
+ m_lock->rdlock();
+
+ // Check if we need to refresh.
+ if (m_local) {
+#ifdef WIN32
+ struct _stat stat_buf;
+ if (_stat(m_source.c_str(), &stat_buf) != 0)
+ return this;
+#else
+ struct stat stat_buf;
+ if (stat(m_source.c_str(), &stat_buf) != 0)
+ return this;
+#endif
+ if (m_filestamp>=stat_buf.st_mtime)
+ return this;
+
+ // Elevate lock and recheck.
+ m_log.debug("timestamp of local resource changed, elevating to a write lock");
+ m_lock->unlock();
+ m_lock->wrlock();
+ if (m_filestamp>=stat_buf.st_mtime) {
+ // Somebody else handled it, just downgrade.
+ m_log.debug("update of local resource handled by another thread, downgrading lock");
+ m_lock->unlock();
+ m_lock->rdlock();
+ return this;
+ }
+
+ // Update the timestamp regardless. No point in repeatedly trying.
+ m_filestamp=stat_buf.st_mtime;
+ m_log.info("change detected, reloading local resource...");
+ }
+ else {
+ time_t now = time(NULL);
+
+ // Time to reload? If we have no data, filestamp is zero
+ // and there's no way current time is less than the interval.
+ if (now - m_filestamp < m_reloadInterval)
+ return this;
+
+ // Elevate lock and recheck.
+ m_log.debug("reload interval for remote resource elapsed, elevating to a write lock");
+ m_lock->unlock();
+ m_lock->wrlock();
+ if (now - m_filestamp < m_reloadInterval) {
+ // Somebody else handled it, just downgrade.
+ m_log.debug("update of remote resource handled by another thread, downgrading lock");
+ m_lock->unlock();
+ m_lock->rdlock();
+ return this;
+ }
+
+ m_filestamp = now;
+ m_log.info("reloading remote resource...");
+ }
+
+ // Do this once...
+ try {
+ // At this point we're holding the write lock, so make sure we pop it.
+ SharedLock lockwrap(m_lock,false);
+ pair<bool,DOMElement*> ret=load();
+ if (ret.first)
+ ret.second->getOwnerDocument()->release();
+ } catch (exception& ex) {
+ m_log.crit("maintaining existing configuration, error reloading resource (%s): %s", m_source.c_str(), ex.what());
+ }
+
+ // If we made it here, the swap may or may not have worked, but we need to relock.
+ m_log.debug("attempt to update resource complete, relocking");
+ m_lock->rdlock();
+ return this;
+}
+
void ReloadableXMLFile::unlock()
{
if (m_lock)
m_lock->unlock();
}
-\r
+
pair<bool,DOMElement*> ReloadableXMLFile::load()
{
return load(false);
m_storage->createString(context, s, "x", expires);
return true;
}
+
+bool ReplayCache::check(const char* context, const XMLCh* s, time_t expires)
+{
+ auto_ptr_char temp(s);
+ return check(context, temp.get(), expires);
+}
* @param s value to check
* @param expires time for disposal of value from cache
*/
- bool check(const char* context, const XMLCh* s, time_t expires) {
- auto_ptr_char temp(s);
- return check(context, temp.get(), expires);
- }
+ bool check(const char* context, const XMLCh* s, time_t expires);
private:
bool m_owned;
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* StorageService.cpp
*
- * Registration of factories for built-in storage services
+ * Generic data storage interface.
*/
#include "internal.h"
XMLToolingConfig& conf=XMLToolingConfig::getConfig();
conf.StorageServiceManager.registerFactory(MEMORY_STORAGE_SERVICE, MemoryStorageServiceFactory);
}
+
+StorageService::StorageService()
+{
+}
+
+StorageService::~StorageService()
+{
+}
{
MAKE_NONCOPYABLE(StorageService);
public:
- virtual ~StorageService() {}
+ virtual ~StorageService();
/**
* Creates a new "short" record in the storage service.
virtual void deleteContext(const char* context)=0;
protected:
- StorageService() {}
+ StorageService();
};
/**
static const pair<const string,string> emptyPair;
}
+TemplateEngine::TemplateEngine()
+{
+ setTagPrefix("mlp");
+}
+
+TemplateEngine::~TemplateEngine()
+{
+}
+
+TemplateEngine::TemplateParameters::TemplateParameters() : m_request(NULL)
+{
+}
+
+TemplateEngine::TemplateParameters::~TemplateParameters()
+{
+}
+
const char* TemplateEngine::TemplateParameters::getParameter(const char* name) const
{
map<string,string>::const_iterator i=m_map.find(name);
MAKE_NONCOPYABLE(TemplateEngine);
public:
/** Default constructor. */
- TemplateEngine() {
- setTagPrefix("mlp");
- }
+ TemplateEngine();
- virtual ~TemplateEngine() {}
+ virtual ~TemplateEngine();
/**
* Sets the tag name to use when locating template replacement tags.
*/
class XMLTOOL_API TemplateParameters {
public:
- TemplateParameters() : m_request(NULL) {}
- virtual ~TemplateParameters() {}
+ TemplateParameters();
+ virtual ~TemplateParameters();
/** Map of known parameters to supply to template. */
std::map<std::string,std::string> m_map;
return(digit);
}
+URLEncoder::URLEncoder()
+{
+}
+
+URLEncoder::~URLEncoder()
+{
+}
+
void URLEncoder::decode(char* s) const
{
register int x,y;
class XMLTOOL_API URLEncoder {
MAKE_NONCOPYABLE(URLEncoder);
public:
- /** Default constructor. */
- URLEncoder() {}
+ URLEncoder();
- virtual ~URLEncoder() {}
+ virtual ~URLEncoder();
/**
* Produce a URL-safe but equivalent version of the input string.
return childElement;
}
+bool XMLHelper::isNodeNamed(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* local)
+{
+ return (n && XMLString::equals(local,n->getLocalName()) && XMLString::equals(ns,n->getNamespaceURI()));
+}
+
const XMLCh* XMLHelper::getTextContent(const DOMElement* e)
{
DOMNode* child=e->getFirstChild();
* @param local local name to compare with
* @return true iff the node's qualified name matches the other parameters
*/
- static bool isNodeNamed(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* local) {
- return (n && xercesc::XMLString::equals(local,n->getLocalName()) && xercesc::XMLString::equals(ns,n->getNamespaceURI()));
- }
+ static bool isNodeNamed(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* local);
/**
* Returns the first matching child element of the node if any.
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @file xmltooling/validation/Validator.h
*
- * Rules checking of XMLObjects
+ * Rules checking of XMLObjects.
*/
#ifndef __xmltooling_validator_h__
{
MAKE_NONCOPYABLE(Validator);
public:
- virtual ~Validator() {}
+ virtual ~Validator();
/**
* Checks to see if an XMLObject is valid.
virtual void validate(const XMLObject* xmlObject) const=0;
protected:
- Validator() {}
+ Validator();
};
};
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
#include "internal.h"
+#include "validation/Validator.h"
#include "validation/ValidatorSuite.h"
-#include "util/XMLHelper.h"
using namespace xmltooling;
using namespace std;
+Validator::Validator()
+{
+}
+
+Validator::~Validator()
+{
+}
+
ValidatorSuite xmltooling::SchemaValidators("SchemaValidators");
+ValidatorSuite::ValidatorSuite(const char* id) : m_id(id)
+{
+}
+
+ValidatorSuite::~ValidatorSuite()
+{
+ destroyValidators();
+}
+
+const char* ValidatorSuite::getId()
+{
+ return m_id.c_str();
+}
+
+void ValidatorSuite::registerValidator(const QName& key, Validator* validator)
+{
+ m_map.insert(pair<const QName,Validator*>(key, validator));
+}
+
void ValidatorSuite::deregisterValidators(const QName& key)
{
pair<multimap<QName,Validator*>::iterator,multimap<QName,Validator*>::iterator> range=m_map.equal_range(key);
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define __xmltooling_valsuite_h__
#include <xmltooling/QName.h>
-#include <xmltooling/validation/Validator.h>
#include <map>
+#include <string>
#if defined (_MSC_VER)
#pragma warning( push )
namespace xmltooling {
+ class XMLTOOL_API Validator;
+
/**
* A collection of validators that can be applied to an XMLObject and its children. These collections can represent
* usage specific checks, such as those outlined in schemas or profiles of specific XML specifications.
*
* @param id an identifier for the suite
*/
- ValidatorSuite(const char* id) : m_id(id) {}
+ ValidatorSuite(const char* id);
- ~ValidatorSuite() {
- destroyValidators();
- }
+ ~ValidatorSuite();
/**
* Gets a unique ID for this suite.
*
* @return a unique ID for this suite
*/
- const char* getId() {
- return m_id.c_str();
- }
+ const char* getId();
/**
* Evaluates the registered validators against the given XMLObject and it's children.
* @param key the key used to retrieve the validator
* @param validator the validator
*/
- void registerValidator(const QName& key, Validator* validator) {
- m_map.insert(std::pair<const QName,Validator*>(key, validator));
- }
+ void registerValidator(const QName& key, Validator* validator);
/**
* Deregisters validators.
>\r
</File>\r
<File\r
+ RelativePath=".\Lockable.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\Namespace.cpp"\r
>\r
</File>\r
>\r
</File>\r
<File\r
+ RelativePath=".\Lockable.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\Namespace.cpp"\r
>\r
</File>\r
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <xmltooling/encryption/Decrypter.h>
#include <xmltooling/encryption/Encrypter.h>
+#include <xmltooling/encryption/Encryption.h>
#include <xmltooling/security/Credential.h>
#include <xmltooling/security/CredentialCriteria.h>
#include <xmltooling/security/CredentialResolver.h>
/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <xmltooling/security/X509Credential.h>
#include <xmltooling/security/KeyInfoResolver.h>
#include <xmltooling/signature/KeyInfo.h>
+#include <xsec/enc/XSECCryptoKey.hpp>
using namespace xmlsignature;