ae25710f953ff61adbd2d085f51404c328f3e513
[shibboleth/cpp-xmltooling.git] / xmltooling / encryption / impl / EncryptionImpl.cpp
1 /*
2  *  Copyright 2001-2006 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * EncryptionImpl.cpp
19  * 
20  * Implementation classes for XML Encryption schema
21  */
22
23 #include "internal.h"
24 #include "AbstractAttributeExtensibleXMLObject.h"
25 #include "AbstractSimpleElement.h"
26 #include "AbstractElementProxy.h"
27 #include "exceptions.h"
28 #include "encryption/Encryption.h"
29 #include "io/AbstractXMLObjectMarshaller.h"
30 #include "io/AbstractXMLObjectUnmarshaller.h"
31 #include "util/XMLHelper.h"
32
33 #include <xercesc/util/XMLUniDefs.hpp>
34
35 using namespace xmlencryption;
36 using namespace xmltooling;
37 using namespace std;
38 using xmlconstants::XMLENC_NS;
39 using xmlconstants::XMLSIG_NS;
40
41 #if defined (_MSC_VER)
42     #pragma warning( push )
43     #pragma warning( disable : 4250 4251 )
44 #endif
45
46 namespace xmlencryption {
47
48     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,CarriedKeyName);
49     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,CipherValue);
50     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,KeySize);
51     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,OAEPparams);
52
53     class XMLTOOL_DLLLOCAL EncryptionMethodImpl : public virtual EncryptionMethod,
54         public AbstractComplexElement,
55         public AbstractDOMCachingXMLObject,
56         public AbstractXMLObjectMarshaller,
57         public AbstractXMLObjectUnmarshaller
58     {
59         void init() {
60             m_Algorithm=NULL;
61             m_KeySize=NULL;
62             m_OAEPparams=NULL;
63             m_children.push_back(NULL);
64             m_children.push_back(NULL);
65             m_pos_KeySize=m_children.begin();
66             m_pos_OAEPparams=m_pos_KeySize;
67             ++m_pos_OAEPparams;
68         }
69     public:
70         virtual ~EncryptionMethodImpl() {
71             XMLString::release(&m_Algorithm);
72         }
73
74         EncryptionMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
75                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
76             init();
77         }
78             
79         EncryptionMethodImpl(const EncryptionMethodImpl& src)
80                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
81             init();
82             setAlgorithm(src.getAlgorithm());
83             if (src.getKeySize())
84                 setKeySize(src.getKeySize()->cloneKeySize());
85             if (src.getOAEPparams())
86                 setOAEPparams(src.getOAEPparams()->cloneOAEPparams());
87             VectorOf(XMLObject) v=getOtherParameters();
88             for (vector<XMLObject*>::const_iterator i=src.m_OtherParameters.begin(); i!=src.m_OtherParameters.end(); i++) {
89                 if (*i) {
90                     v.push_back((*i)->clone());
91                 }
92             }
93         }
94         
95         IMPL_XMLOBJECT_CLONE(EncryptionMethod);
96         IMPL_STRING_ATTRIB(Algorithm);
97         IMPL_TYPED_CHILD(KeySize);
98         IMPL_TYPED_CHILD(OAEPparams);
99         IMPL_XMLOBJECT_CHILDREN(OtherParameter,m_children.end());
100
101     protected:
102         void marshallAttributes(DOMElement* domElement) const {
103             MARSHALL_STRING_ATTRIB(Algorithm,ALGORITHM,NULL);
104         }
105
106         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
107             PROC_TYPED_CHILD(KeySize,XMLENC_NS,false);
108             PROC_TYPED_CHILD(OAEPparams,XMLENC_NS,false);
109             
110             // Unknown child.
111             const XMLCh* nsURI=root->getNamespaceURI();
112             if (!XMLString::equals(nsURI,XMLENC_NS) && nsURI && *nsURI) {
113                 getOtherParameters().push_back(childXMLObject);
114                 return;
115             }
116             
117             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
118         }
119
120         void processAttribute(const DOMAttr* attribute) {
121             PROC_STRING_ATTRIB(Algorithm,ALGORITHM,NULL);
122             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
123         }
124     };
125
126     class XMLTOOL_DLLLOCAL TransformsImpl : public virtual Transforms,
127         public AbstractComplexElement,
128         public AbstractDOMCachingXMLObject,
129         public AbstractXMLObjectMarshaller,
130         public AbstractXMLObjectUnmarshaller
131     {
132     public:
133         virtual ~TransformsImpl() {}
134
135         TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
136             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
137         }
138             
139         TransformsImpl(const TransformsImpl& src)
140                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
141             VectorOf(xmlsignature::Transform) v=getTransforms();
142             for (vector<xmlsignature::Transform*>::const_iterator i=src.m_Transforms.begin(); i!=src.m_Transforms.end(); i++) {
143                 if (*i) {
144                     v.push_back((*i)->cloneTransform());
145                 }
146             }
147         }
148         
149         IMPL_XMLOBJECT_CLONE(Transforms);
150         IMPL_TYPED_FOREIGN_CHILDREN(Transform,xmlsignature,m_children.end());
151
152     protected:
153         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
154             PROC_TYPED_FOREIGN_CHILDREN(Transform,xmlsignature,XMLSIG_NS,false);
155             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
156         }
157     };
158
159     class XMLTOOL_DLLLOCAL CipherReferenceImpl : public virtual CipherReference,
160         public AbstractComplexElement,
161         public AbstractDOMCachingXMLObject,
162         public AbstractXMLObjectMarshaller,
163         public AbstractXMLObjectUnmarshaller
164     {
165         void init() {
166             m_URI=NULL;
167             m_Transforms=NULL;
168             m_children.push_back(NULL);
169             m_pos_Transforms=m_children.begin();
170         }
171     public:
172         virtual ~CipherReferenceImpl() {
173             XMLString::release(&m_URI);
174         }
175
176         CipherReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
177                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
178             init();
179         }
180             
181         CipherReferenceImpl(const CipherReferenceImpl& src)
182                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
183             init();
184             setURI(src.getURI());
185             if (src.getTransforms())
186                 setTransforms(src.getTransforms()->cloneTransforms());
187         }
188         
189         IMPL_XMLOBJECT_CLONE(CipherReference);
190         IMPL_STRING_ATTRIB(URI);
191         IMPL_TYPED_CHILD(Transforms);
192
193     protected:
194         void marshallAttributes(DOMElement* domElement) const {
195             MARSHALL_STRING_ATTRIB(URI,URI,NULL);
196         }
197
198         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
199             PROC_TYPED_CHILD(Transforms,XMLENC_NS,false);
200             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
201         }
202
203         void processAttribute(const DOMAttr* attribute) {
204             PROC_STRING_ATTRIB(URI,URI,NULL);
205             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
206         }
207     };
208
209     class XMLTOOL_DLLLOCAL CipherDataImpl : public virtual CipherData,
210         public AbstractComplexElement,
211         public AbstractDOMCachingXMLObject,
212         public AbstractXMLObjectMarshaller,
213         public AbstractXMLObjectUnmarshaller
214     {
215         void init() {
216             m_CipherValue=NULL;
217             m_CipherReference=NULL;
218             m_children.push_back(NULL);
219             m_children.push_back(NULL);
220             m_pos_CipherValue=m_children.begin();
221             m_pos_CipherReference=m_pos_CipherValue;
222             ++m_pos_CipherReference;
223         }
224     public:
225         virtual ~CipherDataImpl() {}
226
227         CipherDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
228                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
229             init();
230         }
231             
232         CipherDataImpl(const CipherDataImpl& src)
233                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
234             init();
235             if (src.getCipherValue())
236                 setCipherValue(src.getCipherValue()->cloneCipherValue());
237             if (src.getCipherReference())
238                 setCipherReference(src.getCipherReference()->cloneCipherReference());
239         }
240         
241         IMPL_XMLOBJECT_CLONE(CipherData);
242         IMPL_TYPED_CHILD(CipherValue);
243         IMPL_TYPED_CHILD(CipherReference);
244
245     protected:
246         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
247             PROC_TYPED_CHILD(CipherValue,XMLENC_NS,false);
248             PROC_TYPED_CHILD(CipherReference,XMLENC_NS,false);
249             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
250         }
251     };
252
253     class XMLTOOL_DLLLOCAL EncryptionPropertyImpl : public virtual EncryptionProperty,
254         public AbstractElementProxy,
255         public AbstractAttributeExtensibleXMLObject,
256         public AbstractDOMCachingXMLObject,
257         public AbstractXMLObjectMarshaller,
258         public AbstractXMLObjectUnmarshaller
259     {
260         void init() {
261             m_Id=m_Target=NULL;
262         }
263     public:
264         virtual ~EncryptionPropertyImpl() {
265             XMLString::release(&m_Id);
266             XMLString::release(&m_Target);
267         }
268
269         EncryptionPropertyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
270             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
271             init();
272         }
273             
274         EncryptionPropertyImpl(const EncryptionPropertyImpl& src)
275                 : AbstractXMLObject(src),
276                     AbstractElementProxy(src),
277                     AbstractAttributeExtensibleXMLObject(src),
278                     AbstractDOMCachingXMLObject(src) {
279             init();
280             setId(src.getId());
281             setTarget(src.getTarget());
282             for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
283                 if (*i) {
284                     getXMLObjects().push_back((*i)->clone());
285                 }
286             }
287         }
288         
289         IMPL_XMLOBJECT_CLONE(EncryptionProperty);
290         IMPL_ID_ATTRIB(Id);
291         IMPL_STRING_ATTRIB(Target);
292
293         void setAttribute(QName& qualifiedName, const XMLCh* value) {
294             if (!qualifiedName.hasNamespaceURI()) {
295                 if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
296                     setId(value);
297                     return;
298                 }
299                 else if (XMLString::equals(qualifiedName.getLocalPart(),TARGET_ATTRIB_NAME)) {
300                     setTarget(value);
301                     return;
302                 }
303             }
304             AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
305         }
306
307     protected:
308         void marshallAttributes(DOMElement* domElement) const {
309             MARSHALL_ID_ATTRIB(Id,ID,NULL);
310             MARSHALL_STRING_ATTRIB(Target,TARGET,NULL);
311             marshallExtensionAttributes(domElement);
312         }
313
314         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
315             getXMLObjects().push_back(childXMLObject);
316         }
317
318         void processAttribute(const DOMAttr* attribute) {
319             PROC_ID_ATTRIB(Id,ID,NULL);
320             unmarshallExtensionAttribute(attribute);
321         }
322     };
323
324     class XMLTOOL_DLLLOCAL EncryptionPropertiesImpl : public virtual EncryptionProperties,
325         public AbstractComplexElement,
326         public AbstractDOMCachingXMLObject,
327         public AbstractXMLObjectMarshaller,
328         public AbstractXMLObjectUnmarshaller
329     {
330         void init() {
331             m_Id=NULL;
332         }
333     public:
334         virtual ~EncryptionPropertiesImpl() {
335             XMLString::release(&m_Id);
336         }
337
338         EncryptionPropertiesImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
339             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
340             init();
341         }
342             
343         EncryptionPropertiesImpl(const EncryptionPropertiesImpl& src)
344                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
345             init();
346             setId(src.getId());
347             VectorOf(EncryptionProperty) v=getEncryptionPropertys();
348             for (vector<EncryptionProperty*>::const_iterator i=src.m_EncryptionPropertys.begin(); i!=src.m_EncryptionPropertys.end(); i++) {
349                 if (*i) {
350                     v.push_back((*i)->cloneEncryptionProperty());
351                 }
352             }
353         }
354         
355         IMPL_XMLOBJECT_CLONE(EncryptionProperties);
356         IMPL_ID_ATTRIB(Id);
357         IMPL_TYPED_CHILDREN(EncryptionProperty,m_children.end());
358
359     protected:
360         void marshallAttributes(DOMElement* domElement) const {
361             MARSHALL_ID_ATTRIB(Id,ID,NULL);
362         }
363
364         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
365             PROC_TYPED_CHILDREN(EncryptionProperty,XMLENC_NS,false);
366             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
367         }
368
369         void processAttribute(const DOMAttr* attribute) {
370             PROC_ID_ATTRIB(Id,ID,NULL);
371             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
372         }
373     };
374
375     class XMLTOOL_DLLLOCAL ReferenceTypeImpl : public virtual ReferenceType,
376         public AbstractElementProxy,
377         public AbstractDOMCachingXMLObject,
378         public AbstractXMLObjectMarshaller,
379         public AbstractXMLObjectUnmarshaller
380     {
381         void init() {
382             m_URI=NULL;
383         }
384         
385     protected:
386         ReferenceTypeImpl() {
387             init();
388         }
389         
390     public:
391         virtual ~ReferenceTypeImpl() {
392             XMLString::release(&m_URI);
393         }
394
395         ReferenceTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
396             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
397             init();
398         }
399             
400         ReferenceTypeImpl(const ReferenceTypeImpl& src)
401                 : AbstractXMLObject(src), AbstractElementProxy(src), AbstractDOMCachingXMLObject(src) {
402             init();
403             setURI(src.getURI());
404             for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
405                 if (*i) {
406                     getXMLObjects().push_back((*i)->clone());
407                 }
408             }
409         }
410         
411         IMPL_XMLOBJECT_CLONE(ReferenceType);
412         IMPL_STRING_ATTRIB(URI);
413
414     protected:
415         void marshallAttributes(DOMElement* domElement) const {
416             MARSHALL_STRING_ATTRIB(URI,URI,NULL);
417         }
418
419         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
420             getXMLObjects().push_back(childXMLObject);
421         }
422
423         void processAttribute(const DOMAttr* attribute) {
424             PROC_STRING_ATTRIB(URI,URI,NULL);
425             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
426         }
427     };
428
429     class XMLTOOL_DLLLOCAL DataReferenceImpl : public virtual DataReference, public ReferenceTypeImpl
430     {
431     public:
432         virtual ~DataReferenceImpl() {}
433
434         DataReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
435             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
436             
437         DataReferenceImpl(const DataReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {}
438         
439         IMPL_XMLOBJECT_CLONE(DataReference);
440         ReferenceType* cloneReferenceType() const {
441             return new DataReferenceImpl(*this);
442         }
443     };
444
445     class XMLTOOL_DLLLOCAL KeyReferenceImpl : public virtual KeyReference, public ReferenceTypeImpl
446     {
447     public:
448         virtual ~KeyReferenceImpl() {}
449
450         KeyReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
451             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
452             
453         KeyReferenceImpl(const KeyReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {}
454         
455         IMPL_XMLOBJECT_CLONE(KeyReference);
456         ReferenceType* cloneReferenceType() const {
457             return new KeyReferenceImpl(*this);
458         }
459     };
460
461     class XMLTOOL_DLLLOCAL ReferenceListImpl : public virtual ReferenceList,
462         public AbstractComplexElement,
463         public AbstractDOMCachingXMLObject,
464         public AbstractXMLObjectMarshaller,
465         public AbstractXMLObjectUnmarshaller
466     {
467     public:
468         virtual ~ReferenceListImpl() {}
469
470         ReferenceListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
471             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
472         }
473             
474         ReferenceListImpl(const ReferenceListImpl& src)
475                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
476             for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
477                 if (*i) {
478                     DataReference* data=dynamic_cast<DataReference*>(*i);
479                     if (data) {
480                         getDataReferences().push_back(data->cloneDataReference());
481                         continue;
482                     }
483
484                     KeyReference* key=dynamic_cast<KeyReference*>(*i);
485                     if (key) {
486                         getKeyReferences().push_back(key->cloneKeyReference());
487                         continue;
488                     }
489                 }
490             }
491         }
492         
493         IMPL_XMLOBJECT_CLONE(ReferenceList);
494         IMPL_TYPED_CHILDREN(DataReference,m_children.end());
495         IMPL_TYPED_CHILDREN(KeyReference,m_children.end());
496
497     protected:
498         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
499             PROC_TYPED_CHILDREN(DataReference,XMLENC_NS,false);
500             PROC_TYPED_CHILDREN(KeyReference,XMLENC_NS,false);
501             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
502         }
503     };
504
505     class XMLTOOL_DLLLOCAL EncryptedTypeImpl : public virtual EncryptedType,
506         public AbstractComplexElement,
507         public AbstractDOMCachingXMLObject,
508         public AbstractXMLObjectMarshaller,
509         public AbstractXMLObjectUnmarshaller
510     {
511         void init() {
512             m_Id=m_Type=m_MimeType=m_Encoding=NULL;
513             m_EncryptionMethod=NULL;
514             m_KeyInfo=NULL;
515             m_CipherData=NULL;
516             m_EncryptionProperties=NULL;
517             m_children.push_back(NULL);
518             m_children.push_back(NULL);
519             m_children.push_back(NULL);
520             m_children.push_back(NULL);
521             m_pos_EncryptionMethod=m_children.begin();
522             m_pos_KeyInfo=m_pos_EncryptionMethod;
523             ++m_pos_KeyInfo;
524             m_pos_CipherData=m_pos_KeyInfo;
525             ++m_pos_CipherData;
526             m_pos_EncryptionProperties=m_pos_CipherData;
527             ++m_pos_EncryptionProperties;
528         }
529     protected:
530         EncryptedTypeImpl() {
531             init();
532         }
533         
534     public:
535         virtual ~EncryptedTypeImpl() {
536             XMLString::release(&m_Id);
537             XMLString::release(&m_Type);
538             XMLString::release(&m_MimeType);
539             XMLString::release(&m_Encoding);
540         }
541
542         EncryptedTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
543                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
544             init();
545         }
546             
547         EncryptedTypeImpl(const EncryptedTypeImpl& src)
548                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
549             init();
550             setId(src.getId());
551             setType(src.getType());
552             setMimeType(src.getMimeType());
553             setEncoding(src.getEncoding());
554             if (src.getEncryptionMethod())
555                 setEncryptionMethod(src.getEncryptionMethod()->cloneEncryptionMethod());
556             if (src.getKeyInfo())
557                 setKeyInfo(src.getKeyInfo()->cloneKeyInfo());
558             if (src.getCipherData())
559                 setCipherData(src.getCipherData()->cloneCipherData());
560             if (src.getEncryptionProperties())
561                 setEncryptionProperties(src.getEncryptionProperties()->cloneEncryptionProperties());
562         }
563         
564         IMPL_XMLOBJECT_CLONE(EncryptedType);
565         IMPL_ID_ATTRIB(Id);
566         IMPL_STRING_ATTRIB(Type);
567         IMPL_STRING_ATTRIB(MimeType);
568         IMPL_STRING_ATTRIB(Encoding);
569         IMPL_TYPED_CHILD(EncryptionMethod);
570         IMPL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature);
571         IMPL_TYPED_CHILD(CipherData);
572         IMPL_TYPED_CHILD(EncryptionProperties);
573
574     protected:
575         void marshallAttributes(DOMElement* domElement) const {
576             MARSHALL_ID_ATTRIB(Id,ID,NULL);
577             MARSHALL_STRING_ATTRIB(Type,TYPE,NULL);
578             MARSHALL_STRING_ATTRIB(MimeType,MIMETYPE,NULL);
579             MARSHALL_STRING_ATTRIB(Encoding,ENCODING,NULL);
580         }
581
582         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
583             PROC_TYPED_CHILD(EncryptionMethod,XMLENC_NS,false);
584             PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLSIG_NS,false);
585             PROC_TYPED_CHILD(CipherData,XMLENC_NS,false);
586             PROC_TYPED_CHILD(EncryptionProperties,XMLENC_NS,false);
587             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
588         }
589
590         void processAttribute(const DOMAttr* attribute) {
591             PROC_ID_ATTRIB(Id,ID,NULL);
592             PROC_STRING_ATTRIB(Type,TYPE,NULL);
593             PROC_STRING_ATTRIB(MimeType,MIMETYPE,NULL);
594             PROC_STRING_ATTRIB(Encoding,ENCODING,NULL);
595             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
596         }
597     };
598
599     class XMLTOOL_DLLLOCAL EncryptedDataImpl : public virtual EncryptedData, public EncryptedTypeImpl
600     {
601     public:
602         virtual ~EncryptedDataImpl() {}
603
604         EncryptedDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
605             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
606             
607         EncryptedDataImpl(const EncryptedDataImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {}
608         
609         IMPL_XMLOBJECT_CLONE(EncryptedData);
610         EncryptedType* cloneEncryptedType() const {
611             return new EncryptedDataImpl(*this);
612         }
613     };
614
615     class XMLTOOL_DLLLOCAL EncryptedKeyImpl : public virtual EncryptedKey, public EncryptedTypeImpl
616     {
617         void init() {
618             m_Recipient=NULL;
619             m_ReferenceList=NULL;
620             m_CarriedKeyName=NULL;
621             m_children.push_back(NULL);
622             m_children.push_back(NULL);
623             m_pos_ReferenceList=m_pos_EncryptionProperties;
624             ++m_pos_ReferenceList;
625             m_pos_CarriedKeyName=m_pos_ReferenceList;
626             ++m_pos_CarriedKeyName;
627         }
628         
629     public:
630         virtual ~EncryptedKeyImpl() {
631             XMLString::release(&m_Recipient);
632         }
633
634         EncryptedKeyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
635                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
636             init();
637         }
638             
639         EncryptedKeyImpl(const EncryptedKeyImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {
640             init();
641         }
642         
643         IMPL_XMLOBJECT_CLONE(EncryptedKey);
644         EncryptedType* cloneEncryptedType() const {
645             return new EncryptedKeyImpl(*this);
646         }
647         IMPL_STRING_ATTRIB(Recipient);
648         IMPL_TYPED_CHILD(ReferenceList);
649         IMPL_TYPED_CHILD(CarriedKeyName);
650     
651     protected:
652         void marshallAttributes(DOMElement* domElement) const {
653             MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,NULL);
654             EncryptedTypeImpl::marshallAttributes(domElement);
655         }
656
657         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
658             PROC_TYPED_CHILD(ReferenceList,XMLENC_NS,false);
659             PROC_TYPED_CHILD(CarriedKeyName,XMLENC_NS,false);
660             EncryptedTypeImpl::processChildElement(childXMLObject,root);
661         }
662
663         void processAttribute(const DOMAttr* attribute) {
664             PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL);
665             EncryptedTypeImpl::processAttribute(attribute);
666         }
667     };
668
669 };
670
671 #if defined (_MSC_VER)
672     #pragma warning( pop )
673 #endif
674
675 // Builder Implementations
676
677 IMPL_XMLOBJECTBUILDER(CarriedKeyName);
678 IMPL_XMLOBJECTBUILDER(CipherData);
679 IMPL_XMLOBJECTBUILDER(CipherReference);
680 IMPL_XMLOBJECTBUILDER(CipherValue);
681 IMPL_XMLOBJECTBUILDER(DataReference);
682 IMPL_XMLOBJECTBUILDER(EncryptedData);
683 IMPL_XMLOBJECTBUILDER(EncryptedKey);
684 IMPL_XMLOBJECTBUILDER(EncryptionMethod);
685 IMPL_XMLOBJECTBUILDER(EncryptionProperties);
686 IMPL_XMLOBJECTBUILDER(EncryptionProperty);
687 IMPL_XMLOBJECTBUILDER(KeyReference);
688 IMPL_XMLOBJECTBUILDER(KeySize);
689 IMPL_XMLOBJECTBUILDER(OAEPparams);
690 IMPL_XMLOBJECTBUILDER(ReferenceList);
691 IMPL_XMLOBJECTBUILDER(Transforms);
692
693 // Unicode literals
694
695 const XMLCh CarriedKeyName::LOCAL_NAME[] =              UNICODE_LITERAL_14(C,a,r,r,i,e,d,K,e,y,N,a,m,e);
696 const XMLCh CipherData::LOCAL_NAME[] =                  UNICODE_LITERAL_10(C,i,p,h,e,r,D,a,t,a);
697 const XMLCh CipherData::TYPE_NAME[] =                   UNICODE_LITERAL_14(C,i,p,h,e,r,D,a,t,a,T,y,p,e);
698 const XMLCh CipherReference::LOCAL_NAME[] =             UNICODE_LITERAL_15(C,i,p,h,e,r,R,e,f,e,r,e,n,c,e);
699 const XMLCh CipherReference::TYPE_NAME[] =              UNICODE_LITERAL_19(C,i,p,h,e,r,R,e,f,e,r,e,n,c,e,T,y,p,e);
700 const XMLCh CipherReference::URI_ATTRIB_NAME[] =        UNICODE_LITERAL_3(U,R,I);
701 const XMLCh CipherValue::LOCAL_NAME[] =                 UNICODE_LITERAL_11(C,i,p,h,e,r,V,a,l,u,e);
702 const XMLCh DataReference::LOCAL_NAME[] =               UNICODE_LITERAL_13(D,a,t,a,R,e,f,e,r,e,n,c,e);
703 const XMLCh EncryptedData::LOCAL_NAME[] =               UNICODE_LITERAL_13(E,n,c,r,y,p,t,e,d,D,a,t,a);
704 const XMLCh EncryptedData::TYPE_NAME[] =                UNICODE_LITERAL_17(E,n,c,r,y,p,t,e,d,D,a,t,a,T,y,p,e);
705 const XMLCh EncryptedKey::LOCAL_NAME[] =                UNICODE_LITERAL_12(E,n,c,r,y,p,t,e,d,K,e,y);
706 const XMLCh EncryptedKey::TYPE_NAME[] =                 UNICODE_LITERAL_16(E,n,c,r,y,p,t,e,d,K,e,y,T,y,p,e);
707 const XMLCh EncryptedKey::RECIPIENT_ATTRIB_NAME[] =     UNICODE_LITERAL_9(R,e,c,i,p,i,e,n,t);
708 const XMLCh EncryptedType::LOCAL_NAME[] =               {chNull};
709 const XMLCh EncryptedType::TYPE_NAME[] =                UNICODE_LITERAL_13(E,n,c,r,y,p,t,e,d,T,y,p,e);
710 const XMLCh EncryptedType::ID_ATTRIB_NAME[] =           UNICODE_LITERAL_2(I,d);
711 const XMLCh EncryptedType::TYPE_ATTRIB_NAME[] =         UNICODE_LITERAL_4(T,y,p,e);
712 const XMLCh EncryptedType::MIMETYPE_ATTRIB_NAME[] =     UNICODE_LITERAL_8(M,i,m,e,T,y,p,e);
713 const XMLCh EncryptedType::ENCODING_ATTRIB_NAME[] =     UNICODE_LITERAL_8(E,n,c,o,d,i,n,g);
714 const XMLCh EncryptionMethod::LOCAL_NAME[] =            UNICODE_LITERAL_16(E,n,c,r,y,p,t,i,o,n,M,e,t,h,o,d);
715 const XMLCh EncryptionMethod::TYPE_NAME[] =             UNICODE_LITERAL_20(E,n,c,r,y,p,t,i,o,n,M,e,t,h,o,d,T,y,p,e);
716 const XMLCh EncryptionMethod::ALGORITHM_ATTRIB_NAME[] = UNICODE_LITERAL_9(A,l,g,o,r,i,t,h,m);
717 const XMLCh EncryptionProperties::LOCAL_NAME[] =        UNICODE_LITERAL_20(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,i,e,s);
718 const XMLCh EncryptionProperties::TYPE_NAME[] =         UNICODE_LITERAL_24(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,i,e,s,T,y,p,e);
719 const XMLCh EncryptionProperties::ID_ATTRIB_NAME[] =    UNICODE_LITERAL_2(I,d);
720 const XMLCh EncryptionProperty::LOCAL_NAME[] =          UNICODE_LITERAL_18(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,y);
721 const XMLCh EncryptionProperty::TYPE_NAME[] =           UNICODE_LITERAL_22(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,y,T,y,p,e);
722 const XMLCh EncryptionProperty::ID_ATTRIB_NAME[] =      UNICODE_LITERAL_2(I,d);
723 const XMLCh EncryptionProperty::TARGET_ATTRIB_NAME[] =  UNICODE_LITERAL_6(T,a,r,g,e,t);
724 const XMLCh KeyReference::LOCAL_NAME[] =                UNICODE_LITERAL_12(K,e,y,R,e,f,e,r,e,n,c,e);
725 const XMLCh KeySize::LOCAL_NAME[] =                     UNICODE_LITERAL_7(K,e,y,S,i,z,e);
726 const XMLCh OAEPparams::LOCAL_NAME[] =                  UNICODE_LITERAL_10(O,A,E,P,p,a,r,a,m,s);
727 const XMLCh ReferenceList::LOCAL_NAME[] =               UNICODE_LITERAL_13(R,e,f,e,r,e,n,c,e,L,i,s,t);
728 const XMLCh ReferenceType::LOCAL_NAME[] =               {chNull};
729 const XMLCh ReferenceType::TYPE_NAME[] =                UNICODE_LITERAL_13(R,e,f,e,r,e,n,c,e,T,y,p,e);
730 const XMLCh ReferenceType::URI_ATTRIB_NAME[] =          UNICODE_LITERAL_3(U,R,I);
731 const XMLCh Transforms::LOCAL_NAME[] =                  UNICODE_LITERAL_10(T,r,a,n,s,f,o,r,m,s);
732 const XMLCh Transforms::TYPE_NAME[] =                   UNICODE_LITERAL_14(T,r,a,n,s,f,o,r,m,s,T,y,p,e);