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