From 1f87cef41f9948492e13d3d9dc1495652606c441 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Mon, 27 Nov 2006 21:26:18 +0000 Subject: [PATCH] Refined ElementProxy/ElementExtensible interfaces to match Java. --- xmltooling/AbstractElementProxy.h | 67 --------------------- xmltooling/AttributeExtensibleXMLObject.h | 6 +- xmltooling/ElementExtensibleXMLObject.h | 68 ++++++++++++++++++++++ xmltooling/ElementProxy.h | 25 +++----- xmltooling/Makefile.am | 2 +- xmltooling/encryption/Encryption.h | 8 +-- xmltooling/encryption/impl/Decrypter.cpp | 2 +- xmltooling/encryption/impl/Encrypter.cpp | 2 +- xmltooling/encryption/impl/EncryptionImpl.cpp | 45 +++++++------- .../encryption/impl/EncryptionSchemaValidators.cpp | 4 +- xmltooling/impl/AnyElement.cpp | 10 ++-- xmltooling/impl/AnyElement.h | 14 +++-- xmltooling/signature/KeyInfo.h | 13 ++--- xmltooling/signature/impl/KeyInfoImpl.cpp | 50 ++++++++-------- .../signature/impl/KeyInfoSchemaValidators.cpp | 6 +- xmltooling/soap/SOAP.h | 7 +-- xmltooling/soap/impl/SOAPClient.cpp | 2 +- xmltooling/soap/impl/SOAPImpl.cpp | 47 +++++++-------- xmltoolingtest/ComplexXMLObjectTest.h | 10 ++-- 19 files changed, 180 insertions(+), 208 deletions(-) delete mode 100644 xmltooling/AbstractElementProxy.h create mode 100644 xmltooling/ElementExtensibleXMLObject.h diff --git a/xmltooling/AbstractElementProxy.h b/xmltooling/AbstractElementProxy.h deleted file mode 100644 index 473a942..0000000 --- a/xmltooling/AbstractElementProxy.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file xmltooling/AbstractElementProxy.h - * - * AbstractXMLObject mixin that implements an open content model - */ - -#ifndef __xmltooling_abseleproxy_h__ -#define __xmltooling_abseleproxy_h__ - -#include -#include - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - -namespace xmltooling { - - /** - * AbstractXMLObject mixin that layers ElementProxy on top of a complex element. - * Inherit from this class to implement complex content - * and expose the underlying child collection in read/write mode. - */ - class XMLTOOL_API AbstractElementProxy : public virtual ElementProxy, public AbstractComplexElement - { - public: - virtual ~AbstractElementProxy() {} - - virtual ListOf(XMLObject) getXMLObjects() { - return ListOf(XMLObject)(this,m_children,NULL,m_children.end()); - } - - virtual const std::list& getXMLObjects() const { - return m_children; - } - - protected: - AbstractElementProxy() {} - - /** Copy constructor. */ - AbstractElementProxy(const AbstractElementProxy& src) : AbstractXMLObject(src), AbstractComplexElement(src) {} - }; - -}; - -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - -#endif /* __xmltooling_abseleproxy_h__ */ diff --git a/xmltooling/AttributeExtensibleXMLObject.h b/xmltooling/AttributeExtensibleXMLObject.h index 05377f1..2bd10d8 100644 --- a/xmltooling/AttributeExtensibleXMLObject.h +++ b/xmltooling/AttributeExtensibleXMLObject.h @@ -15,18 +15,16 @@ */ /** - * @file AttributeExtensibleXMLObject.h + * @file xmltooling/AttributeExtensibleXMLObject.h * * An XMLObject that supports arbitrary attributes */ -#if !defined(__xmltooling_attrextxmlobj_h__) +#ifndef __xmltooling_attrextxmlobj_h__ #define __xmltooling_attrextxmlobj_h__ #include -using namespace xercesc; - #if defined (_MSC_VER) #pragma warning( push ) #pragma warning( disable : 4250 4251 ) diff --git a/xmltooling/ElementExtensibleXMLObject.h b/xmltooling/ElementExtensibleXMLObject.h new file mode 100644 index 0000000..4e98c97 --- /dev/null +++ b/xmltooling/ElementExtensibleXMLObject.h @@ -0,0 +1,68 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file xmltooling/ElementExtensibleXMLObject.h + * + * An XMLObject that exposes arbitrary children via a mutable vector. + */ + +#ifndef __xmltooling_eleextxmlobj_h__ +#define __xmltooling_eleextxmlobj_h__ + +#include +#include + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4250 4251 ) +#endif + +namespace xmltooling { + + /** + * An XMLObject that exposes arbitrary children via a mutable vector. + */ + class XMLTOOL_API ElementExtensibleXMLObject : public virtual XMLObject + { + protected: + ElementExtensibleXMLObject() {} + + public: + virtual ~ElementExtensibleXMLObject() {} + + /** + * Gets a mutable list of child objects + * + * @return mutable list of child objects + */ + virtual VectorOf(XMLObject) getUnknownXMLObjects()=0; + + /** + * Gets an immutable list of child objects + * + * @return immutable list of child objects + */ + virtual const std::vector& getUnknownXMLObjects() const=0; + }; + +}; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +#endif /* __xmltooling_eleextxmlobj_h__ */ diff --git a/xmltooling/ElementProxy.h b/xmltooling/ElementProxy.h index 6b5c44e..866185e 100644 --- a/xmltooling/ElementProxy.h +++ b/xmltooling/ElementProxy.h @@ -23,7 +23,8 @@ #ifndef __xmltooling_eleproxy_h__ #define __xmltooling_eleproxy_h__ -#include +#include +#include #include using namespace xercesc; @@ -31,27 +32,15 @@ using namespace xercesc; namespace xmltooling { /** - * An XMLObject that exposes its children via mutable list. + * An XMLObject with an open content model. */ - class XMLTOOL_API ElementProxy : public virtual XMLObject + class XMLTOOL_API ElementProxy : public virtual AttributeExtensibleXMLObject, public virtual ElementExtensibleXMLObject { - public: + protected: ElementProxy() {} + + public: virtual ~ElementProxy() {} - - /** - * Gets a mutable list of child objects - * - * @return mutable list of child objects - */ - virtual ListOf(XMLObject) getXMLObjects()=0; - - /** - * Gets an immutable list of child objects - * - * @return immutable list of child objects - */ - virtual const std::list& getXMLObjects() const=0; }; }; diff --git a/xmltooling/Makefile.am b/xmltooling/Makefile.am index d30c2a2..ee9038c 100644 --- a/xmltooling/Makefile.am +++ b/xmltooling/Makefile.am @@ -24,12 +24,12 @@ libxmltoolinginclude_HEADERS = \ AbstractAttributeExtensibleXMLObject.h \ AbstractComplexElement.h \ AbstractDOMCachingXMLObject.h \ - AbstractElementProxy.h \ AbstractSimpleElement.h \ AbstractXMLObject.h \ AttributeExtensibleXMLObject.h \ base.h \ config_pub.h \ + ElementExtensibleXMLObject.h \ ElementProxy.h \ exceptions.h \ Lockable.h \ diff --git a/xmltooling/encryption/Encryption.h b/xmltooling/encryption/Encryption.h index dd698d6..ab1b57c 100644 --- a/xmltooling/encryption/Encryption.h +++ b/xmltooling/encryption/Encryption.h @@ -23,7 +23,6 @@ #ifndef __xmltooling_encryption_h__ #define __xmltooling_encryption_h__ -#include #include #define DECL_XMLENCOBJECTBUILDER(cname) \ @@ -43,11 +42,10 @@ namespace xmlencryption { DECL_INTEGER_CONTENT(Size); END_XMLOBJECT; - BEGIN_XMLOBJECT(XMLTOOL_API,EncryptionMethod,xmltooling::XMLObject,XML Encryption EncryptionMethod element); + BEGIN_XMLOBJECT(XMLTOOL_API,EncryptionMethod,xmltooling::ElementExtensibleXMLObject,XML Encryption EncryptionMethod element); DECL_STRING_ATTRIB(Algorithm,ALGORITHM); DECL_TYPED_CHILD(KeySize); DECL_TYPED_CHILD(OAEPparams); - DECL_XMLOBJECT_CHILDREN(OtherParameter); /** EncryptionMethodType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -72,7 +70,7 @@ namespace xmlencryption { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT2(XMLTOOL_API,EncryptionProperty,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,XML Encryption EncryptionProperty element); + BEGIN_XMLOBJECT(XMLTOOL_API,EncryptionProperty,xmltooling::ElementProxy,XML Encryption EncryptionProperty element); DECL_STRING_ATTRIB(Target,TARGET); DECL_STRING_ATTRIB(Id,ID); /** EncryptionPropertyType local name */ @@ -86,7 +84,7 @@ namespace xmlencryption { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(XMLTOOL_API,ReferenceType,xmltooling::ElementProxy,XML Encryption ReferenceType type); + BEGIN_XMLOBJECT(XMLTOOL_API,ReferenceType,xmltooling::ElementExtensibleXMLObject,XML Encryption ReferenceType type); DECL_STRING_ATTRIB(URI,URI); /** ReferenceType local name */ static const XMLCh TYPE_NAME[]; diff --git a/xmltooling/encryption/impl/Decrypter.cpp b/xmltooling/encryption/impl/Decrypter.cpp index a0fbc7c..7a8d553 100644 --- a/xmltooling/encryption/impl/Decrypter.cpp +++ b/xmltooling/encryption/impl/Decrypter.cpp @@ -74,7 +74,7 @@ DOMDocumentFragment* Decrypter::decryptData(EncryptedData* encryptedData) throw DecryptionException("No EncryptionMethod/@Algorithm set, key decryption cannot proceed."); if (encryptedData->getKeyInfo()) { - const vector& others=const_cast(encryptedData->getKeyInfo())->getOthers(); + const vector& others=const_cast(encryptedData->getKeyInfo())->getUnknownXMLObjects(); for (vector::const_iterator i=others.begin(); i!=others.end(); i++) { EncryptedKey* encKey=dynamic_cast(*i); if (encKey) { diff --git a/xmltooling/encryption/impl/Encrypter.cpp b/xmltooling/encryption/impl/Encrypter.cpp index 43185e8..f6aafd2 100644 --- a/xmltooling/encryption/impl/Encrypter.cpp +++ b/xmltooling/encryption/impl/Encrypter.cpp @@ -211,7 +211,7 @@ EncryptedData* Encrypter::decorateAndUnmarshall(EncryptionParams& encParams, Key // Add the EncryptedKey. if (!xmlEncData->getKeyInfo()) xmlEncData->setKeyInfo(KeyInfoBuilder::buildKeyInfo()); - xmlEncData->getKeyInfo()->getOthers().push_back(xmlEncKey); + xmlEncData->getKeyInfo()->getUnknownXMLObjects().push_back(xmlEncKey); xmlObjectKey.release(); } diff --git a/xmltooling/encryption/impl/EncryptionImpl.cpp b/xmltooling/encryption/impl/EncryptionImpl.cpp index ae25710..c3809d5 100644 --- a/xmltooling/encryption/impl/EncryptionImpl.cpp +++ b/xmltooling/encryption/impl/EncryptionImpl.cpp @@ -22,8 +22,8 @@ #include "internal.h" #include "AbstractAttributeExtensibleXMLObject.h" +#include "AbstractComplexElement.h" #include "AbstractSimpleElement.h" -#include "AbstractElementProxy.h" #include "exceptions.h" #include "encryption/Encryption.h" #include "io/AbstractXMLObjectMarshaller.h" @@ -84,19 +84,16 @@ namespace xmlencryption { setKeySize(src.getKeySize()->cloneKeySize()); if (src.getOAEPparams()) setOAEPparams(src.getOAEPparams()->cloneOAEPparams()); - VectorOf(XMLObject) v=getOtherParameters(); - for (vector::const_iterator i=src.m_OtherParameters.begin(); i!=src.m_OtherParameters.end(); i++) { - if (*i) { - v.push_back((*i)->clone()); - } - } + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } IMPL_XMLOBJECT_CLONE(EncryptionMethod); IMPL_STRING_ATTRIB(Algorithm); IMPL_TYPED_CHILD(KeySize); IMPL_TYPED_CHILD(OAEPparams); - IMPL_XMLOBJECT_CHILDREN(OtherParameter,m_children.end()); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { @@ -110,7 +107,7 @@ namespace xmlencryption { // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,XMLENC_NS) && nsURI && *nsURI) { - getOtherParameters().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); return; } @@ -251,8 +248,8 @@ namespace xmlencryption { }; class XMLTOOL_DLLLOCAL EncryptionPropertyImpl : public virtual EncryptionProperty, - public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -273,22 +270,21 @@ namespace xmlencryption { EncryptionPropertyImpl(const EncryptionPropertyImpl& src) : AbstractXMLObject(src), - AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src), + AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setId(src.getId()); setTarget(src.getTarget()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - getXMLObjects().push_back((*i)->clone()); - } - } + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } IMPL_XMLOBJECT_CLONE(EncryptionProperty); IMPL_ID_ATTRIB(Id); IMPL_STRING_ATTRIB(Target); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end()); void setAttribute(QName& qualifiedName, const XMLCh* value) { if (!qualifiedName.hasNamespaceURI()) { @@ -312,7 +308,7 @@ namespace xmlencryption { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void processAttribute(const DOMAttr* attribute) { @@ -373,7 +369,7 @@ namespace xmlencryption { }; class XMLTOOL_DLLLOCAL ReferenceTypeImpl : public virtual ReferenceType, - public AbstractElementProxy, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -398,18 +394,17 @@ namespace xmlencryption { } ReferenceTypeImpl(const ReferenceTypeImpl& src) - : AbstractXMLObject(src), AbstractElementProxy(src), AbstractDOMCachingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setURI(src.getURI()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - getXMLObjects().push_back((*i)->clone()); - } - } + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } IMPL_XMLOBJECT_CLONE(ReferenceType); IMPL_STRING_ATTRIB(URI); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { @@ -417,7 +412,7 @@ namespace xmlencryption { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void processAttribute(const DOMAttr* attribute) { diff --git a/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp b/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp index 5bf1218..72ac584 100644 --- a/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp +++ b/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp @@ -69,7 +69,7 @@ namespace xmlencryption { BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,EncryptionProperty); if (!ptr->hasChildren()) throw ValidationException("EncryptionProperty must have at least one child element."); - const list& anys=ptr->getXMLObjects(); + const vector& anys=ptr->getUnknownXMLObjects(); for_each(anys.begin(),anys.end(),checkWildcardNS()); END_XMLOBJECTVALIDATOR; @@ -79,7 +79,7 @@ namespace xmlencryption { BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,ReferenceType); XMLOBJECTVALIDATOR_REQUIRE(DataReference,URI); - const list& anys=ptr->getXMLObjects(); + const vector& anys=ptr->getUnknownXMLObjects(); for_each(anys.begin(),anys.end(),checkWildcardNS()); END_XMLOBJECTVALIDATOR; diff --git a/xmltooling/impl/AnyElement.cpp b/xmltooling/impl/AnyElement.cpp index bdb3ccc..5e813a5 100644 --- a/xmltooling/impl/AnyElement.cpp +++ b/xmltooling/impl/AnyElement.cpp @@ -45,10 +45,10 @@ XMLObject* AnyElementImpl::clone() const { } AnyElementImpl::AnyElementImpl(const AnyElementImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), - AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src) { - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - getXMLObjects().push_back((*i) ? (*i)->clone() : NULL); - } + AbstractComplexElement(src), AbstractAttributeExtensibleXMLObject(src) { + const vector& children = src.getUnknownXMLObjects(); + for (vector::const_iterator i=children.begin(); i!=children.end(); ++i) + getUnknownXMLObjects().push_back((*i)->clone()); } void AnyElementImpl::marshallAttributes(DOMElement* domElement) const { @@ -56,7 +56,7 @@ void AnyElementImpl::marshallAttributes(DOMElement* domElement) const { } void AnyElementImpl::processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void AnyElementImpl::processAttribute(const DOMAttr* attribute) { diff --git a/xmltooling/impl/AnyElement.h b/xmltooling/impl/AnyElement.h index 4e668c8..789c6ea 100644 --- a/xmltooling/impl/AnyElement.h +++ b/xmltooling/impl/AnyElement.h @@ -20,11 +20,12 @@ * Advanced anyType implementation suitable for deep processing of unknown content. */ -#if !defined(__xmltooling_anyelement_h__) +#ifndef __xmltooling_anyelement_h__ #define __xmltooling_anyelement_h__ +#include #include -#include +#include #include #include #include @@ -39,8 +40,9 @@ namespace xmltooling { /** * Implements a smart wrapper around unknown or arbitrary DOM content. */ - class XMLTOOL_API AnyElementImpl : public AbstractDOMCachingXMLObject, - public AbstractElementProxy, + class XMLTOOL_API AnyElementImpl : public virtual ElementProxy, + public AbstractDOMCachingXMLObject, + public AbstractComplexElement, public AbstractAttributeExtensibleXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -55,7 +57,9 @@ namespace xmltooling { protected: AnyElementImpl() {} - AnyElementImpl(const AnyElementImpl& src); + AnyElementImpl(const AnyElementImpl& src); + + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); void marshallAttributes(DOMElement* domElement) const; void processChildElement(XMLObject* childXMLObject, const DOMElement* root); diff --git a/xmltooling/signature/KeyInfo.h b/xmltooling/signature/KeyInfo.h index 410403e..720455b 100644 --- a/xmltooling/signature/KeyInfo.h +++ b/xmltooling/signature/KeyInfo.h @@ -77,12 +77,12 @@ namespace xmlsignature { BEGIN_XMLOBJECT(XMLTOOL_API,KeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 KeyValue element); DECL_TYPED_CHILD(DSAKeyValue); DECL_TYPED_CHILD(RSAKeyValue); - DECL_XMLOBJECT_CHILD(OtherKeyValue); + DECL_XMLOBJECT_CHILD(UnknownXMLObject); /** KeyValueType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(XMLTOOL_API,Transform,xmltooling::ElementProxy,XML Digital Signature version 20020212 Transform element); + BEGIN_XMLOBJECT(XMLTOOL_API,Transform,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 Transform element); DECL_STRING_ATTRIB(Algorithm,ALGORITHM); DECL_TYPED_CHILDREN(XPath); /** TransformType local name */ @@ -116,13 +116,12 @@ namespace xmlsignature { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(XMLTOOL_API,X509Data,xmltooling::XMLObject,XML Digital Signature version 20020212 X509Data element); + BEGIN_XMLOBJECT(XMLTOOL_API,X509Data,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 X509Data element); DECL_TYPED_CHILDREN(X509IssuerSerial); DECL_TYPED_CHILDREN(X509SKI); DECL_TYPED_CHILDREN(X509SubjectName); DECL_TYPED_CHILDREN(X509Certificate); DECL_TYPED_CHILDREN(X509CRL); - DECL_XMLOBJECT_CHILDREN(OtherX509Data); /** X509DataType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -138,15 +137,14 @@ namespace xmlsignature { virtual const std::vector< std::pair >& getSPKISexps() const=0; END_XMLOBJECT; - BEGIN_XMLOBJECT(XMLTOOL_API,PGPData,xmltooling::XMLObject,XML Digital Signature version 20020212 PGPData element); + BEGIN_XMLOBJECT(XMLTOOL_API,PGPData,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 PGPData element); DECL_TYPED_CHILD(PGPKeyID); DECL_TYPED_CHILD(PGPKeyPacket); - DECL_XMLOBJECT_CHILDREN(PGPDataExtension); /** PGPDataType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfo,xmltooling::XMLObject,XML Digital Signature version 20020212 KeyInfo element); + BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfo,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 KeyInfo element); DECL_STRING_ATTRIB(Id,ID); DECL_TYPED_CHILDREN(X509Data); DECL_TYPED_CHILDREN(KeyName); @@ -155,7 +153,6 @@ namespace xmlsignature { DECL_TYPED_CHILDREN(MgmtData); DECL_TYPED_CHILDREN(PGPData); DECL_TYPED_CHILDREN(SPKIData); - DECL_XMLOBJECT_CHILDREN(Other); /** KeyInfoType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; diff --git a/xmltooling/signature/impl/KeyInfoImpl.cpp b/xmltooling/signature/impl/KeyInfoImpl.cpp index 215392f..f89eb98 100644 --- a/xmltooling/signature/impl/KeyInfoImpl.cpp +++ b/xmltooling/signature/impl/KeyInfoImpl.cpp @@ -21,9 +21,7 @@ */ #include "internal.h" -#include "AbstractSimpleElement.h" #include "AbstractComplexElement.h" -#include "AbstractElementProxy.h" #include "AbstractSimpleElement.h" #include "exceptions.h" #include "io/AbstractXMLObjectMarshaller.h" @@ -196,28 +194,28 @@ namespace xmlsignature { setDSAKeyValue(src.getDSAKeyValue()->cloneDSAKeyValue()); if (src.getRSAKeyValue()) setRSAKeyValue(src.getRSAKeyValue()->cloneRSAKeyValue()); - if (src.getOtherKeyValue()) - setOtherKeyValue(src.getOtherKeyValue()->clone()); + if (src.getUnknownXMLObject()) + setUnknownXMLObject(src.getUnknownXMLObject()->clone()); } void init() { m_DSAKeyValue=NULL; m_RSAKeyValue=NULL; - m_OtherKeyValue=NULL; + m_UnknownXMLObject=NULL; m_children.push_back(NULL); m_children.push_back(NULL); m_children.push_back(NULL); m_pos_DSAKeyValue=m_children.begin(); m_pos_RSAKeyValue=m_pos_DSAKeyValue; ++m_pos_RSAKeyValue; - m_pos_OtherKeyValue=m_pos_RSAKeyValue; - ++m_pos_OtherKeyValue; + m_pos_UnknownXMLObject=m_pos_RSAKeyValue; + ++m_pos_UnknownXMLObject; } IMPL_XMLOBJECT_CLONE(KeyValue); IMPL_TYPED_CHILD(DSAKeyValue); IMPL_TYPED_CHILD(RSAKeyValue); - IMPL_XMLOBJECT_CHILD(OtherKeyValue); + IMPL_XMLOBJECT_CHILD(UnknownXMLObject); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -227,7 +225,7 @@ namespace xmlsignature { // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,XMLSIG_NS) && nsURI && *nsURI) { - setOtherKeyValue(childXMLObject); + setUnknownXMLObject(childXMLObject); return; } @@ -236,8 +234,8 @@ namespace xmlsignature { }; class XMLTOOL_DLLLOCAL TransformImpl : public virtual Transform, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractElementProxy, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -251,7 +249,7 @@ namespace xmlsignature { } TransformImpl(const TransformImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractElementProxy(src), + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src), m_Algorithm(XMLString::replicate(src.m_Algorithm)) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { if (*i) { @@ -260,7 +258,7 @@ namespace xmlsignature { getXPaths().push_back(x->cloneXPath()); continue; } - getXMLObjects().push_back((*i)->clone()); + getUnknownXMLObjects().push_back((*i)->clone()); } } } @@ -268,6 +266,7 @@ namespace xmlsignature { IMPL_XMLOBJECT_CLONE(Transform); IMPL_STRING_ATTRIB(Algorithm); IMPL_TYPED_CHILDREN(XPath,m_children.end()); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { @@ -280,7 +279,7 @@ namespace xmlsignature { // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,XMLSIG_NS) && nsURI && *nsURI) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); return; } @@ -474,7 +473,7 @@ namespace xmlsignature { continue; } - getOtherX509Datas().push_back((*i)->clone()); + getUnknownXMLObjects().push_back((*i)->clone()); } } } @@ -485,7 +484,7 @@ namespace xmlsignature { IMPL_TYPED_CHILDREN(X509SubjectName,m_children.end()); IMPL_TYPED_CHILDREN(X509Certificate,m_children.end()); IMPL_TYPED_CHILDREN(X509CRL,m_children.end()); - IMPL_XMLOBJECT_CHILDREN(OtherX509Data,m_children.end()); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -498,7 +497,7 @@ namespace xmlsignature { // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,XMLSIG_NS) && nsURI && *nsURI) { - getOtherX509Datas().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); return; } @@ -591,12 +590,9 @@ namespace xmlsignature { setPGPKeyID(src.getPGPKeyID()->clonePGPKeyID()); if (src.getPGPKeyPacket()) setPGPKeyPacket(src.getPGPKeyPacket()->clonePGPKeyPacket()); - VectorOf(XMLObject) v=getPGPDataExtensions(); - for (vector::const_iterator i=src.m_PGPDataExtensions.begin(); i!=src.m_PGPDataExtensions.end(); i++) { - if (*i) { - v.push_back((*i)->clone()); - } - } + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } void init() { @@ -612,7 +608,7 @@ namespace xmlsignature { IMPL_XMLOBJECT_CLONE(PGPData); IMPL_TYPED_CHILD(PGPKeyID); IMPL_TYPED_CHILD(PGPKeyPacket); - IMPL_XMLOBJECT_CHILDREN(PGPDataExtension,m_children.end()); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -622,7 +618,7 @@ namespace xmlsignature { // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,XMLSIG_NS) && nsURI && *nsURI) { - getPGPDataExtensions().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); return; } @@ -693,7 +689,7 @@ namespace xmlsignature { continue; } - getOthers().push_back((*i)->clone()); + getUnknownXMLObjects().push_back((*i)->clone()); } } } @@ -707,7 +703,7 @@ namespace xmlsignature { IMPL_TYPED_CHILDREN(MgmtData,m_children.end()); IMPL_TYPED_CHILDREN(SPKIData,m_children.end()); IMPL_TYPED_CHILDREN(PGPData,m_children.end()); - IMPL_XMLOBJECT_CHILDREN(Other,m_children.end()); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { @@ -726,7 +722,7 @@ namespace xmlsignature { // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,XMLSIG_NS) && nsURI && *nsURI) { - getOthers().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); return; } diff --git a/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp b/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp index e227082..d1bb902 100644 --- a/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp +++ b/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp @@ -66,7 +66,7 @@ namespace xmlsignature { END_XMLOBJECTVALIDATOR; BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,KeyValue); - XMLOBJECTVALIDATOR_ONLYONEOF3(KeyValue,DSAKeyValue,RSAKeyValue,OtherKeyValue); + XMLOBJECTVALIDATOR_ONLYONEOF3(KeyValue,DSAKeyValue,RSAKeyValue,UnknownXMLObject); END_XMLOBJECTVALIDATOR; BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Transform); @@ -102,7 +102,7 @@ namespace xmlsignature { BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,X509Data); if (!ptr->hasChildren()) throw ValidationException("X509Data must have at least one child element."); - const vector& anys=ptr->getOtherX509Datas(); + const vector& anys=ptr->getUnknownXMLObjects(); for_each(anys.begin(),anys.end(),checkWildcardNS()); END_XMLOBJECTVALIDATOR; @@ -117,7 +117,7 @@ namespace xmlsignature { BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,KeyInfo); if (!ptr->hasChildren()) throw ValidationException("KeyInfo must have at least one child element."); - const vector& anys=ptr->getOthers(); + const vector& anys=ptr->getUnknownXMLObjects(); for_each(anys.begin(),anys.end(),checkWildcardNS()); END_XMLOBJECTVALIDATOR; diff --git a/xmltooling/soap/SOAP.h b/xmltooling/soap/SOAP.h index 4ea21e2..e7aeb22 100644 --- a/xmltooling/soap/SOAP.h +++ b/xmltooling/soap/SOAP.h @@ -23,7 +23,6 @@ #ifndef __xmltooling_soap_h__ #define __xmltooling_soap_h__ -#include #include #include #include @@ -48,7 +47,7 @@ namespace soap11 { virtual void setCode(const xmltooling::QName* qname)=0; END_XMLOBJECT; - BEGIN_XMLOBJECT2(XMLTOOL_API,Detail,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SOAP 1.1 detail element); + BEGIN_XMLOBJECT(XMLTOOL_API,Detail,xmltooling::ElementProxy,SOAP 1.1 detail element); /** detail (type) local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -62,13 +61,13 @@ namespace soap11 { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT2(XMLTOOL_API,Body,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SOAP 1.1 Body element); + BEGIN_XMLOBJECT(XMLTOOL_API,Body,xmltooling::ElementProxy,SOAP 1.1 Body element); DECL_STRING_ATTRIB(EncodingStyle,ENCODINGSTYLE); /** Body (type) local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT2(XMLTOOL_API,Header,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SOAP 1.1 Header element); + BEGIN_XMLOBJECT(XMLTOOL_API,Header,xmltooling::ElementProxy,SOAP 1.1 Header element); DECL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,false); DECL_STRING_ATTRIB(Actor,ACTOR); /** Header (type) local name */ diff --git a/xmltooling/soap/impl/SOAPClient.cpp b/xmltooling/soap/impl/SOAPClient.cpp index 2b33055..d785b63 100644 --- a/xmltooling/soap/impl/SOAPClient.cpp +++ b/xmltooling/soap/impl/SOAPClient.cpp @@ -90,7 +90,7 @@ Envelope* SOAPClient::receive() Body* body = env->getBody(); if (body && body->hasChildren()) { //Check for a Fault. - const Fault* fault = dynamic_cast(body->getXMLObjects().front()); + const Fault* fault = dynamic_cast(body->getUnknownXMLObjects().front()); if (fault && handleFault(*fault)) throw IOException("SOAP client detected a Fault."); } diff --git a/xmltooling/soap/impl/SOAPImpl.cpp b/xmltooling/soap/impl/SOAPImpl.cpp index be75300..305255d 100644 --- a/xmltooling/soap/impl/SOAPImpl.cpp +++ b/xmltooling/soap/impl/SOAPImpl.cpp @@ -22,8 +22,8 @@ #include "internal.h" #include "AbstractAttributeExtensibleXMLObject.h" +#include "AbstractComplexElement.h" #include "AbstractSimpleElement.h" -#include "AbstractElementProxy.h" #include "exceptions.h" #include "io/AbstractXMLObjectMarshaller.h" #include "io/AbstractXMLObjectUnmarshaller.h" @@ -86,8 +86,8 @@ namespace { }; class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail, - public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -101,17 +101,16 @@ namespace { DetailImpl(const DetailImpl& src) : AbstractXMLObject(src), - AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src), + AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - getXMLObjects().push_back((*i)->clone()); - } - } + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } IMPL_XMLOBJECT_CLONE(Detail); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { @@ -119,7 +118,7 @@ namespace { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void processAttribute(const DOMAttr* attribute) { @@ -193,8 +192,8 @@ namespace { }; class XMLTOOL_DLLLOCAL BodyImpl : public virtual Body, - public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -214,20 +213,19 @@ namespace { BodyImpl(const BodyImpl& src) : AbstractXMLObject(src), - AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src), + AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setEncodingStyle(src.getEncodingStyle()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - getXMLObjects().push_back((*i)->clone()); - } - } + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } IMPL_XMLOBJECT_CLONE(Body); IMPL_STRING_ATTRIB(EncodingStyle); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end()); void setAttribute(QName& qualifiedName, const XMLCh* value) { if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) { @@ -246,7 +244,7 @@ namespace { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void processAttribute(const DOMAttr* attribute) { @@ -255,8 +253,8 @@ namespace { }; class XMLTOOL_DLLLOCAL HeaderImpl : public virtual Header, - public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -277,22 +275,21 @@ namespace { HeaderImpl(const HeaderImpl& src) : AbstractXMLObject(src), - AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src), + AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setActor(src.getActor()); MustUnderstand(m_MustUnderstand); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - getXMLObjects().push_back((*i)->clone()); - } - } + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } IMPL_XMLOBJECT_CLONE(Header); IMPL_STRING_ATTRIB(Actor); IMPL_BOOLEAN_ATTRIB(MustUnderstand); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end()); void setAttribute(QName& qualifiedName, const XMLCh* value) { if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) { @@ -316,7 +313,7 @@ namespace { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void processAttribute(const DOMAttr* attribute) { diff --git a/xmltoolingtest/ComplexXMLObjectTest.h b/xmltoolingtest/ComplexXMLObjectTest.h index 0633ada..1f8ef10 100644 --- a/xmltoolingtest/ComplexXMLObjectTest.h +++ b/xmltoolingtest/ComplexXMLObjectTest.h @@ -46,20 +46,18 @@ public: ); TS_ASSERT(wcObject.get()!=NULL); - ListOf(XMLObject) kids=wcObject->getXMLObjects(); + VectorOf(XMLObject) kids=wcObject->getUnknownXMLObjects(); TSM_ASSERT_EQUALS("Number of child elements was not expected value", 2, kids.size()); ElementProxy* wc1=dynamic_cast(*(++kids.begin())); - ElementProxy* wc2=dynamic_cast(*(++(wc1->getXMLObjects().begin()))); - TSM_ASSERT_EQUALS("Number of child elements was not expected value", 3, wc2->getXMLObjects().size()); + ElementProxy* wc2=dynamic_cast(*(++(wc1->getUnknownXMLObjects().begin()))); + TSM_ASSERT_EQUALS("Number of child elements was not expected value", 3, wc2->getUnknownXMLObjects().size()); static const XMLCh html[] = {chLatin_h, chLatin_t, chLatin_m, chLatin_l, chNull}; static const XMLCh div[] = {chLatin_d, chLatin_i, chLatin_v, chNull}; auto_ptr_XMLCh htmlns("http://www.w3.org/1999/xhtml"); QName q(htmlns.get(),div,html); - ListOf(XMLObject)::const_iterator it=wc2->getXMLObjects().begin(); - ++it; ++it; - TSM_ASSERT_EQUALS("Element QName unexpected", it->getElementQName(),q); + TSM_ASSERT_EQUALS("Element QName unexpected", wc2->getUnknownXMLObjects()[2]->getElementQName(),q); DOMElement* rebuilt = wcObject->marshall(XMLToolingConfig::getConfig().getParser().newDocument()); wcObject->setDocument(rebuilt->getOwnerDocument()); -- 2.1.4