Removed ValidatingXMLObject interface and implementations.
[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_STRING_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
306             // Take care of wildcard.
307             for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
308                 DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
309                 if (i->first.hasPrefix())
310                     attr->setPrefix(i->first.getPrefix());
311                 attr->setNodeValue(i->second);
312                 domElement->setAttributeNode(attr);
313             }
314         }
315
316         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
317             getXMLObjects().push_back(childXMLObject);
318         }
319
320         void processAttribute(const DOMAttr* attribute) {
321             PROC_ID_ATTRIB(Id,ID,NULL);
322             QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
323             setAttribute(q,attribute->getNodeValue());
324         }
325     };
326
327     class XMLTOOL_DLLLOCAL EncryptionPropertiesImpl : public virtual EncryptionProperties,
328         public AbstractComplexElement,
329         public AbstractDOMCachingXMLObject,
330         public AbstractXMLObjectMarshaller,
331         public AbstractXMLObjectUnmarshaller
332     {
333         void init() {
334             m_Id=NULL;
335         }
336     public:
337         virtual ~EncryptionPropertiesImpl() {
338             XMLString::release(&m_Id);
339         }
340
341         EncryptionPropertiesImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
342             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
343             init();
344         }
345             
346         EncryptionPropertiesImpl(const EncryptionPropertiesImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
347             init();
348             setId(src.getId());
349             VectorOf(EncryptionProperty) v=getEncryptionPropertys();
350             for (vector<EncryptionProperty*>::const_iterator i=src.m_EncryptionPropertys.begin(); i!=src.m_EncryptionPropertys.end(); i++) {
351                 if (*i) {
352                     v.push_back((*i)->cloneEncryptionProperty());
353                 }
354             }
355         }
356         
357         IMPL_XMLOBJECT_CLONE(EncryptionProperties);
358         IMPL_STRING_ATTRIB(Id);
359         IMPL_TYPED_CHILDREN(EncryptionProperty,m_children.end());
360
361     protected:
362         void marshallAttributes(DOMElement* domElement) const {
363             MARSHALL_ID_ATTRIB(Id,ID,NULL);
364         }
365
366         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
367             PROC_TYPED_CHILDREN(EncryptionProperty,XMLConstants::XMLENC_NS,false);
368             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
369         }
370
371         void processAttribute(const DOMAttr* attribute) {
372             PROC_ID_ATTRIB(Id,ID,NULL);
373             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
374         }
375     };
376
377     class XMLTOOL_DLLLOCAL ReferenceTypeImpl : public virtual ReferenceType,
378         public AbstractElementProxy,
379         public AbstractDOMCachingXMLObject,
380         public AbstractXMLObjectMarshaller,
381         public AbstractXMLObjectUnmarshaller
382     {
383         void init() {
384             m_URI=NULL;
385         }
386         
387     protected:
388         ReferenceTypeImpl() {
389             init();
390         }
391         
392     public:
393         virtual ~ReferenceTypeImpl() {
394             XMLString::release(&m_URI);
395         }
396
397         ReferenceTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
398             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
399             init();
400         }
401             
402         ReferenceTypeImpl(const ReferenceTypeImpl& src)
403                 : AbstractXMLObject(src), AbstractElementProxy(src), AbstractDOMCachingXMLObject(src) {
404             init();
405             setURI(src.getURI());
406             for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
407                 if (*i) {
408                     getXMLObjects().push_back((*i)->clone());
409                 }
410             }
411         }
412         
413         IMPL_XMLOBJECT_CLONE(ReferenceType);
414         IMPL_STRING_ATTRIB(URI);
415
416     protected:
417         void marshallAttributes(DOMElement* domElement) const {
418             MARSHALL_STRING_ATTRIB(URI,URI,NULL);
419         }
420
421         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
422             getXMLObjects().push_back(childXMLObject);
423         }
424
425         void processAttribute(const DOMAttr* attribute) {
426             PROC_STRING_ATTRIB(URI,URI,NULL);
427             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
428         }
429     };
430
431     class XMLTOOL_DLLLOCAL DataReferenceImpl : public virtual DataReference, public ReferenceTypeImpl
432     {
433     public:
434         virtual ~DataReferenceImpl() {}
435
436         DataReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
437             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
438             
439         DataReferenceImpl(const DataReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {}
440         
441         IMPL_XMLOBJECT_CLONE(DataReference);
442         ReferenceType* cloneReferenceType() const {
443             return new DataReferenceImpl(*this);
444         }
445     };
446
447     class XMLTOOL_DLLLOCAL KeyReferenceImpl : public virtual KeyReference, public ReferenceTypeImpl
448     {
449     public:
450         virtual ~KeyReferenceImpl() {}
451
452         KeyReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
453             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
454             
455         KeyReferenceImpl(const KeyReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {}
456         
457         IMPL_XMLOBJECT_CLONE(KeyReference);
458         ReferenceType* cloneReferenceType() const {
459             return new KeyReferenceImpl(*this);
460         }
461     };
462
463     class XMLTOOL_DLLLOCAL ReferenceListImpl : public virtual ReferenceList,
464         public AbstractComplexElement,
465         public AbstractDOMCachingXMLObject,
466         public AbstractXMLObjectMarshaller,
467         public AbstractXMLObjectUnmarshaller
468     {
469     public:
470         virtual ~ReferenceListImpl() {}
471
472         ReferenceListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
473             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
474         }
475             
476         ReferenceListImpl(const ReferenceListImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
477             for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
478                 if (*i) {
479                     DataReference* data=dynamic_cast<DataReference*>(*i);
480                     if (data) {
481                         getDataReferences().push_back(data->cloneDataReference());
482                         continue;
483                     }
484
485                     KeyReference* key=dynamic_cast<KeyReference*>(*i);
486                     if (key) {
487                         getKeyReferences().push_back(key->cloneKeyReference());
488                         continue;
489                     }
490                 }
491             }
492         }
493         
494         IMPL_XMLOBJECT_CLONE(ReferenceList);
495         IMPL_TYPED_CHILDREN(DataReference,m_children.end());
496         IMPL_TYPED_CHILDREN(KeyReference,m_children.end());
497
498     protected:
499         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
500             PROC_TYPED_CHILDREN(DataReference,XMLConstants::XMLENC_NS,false);
501             PROC_TYPED_CHILDREN(KeyReference,XMLConstants::XMLENC_NS,false);
502             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
503         }
504     };
505
506     class XMLTOOL_DLLLOCAL EncryptedTypeImpl : public virtual EncryptedType,
507         public AbstractComplexElement,
508         public AbstractDOMCachingXMLObject,
509         public AbstractXMLObjectMarshaller,
510         public AbstractXMLObjectUnmarshaller
511     {
512         void init() {
513             m_Id=m_Type=m_MimeType=m_Encoding=NULL;
514             m_EncryptionMethod=NULL;
515             m_KeyInfo=NULL;
516             m_CipherData=NULL;
517             m_EncryptionProperties=NULL;
518             m_children.push_back(NULL);
519             m_children.push_back(NULL);
520             m_children.push_back(NULL);
521             m_children.push_back(NULL);
522             m_pos_EncryptionMethod=m_children.begin();
523             m_pos_KeyInfo=m_pos_EncryptionMethod;
524             ++m_pos_KeyInfo;
525             m_pos_CipherData=m_pos_KeyInfo;
526             ++m_pos_CipherData;
527             m_pos_EncryptionProperties=m_pos_CipherData;
528             ++m_pos_EncryptionProperties;
529         }
530     protected:
531         EncryptedTypeImpl() {
532             init();
533         }
534         
535     public:
536         virtual ~EncryptedTypeImpl() {
537             XMLString::release(&m_Id);
538             XMLString::release(&m_Type);
539             XMLString::release(&m_MimeType);
540             XMLString::release(&m_Encoding);
541         }
542
543         EncryptedTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
544                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
545             init();
546         }
547             
548         EncryptedTypeImpl(const EncryptedTypeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
549             init();
550             setId(src.getId());
551             setType(src.getType());
552             setMimeType(src.getMimeType());
553             setEncoding(src.getEncoding());
554             if (src.getEncryptionMethod())
555                 setEncryptionMethod(src.getEncryptionMethod()->cloneEncryptionMethod());
556             if (src.getKeyInfo())
557                 setKeyInfo(src.getKeyInfo()->cloneKeyInfo());
558             if (src.getCipherData())
559                 setCipherData(src.getCipherData()->cloneCipherData());
560             if (src.getEncryptionProperties())
561                 setEncryptionProperties(src.getEncryptionProperties()->cloneEncryptionProperties());
562         }
563         
564         IMPL_XMLOBJECT_CLONE(EncryptedType);
565         IMPL_STRING_ATTRIB(Id);
566         IMPL_STRING_ATTRIB(Type);
567         IMPL_STRING_ATTRIB(MimeType);
568         IMPL_STRING_ATTRIB(Encoding);
569         IMPL_TYPED_CHILD(EncryptionMethod);
570         IMPL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature);
571         IMPL_TYPED_CHILD(CipherData);
572         IMPL_TYPED_CHILD(EncryptionProperties);
573
574     protected:
575         void marshallAttributes(DOMElement* domElement) const {
576             MARSHALL_ID_ATTRIB(Id,ID,NULL);
577             MARSHALL_STRING_ATTRIB(Type,TYPE,NULL);
578             MARSHALL_STRING_ATTRIB(MimeType,MIMETYPE,NULL);
579             MARSHALL_STRING_ATTRIB(Encoding,ENCODING,NULL);
580         }
581
582         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
583             PROC_TYPED_CHILD(EncryptionMethod,XMLConstants::XMLENC_NS,false);
584             PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLConstants::XMLSIG_NS,false);
585             PROC_TYPED_CHILD(CipherData,XMLConstants::XMLENC_NS,false);
586             PROC_TYPED_CHILD(EncryptionProperties,XMLConstants::XMLENC_NS,false);
587             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
588         }
589
590         void processAttribute(const DOMAttr* attribute) {
591             PROC_ID_ATTRIB(Id,ID,NULL);
592             PROC_STRING_ATTRIB(Type,TYPE,NULL);
593             PROC_STRING_ATTRIB(MimeType,MIMETYPE,NULL);
594             PROC_STRING_ATTRIB(Encoding,ENCODING,NULL);
595             AbstractXMLObjectUnmarshaller::processAttribute(attribute);
596         }
597     };
598
599     class XMLTOOL_DLLLOCAL EncryptedDataImpl : public virtual EncryptedData, public EncryptedTypeImpl
600     {
601     public:
602         virtual ~EncryptedDataImpl() {}
603
604         EncryptedDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
605             : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
606             
607         EncryptedDataImpl(const EncryptedDataImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {}
608         
609         IMPL_XMLOBJECT_CLONE(EncryptedData);
610         EncryptedType* cloneEncryptedType() const {
611             return new EncryptedDataImpl(*this);
612         }
613     };
614
615     class XMLTOOL_DLLLOCAL EncryptedKeyImpl : public virtual EncryptedKey, public EncryptedTypeImpl
616     {
617         void init() {
618             m_Recipient=NULL;
619             m_ReferenceList=NULL;
620             m_CarriedKeyName=NULL;
621             m_children.push_back(NULL);
622             m_children.push_back(NULL);
623             m_pos_ReferenceList=m_pos_EncryptionProperties;
624             ++m_pos_ReferenceList;
625             m_pos_CarriedKeyName=m_pos_ReferenceList;
626             ++m_pos_CarriedKeyName;
627         }
628         
629     public:
630         virtual ~EncryptedKeyImpl() {
631             XMLString::release(&m_Recipient);
632         }
633
634         EncryptedKeyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
635                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
636             init();
637         }
638             
639         EncryptedKeyImpl(const EncryptedKeyImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {
640             init();
641         }
642         
643         IMPL_XMLOBJECT_CLONE(EncryptedKey);
644         EncryptedType* cloneEncryptedType() const {
645             return new EncryptedKeyImpl(*this);
646         }
647         IMPL_STRING_ATTRIB(Recipient);
648         IMPL_TYPED_CHILD(ReferenceList);
649         IMPL_TYPED_CHILD(CarriedKeyName);
650     
651     protected:
652         void marshallAttributes(DOMElement* domElement) const {
653             MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,NULL);
654             EncryptedTypeImpl::marshallAttributes(domElement);
655         }
656
657         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
658             PROC_TYPED_CHILD(ReferenceList,XMLConstants::XMLENC_NS,false);
659             PROC_TYPED_CHILD(CarriedKeyName,XMLConstants::XMLENC_NS,false);
660             EncryptedTypeImpl::processChildElement(childXMLObject,root);
661         }
662
663         void processAttribute(const DOMAttr* attribute) {
664             PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL);
665             EncryptedTypeImpl::processAttribute(attribute);
666         }
667     };
668
669 };
670
671 #if defined (_MSC_VER)
672     #pragma warning( pop )
673 #endif
674
675 // Builder Implementations
676
677 IMPL_XMLOBJECTBUILDER(CarriedKeyName);
678 IMPL_XMLOBJECTBUILDER(CipherData);
679 IMPL_XMLOBJECTBUILDER(CipherReference);
680 IMPL_XMLOBJECTBUILDER(CipherValue);
681 IMPL_XMLOBJECTBUILDER(DataReference);
682 IMPL_XMLOBJECTBUILDER(EncryptedData);
683 IMPL_XMLOBJECTBUILDER(EncryptedKey);
684 IMPL_XMLOBJECTBUILDER(EncryptionMethod);
685 IMPL_XMLOBJECTBUILDER(EncryptionProperties);
686 IMPL_XMLOBJECTBUILDER(EncryptionProperty);
687 IMPL_XMLOBJECTBUILDER(KeyReference);
688 IMPL_XMLOBJECTBUILDER(KeySize);
689 IMPL_XMLOBJECTBUILDER(OAEPparams);
690 IMPL_XMLOBJECTBUILDER(ReferenceList);
691 IMPL_XMLOBJECTBUILDER(Transforms);
692
693 // Unicode literals
694
695 const XMLCh CarriedKeyName::LOCAL_NAME[] =              UNICODE_LITERAL_14(C,a,r,r,i,e,d,K,e,y,N,a,m,e);
696 const XMLCh CipherData::LOCAL_NAME[] =                  UNICODE_LITERAL_10(C,i,p,h,e,r,D,a,t,a);
697 const XMLCh CipherData::TYPE_NAME[] =                   UNICODE_LITERAL_14(C,i,p,h,e,r,D,a,t,a,T,y,p,e);
698 const XMLCh CipherReference::LOCAL_NAME[] =             UNICODE_LITERAL_15(C,i,p,h,e,r,R,e,f,e,r,e,n,c,e);
699 const XMLCh CipherReference::TYPE_NAME[] =              UNICODE_LITERAL_19(C,i,p,h,e,r,R,e,f,e,r,e,n,c,e,T,y,p,e);
700 const XMLCh CipherReference::URI_ATTRIB_NAME[] =        UNICODE_LITERAL_3(U,R,I);
701 const XMLCh CipherValue::LOCAL_NAME[] =                 UNICODE_LITERAL_11(C,i,p,h,e,r,V,a,l,u,e);
702 const XMLCh DataReference::LOCAL_NAME[] =               UNICODE_LITERAL_13(D,a,t,a,R,e,f,e,r,e,n,c,e);
703 const XMLCh EncryptedData::LOCAL_NAME[] =               UNICODE_LITERAL_13(E,n,c,r,y,p,t,e,d,D,a,t,a);
704 const XMLCh EncryptedData::TYPE_NAME[] =                UNICODE_LITERAL_17(E,n,c,r,y,p,t,e,d,D,a,t,a,T,y,p,e);
705 const XMLCh EncryptedKey::LOCAL_NAME[] =                UNICODE_LITERAL_12(E,n,c,r,y,p,t,e,d,K,e,y);
706 const XMLCh EncryptedKey::TYPE_NAME[] =                 UNICODE_LITERAL_16(E,n,c,r,y,p,t,e,d,K,e,y,T,y,p,e);
707 const XMLCh EncryptedKey::RECIPIENT_ATTRIB_NAME[] =     UNICODE_LITERAL_9(R,e,c,i,p,i,e,n,t);
708 const XMLCh EncryptedType::LOCAL_NAME[] =               {chNull};
709 const XMLCh EncryptedType::TYPE_NAME[] =                UNICODE_LITERAL_13(E,n,c,r,y,p,t,e,d,T,y,p,e);
710 const XMLCh EncryptedType::ID_ATTRIB_NAME[] =           UNICODE_LITERAL_2(I,d);
711 const XMLCh EncryptedType::TYPE_ATTRIB_NAME[] =         UNICODE_LITERAL_4(T,y,p,e);
712 const XMLCh EncryptedType::MIMETYPE_ATTRIB_NAME[] =     UNICODE_LITERAL_8(M,i,m,e,T,y,p,e);
713 const XMLCh EncryptedType::ENCODING_ATTRIB_NAME[] =     UNICODE_LITERAL_8(E,n,c,o,d,i,n,g);
714 const XMLCh EncryptionMethod::LOCAL_NAME[] =            UNICODE_LITERAL_16(E,n,c,r,y,p,t,i,o,n,M,e,t,h,o,d);
715 const XMLCh EncryptionMethod::TYPE_NAME[] =             UNICODE_LITERAL_20(E,n,c,r,y,p,t,i,o,n,M,e,t,h,o,d,T,y,p,e);
716 const XMLCh EncryptionMethod::ALGORITHM_ATTRIB_NAME[] = UNICODE_LITERAL_9(A,l,g,o,r,i,t,h,m);
717 const XMLCh EncryptionProperties::LOCAL_NAME[] =        UNICODE_LITERAL_20(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,i,e,s);
718 const XMLCh EncryptionProperties::TYPE_NAME[] =         UNICODE_LITERAL_24(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,i,e,s,T,y,p,e);
719 const XMLCh EncryptionProperties::ID_ATTRIB_NAME[] =    UNICODE_LITERAL_2(I,d);
720 const XMLCh EncryptionProperty::LOCAL_NAME[] =          UNICODE_LITERAL_18(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,y);
721 const XMLCh EncryptionProperty::TYPE_NAME[] =           UNICODE_LITERAL_22(E,n,c,r,y,p,t,i,o,n,P,r,o,p,e,r,t,y,T,y,p,e);
722 const XMLCh EncryptionProperty::ID_ATTRIB_NAME[] =      UNICODE_LITERAL_2(I,d);
723 const XMLCh EncryptionProperty::TARGET_ATTRIB_NAME[] =  UNICODE_LITERAL_6(T,a,r,g,e,t);
724 const XMLCh KeyReference::LOCAL_NAME[] =                UNICODE_LITERAL_12(K,e,y,R,e,f,e,r,e,n,c,e);
725 const XMLCh KeySize::LOCAL_NAME[] =                     UNICODE_LITERAL_7(K,e,y,S,i,z,e);
726 const XMLCh OAEPparams::LOCAL_NAME[] =                  UNICODE_LITERAL_10(O,A,E,P,p,a,r,a,m,s);
727 const XMLCh ReferenceList::LOCAL_NAME[] =               UNICODE_LITERAL_13(R,e,f,e,r,e,n,c,e,L,i,s,t);
728 const XMLCh ReferenceType::LOCAL_NAME[] =               {chNull};
729 const XMLCh ReferenceType::TYPE_NAME[] =                UNICODE_LITERAL_13(R,e,f,e,r,e,n,c,e,T,y,p,e);
730 const XMLCh ReferenceType::URI_ATTRIB_NAME[] =          UNICODE_LITERAL_3(U,R,I);
731 const XMLCh Transforms::LOCAL_NAME[] =                  UNICODE_LITERAL_10(T,r,a,n,s,f,o,r,m,s);
732 const XMLCh Transforms::TYPE_NAME[] =                   UNICODE_LITERAL_14(T,r,a,n,s,f,o,r,m,s,T,y,p,e);