<cdtproject id="org.eclipse.cdt.make.core.make">\r
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>\r
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>\r
-<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>\r
+<extension id="org.eclipse.cdt.core.nullindexer" point="org.eclipse.cdt.core.CIndexer"/>\r
<data>\r
<item id="scannerConfiguration">\r
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>\r
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = C:/cvs/cpp-xmltooling/xmltooling
-FILE_PATTERNS = *.c \
- *.cc \
- *.cxx \
- *.cpp \
- *.c++ \
- *.d \
+FILE_PATTERNS = *.d \
*.java \
*.ii \
*.ixx \
*.dox \
*.py
RECURSIVE = YES
-EXCLUDE =
+EXCLUDE = C:/cvs/cpp-xmltooling/xmltooling/signature/impl
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = NO
+MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH = C:\cvs\cpp-xmltooling
for_each(m_attributeMap.begin(),m_attributeMap.end(),_release());\r
}\r
\r
+AbstractAttributeExtensibleXMLObject::AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src)\r
+ : AbstractXMLObject(src)\r
+{\r
+ for (map<QName,XMLCh*>::const_iterator i=src.m_attributeMap.begin(); i!=src.m_attributeMap.end(); i++) {\r
+ m_attributeMap[i->first] = XMLString::replicate(i->second);\r
+ }\r
+}\r
+\r
void AbstractAttributeExtensibleXMLObject::setAttribute(QName& qualifiedName, const XMLCh* value)\r
{\r
map<QName,XMLCh*>::iterator i=m_attributeMap.find(qualifiedName);\r
/**\r
* @file AbstractAttributeExtensibleXMLObject.h\r
* \r
- * An abstract implementation of a DOM-caching AttributeExtensibleXMLObject \r
+ * An abstract implementation of an AttributeExtensibleXMLObject \r
*/\r
\r
-#if !defined(__xmltooling_absattrextxmlobj_h__)\r
+#ifndef __xmltooling_absattrextxmlobj_h__\r
#define __xmltooling_absattrextxmlobj_h__\r
\r
#include <map>\r
namespace xmltooling {\r
\r
/**\r
- * An abstract implementation of a DOM-caching AttributeExtensibleXMLObject.\r
+ * An abstract implementation of an AttributeExtensibleXMLObject.\r
*/\r
- class XMLTOOL_API AbstractAttributeExtensibleXMLObject : public virtual AttributeExtensibleXMLObject, public virtual AbstractDOMCachingXMLObject\r
+ class XMLTOOL_API AbstractAttributeExtensibleXMLObject : public virtual AttributeExtensibleXMLObject, public virtual AbstractXMLObject\r
{\r
public:\r
virtual ~AbstractAttributeExtensibleXMLObject();\r
\r
- /**\r
- * @see AttributeExtensibleXMLObject::getAttribute()\r
- */\r
virtual const XMLCh* getAttribute(QName& qualifiedName) const {\r
std::map<QName,XMLCh*>::const_iterator i=m_attributeMap.find(qualifiedName);\r
return (i==m_attributeMap.end()) ? NULL : i->second;\r
}\r
\r
- /**\r
- * @see AttributeExtensibleXMLObject::setAttribute()\r
- */\r
virtual void setAttribute(QName& qualifiedName, const XMLCh* value);\r
\r
protected:\r
AbstractAttributeExtensibleXMLObject() {}\r
\r
+ /** Copy constructor. */\r
+ AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src);\r
+\r
+ /** Map of arbitrary attributes. */\r
std::map<QName,XMLCh*> m_attributeMap;\r
};\r
\r
\r
void AbstractDOMCachingXMLObject::releaseParentDOM(bool propagateRelease) const\r
{\r
- DOMCachingXMLObject* domCachingParent = dynamic_cast<DOMCachingXMLObject*>(getParent());\r
- if (domCachingParent) {\r
- if (domCachingParent->getDOM()) {\r
- Category::getInstance(XMLTOOLING_LOGCAT".DOM").debug(\r
- "releasing cached DOM representation for parent object with propagation set to %s",\r
- propagateRelease ? "true" : "false"\r
- );\r
- domCachingParent->releaseDOM();\r
- if (propagateRelease)\r
- domCachingParent->releaseParentDOM(propagateRelease);\r
- }\r
+ if (getParent() && getParent()->getDOM()) {\r
+ Category::getInstance(XMLTOOLING_LOGCAT".DOM").debug(\r
+ "releasing cached DOM representation for parent object with propagation set to %s",\r
+ propagateRelease ? "true" : "false"\r
+ );\r
+ getParent()->releaseDOM();\r
+ if (propagateRelease)\r
+ getParent()->releaseParentDOM(propagateRelease);\r
}\r
}\r
\r
class _release : public binary_function<XMLObject*,bool,void> {\r
public:\r
void operator()(XMLObject* obj, bool propagate) const {\r
- DOMCachingXMLObject* domCaching = dynamic_cast<DOMCachingXMLObject*>(obj);\r
- if (domCaching) {\r
- domCaching->releaseDOM();\r
+ if (obj) {\r
+ obj->releaseDOM();\r
if (propagate)\r
- domCaching->releaseChildrenDOM(propagate);\r
+ obj->releaseChildrenDOM(propagate);\r
}\r
}\r
};\r
}\r
return NULL;\r
}\r
-\r
-XMLObject* AbstractDOMCachingXMLObject::prepareForAssignment(XMLObject* oldValue, XMLObject* newValue) {\r
-\r
- if (newValue && newValue->hasParent())\r
- throw XMLObjectException("child XMLObject cannot be added - it is already the child of another XMLObject");\r
-\r
- if (!oldValue) {\r
- if (newValue) {\r
- releaseThisandParentDOM();\r
- newValue->setParent(this);\r
- return newValue;\r
- }\r
- else {\r
- return NULL;\r
- }\r
- }\r
-\r
- if (oldValue != newValue) {\r
- delete oldValue;\r
- releaseThisandParentDOM();\r
- newValue->setParent(this);\r
- }\r
-\r
- return newValue;\r
-}\r
/**\r
* @file AbstractDOMCachingXMLObject.h\r
* \r
- * Extension of AbstractXMLObject that implements a DOMCachingXMLObject. \r
+ * Extension of AbstractXMLObject that adds DOM caching methods\r
*/\r
\r
#if !defined(__xmltooling_abstractdomxmlobj_h__)\r
#define __xmltooling_abstractdomxmlobj_h__\r
\r
#include <xmltooling/AbstractXMLObject.h>\r
-#include <xmltooling/DOMCachingXMLObject.h>\r
\r
#if defined (_MSC_VER)\r
#pragma warning( push )\r
namespace xmltooling {\r
\r
/**\r
- * Extension of AbstractXMLObject that implements a DOMCachingXMLObject.\r
+ * Extension of AbstractXMLObject that adds DOM caching methods\r
*/\r
- class XMLTOOL_API AbstractDOMCachingXMLObject : public virtual AbstractXMLObject, public virtual DOMCachingXMLObject\r
+ class XMLTOOL_API AbstractDOMCachingXMLObject : public virtual AbstractXMLObject\r
{\r
public:\r
virtual ~AbstractDOMCachingXMLObject();\r
\r
- /**\r
- * @see DOMCachingXMLObject::getDOM()\r
- */\r
DOMElement* getDOM() const {\r
return m_dom;\r
}\r
\r
- /**\r
- * @see DOMCachingXMLObject::setDOM()\r
- */\r
void setDOM(DOMElement* dom, bool bindDocument=false) const;\r
\r
- /**\r
- * @see DOMCachingXMLObject::setDocument()\r
- */\r
void setDocument(DOMDocument* doc) const {\r
if (m_document)\r
m_document->release();\r
m_document=doc;\r
}\r
\r
- /**\r
- * @see DOMCachingXMLObject::releaseDOM()\r
- */\r
virtual void releaseDOM() const;\r
\r
- /**\r
- * @see DOMCachingXMLObject::releaseParentDOM()\r
- */\r
virtual void releaseParentDOM(bool propagateRelease=true) const;\r
\r
- /**\r
- * @see DOMCachingXMLObject::releaseChildrenDOM()\r
- */\r
virtual void releaseChildrenDOM(bool propagateRelease=true) const;\r
\r
- /**\r
- * A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).\r
- */\r
- void releaseThisandParentDOM() const {\r
- if (m_dom) {\r
- releaseDOM();\r
- releaseParentDOM(true);\r
- }\r
- }\r
- \r
- /**\r
- * A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().\r
- */\r
- void releaseThisAndChildrenDOM() const {\r
- if (m_dom) {\r
- releaseChildrenDOM(true);\r
- releaseDOM();\r
- }\r
- }\r
- \r
- /**\r
- * @see XMLObject::clone()\r
- */\r
XMLObject* clone() const;\r
\r
protected:\r
AbstractDOMCachingXMLObject() : m_dom(NULL), m_document(NULL) {}\r
\r
+ /** Copy constructor. */\r
+ AbstractDOMCachingXMLObject(const AbstractDOMCachingXMLObject& src)\r
+ : AbstractXMLObject(src), m_dom(NULL), m_document(NULL) {}\r
+\r
/**\r
* If a DOM representation exists, this clones it into a new document.\r
* \r
*/\r
DOMElement* cloneDOM(DOMDocument* doc=NULL) const;\r
\r
- /**\r
- * A helper function for derived classes.\r
- * This 'normalizes' newString, and then if it is different from oldString,\r
- * it invalidates the DOM, frees the old string, and return the new.\r
- * If not different, it frees the new string and just returns the old value.\r
- * \r
- * @param oldValue - the current value\r
- * @param newValue - the new value\r
- * \r
- * @return the value that should be assigned\r
- */\r
- XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue) {\r
- XMLCh* newString = XMLString::replicate(newValue);\r
- XMLString::trim(newString);\r
- if (!XMLString::equals(oldValue,newValue)) {\r
- releaseThisandParentDOM();\r
- XMLString::release(&oldValue);\r
- return newString;\r
- }\r
- XMLString::release(&newString);\r
- return oldValue; \r
- }\r
-\r
- /**\r
- * A helper function for derived classes, for assignment of (singleton) XML objects.\r
- * \r
- * It is indifferent to whether either the old or the new version of the value is null. \r
- * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate\r
- * \r
- * @param oldValue - current value\r
- * @param newValue - proposed new value\r
- * @return the value to assign \r
- * \r
- * @throws XMLObjectException if the new child already has a parent.\r
- */\r
- XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);\r
-\r
private:\r
mutable DOMElement* m_dom;\r
mutable DOMDocument* m_document;\r
/**\r
* @file AbstractElementProxy.h\r
* \r
- * An abstract implementation of a DOM-caching ElementProxy \r
+ * An abstract implementation of an ElementProxy \r
*/\r
\r
-#if !defined(__xmltooling_abseleproxy_h__)\r
+#ifndef __xmltooling_abseleproxy_h__\r
#define __xmltooling_abseleproxy_h__\r
\r
#include <xmltooling/AbstractDOMCachingXMLObject.h>\r
namespace xmltooling {\r
\r
/**\r
- * An abstract implementation of a DOM-caching ExtensibleXMLObject.\r
+ * An abstract implementation of an ExtensibleXMLObject.\r
*/\r
- class XMLTOOL_API AbstractElementProxy : public virtual ElementProxy, public virtual AbstractDOMCachingXMLObject\r
+ class XMLTOOL_API AbstractElementProxy : public virtual ElementProxy, public virtual AbstractXMLObject\r
{\r
public:\r
virtual ~AbstractElementProxy() {}\r
\r
- /**\r
- * @see ElementProxy::getTextContent()\r
- */\r
virtual const XMLCh* getTextContent() const {\r
return m_value;\r
}\r
\r
- /**\r
- * @see ElementProxy::setTextContent()\r
- */\r
virtual void setTextContent(const XMLCh* value);\r
\r
-\r
- /**\r
- * @see ElementProxy::getXMLObjects()\r
- */\r
virtual ListOf(XMLObject) getXMLObjects();\r
\r
protected:\r
AbstractElementProxy() : m_value(NULL) {}\r
+ \r
+ /** Copy constructor. */\r
+ AbstractElementProxy(const AbstractElementProxy& src)\r
+ : AbstractXMLObject(src), m_value(XMLString::replicate(src.m_value)) {}\r
\r
private:\r
XMLCh* m_value;\r
\r
#include "internal.h"\r
#include "AbstractXMLObject.h"\r
+#include "exceptions.h"\r
\r
#include <algorithm>\r
#include <log4cpp/Category.hh>\r
{\r
addNamespace(Namespace(namespaceURI, namespacePrefix));\r
}\r
+\r
+AbstractXMLObject::AbstractXMLObject(const AbstractXMLObject& src)\r
+ : m_namespaces(src.m_namespaces), m_log(src.m_log), m_parent(NULL), m_elementQname(src.m_elementQname), m_typeQname(NULL)\r
+{\r
+ if (src.m_typeQname)\r
+ m_typeQname=new QName(*src.m_typeQname);\r
+}\r
+\r
+XMLObject* AbstractXMLObject::prepareForAssignment(XMLObject* oldValue, XMLObject* newValue) {\r
+\r
+ if (newValue && newValue->hasParent())\r
+ throw XMLObjectException("child XMLObject cannot be added - it is already the child of another XMLObject");\r
+\r
+ if (!oldValue) {\r
+ if (newValue) {\r
+ releaseThisandParentDOM();\r
+ newValue->setParent(this);\r
+ return newValue;\r
+ }\r
+ else {\r
+ return NULL;\r
+ }\r
+ }\r
+\r
+ if (oldValue != newValue) {\r
+ delete oldValue;\r
+ releaseThisandParentDOM();\r
+ newValue->setParent(this);\r
+ }\r
+\r
+ return newValue;\r
+}\r
public:\r
virtual ~AbstractXMLObject();\r
\r
- /**\r
- * @see XMLObject::getElementQName()\r
- */\r
const QName& getElementQName() const {\r
return m_elementQname;\r
}\r
\r
- /**\r
- * @see XMLObject::getNamespaces()\r
- */\r
const std::set<Namespace>& getNamespaces() const {\r
return m_namespaces;\r
}\r
\r
- /**\r
- * @see XMLObject::addNamespace()\r
- */\r
void addNamespace(const Namespace& ns) const {\r
if (ns.alwaysDeclare() || m_namespaces.find(ns)==m_namespaces.end()) {\r
m_namespaces.insert(ns);\r
}\r
}\r
\r
- /**\r
- * @see XMLObject::removeNamespace()\r
- */\r
void removeNamespace(const Namespace& ns) {\r
m_namespaces.erase(ns);\r
}\r
\r
- /**\r
- * @see XMLObject::getSchemaType()\r
- */\r
const QName* getSchemaType() const {\r
return m_typeQname;\r
}\r
\r
- /**\r
- * @see XMLObject::setSchemaType()\r
- */\r
void setSchemaType(const QName* type) {\r
delete m_typeQname;\r
m_typeQname = NULL;\r
}\r
}\r
\r
- /**\r
- * @see XMLObject::hasParent()\r
- */\r
bool hasParent() const {\r
return m_parent != NULL;\r
}\r
\r
- /**\r
- * @see XMLObject::getParent()\r
- */\r
XMLObject* getParent() const {\r
return m_parent;\r
}\r
\r
- /**\r
- * @see XMLObject::setParent()\r
- */\r
void setParent(XMLObject* parent) {\r
m_parent = parent;\r
}\r
\r
- /**\r
- * @see XMLObject::hasChildren()\r
- */\r
bool hasChildren() const {\r
return !m_children.empty();\r
}\r
\r
- /**\r
- * @see XMLObject::getOrderedChildren()\r
- */\r
const std::list<XMLObject*>& getOrderedChildren() const {\r
return m_children;\r
}\r
*/\r
AbstractXMLObject(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL);\r
\r
+ /** Copy constructor. */\r
+ AbstractXMLObject(const AbstractXMLObject& src);\r
+ \r
+ /**\r
+ * A helper function for derived classes.\r
+ * This 'normalizes' newString, and then if it is different from oldString,\r
+ * it invalidates the DOM, frees the old string, and return the new.\r
+ * If not different, it frees the new string and just returns the old value.\r
+ * \r
+ * @param oldValue - the current value\r
+ * @param newValue - the new value\r
+ * \r
+ * @return the value that should be assigned\r
+ */\r
+ XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue) {\r
+ XMLCh* newString = XMLString::replicate(newValue);\r
+ XMLString::trim(newString);\r
+ if (!XMLString::equals(oldValue,newValue)) {\r
+ releaseThisandParentDOM();\r
+ XMLString::release(&oldValue);\r
+ return newString;\r
+ }\r
+ XMLString::release(&newString);\r
+ return oldValue; \r
+ }\r
+\r
+ /**\r
+ * A helper function for derived classes, for assignment of (singleton) XML objects.\r
+ * \r
+ * It is indifferent to whether either the old or the new version of the value is null. \r
+ * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate\r
+ * \r
+ * @param oldValue - current value\r
+ * @param newValue - proposed new value\r
+ * @return the value to assign \r
+ * \r
+ * @throws XMLObjectException if the new child already has a parent.\r
+ */\r
+ XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);\r
+\r
/**\r
* Underlying list of child objects.\r
* Manages the lifetime of the children.\r
+++ /dev/null
-/*\r
- * Copyright 2001-2006 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * @file DOMCachingXMLObject.h\r
- * \r
- * An XMLObject that can cached a DOM representation of itself. \r
- */\r
-\r
-#if !defined(__xmltooling_domxmlobj_h__)\r
-#define __xmltooling_domxmlobj_h__\r
-\r
-#include <xercesc/dom/DOM.hpp>\r
-#include <xmltooling/XMLObject.h>\r
-\r
-using namespace xercesc;\r
-\r
-namespace xmltooling {\r
-\r
- /**\r
- * An XMLObject that can cached a DOM representation of itself.\r
- */\r
- class XMLTOOL_API DOMCachingXMLObject : public virtual XMLObject\r
- {\r
- public:\r
- DOMCachingXMLObject() {}\r
- virtual ~DOMCachingXMLObject() {}\r
- \r
- /**\r
- * Gets the DOM representation of this XMLObject, if one exists.\r
- * \r
- * @return the DOM representation of this XMLObject\r
- */\r
- virtual DOMElement* getDOM() const=0;\r
- \r
- /**\r
- * Sets the DOM representation of this XMLObject.\r
- * \r
- * @param dom DOM representation of this XMLObject\r
- * @param bindDocument true if the object should take ownership of the associated Document\r
- */\r
- virtual void setDOM(DOMElement* dom, bool bindDocument=false) const=0;\r
- \r
- /**\r
- * Assigns ownership of a DOM document to the XMLObject.\r
- * This binds the lifetime of the document to the lifetime of the object.\r
- * \r
- * @param doc DOM document bound to this object \r
- */\r
- virtual void setDocument(DOMDocument* doc) const=0;\r
-\r
- /**\r
- * Releases the DOM representation of this XMLObject, if there is one.\r
- */\r
- virtual void releaseDOM() const=0;\r
- \r
- /**\r
- * Releases the DOM representation of this XMLObject's parent.\r
- * \r
- * @param propagateRelease true if all ancestors of this element should release their DOM\r
- */\r
- virtual void releaseParentDOM(bool propagateRelease=true) const=0;\r
- \r
- /**\r
- * Releases the DOM representation of this XMLObject's children.\r
- * \r
- * @param propagateRelease true if all descendants of this element should release their DOM\r
- */\r
- virtual void releaseChildrenDOM(bool propagateRelease=true) const=0;\r
- };\r
- \r
-};\r
-\r
-#endif /* __xmltooling_domxmlobj_h__ */\r
AttributeExtensibleXMLObject.h \
base.h \
config_pub.h \
- DOMCachingXMLObject.h \
ElementProxy.h \
exceptions.h \
ILockable.h \
io/AbstractXMLObjectUnmarshaller.h \
siginclude_HEADERS = \
+ signature/KeyInfo.h \
signature/Signature.h \
signature/SigningContext.h \
signature/VerifyingContext.h
noinst_HEADERS = \
internal.h \
- signature/impl/XMLSecSignature.h
+ signature/impl/KeyInfoImpl.h \
+ signature/impl/XMLSecSignatureImpl.h \
if BUILD_XMLSEC
xmlsec_sources = \
- signature/impl/XMLSecSignature.cpp
+ signature/impl/KeyInfoImpl.cpp \
+ signature/impl/XMLSecSignatureImpl.cpp
else
xmlsec_sources =
endif
{\r
MAKE_NONCOPYABLE(MarshallingContext);\r
public:\r
+ /**\r
+ * Default constructor.\r
+ */\r
MarshallingContext() {}\r
~MarshallingContext() {}\r
\r
#ifndef XMLTOOLING_NO_XMLSEC\r
+ /**\r
+ * Builds a marshalling context with an initial signature/context pair.\r
+ * \r
+ * @param sig a signature object\r
+ * @param ctx the signing context to associate with the signature \r
+ */\r
MarshallingContext(Signature* sig, const SigningContext* ctx) {\r
m_signingContexts.push_back(std::make_pair(sig,ctx));\r
}\r
*/\r
class XMLTOOL_API XMLObject\r
{\r
- MAKE_NONCOPYABLE(XMLObject);\r
public:\r
virtual ~XMLObject() {}\r
\r
virtual const std::list<XMLObject*>& getOrderedChildren() const=0;\r
\r
/**\r
+ * Gets the DOM representation of this XMLObject, if one exists.\r
+ * \r
+ * @return the DOM representation of this XMLObject\r
+ */\r
+ virtual DOMElement* getDOM() const=0;\r
+ \r
+ /**\r
+ * Sets the DOM representation of this XMLObject.\r
+ * \r
+ * @param dom DOM representation of this XMLObject\r
+ * @param bindDocument true if the object should take ownership of the associated Document\r
+ */\r
+ virtual void setDOM(DOMElement* dom, bool bindDocument=false) const=0;\r
+ \r
+ /**\r
+ * Assigns ownership of a DOM document to the XMLObject.\r
+ * This binds the lifetime of the document to the lifetime of the object.\r
+ * \r
+ * @param doc DOM document bound to this object \r
+ */\r
+ virtual void setDocument(DOMDocument* doc) const=0;\r
+\r
+ /**\r
+ * Releases the DOM representation of this XMLObject, if there is one.\r
+ */\r
+ virtual void releaseDOM() const=0;\r
+ \r
+ /**\r
+ * Releases the DOM representation of this XMLObject's parent.\r
+ * \r
+ * @param propagateRelease true if all ancestors of this element should release their DOM\r
+ */\r
+ virtual void releaseParentDOM(bool propagateRelease=true) const=0;\r
+ \r
+ /**\r
+ * Releases the DOM representation of this XMLObject's children.\r
+ * \r
+ * @param propagateRelease true if all descendants of this element should release their DOM\r
+ */\r
+ virtual void releaseChildrenDOM(bool propagateRelease=true) const=0;\r
+\r
+ /**\r
+ * A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).\r
+ */\r
+ void releaseThisandParentDOM() const {\r
+ if (getDOM()) {\r
+ releaseDOM();\r
+ releaseParentDOM(true);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().\r
+ */\r
+ void releaseThisAndChildrenDOM() const {\r
+ if (getDOM()) {\r
+ releaseChildrenDOM(true);\r
+ releaseDOM();\r
+ }\r
+ }\r
+\r
+ /**\r
* Marshalls the XMLObject, and its children, into a DOM element.\r
* If a document is supplied, then it will be used to create the resulting elements.\r
* If the document does not have a Document Element set, then the resulting\r
\r
protected:\r
XMLObject() {}\r
+ private:\r
+ XMLObject& operator=(const XMLObject& src);\r
};\r
\r
#if defined (_MSC_VER)\r
*/
#include "internal.h"
+
+#define XMLTOOLING_DEFINE_CONSTANTS
+#include <xercesc/util/XMLUniDefs.hpp>
+
#include "exceptions.h"
#include "XMLToolingConfig.h"
#include "impl/UnknownElement.h"
-#include "signature/impl/XMLSecSignature.h"
+#include "signature/impl/KeyInfoImpl.h"
+#include "signature/impl/XMLSecSignatureImpl.h"
#include "util/NDC.h"
+#include "util/XMLConstants.h"
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
DECL_EXCEPTION_FACTORY(ValidationException);
DECL_EXCEPTION_FACTORY(SignatureException);
-namespace {
+namespace xmltooling {
XMLToolingInternalConfig g_config;
}
// default registrations
XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder());
+ XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,KeyInfo::LOCAL_NAME),new KeyInfoBuilderImpl());
#ifndef XMLTOOLING_NO_XMLSEC
XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME),new XMLSecSignatureBuilder());
#endif
* Must be included prior to including any other header
*/
-#if !defined(__xmltooling_base_h__)
+#ifndef __xmltooling_base_h__
#define __xmltooling_base_h__
#if defined (_MSC_VER) || defined(__BORLANDC__)
*/
// Windows and GCC4 Symbol Visibility Macros
-
#ifdef WIN32
#define XMLTOOL_IMPORT __declspec(dllimport)
#define XMLTOOL_EXPORT __declspec(dllexport)
#define XMLTOOL_EXCEPTIONAPI(api)
#endif
-// Macro to block copy c'tor and assignment operator for a class
+#ifndef NULL
+#define NULL 0
+#endif
+
+/**
+ * Blocks copy c'tor and assignment operator for a class.
+ */
#define MAKE_NONCOPYABLE(type) \
private: \
type(const type&); \
type& operator=(const type&);
-#ifndef NULL
-#define NULL 0
-#endif
+/**
+ * Begins the declaration of an XMLObject specialization.
+ * Basic boilerplate includes a protected constructor, empty virtual destructor,
+ * and Unicode constants for the default associated element's name and prefix.
+ *
+ * @param cname the name of the class to declare
+ * @param base the base class to derive from using public virtual inheritance
+ */
+#define BEGIN_XMLOBJECT(cname,base) \
+ class XMLTOOL_API cname : public virtual base, public virtual ValidatingXMLObject { \
+ protected: \
+ cname() {} \
+ public: \
+ virtual ~cname() {} \
+ /##** Type-specific clone method. */ \
+ virtual cname* clone##cname() const=0; \
+ /##** Element prefix */ \
+ static const XMLCh PREFIX[]; \
+ /##** Element local name */ \
+ static const XMLCh LOCAL_NAME[]
+
+/**
+ * Ends the declaration of an XMLObject specialization.
+ */
+#define END_XMLOBJECT }
+
+/**
+ * Declares abstract get/set methods for a named XML attribute.
+ *
+ * @param proper the proper name of the attribute
+ * @param upcased the upcased name of the attribute
+ */
+#define DECL_XMLOBJECT_ATTRIB(proper,upcased) \
+ /##** proper attribute name */ \
+ static const XMLCh upcased##_ATTRIB_NAME[]; \
+ /##** Returns the proper attribute. */ \
+ virtual const XMLCh* get##proper() const=0; \
+ /##** Sets the proper attribute. */ \
+ virtual void set##proper(const XMLCh* proper)=0
+
+/**
+ * Implements get/set methods and a private member for a named XML attribute.
+ *
+ * @param proper the proper name of the attribute
+ */
+#define IMPL_XMLOBJECT_ATTRIB(proper) \
+ private: \
+ XMLCh* m_##proper; \
+ public: \
+ const XMLCh* get##proper() const { \
+ return m_##proper; \
+ } \
+ void set##proper(const XMLCh* proper) { \
+ m_##proper = prepareForAssignment(m_##proper,proper); \
+ }
+
+/**
+ * Implements cloning methods for an XMLObject specialization implementation class.
+ *
+ * @param cname the name of the XMLObject specialization
+ */
+#define IMPL_XMLOBJECT_CLONE(cname) \
+ cname* clone##cname() const { \
+ return clone(); \
+ } \
+ cname* clone() const { \
+ auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone()); \
+ cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
+ if (ret) { \
+ domClone.release(); \
+ return ret; \
+ } \
+ return new cname##Impl(*this); \
+ }
+
+/**
+ * Begins the declaration of an XMLObjectBuilder specialization.
+ * Basic boilerplate includes an empty virtual destructor, and
+ * a default builder.
+ *
+ * @param cname the name of the XMLObject specialization
+ */
+#define BEGIN_XMLOBJECTBUILDER(cname) \
+ /##** Builder for cname objects. */ \
+ class XMLTOOL_API cname##Builder : public xmltooling::XMLObjectBuilder { \
+ public: \
+ virtual ~cname##Builder() {} \
+ /##** Default builder. */ \
+ virtual cname* buildObject() const=0
+
+/**
+ * Ends the declaration of an XMLObjectBuilder specialization.
+ */
+#define END_XMLOBJECTBUILDER }
+
+/**
+ * Begins the declaration of an XMLObjectBuilder specialization implementation class.
+ *
+ * @param cname the name of the XMLObject specialization
+ * @param namespaceURI the XML namespace of the default associated element
+ */
+#define BEGIN_XMLOBJECTBUILDERIMPL(cname,namespaceURI) \
+ class XMLTOOL_DLLLOCAL cname##BuilderImpl : public cname##Builder { \
+ public: \
+ cname* buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix=NULL) const; \
+ cname* buildObject() const { \
+ return buildObject(namespaceURI,cname::LOCAL_NAME,cname::PREFIX); \
+ }
+
+/**
+ * Ends the declaration of an XMLObjectBuilder specialization implementation class.
+ */
+#define END_XMLOBJECTBUILDERIMPL }
#include <utility>
}
}
- /*
+ /**
* Functor for cleaning up heap objects in containers.
*/
template<class T> struct cleanup
void operator()(const T* ptr) {delete const_cast<T*>(ptr);}
};
- /*
+ /**
* Functor for cleaning up heap objects in key/value containers.
*/
template<class A,class B> struct cleanup_pair
* Exception classes\r
*/\r
\r
-#if !defined(__xmltooling_exceptions_h__)\r
+#ifndef __xmltooling_exceptions_h__\r
#define __xmltooling_exceptions_h__\r
\r
#include <map>\r
* \r
* @param name the exception class\r
* @param base the base class\r
+ * @param desc\r
*/\r
-#define DECL_XMLTOOLING_EXCEPTION(name,base) \\r
+#define DECL_XMLTOOLING_EXCEPTION(name,base,desc) \\r
+ /##** desc */ \\r
class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) name : public xmltooling::base { \\r
public: \\r
+ /##** base##::##base(const char*,const xmltooling::params&) */ \\r
name(const char* msg=NULL, const xmltooling::params& p=xmltooling::params()) \\r
: xmltooling::base(msg,p) {} \\r
+ /##** base##::##base(const char*,const xmltooling::namedparams&) */ \\r
name(const char* msg, const xmltooling::namedparams& p) \\r
: xmltooling::base(msg,p) {} \\r
+ /##** base##::##base(const std::string&,const xmltooling::params&) */ \\r
name(const std::string& msg, const xmltooling::params& p=xmltooling::params()) \\r
: xmltooling::base(msg,p) {} \\r
+ /##** base##::##base(const std::string&,const xmltooling::namedparams&) */ \\r
name(const std::string& msg, const xmltooling::namedparams& p) \\r
: xmltooling::base(msg,p) {} \\r
virtual ~name() {} \\r
const std::vector<const char*>& get() const {return v;}\r
\r
protected:\r
+ /** Contains the parameters being passed. */\r
std::vector<const char*> v;\r
};\r
\r
namedparams(int count,...);\r
};\r
\r
+ class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) XMLToolingException;\r
+ \r
+ /** A factory function that returns an empty exception object of a given type. */\r
+ typedef XMLToolingException* ExceptionFactory();\r
+ \r
/**\r
* Base exception class, supports parametrized messages and XML serialization.\r
* Parameters are prefixed with a dollar sign ($) and can be positional ($1)\r
* or named ($info).\r
*/\r
- class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) XMLToolingException;\r
- typedef XMLToolingException* ExceptionFactory();\r
- \r
class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) XMLToolingException\r
{\r
public:\r
static ExceptionFactoryMap m_factoryMap;\r
};\r
\r
- DECL_XMLTOOLING_EXCEPTION(XMLParserException,XMLToolingException);\r
- DECL_XMLTOOLING_EXCEPTION(XMLObjectException,XMLToolingException);\r
- DECL_XMLTOOLING_EXCEPTION(MarshallingException,XMLToolingException);\r
- DECL_XMLTOOLING_EXCEPTION(UnmarshallingException,XMLToolingException);\r
- DECL_XMLTOOLING_EXCEPTION(UnknownElementException,XMLToolingException);\r
- DECL_XMLTOOLING_EXCEPTION(UnknownAttributeException,XMLToolingException);\r
- DECL_XMLTOOLING_EXCEPTION(ValidationException,XMLToolingException);\r
- DECL_XMLTOOLING_EXCEPTION(SignatureException,XMLToolingException);\r
+ DECL_XMLTOOLING_EXCEPTION(XMLParserException,XMLToolingException,Exceptions related to XML parsing);\r
+ DECL_XMLTOOLING_EXCEPTION(XMLObjectException,XMLToolingException,Exceptions in basic object usage);\r
+ DECL_XMLTOOLING_EXCEPTION(MarshallingException,XMLToolingException,Exceptions during object marshalling);\r
+ DECL_XMLTOOLING_EXCEPTION(UnmarshallingException,XMLToolingException,Exceptions during object unmarshalling);\r
+ DECL_XMLTOOLING_EXCEPTION(UnknownElementException,XMLToolingException,Exceptions due to processing of unknown element content);\r
+ DECL_XMLTOOLING_EXCEPTION(UnknownAttributeException,XMLToolingException,Exceptions due to processing of unknown attributes);\r
+ DECL_XMLTOOLING_EXCEPTION(ValidationException,XMLToolingException,Exceptions during object validation);\r
+ DECL_XMLTOOLING_EXCEPTION(SignatureException,XMLToolingException,Exceptions in signature processing);\r
\r
};\r
\r
*/
/**
- * @file AnyElement.h
+ * AnyElement.cpp
*
* Advanced anyType implementation suitable for deep processing of unknown content.
*/
/**
* Implements a smart wrapper around unknown DOM content.
*/
- class XMLTOOL_DLLLOCAL AnyElementImpl : public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject,
+ class XMLTOOL_DLLLOCAL AnyElementImpl : public AbstractDOMCachingXMLObject,
+ public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject,
public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller
{
public:
+ virtual ~AnyElementImpl() {}
+
AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix)
: AbstractXMLObject(nsURI, localName, prefix) {}
- virtual ~AnyElementImpl() {}
AnyElementImpl* clone() const {
auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
return ret;
}
- ret=new AnyElementImpl(
- getElementQName().getNamespaceURI(),getElementQName().getLocalPart(),getElementQName().getPrefix()
- );
- ret->m_namespaces=m_namespaces;
- for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
- ret->m_attributeMap[i->first]=XMLString::replicate(i->second);
- }
- ret->setTextContent(getTextContent());
- xmltooling::clone(m_children, ret->m_children);
- return ret;
+ return new AnyElementImpl(*this);
}
+ protected:
+ AnyElementImpl(const AnyElementImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),
+ AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src) {
+ for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
+ getXMLObjects().push_back((*i) ? (*i)->clone() : NULL);
+ }
+ }
+
void marshallAttributes(DOMElement* domElement) const {
for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
namespace xmltooling {
/**
- * Implements a smart wrapper around unknown DOM content.
- */
- class XMLTOOL_DLLLOCAL AnyElementImpl;
-
- /**
* Builder for AnyElementImpl objects.
+ * Use as the default builder when you want to wrap each unknown element and
+ * process the DOM content through xmltooling interfaces.
*/
class XMLTOOL_API AnyElementBuilder : public XMLObjectBuilder
{
public:
- /**
- * @see XMLObjectBuilder::buildObject(const XMLCh*,const XMLCh*,const XMLCh*)
- */
XMLObject* buildObject(
const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL
) const;
\r
namespace xmltooling {\r
\r
- /**\r
- * Implements a thin wrapper around unknown DOM content.\r
- */\r
+ /// @cond off\r
class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractDOMCachingXMLObject\r
{\r
public:\r
\r
void serialize(std::string& s) const;\r
};\r
-\r
+ /// @endcond\r
+ \r
/**\r
* Builder for UnknownElementImpl objects.\r
+ * Use as the default builder when you want unknown DOM content treated as raw/ignored XML.\r
*/\r
class XMLTOOL_API UnknownElementBuilder : public XMLObjectBuilder\r
{\r
public:\r
- /**\r
- * @see XMLObjectBuilder::buildObject(const XMLCh*,const XMLCh*,const XMLCh*)\r
- */\r
- UnknownElementImpl* buildObject(\r
+ XMLObject* buildObject(\r
const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL\r
) const {\r
return new UnknownElementImpl(namespaceURI,elementLocalName,namespacePrefix);\r
namespace xmltooling {
+ /// @cond OFF
class XMLToolingInternalConfig : public xmltooling::XMLToolingConfig
{
public:
void* m_lock;
//PlugManager m_plugMgr;
};
+ /// @endcond
+
};
#endif /* __xmltooling_internal_h__ */
/**\r
* A thread-safe abstract marshaller.\r
*/\r
- class XMLTOOL_API AbstractXMLObjectMarshaller : public virtual AbstractDOMCachingXMLObject\r
+ class XMLTOOL_API AbstractXMLObjectMarshaller : public virtual AbstractXMLObject\r
{\r
public:\r
virtual ~AbstractXMLObjectMarshaller() {}\r
\r
- /**\r
- * @see XMLObject::marshall(DOMDocument*,const MarshallingContext*)\r
- */\r
DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
\r
- /**\r
- * @see XMLObject::marshall(DOMElement*,const MarshallingContext*)\r
- */\r
DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
\r
protected:\r
/**\r
* A thread-safe abstract unmarshaller.\r
*/\r
- class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual AbstractDOMCachingXMLObject\r
+ class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual AbstractXMLObject\r
{\r
public:\r
virtual ~AbstractXMLObjectUnmarshaller() {}\r
\r
- /**\r
- * @see XMLObject::unmarshall()\r
- */\r
XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
\r
protected:\r
--- /dev/null
+/*\r
+ * Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * @file KeyInfo.h\r
+ * \r
+ * XMLObjects representing XML Digital Signature, version 20020212, KeyInfo element\r
+ * and related content.\r
+ */\r
+\r
+#ifndef __xmltooling_keyinfo_h__\r
+#define __xmltooling_keyinfo_h__\r
+\r
+#include <xmltooling/ElementProxy.h>\r
+#include <xmltooling/XMLObjectBuilder.h>\r
+#include <xmltooling/validation/ValidatingXMLObject.h>\r
+\r
+namespace xmltooling {\r
+\r
+ /**\r
+ * XMLObject representing XML Digital Signature, version 20020212, KeyInfo element.\r
+ */\r
+ BEGIN_XMLOBJECT(KeyInfo,ElementProxy);\r
+ DECL_XMLOBJECT_ATTRIB(Id,ID);\r
+ END_XMLOBJECT;\r
+\r
+ BEGIN_XMLOBJECTBUILDER(KeyInfo);\r
+ END_XMLOBJECTBUILDER;\r
+\r
+#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
+ const XMLCh KeyInfo::LOCAL_NAME[] = {\r
+ chLatin_K, chLatin_e, chLatin_y, chLatin_I, chLatin_n, chLatin_f, chLatin_o, chNull\r
+ }; \r
+ const XMLCh KeyInfo::PREFIX[] = {\r
+ chLatin_d, chLatin_s, chNull\r
+ };\r
+ const XMLCh KeyInfo::ID_ATTRIB_NAME[] = {\r
+ chLatin_I, chLatin_d, chNull\r
+ };\r
+#endif\r
+\r
+};\r
+\r
+#endif /* __xmltooling_keyinfo_h__ */\r
Signature() {}\r
};\r
\r
+#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
+ const XMLCh Signature::LOCAL_NAME[] = {\r
+ chLatin_S, chLatin_i, chLatin_g, chLatin_n, chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chNull\r
+ }; \r
+ const XMLCh Signature::PREFIX[] = {\r
+ chLatin_d, chLatin_s, chNull\r
+ };\r
+#endif\r
+\r
/**\r
* Builder for Signature objects.\r
*/\r
virtual ~SignatureBuilder() {}\r
\r
/**\r
- * Default typed builder method.\r
+ * Default builder.\r
*/\r
virtual Signature* buildObject() const=0;\r
};\r
--- /dev/null
+/*\r
+* Copyright 2001-2006 Internet2\r
+ * \r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * XMLSecSignatureImpl.cpp\r
+ * \r
+ * Signature class for XMLSec-based signature-handling\r
+ */\r
+\r
+#include "internal.h"\r
+#include "AbstractElementProxy.h"\r
+#include "exceptions.h"\r
+#include "io/AbstractXMLObjectMarshaller.h"\r
+#include "io/AbstractXMLObjectUnmarshaller.h"\r
+#include "signature/impl/KeyInfoImpl.h"\r
+#include "util/NDC.h"\r
+#include "util/XMLHelper.h"\r
+#include "validation/AbstractValidatingXMLObject.h"\r
+\r
+#include <log4cpp/Category.hh>\r
+\r
+using namespace xmltooling;\r
+using namespace log4cpp;\r
+using namespace std;\r
+\r
+#if defined (_MSC_VER)\r
+ #pragma warning( push )\r
+ #pragma warning( disable : 4250 4251 )\r
+#endif\r
+\r
+namespace xmltooling {\r
+ \r
+ class XMLTOOL_DLLLOCAL KeyInfoImpl : public KeyInfo, public AbstractDOMCachingXMLObject, public AbstractElementProxy,\r
+ public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller\r
+ {\r
+ public:\r
+ virtual ~KeyInfoImpl() {}\r
+\r
+ KeyInfoImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix)\r
+ : AbstractXMLObject(nsURI, localName, prefix), m_Id(NULL) {}\r
+ \r
+ KeyInfoImpl(const KeyInfoImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),\r
+ AbstractElementProxy(src), AbstractValidatingXMLObject(src), m_Id(XMLString::replicate(src.m_Id)) {\r
+ for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {\r
+ getXMLObjects().push_back((*i) ? (*i)->clone() : NULL);\r
+ }\r
+ }\r
+ \r
+ IMPL_XMLOBJECT_ATTRIB(Id);\r
+ IMPL_XMLOBJECT_CLONE(KeyInfo);\r
+\r
+ protected:\r
+ void marshallAttributes(DOMElement* domElement) const {\r
+ if(getId()) {\r
+ domElement->setAttributeNS(NULL, ID_ATTRIB_NAME, getId());\r
+ domElement->setIdAttributeNS(NULL, ID_ATTRIB_NAME);\r
+ }\r
+ }\r
+\r
+ void marshallElementContent(DOMElement* domElement) const {\r
+ if(getTextContent()) {\r
+ domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent()));\r
+ }\r
+ }\r
+\r
+ void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {\r
+ getXMLObjects().push_back(childXMLObject);\r
+ }\r
+\r
+ void processAttribute(const DOMAttr* attribute) {\r
+ if (XMLHelper::isNodeNamed(attribute, NULL, ID_ATTRIB_NAME))\r
+ setId(attribute->getValue());\r
+ }\r
+\r
+ void processElementContent(const XMLCh* elementContent) {\r
+ setTextContent(elementContent);\r
+ }\r
+ };\r
+ \r
+};\r
+\r
+#if defined (_MSC_VER)\r
+ #pragma warning( pop )\r
+#endif\r
+\r
+KeyInfo* KeyInfoBuilderImpl::buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix) const\r
+{\r
+ return new KeyInfoImpl(ns,name,prefix);\r
+}\r
--- /dev/null
+/*\r
+* Copyright 2001-2006 Internet2\r
+ * \r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * KeyInfoImpl.h\r
+ * \r
+ * Builder class for KeyInfo \r
+ */\r
+\r
+#ifndef __xmltooling_keyinfoimpl_h__\r
+#define __xmltooling_keyinfoimpl_h__\r
+\r
+#include <xmltooling/signature/KeyInfo.h>\r
+#include <xmltooling/util/XMLConstants.h>\r
+\r
+namespace xmltooling {\r
+\r
+ BEGIN_XMLOBJECTBUILDERIMPL(KeyInfo,XMLConstants::XMLSIG_NS);\r
+ END_XMLOBJECTBUILDERIMPL;\r
+\r
+};\r
+\r
+#endif /* __xmltooling_keyinfoimpl_h__ */\r
+++ /dev/null
-/*\r
-* Copyright 2001-2006 Internet2\r
- * \r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * XMLSecSignature.h\r
- * \r
- * Signature classes for XMLSec-based signature-handling\r
- */\r
-\r
-#if !defined(__xmltooling_xmlsecsig_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
-#define __xmltooling_xmlsecsig_h__\r
-\r
-#include "internal.h"\r
-#include "impl/UnknownElement.h"\r
-#include "signature/Signature.h"\r
-#include "util/XMLConstants.h"\r
-\r
-#include <string>\r
-\r
-#if defined (_MSC_VER)\r
- #pragma warning( push )\r
- #pragma warning( disable : 4250 4251 )\r
-#endif\r
-\r
-namespace xmltooling {\r
-\r
- class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
- {\r
- public:\r
- XMLSecSignatureImpl() : UnknownElementImpl(XMLConstants::XMLSIG_NS, Signature::LOCAL_NAME, XMLConstants::XMLSIG_PREFIX),\r
- m_signature(NULL), m_c14n(NULL), m_sm(NULL) {}\r
- virtual ~XMLSecSignatureImpl();\r
- \r
- void releaseDOM();\r
- XMLObject* clone() const;\r
-\r
- DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
- DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
- XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
- \r
- // Getters\r
- const XMLCh* getCanonicalizationMethod() const { return m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC; }\r
- const XMLCh* getSignatureAlgorithm() const { return m_sm ? m_sm : DSIGConstants::s_unicodeStrURIRSA_SHA1; }\r
-\r
- // Setters\r
- void setCanonicalizationMethod(const XMLCh* c14n) { m_c14n = prepareForAssignment(m_c14n,c14n); }\r
- void setSignatureAlgorithm(const XMLCh* sm) { m_sm = prepareForAssignment(m_sm,sm); }\r
-\r
- void sign(const SigningContext& ctx);\r
- void verify(const VerifyingContext& ctx) const;\r
-\r
- private:\r
- mutable DSIGSignature* m_signature;\r
- XMLCh* m_c14n;\r
- XMLCh* m_sm;\r
- };\r
-\r
- class XMLTOOL_DLLLOCAL XMLSecSignatureBuilder : public virtual XMLObjectBuilder\r
- {\r
- public:\r
- XMLSecSignatureImpl* buildObject(\r
- const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL\r
- ) const {\r
- if (!XMLString::equals(namespaceURI,XMLConstants::XMLSIG_NS) || !XMLString::equals(elementLocalName, Signature::LOCAL_NAME))\r
- throw XMLObjectException("XMLSecSignatureBuilder requires standard Signature element name.");\r
- return buildObject();\r
- }\r
- \r
- XMLSecSignatureImpl* buildObject() const {\r
- return new XMLSecSignatureImpl();\r
- }\r
- };\r
-\r
-};\r
-\r
-#if defined (_MSC_VER)\r
- #pragma warning( pop )\r
-#endif\r
-\r
-#endif /* __xmltooling_xmlsecsig_h__ */\r
*/\r
\r
/**\r
- * XMLSecSignature.cpp\r
+ * XMLSecSignatureImpl.cpp\r
* \r
- * Signature classes for XMLSec-based signature-handling\r
+ * Signature class for XMLSec-based signature-handling\r
*/\r
\r
#include "internal.h"\r
#include "exceptions.h"\r
-#include "signature/impl/XMLSecSignature.h"\r
+#include "impl/UnknownElement.h"\r
+#include "signature/impl/XMLSecSignatureImpl.h"\r
#include "util/NDC.h"\r
+#include "util/XMLConstants.h"\r
#include "util/XMLHelper.h"\r
\r
#include <log4cpp/Category.hh>\r
#include <xercesc/framework/MemBufInputSource.hpp>\r
#include <xercesc/framework/Wrapper4InputSource.hpp>\r
-#include <xercesc/util/XMLUniDefs.hpp>\r
#include <xsec/dsig/DSIGKeyInfoX509.hpp>\r
#include <xsec/enc/XSECCryptoException.hpp>\r
#include <xsec/framework/XSECException.hpp>\r
using namespace log4cpp;\r
using namespace std;\r
\r
-const XMLCh xmltooling::Signature::LOCAL_NAME[] = {\r
- chLatin_S, chLatin_i, chLatin_g, chLatin_n, chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chNull\r
-}; \r
+#if defined (_MSC_VER)\r
+ #pragma warning( push )\r
+ #pragma warning( disable : 4250 4251 )\r
+#endif\r
+\r
+namespace xmltooling {\r
+ \r
+ class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
+ {\r
+ public:\r
+ XMLSecSignatureImpl() : UnknownElementImpl(XMLConstants::XMLSIG_NS, Signature::LOCAL_NAME, XMLConstants::XMLSIG_PREFIX),\r
+ m_signature(NULL), m_c14n(NULL), m_sm(NULL) {}\r
+ virtual ~XMLSecSignatureImpl();\r
+ \r
+ void releaseDOM();\r
+ XMLObject* clone() const;\r
\r
-const XMLCh xmltooling::Signature::PREFIX[] = {\r
- chLatin_d, chLatin_s, chNull\r
-}; \r
+ DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
+ DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
+ XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
+ \r
+ // Getters\r
+ const XMLCh* getCanonicalizationMethod() const { return m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC; }\r
+ const XMLCh* getSignatureAlgorithm() const { return m_sm ? m_sm : DSIGConstants::s_unicodeStrURIRSA_SHA1; }\r
+\r
+ // Setters\r
+ void setCanonicalizationMethod(const XMLCh* c14n) { m_c14n = prepareForAssignment(m_c14n,c14n); }\r
+ void setSignatureAlgorithm(const XMLCh* sm) { m_sm = prepareForAssignment(m_sm,sm); }\r
+\r
+ void sign(const SigningContext& ctx);\r
+ void verify(const VerifyingContext& ctx) const;\r
+\r
+ private:\r
+ mutable DSIGSignature* m_signature;\r
+ XMLCh* m_c14n;\r
+ XMLCh* m_sm;\r
+ };\r
+ \r
+};\r
+\r
+#if defined (_MSC_VER)\r
+ #pragma warning( pop )\r
+#endif\r
\r
XMLSecSignatureImpl::~XMLSecSignatureImpl()\r
{\r
setDOM(element, bindDocument);\r
return this;\r
}\r
+\r
+Signature* XMLSecSignatureBuilder::buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix) const\r
+{\r
+ if (!XMLString::equals(ns,XMLConstants::XMLSIG_NS) || !XMLString::equals(name,Signature::LOCAL_NAME))\r
+ throw XMLObjectException("XMLSecSignatureBuilder requires standard Signature element name.");\r
+ return buildObject();\r
+}\r
+\r
+Signature* XMLSecSignatureBuilder::buildObject() const\r
+{\r
+ return new XMLSecSignatureImpl();\r
+}\r
--- /dev/null
+/*\r
+* Copyright 2001-2006 Internet2\r
+ * \r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * XMLSecSignatureImpl.h\r
+ * \r
+ * Builder class for XMLSec-based signature-handling\r
+ */\r
+\r
+#if !defined(__xmltooling_xmlsecsig_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
+#define __xmltooling_xmlsecsig_h__\r
+\r
+#include <xmltooling/signature/Signature.h>\r
+\r
+namespace xmltooling {\r
+\r
+ class XMLTOOL_DLLLOCAL XMLSecSignatureBuilder : public SignatureBuilder\r
+ {\r
+ public:\r
+ Signature* buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix=NULL) const;\r
+ Signature* buildObject() const;\r
+ };\r
+\r
+};\r
+\r
+#endif /* __xmltooling_xmlsecsig_h__ */\r
*/\r
bool loadCatalog(const XMLCh* pathname);\r
\r
- /*\r
+ /**\r
* Load a schema explicitly from a local file.\r
* \r
* Note that "successful processing" does not imply that the schema is valid,\r
* @param systemId optional system identifier to attach to the stream\r
*/\r
StreamInputSource(std::istream& is, const char* systemId=NULL) : InputSource(systemId), m_is(is) {}\r
+ /// @cond off\r
virtual BinInputStream* makeStream() const { return new StreamBinInputStream(m_is); }\r
+ /// @endcond\r
+\r
\r
private:\r
std::istream& m_is;\r
* STL-compatible container wrapper
*/
-#if !defined(__xmltooling_list_h__)
+#ifndef __xmltooling_list_h__
#define __xmltooling_list_h__
-#include <xmltooling/DOMCachingXMLObject.h>
#include <xmltooling/exceptions.h>
+/**
+ * Shorthand for an XMLObjectChildrenList wrapped around a vector
+ *
+ * @param type the type of object in the vector
+ */
#define VectorOf(type) xmltooling::XMLObjectChildrenList< std::vector<type*> >
+
+/**
+ * Shorthand for an XMLObjectChildrenList wrapped around a list
+ *
+ * @param type the type of object in the list
+ */
#define ListOf(type) xmltooling::XMLObjectChildrenList< std::list<type*> >
+
+/**
+ * Shorthand for an XMLObjectChildrenList wrapped around a deque
+ *
+ * @param type the type of object in the deque
+ */
#define DequeOf(type) xmltooling::XMLObjectChildrenList< std::deque<type*> >
namespace xmltooling {
template <class _Ty>
class XMLObjectChildrenIterator
{
+ /// @cond OFF
typename _Ty::iterator m_iter;
template <class _Tx, class _Tz> friend class XMLObjectChildrenList;
public:
// test for iterator inequality
return (!(m_iter == _Right.m_iter));
}
+ /// @endcond
};
/**
XMLObject* m_parent;
public:
+ /// @cond OFF
typedef typename Container::value_type value_type;
typedef typename Container::reference reference;
typedef typename Container::const_reference const_reference;
// We override the iterator types with our constrained wrapper.
typedef XMLObjectChildrenIterator<Container> iterator;
typedef XMLObjectChildrenIterator<Container> const_iterator;
+ /// @endcond
/**
* Constructor to expose a typed collection of children backed by a list of a base type.
) : m_parent(parent), m_container(sublist), m_list(backing), m_fence(ins_fence) {
}
+ /// @cond OFF
+
size_type size() const {
// return length of sequence
return m_container.size();
if (_Val->getParent())
throw XMLObjectException("Child object already has a parent.");
_Val->setParent(m_parent);
- DOMCachingXMLObject* dc=dynamic_cast<DOMCachingXMLObject*>(_Val);
- if (dc) {
- dc->releaseParentDOM(true);
- }
+ _Val->releaseParentDOM(true);
}
void removeParent(const_reference _Val) {
if (_Val->getParent()!=m_parent)
throw XMLObjectException("Child object not owned by this parent.");
_Val->setParent(NULL);
- DOMCachingXMLObject* dc=dynamic_cast<DOMCachingXMLObject*>(m_parent);
- if (dc) {
- dc->releaseParentDOM(true);
- }
+ m_parent->releaseParentDOM(true);
}
void removeChild(const_reference _Val) {
}
}
}
+ /// @endcond
};
};
for_each(v.begin(),v.end(),cleanup<Validator>());\r
}\r
\r
+AbstractValidatingXMLObject::AbstractValidatingXMLObject(const AbstractValidatingXMLObject& src) : AbstractXMLObject(src)\r
+{\r
+ if (src.m_validators) {\r
+ m_validators=new ValidatorWrapper();\r
+ xmltooling::clone(src.m_validators->v,m_validators->v);\r
+ }\r
+}\r
+\r
AbstractValidatingXMLObject::~AbstractValidatingXMLObject()\r
{\r
delete m_validators;\r
protected:\r
AbstractValidatingXMLObject() : m_validators(NULL) {}\r
\r
+ /** Copy constructor. */\r
+ AbstractValidatingXMLObject(const AbstractValidatingXMLObject& src);\r
+\r
private:\r
struct XMLTOOL_DLLLOCAL ValidatorWrapper {\r
~ValidatorWrapper(); \r
virtual void validate(const XMLObject* xmlObject) const=0;\r
\r
/**\r
+ * Returns a copy of the validator.\r
+ *\r
+ * @return the new validator\r
+ */\r
+ virtual Validator* clone() const=0;\r
+\r
+ /**\r
* Evaluates the registered validators against the given XMLObject and it's children.\r
* \r
* @param xmlObject the XMLObject tree to validate\r
*/\r
\r
/**\r
- * @file version.h\r
+ * version.h\r
* \r
* Library version macros and constants \r
*/\r
Name="impl"\r
>\r
<File\r
- RelativePath=".\signature\impl\XMLSecSignature.cpp"\r
+ RelativePath=".\signature\impl\KeyInfoImpl.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\signature\impl\XMLSecSignatureImpl.cpp"\r
>\r
</File>\r
</Filter>\r
>\r
</File>\r
<File\r
- RelativePath=".\DOMCachingXMLObject.h"\r
- >\r
- </File>\r
- <File\r
RelativePath=".\ElementProxy.h"\r
>\r
</File>\r
Name="impl"\r
>\r
<File\r
- RelativePath=".\signature\impl\XMLSecSignature.h"\r
+ RelativePath=".\signature\impl\KeyInfoImpl.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\signature\impl\XMLSecSignatureImpl.h"\r
>\r
</File>\r
</Filter>\r
TSM_ASSERT_EQUALS("Child's schema type was not expected value", m_qtype, *(kids.back()->getSchemaType()));\r
}\r
\r
+ void testUnmarshallingWithClone() {\r
+ TS_TRACE("testUnmarshallingWithClone");\r
+\r
+ string path=data_path + "SimpleXMLObjectWithChildren.xml";\r
+ ifstream fs(path.c_str());\r
+ DOMDocument* doc=nonvalidatingPool->parse(fs);\r
+ TS_ASSERT(doc!=NULL);\r
+\r
+ const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());\r
+ TS_ASSERT(b!=NULL);\r
+\r
+ auto_ptr<SimpleXMLObject> sxObject(\r
+ dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc))\r
+ );\r
+ TS_ASSERT(sxObject.get()!=NULL);\r
+\r
+ sxObject->releaseThisAndChildrenDOM();\r
+ auto_ptr<SimpleXMLObject> clonedObject(sxObject->clone());\r
+\r
+ VectorOf(SimpleXMLObject) kids=clonedObject->getSimpleXMLObjects();\r
+ TSM_ASSERT_EQUALS("Number of child elements was not expected value", 3, kids.size());\r
+ TSM_ASSERT_EQUALS("Child's schema type was not expected value", m_qtype, *(kids.back()->getSchemaType()));\r
+ }\r
+\r
void testUnmarshallingWithUnknownChild() {\r
TS_TRACE("testUnmarshallingWithUnknownChild");\r
\r
#pragma warning( disable : 4250 4251 )
#endif
-class SimpleXMLObject : public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller
+class SimpleXMLObject : public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller
{
+protected:
+ SimpleXMLObject(const SimpleXMLObject& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),
+ m_id(XMLString::replicate(src.m_id)), m_value(XMLString::replicate(src.m_value)) {
+#ifndef XMLTOOLING_NO_XMLSEC
+ m_children.push_back(NULL);
+ m_signature=m_children.begin();
+#endif
+ VectorOf(SimpleXMLObject) mine=getSimpleXMLObjects();
+ for (vector<SimpleXMLObject*>::const_iterator i=src.m_simples.begin(); i!=src.m_simples.end(); i++) {
+ mine.push_back((*i) ? (*i)->clone() : NULL);
+ }
+ }
+
public:
static const XMLCh NAMESPACE[];
static const XMLCh NAMESPACE_PREFIX[];
XMLString::release(&m_id);
XMLString::release(&m_value);
}
-
+
+ SimpleXMLObject* clone() const {
+ auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
+ SimpleXMLObject* ret=dynamic_cast<SimpleXMLObject*>(domClone.get());
+ if (ret) {
+ domClone.release();
+ return ret;
+ }
+
+ return new SimpleXMLObject(*this);
+ }
+
const XMLCh* getId() const { return m_id; }
void setId(const XMLCh* id) { m_id=prepareForAssignment(m_id,id); }
VectorOf(SimpleXMLObject) getSimpleXMLObjects() {
return VectorOf(SimpleXMLObject)(this, m_simples, &m_children, m_children.end());
}
-
- SimpleXMLObject* clone() const {
- auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
- SimpleXMLObject* ret=dynamic_cast<SimpleXMLObject*>(domClone.get());
- if (ret) {
- domClone.release();
- return ret;
- }
-
- ret=new SimpleXMLObject();
- ret->m_namespaces=m_namespaces;
- ret->setId(m_id);
- ret->setValue(m_value);
- xmltooling::clone(m_children, ret->m_children);
- return ret;
- }
+protected:
void marshallAttributes(DOMElement* domElement) const {
if(getId()) {
domElement->setAttributeNS(NULL, SimpleXMLObject::ID_ATTRIB_NAME, getId());