X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fencryption%2Fimpl%2FEncryptionImpl.cpp;h=612db9fd9dc78bc5107ae2c7c4972943175f3fbf;hb=81b488b2790e7bdeb2f43560b1d4a7d22c3dfdf5;hp=c3809d5bb9af4bf672c340c598b5897d1ff6f20a;hpb=1f87cef41f9948492e13d3d9dc1495652606c441;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/encryption/impl/EncryptionImpl.cpp b/xmltooling/encryption/impl/EncryptionImpl.cpp index c3809d5..612db9f 100644 --- a/xmltooling/encryption/impl/EncryptionImpl.cpp +++ b/xmltooling/encryption/impl/EncryptionImpl.cpp @@ -1,23 +1,27 @@ -/* - * 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" @@ -28,12 +32,14 @@ #include "encryption/Encryption.h" #include "io/AbstractXMLObjectMarshaller.h" #include "io/AbstractXMLObjectUnmarshaller.h" +#include "signature/KeyInfo.h" #include "util/XMLHelper.h" #include using namespace xmlencryption; using namespace xmltooling; +using namespace xercesc; using namespace std; using xmlconstants::XMLENC_NS; using xmlconstants::XMLSIG_NS; @@ -57,11 +63,11 @@ namespace xmlencryption { 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,7 +77,7 @@ 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(); } @@ -97,7 +103,7 @@ namespace xmlencryption { 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) { @@ -115,7 +121,7 @@ namespace xmlencryption { } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Algorithm,ALGORITHM,NULL); + PROC_STRING_ATTRIB(Algorithm,ALGORITHM,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -129,7 +135,7 @@ namespace xmlencryption { 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) { } @@ -160,9 +166,9 @@ namespace xmlencryption { 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: @@ -170,7 +176,7 @@ 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(); } @@ -189,7 +195,7 @@ 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) { @@ -198,7 +204,7 @@ namespace xmlencryption { } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(URI,URI,NULL); + PROC_STRING_ATTRIB(URI,URI,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -210,10 +216,10 @@ namespace xmlencryption { 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; @@ -221,7 +227,7 @@ 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(); } @@ -255,7 +261,7 @@ namespace xmlencryption { public AbstractXMLObjectUnmarshaller { void init() { - m_Id=m_Target=NULL; + m_Id=m_Target=nullptr; } public: virtual ~EncryptionPropertyImpl() { @@ -263,7 +269,7 @@ 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(); } @@ -282,11 +288,11 @@ namespace xmlencryption { } IMPL_XMLOBJECT_CLONE(EncryptionProperty); - IMPL_ID_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)) { setId(value); @@ -297,13 +303,13 @@ namespace xmlencryption { 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); + MARSHALL_ID_ATTRIB(Id,ID,nullptr); + MARSHALL_STRING_ATTRIB(Target,TARGET,nullptr); marshallExtensionAttributes(domElement); } @@ -312,7 +318,7 @@ namespace xmlencryption { } void processAttribute(const DOMAttr* attribute) { - PROC_ID_ATTRIB(Id,ID,NULL); + PROC_ID_ATTRIB(Id,ID,nullptr); unmarshallExtensionAttribute(attribute); } }; @@ -324,14 +330,14 @@ namespace xmlencryption { 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(); } @@ -349,12 +355,12 @@ namespace xmlencryption { } IMPL_XMLOBJECT_CLONE(EncryptionProperties); - IMPL_ID_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) { @@ -363,7 +369,7 @@ namespace xmlencryption { } void processAttribute(const DOMAttr* attribute) { - PROC_ID_ATTRIB(Id,ID,NULL); + PROC_ID_ATTRIB(Id,ID,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -375,7 +381,7 @@ namespace xmlencryption { public AbstractXMLObjectUnmarshaller { void init() { - m_URI=NULL; + m_URI=nullptr; } protected: @@ -388,7 +394,7 @@ 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(); } @@ -408,7 +414,7 @@ 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) { @@ -416,7 +422,7 @@ namespace xmlencryption { } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(URI,URI,NULL); + PROC_STRING_ATTRIB(URI,URI,nullptr); AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -426,7 +432,7 @@ 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) {} @@ -442,7 +448,7 @@ 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) {} @@ -462,7 +468,7 @@ namespace xmlencryption { 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) { } @@ -504,15 +510,15 @@ namespace xmlencryption { 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; @@ -534,7 +540,7 @@ 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(); } @@ -557,7 +563,7 @@ namespace xmlencryption { } IMPL_XMLOBJECT_CLONE(EncryptedType); - IMPL_ID_ATTRIB(Id); + IMPL_ID_ATTRIB_EX(Id,ID,nullptr); IMPL_STRING_ATTRIB(Type); IMPL_STRING_ATTRIB(MimeType); IMPL_STRING_ATTRIB(Encoding); @@ -568,10 +574,10 @@ 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) { @@ -583,10 +589,10 @@ namespace xmlencryption { } 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); } }; @@ -596,7 +602,7 @@ 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) {} @@ -610,11 +616,11 @@ namespace xmlencryption { 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; @@ -626,7 +632,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(); } @@ -645,7 +651,7 @@ namespace xmlencryption { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,NULL); + MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,nullptr); EncryptedTypeImpl::marshallAttributes(domElement); } @@ -656,7 +662,7 @@ namespace xmlencryption { } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL); + PROC_STRING_ATTRIB(Recipient,RECIPIENT,nullptr); EncryptedTypeImpl::processAttribute(attribute); } };