Xerces 3 revisions.
[shibboleth/cpp-xmltooling.git] / xmltooling / encryption / impl / EncryptionImpl.cpp
1 /*
2  *  Copyright 2001-2007 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 "AbstractComplexElement.h"
26 #include "AbstractSimpleElement.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 xercesc;
38 using namespace std;
39 using xmlconstants::XMLENC_NS;
40 using xmlconstants::XMLSIG_NS;
41
42 #if defined (_MSC_VER)
43     #pragma warning( push )
44     #pragma warning( disable : 4250 4251 )
45 #endif
46
47 namespace xmlencryption {
48
49     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,CarriedKeyName);
50     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,CipherValue);
51     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,KeySize);
52     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,OAEPparams);
53
54     class XMLTOOL_DLLLOCAL EncryptionMethodImpl : public virtual EncryptionMethod,
55         public AbstractComplexElement,
56         public AbstractDOMCachingXMLObject,
57         public AbstractXMLObjectMarshaller,
58         public AbstractXMLObjectUnmarshaller
59     {
60         void init() {
61             m_Algorithm=NULL;
62             m_KeySize=NULL;
63             m_OAEPparams=NULL;
64             m_children.push_back(NULL);
65             m_children.push_back(NULL);
66             m_pos_KeySize=m_children.begin();
67             m_pos_OAEPparams=m_pos_KeySize;
68             ++m_pos_OAEPparams;
69         }
70     public:
71         virtual ~EncryptionMethodImpl() {
72             XMLString::release(&m_Algorithm);
73         }
74
75         EncryptionMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
76                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
77             init();
78         }
79             
80         EncryptionMethodImpl(const EncryptionMethodImpl& src)
81                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
82             init();
83             setAlgorithm(src.getAlgorithm());
84             if (src.getKeySize())
85                 setKeySize(src.getKeySize()->cloneKeySize());
86             if (src.getOAEPparams())
87                 setOAEPparams(src.getOAEPparams()->cloneOAEPparams());
88             VectorOf(XMLObject) v=getUnknownXMLObjects();
89             for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
90                 v.push_back((*i)->clone());
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(UnknownXMLObject,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,XMLENC_NS,false);
106             PROC_TYPED_CHILD(OAEPparams,XMLENC_NS,false);
107             
108             // Unknown child.
109             const XMLCh* nsURI=root->getNamespaceURI();
110             if (!XMLString::equals(nsURI,XMLENC_NS) && nsURI && *nsURI) {
111                 getUnknownXMLObjects().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 xmltooling::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,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 xmltooling::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,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 xmltooling::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,XMLENC_NS,false);
246             PROC_TYPED_CHILD(CipherReference,XMLENC_NS,false);
247             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
248         }
249     };
250
251     class XMLTOOL_DLLLOCAL EncryptionPropertyImpl : public virtual EncryptionProperty,
252         public AbstractAttributeExtensibleXMLObject,
253         public AbstractComplexElement,
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 xmltooling::QName* schemaType)
268             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
269             init();
270         }
271             
272         EncryptionPropertyImpl(const EncryptionPropertyImpl& src)
273                 : AbstractXMLObject(src),
274                     AbstractAttributeExtensibleXMLObject(src),
275                     AbstractComplexElement(src),
276                     AbstractDOMCachingXMLObject(src) {
277             init();
278             setId(src.getId());
279             setTarget(src.getTarget());
280             VectorOf(XMLObject) v=getUnknownXMLObjects();
281             for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
282                 v.push_back((*i)->clone());
283         }
284         
285         IMPL_XMLOBJECT_CLONE(EncryptionProperty);
286         IMPL_ID_ATTRIB(Id);
287         IMPL_STRING_ATTRIB(Target);
288         IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
289
290         void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) {
291             if (!qualifiedName.hasNamespaceURI()) {
292                 if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
293                     setId(value);
294                     return;
295                 }
296                 else if (XMLString::equals(qualifiedName.getLocalPart(),TARGET_ATTRIB_NAME)) {
297                     setTarget(value);
298                     return;
299                 }
300             }
301             AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
302         }
303
304     protected:
305         void marshallAttributes(DOMElement* domElement) const {
306             MARSHALL_ID_ATTRIB(Id,ID,NULL);
307             MARSHALL_STRING_ATTRIB(Target,TARGET,NULL);
308             marshallExtensionAttributes(domElement);
309         }
310
311         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
312             getUnknownXMLObjects().push_back(childXMLObject);
313         }
314
315         void processAttribute(const DOMAttr* attribute) {
316             PROC_ID_ATTRIB(Id,ID,NULL);
317             unmarshallExtensionAttribute(attribute);
318         }
319     };
320
321     class XMLTOOL_DLLLOCAL EncryptionPropertiesImpl : public virtual EncryptionProperties,
322         public AbstractComplexElement,
323         public AbstractDOMCachingXMLObject,
324         public AbstractXMLObjectMarshaller,
325         public AbstractXMLObjectUnmarshaller
326     {
327         void init() {
328             m_Id=NULL;
329         }
330     public:
331         virtual ~EncryptionPropertiesImpl() {
332             XMLString::release(&m_Id);
333         }
334
335         EncryptionPropertiesImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
336             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
337             init();
338         }
339             
340         EncryptionPropertiesImpl(const EncryptionPropertiesImpl& src)
341                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
342             init();
343             setId(src.getId());
344             VectorOf(EncryptionProperty) v=getEncryptionPropertys();
345             for (vector<EncryptionProperty*>::const_iterator i=src.m_EncryptionPropertys.begin(); i!=src.m_EncryptionPropertys.end(); i++) {
346                 if (*i) {
347                     v.push_back((*i)->cloneEncryptionProperty());
348                 }
349             }
350         }
351         
352         IMPL_XMLOBJECT_CLONE(EncryptionProperties);
353         IMPL_ID_ATTRIB(Id);
354         IMPL_TYPED_CHILDREN(EncryptionProperty,m_children.end());
355
356     protected:
357         void marshallAttributes(DOMElement* domElement) const {
358             MARSHALL_ID_ATTRIB(Id,ID,NULL);
359         }
360
361         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
362             PROC_TYPED_CHILDREN(EncryptionProperty,XMLENC_NS,false);
363             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
364         }
365
366         void processAttribute(const DOMAttr* attribute) {
367             PROC_ID_ATTRIB(Id,ID,NULL);
368             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
369         }
370     };
371
372     class XMLTOOL_DLLLOCAL ReferenceTypeImpl : public virtual ReferenceType,
373         public AbstractComplexElement,
374         public AbstractDOMCachingXMLObject,
375         public AbstractXMLObjectMarshaller,
376         public AbstractXMLObjectUnmarshaller
377     {
378         void init() {
379             m_URI=NULL;
380         }
381         
382     protected:
383         ReferenceTypeImpl() {
384             init();
385         }
386         
387     public:
388         virtual ~ReferenceTypeImpl() {
389             XMLString::release(&m_URI);
390         }
391
392         ReferenceTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
393             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
394             init();
395         }
396             
397         ReferenceTypeImpl(const ReferenceTypeImpl& src)
398                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
399             init();
400             setURI(src.getURI());
401             VectorOf(XMLObject) v=getUnknownXMLObjects();
402             for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
403                 v.push_back((*i)->clone());
404         }
405         
406         IMPL_XMLOBJECT_CLONE(ReferenceType);
407         IMPL_STRING_ATTRIB(URI);
408         IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
409
410     protected:
411         void marshallAttributes(DOMElement* domElement) const {
412             MARSHALL_STRING_ATTRIB(URI,URI,NULL);
413         }
414
415         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
416             getUnknownXMLObjects().push_back(childXMLObject);
417         }
418
419         void processAttribute(const DOMAttr* attribute) {
420             PROC_STRING_ATTRIB(URI,URI,NULL);
421             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
422         }
423     };
424
425     class XMLTOOL_DLLLOCAL DataReferenceImpl : public virtual DataReference, public ReferenceTypeImpl
426     {
427     public:
428         virtual ~DataReferenceImpl() {}
429
430         DataReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
431             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
432             
433         DataReferenceImpl(const DataReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {}
434         
435         IMPL_XMLOBJECT_CLONE(DataReference);
436         ReferenceType* cloneReferenceType() const {
437             return new DataReferenceImpl(*this);
438         }
439     };
440
441     class XMLTOOL_DLLLOCAL KeyReferenceImpl : public virtual KeyReference, public ReferenceTypeImpl
442     {
443     public:
444         virtual ~KeyReferenceImpl() {}
445
446         KeyReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
447             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
448             
449         KeyReferenceImpl(const KeyReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {}
450         
451         IMPL_XMLOBJECT_CLONE(KeyReference);
452         ReferenceType* cloneReferenceType() const {
453             return new KeyReferenceImpl(*this);
454         }
455     };
456
457     class XMLTOOL_DLLLOCAL ReferenceListImpl : public virtual ReferenceList,
458         public AbstractComplexElement,
459         public AbstractDOMCachingXMLObject,
460         public AbstractXMLObjectMarshaller,
461         public AbstractXMLObjectUnmarshaller
462     {
463     public:
464         virtual ~ReferenceListImpl() {}
465
466         ReferenceListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
467             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
468         }
469             
470         ReferenceListImpl(const ReferenceListImpl& src)
471                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
472             for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
473                 if (*i) {
474                     DataReference* data=dynamic_cast<DataReference*>(*i);
475                     if (data) {
476                         getDataReferences().push_back(data->cloneDataReference());
477                         continue;
478                     }
479
480                     KeyReference* key=dynamic_cast<KeyReference*>(*i);
481                     if (key) {
482                         getKeyReferences().push_back(key->cloneKeyReference());
483                         continue;
484                     }
485                 }
486             }
487         }
488         
489         IMPL_XMLOBJECT_CLONE(ReferenceList);
490         IMPL_TYPED_CHILDREN(DataReference,m_children.end());
491         IMPL_TYPED_CHILDREN(KeyReference,m_children.end());
492
493     protected:
494         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
495             PROC_TYPED_CHILDREN(DataReference,XMLENC_NS,false);
496             PROC_TYPED_CHILDREN(KeyReference,XMLENC_NS,false);
497             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
498         }
499     };
500
501     class XMLTOOL_DLLLOCAL EncryptedTypeImpl : public virtual EncryptedType,
502         public AbstractComplexElement,
503         public AbstractDOMCachingXMLObject,
504         public AbstractXMLObjectMarshaller,
505         public AbstractXMLObjectUnmarshaller
506     {
507         void init() {
508             m_Id=m_Type=m_MimeType=m_Encoding=NULL;
509             m_EncryptionMethod=NULL;
510             m_KeyInfo=NULL;
511             m_CipherData=NULL;
512             m_EncryptionProperties=NULL;
513             m_children.push_back(NULL);
514             m_children.push_back(NULL);
515             m_children.push_back(NULL);
516             m_children.push_back(NULL);
517             m_pos_EncryptionMethod=m_children.begin();
518             m_pos_KeyInfo=m_pos_EncryptionMethod;
519             ++m_pos_KeyInfo;
520             m_pos_CipherData=m_pos_KeyInfo;
521             ++m_pos_CipherData;
522             m_pos_EncryptionProperties=m_pos_CipherData;
523             ++m_pos_EncryptionProperties;
524         }
525     protected:
526         EncryptedTypeImpl() {
527             init();
528         }
529         
530     public:
531         virtual ~EncryptedTypeImpl() {
532             XMLString::release(&m_Id);
533             XMLString::release(&m_Type);
534             XMLString::release(&m_MimeType);
535             XMLString::release(&m_Encoding);
536         }
537
538         EncryptedTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
539                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
540             init();
541         }
542             
543         EncryptedTypeImpl(const EncryptedTypeImpl& src)
544                 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
545             init();
546             setId(src.getId());
547             setType(src.getType());
548             setMimeType(src.getMimeType());
549             setEncoding(src.getEncoding());
550             if (src.getEncryptionMethod())
551                 setEncryptionMethod(src.getEncryptionMethod()->cloneEncryptionMethod());
552             if (src.getKeyInfo())
553                 setKeyInfo(src.getKeyInfo()->cloneKeyInfo());
554             if (src.getCipherData())
555                 setCipherData(src.getCipherData()->cloneCipherData());
556             if (src.getEncryptionProperties())
557                 setEncryptionProperties(src.getEncryptionProperties()->cloneEncryptionProperties());
558         }
559         
560         IMPL_XMLOBJECT_CLONE(EncryptedType);
561         IMPL_ID_ATTRIB(Id);
562         IMPL_STRING_ATTRIB(Type);
563         IMPL_STRING_ATTRIB(MimeType);
564         IMPL_STRING_ATTRIB(Encoding);
565         IMPL_TYPED_CHILD(EncryptionMethod);
566         IMPL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature);
567         IMPL_TYPED_CHILD(CipherData);
568         IMPL_TYPED_CHILD(EncryptionProperties);
569
570     protected:
571         void marshallAttributes(DOMElement* domElement) const {
572             MARSHALL_ID_ATTRIB(Id,ID,NULL);
573             MARSHALL_STRING_ATTRIB(Type,TYPE,NULL);
574             MARSHALL_STRING_ATTRIB(MimeType,MIMETYPE,NULL);
575             MARSHALL_STRING_ATTRIB(Encoding,ENCODING,NULL);
576         }
577
578         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
579             PROC_TYPED_CHILD(EncryptionMethod,XMLENC_NS,false);
580             PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLSIG_NS,false);
581             PROC_TYPED_CHILD(CipherData,XMLENC_NS,false);
582             PROC_TYPED_CHILD(EncryptionProperties,XMLENC_NS,false);
583             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
584         }
585
586         void processAttribute(const DOMAttr* attribute) {
587             PROC_ID_ATTRIB(Id,ID,NULL);
588             PROC_STRING_ATTRIB(Type,TYPE,NULL);
589             PROC_STRING_ATTRIB(MimeType,MIMETYPE,NULL);
590             PROC_STRING_ATTRIB(Encoding,ENCODING,NULL);
591             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
592         }
593     };
594
595     class XMLTOOL_DLLLOCAL EncryptedDataImpl : public virtual EncryptedData, public EncryptedTypeImpl
596     {
597     public:
598         virtual ~EncryptedDataImpl() {}
599
600         EncryptedDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
601             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
602             
603         EncryptedDataImpl(const EncryptedDataImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {}
604         
605         IMPL_XMLOBJECT_CLONE(EncryptedData);
606         EncryptedType* cloneEncryptedType() const {
607             return new EncryptedDataImpl(*this);
608         }
609     };
610
611     class XMLTOOL_DLLLOCAL EncryptedKeyImpl : public virtual EncryptedKey, public EncryptedTypeImpl
612     {
613         void init() {
614             m_Recipient=NULL;
615             m_ReferenceList=NULL;
616             m_CarriedKeyName=NULL;
617             m_children.push_back(NULL);
618             m_children.push_back(NULL);
619             m_pos_ReferenceList=m_pos_EncryptionProperties;
620             ++m_pos_ReferenceList;
621             m_pos_CarriedKeyName=m_pos_ReferenceList;
622             ++m_pos_CarriedKeyName;
623         }
624         
625     public:
626         virtual ~EncryptedKeyImpl() {
627             XMLString::release(&m_Recipient);
628         }
629
630         EncryptedKeyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
631                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
632             init();
633         }
634             
635         EncryptedKeyImpl(const EncryptedKeyImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {
636             init();
637         }
638         
639         IMPL_XMLOBJECT_CLONE(EncryptedKey);
640         EncryptedType* cloneEncryptedType() const {
641             return new EncryptedKeyImpl(*this);
642         }
643         IMPL_STRING_ATTRIB(Recipient);
644         IMPL_TYPED_CHILD(ReferenceList);
645         IMPL_TYPED_CHILD(CarriedKeyName);
646     
647     protected:
648         void marshallAttributes(DOMElement* domElement) const {
649             MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,NULL);
650             EncryptedTypeImpl::marshallAttributes(domElement);
651         }
652
653         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
654             PROC_TYPED_CHILD(ReferenceList,XMLENC_NS,false);
655             PROC_TYPED_CHILD(CarriedKeyName,XMLENC_NS,false);
656             EncryptedTypeImpl::processChildElement(childXMLObject,root);
657         }
658
659         void processAttribute(const DOMAttr* attribute) {
660             PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL);
661             EncryptedTypeImpl::processAttribute(attribute);
662         }
663     };
664
665 };
666
667 #if defined (_MSC_VER)
668     #pragma warning( pop )
669 #endif
670
671 // Builder Implementations
672
673 IMPL_XMLOBJECTBUILDER(CarriedKeyName);
674 IMPL_XMLOBJECTBUILDER(CipherData);
675 IMPL_XMLOBJECTBUILDER(CipherReference);
676 IMPL_XMLOBJECTBUILDER(CipherValue);
677 IMPL_XMLOBJECTBUILDER(DataReference);
678 IMPL_XMLOBJECTBUILDER(EncryptedData);
679 IMPL_XMLOBJECTBUILDER(EncryptedKey);
680 IMPL_XMLOBJECTBUILDER(EncryptionMethod);
681 IMPL_XMLOBJECTBUILDER(EncryptionProperties);
682 IMPL_XMLOBJECTBUILDER(EncryptionProperty);
683 IMPL_XMLOBJECTBUILDER(KeyReference);
684 IMPL_XMLOBJECTBUILDER(KeySize);
685 IMPL_XMLOBJECTBUILDER(OAEPparams);
686 IMPL_XMLOBJECTBUILDER(ReferenceList);
687 IMPL_XMLOBJECTBUILDER(Transforms);
688
689 // Unicode literals
690
691 const XMLCh CarriedKeyName::LOCAL_NAME[] =              UNICODE_LITERAL_14(C,a,r,r,i,e,d,K,e,y,N,a,m,e);
692 const XMLCh CipherData::LOCAL_NAME[] =                  UNICODE_LITERAL_10(C,i,p,h,e,r,D,a,t,a);
693 const XMLCh CipherData::TYPE_NAME[] =                   UNICODE_LITERAL_14(C,i,p,h,e,r,D,a,t,a,T,y,p,e);
694 const XMLCh CipherReference::LOCAL_NAME[] =             UNICODE_LITERAL_15(C,i,p,h,e,r,R,e,f,e,r,e,n,c,e);
695 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);
696 const XMLCh CipherReference::URI_ATTRIB_NAME[] =        UNICODE_LITERAL_3(U,R,I);
697 const XMLCh CipherValue::LOCAL_NAME[] =                 UNICODE_LITERAL_11(C,i,p,h,e,r,V,a,l,u,e);
698 const XMLCh DataReference::LOCAL_NAME[] =               UNICODE_LITERAL_13(D,a,t,a,R,e,f,e,r,e,n,c,e);
699 const XMLCh EncryptedData::LOCAL_NAME[] =               UNICODE_LITERAL_13(E,n,c,r,y,p,t,e,d,D,a,t,a);
700 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);
701 const XMLCh EncryptedKey::LOCAL_NAME[] =                UNICODE_LITERAL_12(E,n,c,r,y,p,t,e,d,K,e,y);
702 const XMLCh EncryptedKey::TYPE_NAME[] =                 UNICODE_LITERAL_16(E,n,c,r,y,p,t,e,d,K,e,y,T,y,p,e);
703 const XMLCh EncryptedKey::RECIPIENT_ATTRIB_NAME[] =     UNICODE_LITERAL_9(R,e,c,i,p,i,e,n,t);
704 const XMLCh EncryptedType::LOCAL_NAME[] =               {chNull};
705 const XMLCh EncryptedType::TYPE_NAME[] =                UNICODE_LITERAL_13(E,n,c,r,y,p,t,e,d,T,y,p,e);
706 const XMLCh EncryptedType::ID_ATTRIB_NAME[] =           UNICODE_LITERAL_2(I,d);
707 const XMLCh EncryptedType::TYPE_ATTRIB_NAME[] =         UNICODE_LITERAL_4(T,y,p,e);
708 const XMLCh EncryptedType::MIMETYPE_ATTRIB_NAME[] =     UNICODE_LITERAL_8(M,i,m,e,T,y,p,e);
709 const XMLCh EncryptedType::ENCODING_ATTRIB_NAME[] =     UNICODE_LITERAL_8(E,n,c,o,d,i,n,g);
710 const XMLCh EncryptionMethod::LOCAL_NAME[] =            UNICODE_LITERAL_16(E,n,c,r,y,p,t,i,o,n,M,e,t,h,o,d);
711 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);
712 const XMLCh EncryptionMethod::ALGORITHM_ATTRIB_NAME[] = UNICODE_LITERAL_9(A,l,g,o,r,i,t,h,m);
713 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);
714 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);
715 const XMLCh EncryptionProperties::ID_ATTRIB_NAME[] =    UNICODE_LITERAL_2(I,d);
716 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);
717 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);
718 const XMLCh EncryptionProperty::ID_ATTRIB_NAME[] =      UNICODE_LITERAL_2(I,d);
719 const XMLCh EncryptionProperty::TARGET_ATTRIB_NAME[] =  UNICODE_LITERAL_6(T,a,r,g,e,t);
720 const XMLCh KeyReference::LOCAL_NAME[] =                UNICODE_LITERAL_12(K,e,y,R,e,f,e,r,e,n,c,e);
721 const XMLCh KeySize::LOCAL_NAME[] =                     UNICODE_LITERAL_7(K,e,y,S,i,z,e);
722 const XMLCh OAEPparams::LOCAL_NAME[] =                  UNICODE_LITERAL_10(O,A,E,P,p,a,r,a,m,s);
723 const XMLCh ReferenceList::LOCAL_NAME[] =               UNICODE_LITERAL_13(R,e,f,e,r,e,n,c,e,L,i,s,t);
724 const XMLCh ReferenceType::LOCAL_NAME[] =               {chNull};
725 const XMLCh ReferenceType::TYPE_NAME[] =                UNICODE_LITERAL_13(R,e,f,e,r,e,n,c,e,T,y,p,e);
726 const XMLCh ReferenceType::URI_ATTRIB_NAME[] =          UNICODE_LITERAL_3(U,R,I);
727 const XMLCh Transforms::LOCAL_NAME[] =                  UNICODE_LITERAL_10(T,r,a,n,s,f,o,r,m,s);
728 const XMLCh Transforms::TYPE_NAME[] =                   UNICODE_LITERAL_14(T,r,a,n,s,f,o,r,m,s,T,y,p,e);