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