X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fencryption%2Fimpl%2FEncryptionImpl.cpp;h=8e006da195429605f23ee28fd979bb6d13f5dfa1;hb=3a89fe08a9cc882e435aa2976210b7b1ae4cd264;hp=324f8f6122dc9d607bad212829e67b51f5ea479e;hpb=662e29b6668db409b0d81da58f3d68a9ab12c20b;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/encryption/impl/EncryptionImpl.cpp b/xmltooling/encryption/impl/EncryptionImpl.cpp index 324f8f6..8e006da 100644 --- a/xmltooling/encryption/impl/EncryptionImpl.cpp +++ b/xmltooling/encryption/impl/EncryptionImpl.cpp @@ -1,41 +1,48 @@ -/* - * 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 +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + * + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ /** * EncryptionImpl.cpp * - * Implementation classes for XML Encryption schema + * Implementation classes for XML Encryption schema. */ #include "internal.h" #include "AbstractAttributeExtensibleXMLObject.h" -#include "AbstractChildlessElement.h" -#include "AbstractElementProxy.h" +#include "AbstractComplexElement.h" +#include "AbstractSimpleElement.h" #include "exceptions.h" #include "encryption/Encryption.h" #include "io/AbstractXMLObjectMarshaller.h" #include "io/AbstractXMLObjectUnmarshaller.h" +#include "signature/KeyInfo.h" #include "util/XMLHelper.h" -#include "validation/AbstractValidatingXMLObject.h" #include using namespace xmlencryption; using namespace xmltooling; +using namespace xercesc; using namespace std; +using xmlconstants::XMLENC_NS; +using xmlconstants::XMLSIG_NS; #if defined (_MSC_VER) #pragma warning( push ) @@ -52,16 +59,15 @@ namespace xmlencryption { class XMLTOOL_DLLLOCAL EncryptionMethodImpl : public virtual EncryptionMethod, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { void init() { - m_Algorithm=NULL; - m_KeySize=NULL; - m_OAEPparams=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); + m_Algorithm=nullptr; + m_KeySize=nullptr; + m_OAEPparams=nullptr; + m_children.push_back(nullptr); + m_children.push_back(nullptr); m_pos_KeySize=m_children.begin(); m_pos_OAEPparams=m_pos_KeySize; ++m_pos_OAEPparams; @@ -71,52 +77,51 @@ namespace xmlencryption { XMLString::release(&m_Algorithm); } - EncryptionMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptionMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } EncryptionMethodImpl(const EncryptionMethodImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setAlgorithm(src.getAlgorithm()); if (src.getKeySize()) 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 { - MARSHALL_STRING_ATTRIB(Algorithm,ALGORITHM,NULL); + MARSHALL_STRING_ATTRIB(Algorithm,ALGORITHM,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(KeySize,XMLConstants::XMLENC_NS,false); - PROC_TYPED_CHILD(OAEPparams,XMLConstants::XMLENC_NS,false); + PROC_TYPED_CHILD(KeySize,XMLENC_NS,false); + PROC_TYPED_CHILD(OAEPparams,XMLENC_NS,false); // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); - if (!XMLString::equals(nsURI,XMLConstants::XMLENC_NS) && nsURI && *nsURI) - getOtherParameters().push_back(childXMLObject); + if (!XMLString::equals(nsURI,XMLENC_NS) && nsURI && *nsURI) { + getUnknownXMLObjects().push_back(childXMLObject); + return; + } AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Algorithm,ALGORITHM,NULL); + PROC_STRING_ATTRIB(Algorithm,ALGORITHM,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -124,19 +129,18 @@ namespace xmlencryption { class XMLTOOL_DLLLOCAL TransformsImpl : public virtual Transforms, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { public: virtual ~TransformsImpl() {} - TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } TransformsImpl(const TransformsImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOf(xmlsignature::Transform) v=getTransforms(); for (vector::const_iterator i=src.m_Transforms.begin(); i!=src.m_Transforms.end(); i++) { if (*i) { @@ -150,7 +154,7 @@ namespace xmlencryption { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILDREN(Transform,xmlsignature,XMLConstants::XMLSIG_NS,false); + PROC_TYPED_FOREIGN_CHILDREN(Transform,xmlsignature,XMLSIG_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; @@ -158,14 +162,13 @@ namespace xmlencryption { class XMLTOOL_DLLLOCAL CipherReferenceImpl : public virtual CipherReference, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { void init() { - m_URI=NULL; - m_Transforms=NULL; - m_children.push_back(NULL); + m_URI=nullptr; + m_Transforms=nullptr; + m_children.push_back(nullptr); m_pos_Transforms=m_children.begin(); } public: @@ -173,13 +176,13 @@ namespace xmlencryption { XMLString::release(&m_URI); } - CipherReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + CipherReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } CipherReferenceImpl(const CipherReferenceImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setURI(src.getURI()); if (src.getTransforms()) @@ -192,16 +195,16 @@ namespace xmlencryption { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(URI,URI,NULL); + MARSHALL_STRING_ATTRIB(URI,URI,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Transforms,XMLConstants::XMLENC_NS,false); + PROC_TYPED_CHILD(Transforms,XMLENC_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(URI,URI,NULL); + PROC_STRING_ATTRIB(URI,URI,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -209,15 +212,14 @@ namespace xmlencryption { class XMLTOOL_DLLLOCAL CipherDataImpl : public virtual CipherData, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { void init() { - m_CipherValue=NULL; - m_CipherReference=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); + m_CipherValue=nullptr; + m_CipherReference=nullptr; + m_children.push_back(nullptr); + m_children.push_back(nullptr); m_pos_CipherValue=m_children.begin(); m_pos_CipherReference=m_pos_CipherValue; ++m_pos_CipherReference; @@ -225,13 +227,13 @@ namespace xmlencryption { public: virtual ~CipherDataImpl() {} - CipherDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + CipherDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } CipherDataImpl(const CipherDataImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getCipherValue()) setCipherValue(src.getCipherValue()->cloneCipherValue()); @@ -245,22 +247,21 @@ namespace xmlencryption { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(CipherValue,XMLConstants::XMLENC_NS,false); - PROC_TYPED_CHILD(CipherReference,XMLConstants::XMLENC_NS,false); + PROC_TYPED_CHILD(CipherValue,XMLENC_NS,false); + PROC_TYPED_CHILD(CipherReference,XMLENC_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; class XMLTOOL_DLLLOCAL EncryptionPropertyImpl : public virtual EncryptionProperty, - public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { void init() { - m_Id=m_Target=NULL; + m_Id=m_Target=nullptr; } public: virtual ~EncryptionPropertyImpl() { @@ -268,91 +269,81 @@ namespace xmlencryption { XMLString::release(&m_Target); } - EncryptionPropertyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptionPropertyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } EncryptionPropertyImpl(const EncryptionPropertyImpl& src) : AbstractXMLObject(src), - AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(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_STRING_ATTRIB(Id); + IMPL_ID_ATTRIB_EX(Id,ID,nullptr); IMPL_STRING_ATTRIB(Target); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end()); - void setAttribute(QName& qualifiedName, const XMLCh* value) { + void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) { if (!qualifiedName.hasNamespaceURI()) { - if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) + if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) { setId(value); - else if (XMLString::equals(qualifiedName.getLocalPart(),TARGET_ATTRIB_NAME)) + return; + } + else if (XMLString::equals(qualifiedName.getLocalPart(),TARGET_ATTRIB_NAME)) { setTarget(value); + return; + } } - AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value); + AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID); } protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_ID_ATTRIB(Id,ID,NULL); - MARSHALL_STRING_ATTRIB(Target,TARGET,NULL); - - // Take care of wildcard. - for (map::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) { - DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart()); - if (i->first.hasPrefix()) - attr->setPrefix(i->first.getPrefix()); - attr->setNodeValue(i->second); - domElement->setAttributeNode(attr); - } + MARSHALL_ID_ATTRIB(Id,ID,nullptr); + MARSHALL_STRING_ATTRIB(Target,TARGET,nullptr); + marshallExtensionAttributes(domElement); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void processAttribute(const DOMAttr* attribute) { - PROC_ID_ATTRIB(Id,ID,NULL); - QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); - setAttribute(q,attribute->getNodeValue()); + PROC_ID_ATTRIB(Id,ID,nullptr); + unmarshallExtensionAttribute(attribute); } }; class XMLTOOL_DLLLOCAL EncryptionPropertiesImpl : public virtual EncryptionProperties, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { void init() { - m_Id=NULL; + m_Id=nullptr; } public: virtual ~EncryptionPropertiesImpl() { XMLString::release(&m_Id); } - EncryptionPropertiesImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptionPropertiesImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } EncryptionPropertiesImpl(const EncryptionPropertiesImpl& src) - : AbstractXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setId(src.getId()); VectorOf(EncryptionProperty) v=getEncryptionPropertys(); @@ -364,39 +355,34 @@ namespace xmlencryption { } IMPL_XMLOBJECT_CLONE(EncryptionProperties); - IMPL_STRING_ATTRIB(Id); + IMPL_ID_ATTRIB_EX(Id,ID,nullptr); IMPL_TYPED_CHILDREN(EncryptionProperty,m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_ID_ATTRIB(Id,ID,NULL); + MARSHALL_ID_ATTRIB(Id,ID,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(EncryptionProperty,XMLConstants::XMLENC_NS,false); + PROC_TYPED_CHILDREN(EncryptionProperty,XMLENC_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } void processAttribute(const DOMAttr* attribute) { - PROC_ID_ATTRIB(Id,ID,NULL); + PROC_ID_ATTRIB(Id,ID,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; class XMLTOOL_DLLLOCAL ReferenceTypeImpl : public virtual ReferenceType, - public AbstractElementProxy, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { - void init() { - m_URI=NULL; - } - protected: ReferenceTypeImpl() { - init(); + m_URI=nullptr; } public: @@ -404,39 +390,38 @@ namespace xmlencryption { XMLString::release(&m_URI); } - ReferenceTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + ReferenceTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - init(); + m_URI=nullptr; } ReferenceTypeImpl(const ReferenceTypeImpl& src) - : AbstractXMLObject(src), - AbstractElementProxy(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(src) { - init(); + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + m_URI=nullptr; + } + + void _clone(const ReferenceTypeImpl& src) { 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_XMLOBJECT_CLONE_EX(ReferenceType); IMPL_STRING_ATTRIB(URI); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(URI,URI,NULL); + MARSHALL_STRING_ATTRIB(URI,URI,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getXMLObjects().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(URI,URI,NULL); + PROC_STRING_ATTRIB(URI,URI,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -446,15 +431,12 @@ namespace xmlencryption { public: virtual ~DataReferenceImpl() {} - DataReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + DataReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} DataReferenceImpl(const DataReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {} - - IMPL_XMLOBJECT_CLONE(DataReference); - ReferenceType* cloneReferenceType() const { - return new DataReferenceImpl(*this); - } + + IMPL_XMLOBJECT_CLONE_EX(DataReference); }; class XMLTOOL_DLLLOCAL KeyReferenceImpl : public virtual KeyReference, public ReferenceTypeImpl @@ -462,33 +444,29 @@ namespace xmlencryption { public: virtual ~KeyReferenceImpl() {} - KeyReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + KeyReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} KeyReferenceImpl(const KeyReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(KeyReference); - ReferenceType* cloneReferenceType() const { - return new KeyReferenceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(KeyReference); }; class XMLTOOL_DLLLOCAL ReferenceListImpl : public virtual ReferenceList, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { public: virtual ~ReferenceListImpl() {} - ReferenceListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + ReferenceListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } ReferenceListImpl(const ReferenceListImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { if (*i) { DataReference* data=dynamic_cast(*i); @@ -512,8 +490,8 @@ namespace xmlencryption { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(DataReference,XMLConstants::XMLENC_NS,false); - PROC_TYPED_CHILDREN(KeyReference,XMLConstants::XMLENC_NS,false); + PROC_TYPED_CHILDREN(DataReference,XMLENC_NS,false); + PROC_TYPED_CHILDREN(KeyReference,XMLENC_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; @@ -521,20 +499,19 @@ namespace xmlencryption { class XMLTOOL_DLLLOCAL EncryptedTypeImpl : public virtual EncryptedType, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { void init() { - m_Id=m_Type=m_MimeType=m_Encoding=NULL; - m_EncryptionMethod=NULL; - m_KeyInfo=NULL; - m_CipherData=NULL; - m_EncryptionProperties=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); + m_Id=m_Type=m_MimeType=m_Encoding=nullptr; + m_EncryptionMethod=nullptr; + m_KeyInfo=nullptr; + m_CipherData=nullptr; + m_EncryptionProperties=nullptr; + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_children.push_back(nullptr); m_pos_EncryptionMethod=m_children.begin(); m_pos_KeyInfo=m_pos_EncryptionMethod; ++m_pos_KeyInfo; @@ -556,14 +533,17 @@ namespace xmlencryption { XMLString::release(&m_Encoding); } - EncryptedTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptedTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } EncryptedTypeImpl(const EncryptedTypeImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const EncryptedTypeImpl& src) { setId(src.getId()); setType(src.getType()); setMimeType(src.getMimeType()); @@ -578,8 +558,8 @@ namespace xmlencryption { setEncryptionProperties(src.getEncryptionProperties()->cloneEncryptionProperties()); } - IMPL_XMLOBJECT_CLONE(EncryptedType); - IMPL_STRING_ATTRIB(Id); + IMPL_XMLOBJECT_CLONE_EX(EncryptedType); + IMPL_ID_ATTRIB_EX(Id,ID,nullptr); IMPL_STRING_ATTRIB(Type); IMPL_STRING_ATTRIB(MimeType); IMPL_STRING_ATTRIB(Encoding); @@ -590,25 +570,25 @@ namespace xmlencryption { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_ID_ATTRIB(Id,ID,NULL); - MARSHALL_STRING_ATTRIB(Type,TYPE,NULL); - MARSHALL_STRING_ATTRIB(MimeType,MIMETYPE,NULL); - MARSHALL_STRING_ATTRIB(Encoding,ENCODING,NULL); + MARSHALL_ID_ATTRIB(Id,ID,nullptr); + MARSHALL_STRING_ATTRIB(Type,TYPE,nullptr); + MARSHALL_STRING_ATTRIB(MimeType,MIMETYPE,nullptr); + MARSHALL_STRING_ATTRIB(Encoding,ENCODING,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(EncryptionMethod,XMLConstants::XMLENC_NS,false); - PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLConstants::XMLSIG_NS,false); - PROC_TYPED_CHILD(CipherData,XMLConstants::XMLENC_NS,false); - PROC_TYPED_CHILD(EncryptionProperties,XMLConstants::XMLENC_NS,false); + PROC_TYPED_CHILD(EncryptionMethod,XMLENC_NS,false); + PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLSIG_NS,false); + PROC_TYPED_CHILD(CipherData,XMLENC_NS,false); + PROC_TYPED_CHILD(EncryptionProperties,XMLENC_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } void processAttribute(const DOMAttr* attribute) { - PROC_ID_ATTRIB(Id,ID,NULL); - PROC_STRING_ATTRIB(Type,TYPE,NULL); - PROC_STRING_ATTRIB(MimeType,MIMETYPE,NULL); - PROC_STRING_ATTRIB(Encoding,ENCODING,NULL); + PROC_ID_ATTRIB(Id,ID,nullptr); + PROC_STRING_ATTRIB(Type,TYPE,nullptr); + PROC_STRING_ATTRIB(MimeType,MIMETYPE,nullptr); + PROC_STRING_ATTRIB(Encoding,ENCODING,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -618,25 +598,22 @@ namespace xmlencryption { public: virtual ~EncryptedDataImpl() {} - EncryptedDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptedDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} EncryptedDataImpl(const EncryptedDataImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(EncryptedData); - EncryptedType* cloneEncryptedType() const { - return new EncryptedDataImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(EncryptedData); }; class XMLTOOL_DLLLOCAL EncryptedKeyImpl : public virtual EncryptedKey, public EncryptedTypeImpl { void init() { - m_Recipient=NULL; - m_ReferenceList=NULL; - m_CarriedKeyName=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); + m_Recipient=nullptr; + m_ReferenceList=nullptr; + m_CarriedKeyName=nullptr; + m_children.push_back(nullptr); + m_children.push_back(nullptr); m_pos_ReferenceList=m_pos_EncryptionProperties; ++m_pos_ReferenceList; m_pos_CarriedKeyName=m_pos_ReferenceList; @@ -648,7 +625,7 @@ namespace xmlencryption { XMLString::release(&m_Recipient); } - EncryptedKeyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptedKeyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -657,28 +634,35 @@ namespace xmlencryption { init(); } - IMPL_XMLOBJECT_CLONE(EncryptedKey); - EncryptedType* cloneEncryptedType() const { - return new EncryptedKeyImpl(*this); + void _clone(const EncryptedKeyImpl& src) { + EncryptedTypeImpl::_clone(src); + setRecipient(src.getRecipient()); + if (src.getReferenceList()) + setReferenceList(src.getReferenceList()->cloneReferenceList()); + if (src.getCarriedKeyName()) + setCarriedKeyName(src.getCarriedKeyName()->cloneCarriedKeyName()); } + + IMPL_XMLOBJECT_CLONE_EX(EncryptedKey); + IMPL_STRING_ATTRIB(Recipient); IMPL_TYPED_CHILD(ReferenceList); IMPL_TYPED_CHILD(CarriedKeyName); protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,NULL); + MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,nullptr); EncryptedTypeImpl::marshallAttributes(domElement); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(ReferenceList,XMLConstants::XMLENC_NS,false); - PROC_TYPED_CHILD(CarriedKeyName,XMLConstants::XMLENC_NS,false); + PROC_TYPED_CHILD(ReferenceList,XMLENC_NS,false); + PROC_TYPED_CHILD(CarriedKeyName,XMLENC_NS,false); EncryptedTypeImpl::processChildElement(childXMLObject,root); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL); + PROC_STRING_ATTRIB(Recipient,RECIPIENT,nullptr); EncryptedTypeImpl::processAttribute(attribute); } };