55489649f72805f43e439a99056cbd79d6aa026d
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / impl / MetadataImpl.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  * MetadataImpl.cpp
19  * 
20  * Implementation classes for SAML 2.0 Assertions schema
21  */
22
23 #include "internal.h"
24 #include "exceptions.h"
25 #include "saml2/metadata/Metadata.h"
26
27 #include <xmltooling/AbstractComplexElement.h>
28 #include <xmltooling/AbstractElementProxy.h>
29 #include <xmltooling/AbstractSimpleElement.h>
30 #include <xmltooling/impl/AnyElement.h>
31 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
32 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
33 #include <xmltooling/util/XMLHelper.h>
34
35 #include <ctime>
36 #include <xercesc/util/XMLUniDefs.hpp>
37
38 using namespace opensaml::saml2md;
39 using namespace opensaml::saml2;
40 using namespace opensaml;
41 using namespace xmlencryption;
42 using namespace xmlsignature;
43 using namespace xmltooling;
44 using namespace std;
45
46 #if defined (_MSC_VER)
47     #pragma warning( push )
48     #pragma warning( disable : 4250 4251 )
49 #endif
50
51 namespace opensaml {
52     namespace saml2md {
53
54         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AffiliateMember);
55         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AttributeProfile);
56         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,Company);
57         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,EmailAddress);
58         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,GivenName);
59         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,NameIDFormat);
60         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,SurName);
61         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,TelephoneNumber);
62
63         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,ActionNamespace);
64         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,SourceID);
65
66         class SAML_DLLLOCAL localizedNameTypeImpl : public virtual localizedNameType,
67             public AbstractSimpleElement,
68             public AbstractDOMCachingXMLObject,
69             public AbstractXMLObjectMarshaller,
70             public AbstractXMLObjectUnmarshaller
71         {
72             void init() {
73                 m_Lang=NULL;
74             }
75             
76         protected:
77             localizedNameTypeImpl() {
78                 init();
79             }
80             
81         public:
82             virtual ~localizedNameTypeImpl() {
83                 XMLString::release(&m_Lang);
84             }
85     
86             localizedNameTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
87                     : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
88                 init();
89             }
90                 
91             localizedNameTypeImpl(const localizedNameTypeImpl& src)
92                     : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
93                 init();
94                 setLang(src.getLang());
95             }
96             
97             IMPL_XMLOBJECT_CLONE(localizedNameType);
98             IMPL_STRING_ATTRIB(Lang);
99     
100         protected:
101             void marshallAttributes(DOMElement* domElement) const {
102                 MARSHALL_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
103             }
104
105             void processAttribute(const DOMAttr* attribute) {
106                 PROC_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
107                 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
108             }
109         };
110
111         class SAML_DLLLOCAL localizedURITypeImpl : public virtual localizedURIType,
112             public AbstractSimpleElement,
113             public AbstractDOMCachingXMLObject,
114             public AbstractXMLObjectMarshaller,
115             public AbstractXMLObjectUnmarshaller
116         {
117             void init() {
118                 m_Lang=NULL;
119             }
120             
121         protected:
122             localizedURITypeImpl() {
123                 init();
124             }
125             
126         public:
127             virtual ~localizedURITypeImpl() {
128                 XMLString::release(&m_Lang);
129             }
130     
131             localizedURITypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
132                     : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
133                 init();
134             }
135                 
136             localizedURITypeImpl(const localizedURITypeImpl& src)
137                     : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
138                 init();
139                 setLang(src.getLang());
140             }
141             
142             IMPL_XMLOBJECT_CLONE(localizedURIType);
143             IMPL_STRING_ATTRIB(Lang);
144     
145         protected:
146             void marshallAttributes(DOMElement* domElement) const {
147                 MARSHALL_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
148             }
149
150             void processAttribute(const DOMAttr* attribute) {
151                 PROC_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
152                 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
153             }
154         };
155
156         class SAML_DLLLOCAL OrganizationNameImpl : public virtual OrganizationName, public localizedNameTypeImpl
157         {
158         public:
159             virtual ~OrganizationNameImpl() {}
160     
161             OrganizationNameImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
162                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
163                 
164             OrganizationNameImpl(const OrganizationNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
165             
166             IMPL_XMLOBJECT_CLONE(OrganizationName);
167             localizedNameType* clonelocalizedNameType() const {
168                 return new OrganizationNameImpl(*this);
169             }
170         };
171                 
172         class SAML_DLLLOCAL OrganizationDisplayNameImpl : public virtual OrganizationDisplayName, public localizedNameTypeImpl
173         {
174         public:
175             virtual ~OrganizationDisplayNameImpl() {}
176     
177             OrganizationDisplayNameImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
178                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
179                 
180             OrganizationDisplayNameImpl(const OrganizationDisplayNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
181             
182             IMPL_XMLOBJECT_CLONE(OrganizationDisplayName);
183             localizedNameType* clonelocalizedNameType() const {
184                 return new OrganizationDisplayNameImpl(*this);
185             }
186         };
187
188         class SAML_DLLLOCAL OrganizationURLImpl : public virtual OrganizationURL, public localizedURITypeImpl
189         {
190         public:
191             virtual ~OrganizationURLImpl() {}
192     
193             OrganizationURLImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
194                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
195                 
196             OrganizationURLImpl(const OrganizationURLImpl& src) : AbstractXMLObject(src), localizedURITypeImpl(src) {}
197             
198             IMPL_XMLOBJECT_CLONE(OrganizationURL);
199             localizedURIType* clonelocalizedURIType() const {
200                 return new OrganizationURLImpl(*this);
201             }
202         };
203
204         class SAML_DLLLOCAL ServiceNameImpl : public virtual ServiceName, public localizedNameTypeImpl
205         {
206         public:
207             virtual ~ServiceNameImpl() {}
208     
209             ServiceNameImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
210                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
211                 
212             ServiceNameImpl(const ServiceNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
213             
214             IMPL_XMLOBJECT_CLONE(ServiceName);
215             localizedNameType* clonelocalizedNameType() const {
216                 return new ServiceNameImpl(*this);
217             }
218         };
219
220         class SAML_DLLLOCAL ServiceDescriptionImpl : public virtual ServiceDescription, public localizedNameTypeImpl
221         {
222         public:
223             virtual ~ServiceDescriptionImpl() {}
224     
225             ServiceDescriptionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
226                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
227                 
228             ServiceDescriptionImpl(const ServiceDescriptionImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
229             
230             IMPL_XMLOBJECT_CLONE(ServiceDescription);
231             localizedNameType* clonelocalizedNameType() const {
232                 return new ServiceDescriptionImpl(*this);
233             }
234         };
235
236         class SAML_DLLLOCAL ExtensionsImpl : public virtual Extensions,
237             public AbstractElementProxy,
238             public AbstractDOMCachingXMLObject,
239             public AbstractXMLObjectMarshaller,
240             public AbstractXMLObjectUnmarshaller
241         {
242         public:
243             virtual ~ExtensionsImpl() {}
244     
245             ExtensionsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
246                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
247             }
248                 
249             ExtensionsImpl(const ExtensionsImpl& src)
250                     : AbstractXMLObject(src), AbstractElementProxy(src), AbstractDOMCachingXMLObject(src) {
251                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
252                     if (*i) {
253                         getXMLObjects().push_back((*i)->clone());
254                     }
255                 }
256             }
257             
258             IMPL_XMLOBJECT_CLONE(Extensions);
259     
260         protected:
261             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
262                 // Unknown child.
263                 const XMLCh* nsURI=root->getNamespaceURI();
264                 if (!XMLString::equals(nsURI,SAMLConstants::SAML20MD_NS) && nsURI && *nsURI) {
265                     getXMLObjects().push_back(childXMLObject);
266                     return;
267                 }
268                 
269                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
270             }
271         };
272
273         class SAML_DLLLOCAL OrganizationImpl : public virtual Organization,
274             public AbstractComplexElement,
275             public AbstractAttributeExtensibleXMLObject,
276             public AbstractDOMCachingXMLObject,
277             public AbstractXMLObjectMarshaller,
278             public AbstractXMLObjectUnmarshaller
279         {
280             list<XMLObject*>::iterator m_pos_OrganizationDisplayName;
281             list<XMLObject*>::iterator m_pos_OrganizationURL;
282             
283             void init() {
284                 m_children.push_back(NULL);
285                 m_children.push_back(NULL);
286                 m_children.push_back(NULL);
287                 m_Extensions=NULL;
288                 m_pos_Extensions=m_children.begin();
289                 m_pos_OrganizationDisplayName=m_pos_Extensions;
290                 ++m_pos_OrganizationDisplayName;
291                 m_pos_OrganizationURL=m_pos_OrganizationDisplayName;
292                 ++m_pos_OrganizationURL;
293             }
294         public:
295             virtual ~OrganizationImpl() {}
296     
297             OrganizationImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
298                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
299                 init();
300             }
301                 
302             OrganizationImpl(const OrganizationImpl& src)
303                     : AbstractXMLObject(src), AbstractComplexElement(src),
304                         AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
305                 init();
306                 if (src.getExtensions())
307                     setExtensions(src.getExtensions()->cloneExtensions());
308                 VectorOf(OrganizationName) v=getOrganizationNames();
309                 for (vector<OrganizationName*>::const_iterator i=src.m_OrganizationNames.begin(); i!=src.m_OrganizationNames.end(); i++) {
310                     if (*i) {
311                         v.push_back((*i)->cloneOrganizationName());
312                     }
313                 }
314                 VectorOf(OrganizationDisplayName) w=getOrganizationDisplayNames();
315                 for (vector<OrganizationDisplayName*>::const_iterator j=src.m_OrganizationDisplayNames.begin(); j!=src.m_OrganizationDisplayNames.end(); j++) {
316                     if (*j) {
317                         w.push_back((*j)->cloneOrganizationDisplayName());
318                     }
319                 }
320                 VectorOf(OrganizationURL) x=getOrganizationURLs();
321                 for (vector<OrganizationURL*>::const_iterator k=src.m_OrganizationURLs.begin(); k!=src.m_OrganizationURLs.end(); k++) {
322                     if (*k) {
323                         x.push_back((*k)->cloneOrganizationURL());
324                     }
325                 }
326             }
327             
328             IMPL_XMLOBJECT_CLONE(Organization);
329             IMPL_TYPED_CHILD(Extensions);
330             IMPL_TYPED_CHILDREN(OrganizationName,m_pos_OrganizationDisplayName);
331             IMPL_TYPED_CHILDREN(OrganizationDisplayName,m_pos_OrganizationURL);
332             IMPL_TYPED_CHILDREN(OrganizationURL,m_children.end());
333     
334         protected:
335             void marshallAttributes(DOMElement* domElement) const {
336                 marshallExtensionAttributes(domElement);
337             }
338
339             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
340                 PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
341                 PROC_TYPED_CHILDREN(OrganizationName,SAMLConstants::SAML20MD_NS,false);
342                 PROC_TYPED_CHILDREN(OrganizationDisplayName,SAMLConstants::SAML20MD_NS,false);
343                 PROC_TYPED_CHILDREN(OrganizationURL,SAMLConstants::SAML20MD_NS,false);
344                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
345             }
346
347             void processAttribute(const DOMAttr* attribute) {
348                 unmarshallExtensionAttribute(attribute);
349             }
350         };
351
352         class SAML_DLLLOCAL ContactPersonImpl : public virtual ContactPerson,
353             public AbstractComplexElement,
354             public AbstractAttributeExtensibleXMLObject,
355             public AbstractDOMCachingXMLObject,
356             public AbstractXMLObjectMarshaller,
357             public AbstractXMLObjectUnmarshaller
358         {
359             list<XMLObject*>::iterator m_pos_TelephoneNumber;
360             
361             void init() {
362                 m_ContactType=NULL;
363                 m_children.push_back(NULL);
364                 m_children.push_back(NULL);
365                 m_children.push_back(NULL);
366                 m_children.push_back(NULL);
367                 m_children.push_back(NULL);
368                 m_Extensions=NULL;
369                 m_Company=NULL;
370                 m_GivenName=NULL;
371                 m_SurName=NULL;
372                 m_pos_Extensions=m_children.begin();
373                 m_pos_Company=m_pos_Extensions;
374                 ++m_pos_Company;
375                 m_pos_GivenName=m_pos_Company;
376                 ++m_pos_GivenName;
377                 m_pos_SurName=m_pos_GivenName;
378                 ++m_pos_SurName;
379                 m_pos_TelephoneNumber=m_pos_SurName;
380                 ++m_pos_TelephoneNumber;
381             }
382         public:
383             virtual ~ContactPersonImpl() {}
384     
385             ContactPersonImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
386                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
387                 init();
388             }
389                 
390             ContactPersonImpl(const ContactPersonImpl& src)
391                     : AbstractXMLObject(src), AbstractComplexElement(src),
392                         AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
393                 init();
394                 if (src.getExtensions())
395                     setExtensions(src.getExtensions()->cloneExtensions());
396                 if (src.getCompany())
397                     setCompany(src.getCompany()->cloneCompany());
398                 if (src.getGivenName())
399                     setGivenName(src.getGivenName()->cloneGivenName());
400                 if (src.getSurName())
401                     setSurName(src.getSurName()->cloneSurName());
402                 
403                 VectorOf(EmailAddress) v=getEmailAddresss();
404                 for (vector<EmailAddress*>::const_iterator i=src.m_EmailAddresss.begin(); i!=src.m_EmailAddresss.end(); i++) {
405                     if (*i) {
406                         v.push_back((*i)->cloneEmailAddress());
407                     }
408                 }
409                 VectorOf(TelephoneNumber) w=getTelephoneNumbers();
410                 for (vector<TelephoneNumber*>::const_iterator j=src.m_TelephoneNumbers.begin(); j!=src.m_TelephoneNumbers.end(); j++) {
411                     if (*j) {
412                         w.push_back((*j)->cloneTelephoneNumber());
413                     }
414                 }
415             }
416             
417             IMPL_XMLOBJECT_CLONE(ContactPerson);
418             IMPL_STRING_ATTRIB(ContactType);
419             IMPL_TYPED_CHILD(Extensions);
420             IMPL_TYPED_CHILD(Company);
421             IMPL_TYPED_CHILD(GivenName);
422             IMPL_TYPED_CHILD(SurName);
423             IMPL_TYPED_CHILDREN(EmailAddress,m_pos_TelephoneNumber);
424             IMPL_TYPED_CHILDREN(TelephoneNumber,m_children.end());
425     
426             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
427                 if (!qualifiedName.hasNamespaceURI()) {
428                     if (XMLString::equals(qualifiedName.getLocalPart(),CONTACTTYPE_ATTRIB_NAME)) {
429                         setContactType(value);
430                         return;
431                     }
432                 }
433                 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
434             }
435
436         protected:
437             void marshallAttributes(DOMElement* domElement) const {
438                 MARSHALL_STRING_ATTRIB(ContactType,CONTACTTYPE,NULL);
439                 marshallExtensionAttributes(domElement);
440             }
441
442             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
443                 PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
444                 PROC_TYPED_CHILD(Company,SAMLConstants::SAML20MD_NS,false);
445                 PROC_TYPED_CHILD(GivenName,SAMLConstants::SAML20MD_NS,false);
446                 PROC_TYPED_CHILD(SurName,SAMLConstants::SAML20MD_NS,false);
447                 PROC_TYPED_CHILDREN(EmailAddress,SAMLConstants::SAML20MD_NS,false);
448                 PROC_TYPED_CHILDREN(TelephoneNumber,SAMLConstants::SAML20MD_NS,false);
449                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
450             }
451
452             void processAttribute(const DOMAttr* attribute) {
453                 unmarshallExtensionAttribute(attribute);
454             }
455         };
456
457         class SAML_DLLLOCAL AdditionalMetadataLocationImpl : public virtual AdditionalMetadataLocation,
458             public AbstractSimpleElement,
459             public AbstractDOMCachingXMLObject,
460             public AbstractXMLObjectMarshaller,
461             public AbstractXMLObjectUnmarshaller
462         {
463             void init() {
464                 m_Namespace=NULL;
465             }
466             
467         public:
468             virtual ~AdditionalMetadataLocationImpl() {
469                 XMLString::release(&m_Namespace);
470             }
471     
472             AdditionalMetadataLocationImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
473                     : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
474                 init();
475             }
476                 
477             AdditionalMetadataLocationImpl(const AdditionalMetadataLocationImpl& src)
478                     : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
479                 init();
480             }
481             
482             IMPL_XMLOBJECT_CLONE(AdditionalMetadataLocation);
483             IMPL_STRING_ATTRIB(Namespace);
484     
485         protected:
486             void marshallAttributes(DOMElement* domElement) const {
487                 MARSHALL_STRING_ATTRIB(Namespace,NAMESPACE,NULL);
488             }
489
490             void processAttribute(const DOMAttr* attribute) {
491                 PROC_STRING_ATTRIB(Namespace,NAMESPACE,NULL);
492                 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
493             }
494         };
495
496         class SAML_DLLLOCAL KeyDescriptorImpl : public virtual KeyDescriptor,
497             public AbstractComplexElement,
498             public AbstractDOMCachingXMLObject,
499             public AbstractXMLObjectMarshaller,
500             public AbstractXMLObjectUnmarshaller
501         {
502                 void init() {
503                 m_Use=NULL;
504                 m_KeyInfo=NULL;
505                 m_children.push_back(NULL);
506                 m_pos_KeyInfo=m_children.begin();
507             }
508         public:
509             virtual ~KeyDescriptorImpl() {
510                 XMLString::release(&m_Use);
511             }
512     
513             KeyDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
514                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
515                 init();
516             }
517                 
518             KeyDescriptorImpl(const KeyDescriptorImpl& src)
519                     : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
520                 init();
521                 setUse(src.getUse());
522                 if (src.getKeyInfo())
523                     setKeyInfo(src.getKeyInfo()->cloneKeyInfo());
524                 VectorOf(EncryptionMethod) v=getEncryptionMethods();
525                 for (vector<EncryptionMethod*>::const_iterator i=src.m_EncryptionMethods.begin(); i!=src.m_EncryptionMethods.end(); i++) {
526                     if (*i) {
527                         v.push_back((*i)->cloneEncryptionMethod());
528                     }
529                 }
530             }
531             
532             IMPL_XMLOBJECT_CLONE(KeyDescriptor);
533             IMPL_STRING_ATTRIB(Use);
534             IMPL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature);
535             IMPL_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption,m_children.end());
536     
537         protected:
538             void marshallAttributes(DOMElement* domElement) const {
539                 MARSHALL_STRING_ATTRIB(Use,USE,NULL);
540             }
541
542             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
543                 PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLConstants::XMLSIG_NS,false);
544                 PROC_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption,SAMLConstants::SAML20MD_NS,false);
545                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
546             }
547
548             void processAttribute(const DOMAttr* attribute) {
549                 PROC_STRING_ATTRIB(Use,USE,NULL);
550                 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
551             }
552         };
553
554         class SAML_DLLLOCAL EndpointTypeImpl : public virtual EndpointType,
555             public AbstractElementProxy,
556             public AbstractAttributeExtensibleXMLObject,
557             public AbstractDOMCachingXMLObject,
558             public AbstractXMLObjectMarshaller,
559             public AbstractXMLObjectUnmarshaller
560         {
561             void init() {
562                 m_Binding=m_Location=m_ResponseLocation=NULL;
563             }
564         
565         protected:
566             EndpointTypeImpl() {
567                 init();
568             }
569             
570         public:
571             virtual ~EndpointTypeImpl() {
572                 XMLString::release(&m_Binding);
573                 XMLString::release(&m_Location);
574                 XMLString::release(&m_ResponseLocation);
575             }
576     
577             EndpointTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
578                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
579             }
580                 
581             EndpointTypeImpl(const EndpointTypeImpl& src)
582                     : AbstractXMLObject(src), AbstractElementProxy(src),
583                         AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
584                 setBinding(src.getBinding());
585                 setLocation(src.getLocation());
586                 setResponseLocation(src.getResponseLocation());
587                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
588                     if (*i) {
589                         getXMLObjects().push_back((*i)->clone());
590                     }
591                 }
592             }
593             
594             IMPL_XMLOBJECT_CLONE(EndpointType);
595             IMPL_STRING_ATTRIB(Binding);
596             IMPL_STRING_ATTRIB(Location);
597             IMPL_STRING_ATTRIB(ResponseLocation);
598     
599             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
600                 if (!qualifiedName.hasNamespaceURI()) {
601                     if (XMLString::equals(qualifiedName.getLocalPart(),BINDING_ATTRIB_NAME)) {
602                         setBinding(value);
603                         return;
604                     }
605                     else if (XMLString::equals(qualifiedName.getLocalPart(),LOCATION_ATTRIB_NAME)) {
606                         setLocation(value);
607                         return;
608                     }
609                     else if (XMLString::equals(qualifiedName.getLocalPart(),RESPONSELOCATION_ATTRIB_NAME)) {
610                         setResponseLocation(value);
611                         return;
612                     }
613                 }
614                 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
615             }
616         protected:
617             void marshallAttributes(DOMElement* domElement) const {
618                 MARSHALL_STRING_ATTRIB(Binding,BINDING,NULL);
619                 MARSHALL_STRING_ATTRIB(Location,LOCATION,NULL);
620                 MARSHALL_STRING_ATTRIB(ResponseLocation,RESPONSELOCATION,NULL);
621                 marshallExtensionAttributes(domElement);
622             }
623
624             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
625                 // Unknown child.
626                 const XMLCh* nsURI=root->getNamespaceURI();
627                 if (!XMLString::equals(nsURI,SAMLConstants::SAML20MD_NS) && nsURI && *nsURI) {
628                     getXMLObjects().push_back(childXMLObject);
629                     return;
630                 }
631                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
632             }
633
634             void processAttribute(const DOMAttr* attribute) {
635                 unmarshallExtensionAttribute(attribute);
636             }
637         };
638
639         class SAML_DLLLOCAL IndexedEndpointTypeImpl : public virtual IndexedEndpointType, public EndpointTypeImpl
640         {
641             void init() {
642                 m_Index=NULL;
643                 m_isDefault=XMLConstants::XML_BOOL_NULL;
644             }
645         
646         protected:
647             IndexedEndpointTypeImpl() {
648                 init();
649             }
650         public:
651             virtual ~IndexedEndpointTypeImpl() {
652                 XMLString::release(&m_Index);
653             }
654     
655             IndexedEndpointTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
656                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
657                 
658             IndexedEndpointTypeImpl(const IndexedEndpointTypeImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {
659                 setIndex(src.m_Index);
660                 isDefault(src.m_isDefault);
661             }
662             
663             IMPL_XMLOBJECT_CLONE(IndexedEndpointType);
664             EndpointType* cloneEndpointType() const {
665                 return new IndexedEndpointTypeImpl(*this);
666             }
667             
668             IMPL_INTEGER_ATTRIB(Index);
669             IMPL_BOOLEAN_ATTRIB(isDefault);
670
671             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
672                 if (!qualifiedName.hasNamespaceURI()) {
673                     if (XMLString::equals(qualifiedName.getLocalPart(),INDEX_ATTRIB_NAME)) {
674                         setIndex(value);
675                         return;
676                     }
677                     else if (XMLString::equals(qualifiedName.getLocalPart(),ISDEFAULT_ATTRIB_NAME)) {
678                         setisDefault(value);
679                         return;
680                     }
681                 }
682                 EndpointTypeImpl::setAttribute(qualifiedName, value, ID);
683             }
684         
685         protected:
686             void marshallAttributes(DOMElement* domElement) const {
687                 MARSHALL_INTEGER_ATTRIB(Index,INDEX,NULL);
688                 MARSHALL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,NULL);
689                 EndpointTypeImpl::marshallAttributes(domElement);
690             }
691         };
692
693         class SAML_DLLLOCAL ArtifactResolutionServiceImpl : public virtual ArtifactResolutionService, public IndexedEndpointTypeImpl
694         {
695         public:
696             virtual ~ArtifactResolutionServiceImpl() {}
697     
698             ArtifactResolutionServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
699                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
700                 
701             ArtifactResolutionServiceImpl(const ArtifactResolutionServiceImpl& src) : AbstractXMLObject(src), IndexedEndpointTypeImpl(src) {}
702             
703             IMPL_XMLOBJECT_CLONE(ArtifactResolutionService);
704             IndexedEndpointType* cloneIndexedEndpointType() const {
705                 return new ArtifactResolutionServiceImpl(*this);
706             }
707             EndpointType* cloneEndpointType() const {
708                 return new ArtifactResolutionServiceImpl(*this);
709             }
710         };
711
712         class SAML_DLLLOCAL SingleLogoutServiceImpl : public virtual SingleLogoutService, public EndpointTypeImpl
713         {
714         public:
715             virtual ~SingleLogoutServiceImpl() {}
716     
717             SingleLogoutServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
718                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
719                 
720             SingleLogoutServiceImpl(const SingleLogoutServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
721             
722             IMPL_XMLOBJECT_CLONE(SingleLogoutService);
723             EndpointType* cloneEndpointType() const {
724                 return new SingleLogoutServiceImpl(*this);
725             }
726         };
727
728         class SAML_DLLLOCAL ManageNameIDServiceImpl : public virtual ManageNameIDService, public EndpointTypeImpl
729         {
730         public:
731             virtual ~ManageNameIDServiceImpl() {}
732     
733             ManageNameIDServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
734                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
735                 
736             ManageNameIDServiceImpl(const ManageNameIDServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
737             
738             IMPL_XMLOBJECT_CLONE(ManageNameIDService);
739             EndpointType* cloneEndpointType() const {
740                 return new ManageNameIDServiceImpl(*this);
741             }
742         };
743
744         class SAML_DLLLOCAL SingleSignOnServiceImpl : public virtual SingleSignOnService, public EndpointTypeImpl
745         {
746         public:
747             virtual ~SingleSignOnServiceImpl() {}
748     
749             SingleSignOnServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
750                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
751                 
752             SingleSignOnServiceImpl(const SingleSignOnServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
753             
754             IMPL_XMLOBJECT_CLONE(SingleSignOnService);
755             EndpointType* cloneEndpointType() const {
756                 return new SingleSignOnServiceImpl(*this);
757             }
758         };
759
760         class SAML_DLLLOCAL NameIDMappingServiceImpl : public virtual NameIDMappingService, public EndpointTypeImpl
761         {
762         public:
763             virtual ~NameIDMappingServiceImpl() {}
764     
765             NameIDMappingServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
766                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
767                 
768             NameIDMappingServiceImpl(const NameIDMappingServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
769             
770             IMPL_XMLOBJECT_CLONE(NameIDMappingService);
771             EndpointType* cloneEndpointType() const {
772                 return new NameIDMappingServiceImpl(*this);
773             }
774         };
775                 
776         class SAML_DLLLOCAL AssertionIDRequestServiceImpl : public virtual AssertionIDRequestService, public EndpointTypeImpl
777         {
778         public:
779             virtual ~AssertionIDRequestServiceImpl() {}
780     
781             AssertionIDRequestServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
782                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
783                 
784             AssertionIDRequestServiceImpl(const AssertionIDRequestServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
785             
786             IMPL_XMLOBJECT_CLONE(AssertionIDRequestService);
787             EndpointType* cloneEndpointType() const {
788                 return new AssertionIDRequestServiceImpl(*this);
789             }
790         };
791
792         class SAML_DLLLOCAL AssertionConsumerServiceImpl : public virtual AssertionConsumerService, public IndexedEndpointTypeImpl
793         {
794         public:
795             virtual ~AssertionConsumerServiceImpl() {}
796     
797             AssertionConsumerServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
798                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
799                 
800             AssertionConsumerServiceImpl(const AssertionConsumerServiceImpl& src) : AbstractXMLObject(src), IndexedEndpointTypeImpl(src) {}
801             
802             IMPL_XMLOBJECT_CLONE(AssertionConsumerService);
803             EndpointType* cloneEndpointType() const {
804                 return new AssertionConsumerServiceImpl(*this);
805             }
806             IndexedEndpointType* cloneIndexedEndpointType() const {
807                 return new AssertionConsumerServiceImpl(*this);
808             }
809         };
810
811         class SAML_DLLLOCAL AuthnQueryServiceImpl : public virtual AuthnQueryService, public EndpointTypeImpl
812         {
813         public:
814             virtual ~AuthnQueryServiceImpl() {}
815     
816             AuthnQueryServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
817                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
818                 
819             AuthnQueryServiceImpl(const AuthnQueryServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
820             
821             IMPL_XMLOBJECT_CLONE(AuthnQueryService);
822             EndpointType* cloneEndpointType() const {
823                 return new AuthnQueryServiceImpl(*this);
824             }
825         };
826
827         class SAML_DLLLOCAL AuthzServiceImpl : public virtual AuthzService, public EndpointTypeImpl
828         {
829         public:
830             virtual ~AuthzServiceImpl() {}
831     
832             AuthzServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
833                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
834                 
835             AuthzServiceImpl(const AuthzServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
836             
837             IMPL_XMLOBJECT_CLONE(AuthzService);
838             EndpointType* cloneEndpointType() const {
839                 return new AuthzServiceImpl(*this);
840             }
841         };
842
843         class SAML_DLLLOCAL AttributeServiceImpl : public virtual AttributeService, public EndpointTypeImpl
844         {
845         public:
846             virtual ~AttributeServiceImpl() {}
847     
848             AttributeServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
849                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
850                 
851             AttributeServiceImpl(const AttributeServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
852             
853             IMPL_XMLOBJECT_CLONE(AttributeService);
854             EndpointType* cloneEndpointType() const {
855                 return new AttributeServiceImpl(*this);
856             }
857         };
858
859         class SAML_DLLLOCAL RoleDescriptorImpl : public virtual RoleDescriptor,
860             public virtual SignableObject,
861             public AbstractComplexElement,
862             public AbstractAttributeExtensibleXMLObject,
863             public AbstractDOMCachingXMLObject,
864             public AbstractXMLObjectMarshaller,
865             public AbstractXMLObjectUnmarshaller
866         {
867             void init() {
868                 m_ID=m_ProtocolSupportEnumeration=m_ErrorURL=NULL;
869                 m_ValidUntil=m_CacheDuration=NULL;
870                 m_children.push_back(NULL);
871                 m_children.push_back(NULL);
872                 m_children.push_back(NULL);
873                 m_children.push_back(NULL);
874                 m_Signature=NULL;
875                 m_Extensions=NULL;
876                 m_Organization=NULL;
877                 m_pos_Signature=m_children.begin();
878                 m_pos_Extensions=m_pos_Signature;
879                 ++m_pos_Extensions;
880                 m_pos_Organization=m_pos_Extensions;
881                 ++m_pos_Organization;
882                 m_pos_ContactPerson=m_pos_Organization;
883                 ++m_pos_ContactPerson;
884             }
885             
886         protected:
887             list<XMLObject*>::iterator m_pos_ContactPerson;
888
889             RoleDescriptorImpl() {
890                 init();
891             }
892             
893         public:
894             virtual ~RoleDescriptorImpl() {
895                 XMLString::release(&m_ID);
896                 XMLString::release(&m_ProtocolSupportEnumeration);
897                 XMLString::release(&m_ErrorURL);
898                 delete m_ValidUntil;
899                 delete m_CacheDuration;
900             }
901     
902             RoleDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
903                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
904                 init();
905             }
906                 
907             RoleDescriptorImpl(const RoleDescriptorImpl& src)
908                     : AbstractXMLObject(src), AbstractComplexElement(src),
909                         AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
910                 init();
911                 setID(src.getID());
912                 setProtocolSupportEnumeration(src.getProtocolSupportEnumeration());
913                 setErrorURL(src.getErrorURL());
914                 setValidUntil(src.getValidUntil());
915                 setCacheDuration(src.getCacheDuration());
916                 if (src.getSignature())
917                     setSignature(src.getSignature()->cloneSignature());
918                 if (src.getExtensions())
919                     setExtensions(src.getExtensions()->cloneExtensions());
920                 if (src.getOrganization())
921                     setOrganization(src.getOrganization()->cloneOrganization());
922                 
923                 VectorOf(KeyDescriptor) v=getKeyDescriptors();
924                 for (vector<KeyDescriptor*>::const_iterator i=src.m_KeyDescriptors.begin(); i!=src.m_KeyDescriptors.end(); i++) {
925                     if (*i) {
926                         v.push_back((*i)->cloneKeyDescriptor());
927                     }
928                 }
929                 VectorOf(ContactPerson) w=getContactPersons();
930                 for (vector<ContactPerson*>::const_iterator j=src.m_ContactPersons.begin(); j!=src.m_ContactPersons.end(); j++) {
931                     if (*j) {
932                         w.push_back((*j)->cloneContactPerson());
933                     }
934                 }
935             }
936
937             //IMPL_TYPED_CHILD(Signature);
938             // Need customized setter.
939         protected:
940             Signature* m_Signature;
941             list<XMLObject*>::iterator m_pos_Signature;
942         public:
943             Signature* getSignature() const {
944                 return m_Signature;
945             }
946             
947             void setSignature(Signature* sig) {
948                 prepareForAssignment(m_Signature,sig);
949                 *m_pos_Signature=m_Signature=sig;
950                 // Sync content reference back up.
951                 if (m_Signature)
952                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
953             }
954             
955             IMPL_ID_ATTRIB(ID);
956             IMPL_STRING_ATTRIB(ProtocolSupportEnumeration);
957             IMPL_STRING_ATTRIB(ErrorURL);
958             IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
959             IMPL_DATETIME_ATTRIB(CacheDuration,0);
960             IMPL_TYPED_CHILD(Extensions);
961             IMPL_TYPED_CHILDREN(KeyDescriptor,m_pos_Organization);
962             IMPL_TYPED_CHILD(Organization);
963             IMPL_TYPED_CHILDREN(ContactPerson,m_pos_ContactPerson);
964
965             bool hasSupport(const XMLCh* protocol) const {
966                 if (m_ProtocolSupportEnumeration) {
967                     // Look for first character.
968                     unsigned int len=XMLString::stringLen(protocol);
969                     unsigned int pos=0;
970                     int index=XMLString::indexOf(m_ProtocolSupportEnumeration,protocol[0],pos);
971                     while (index>=0) {
972                         // Only possible match is if it's the first character or a space comes before it.
973                         if (index==0 || m_ProtocolSupportEnumeration[index-1]==chSpace) {
974                             // See if rest of protocol string is present.
975                             if (0==XMLString::compareNString(m_ProtocolSupportEnumeration+index+1,protocol+1,len-1)) {
976                                 // Only possible match is if it's the last character or a space comes after it.
977                                 if (m_ProtocolSupportEnumeration[index+len]==chNull || m_ProtocolSupportEnumeration[index+len]==chSpace)
978                                     return true;
979                                 else
980                                     pos=index+len;
981                             }
982                             else {
983                                 // Move past last search and start again.
984                                 pos=index+1;
985                             }
986                         }
987                         else {
988                             // Move past last search and start again.
989                             pos=index+1;
990                         }
991                         index=XMLString::indexOf(m_ProtocolSupportEnumeration,protocol[0],pos);
992                     }
993                 }
994                 return false;
995             }
996     
997             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
998                 if (!qualifiedName.hasNamespaceURI()) {
999                     if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
1000                         setID(value);
1001                         return;
1002                     }
1003                     else if (XMLString::equals(qualifiedName.getLocalPart(),PROTOCOLSUPPORTENUMERATION_ATTRIB_NAME)) {
1004                         setProtocolSupportEnumeration(value);
1005                         return;
1006                     }
1007                     else if (XMLString::equals(qualifiedName.getLocalPart(),ERRORURL_ATTRIB_NAME)) {
1008                         setErrorURL(value);
1009                         return;
1010                     }
1011                     else if (XMLString::equals(qualifiedName.getLocalPart(),VALIDUNTIL_ATTRIB_NAME)) {
1012                         setValidUntil(value);
1013                         return;
1014                     }
1015                     else if (XMLString::equals(qualifiedName.getLocalPart(),CACHEDURATION_ATTRIB_NAME)) {
1016                         setCacheDuration(value);
1017                         return;
1018                     }
1019                 }
1020                 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
1021             }
1022
1023         protected:
1024             void marshallAttributes(DOMElement* domElement) const {
1025                 MARSHALL_ID_ATTRIB(ID,ID,NULL);
1026                 MARSHALL_STRING_ATTRIB(ProtocolSupportEnumeration,PROTOCOLSUPPORTENUMERATION,NULL);
1027                 MARSHALL_STRING_ATTRIB(ErrorURL,ERRORURL,NULL);
1028                 MARSHALL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
1029                 MARSHALL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
1030                 marshallExtensionAttributes(domElement);
1031             }
1032
1033             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1034                 PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
1035                 PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
1036                 PROC_TYPED_CHILDREN(KeyDescriptor,SAMLConstants::SAML20MD_NS,false);
1037                 PROC_TYPED_CHILD(Organization,SAMLConstants::SAML20MD_NS,false);
1038                 PROC_TYPED_CHILDREN(ContactPerson,SAMLConstants::SAML20MD_NS,false);
1039                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
1040             }
1041
1042             void processAttribute(const DOMAttr* attribute) {
1043                 PROC_ID_ATTRIB(ID,ID,NULL);
1044                 unmarshallExtensionAttribute(attribute);
1045             }
1046         };
1047
1048         class SAML_DLLLOCAL SSODescriptorTypeImpl : public virtual SSODescriptorType, public RoleDescriptorImpl
1049         {
1050             void init() {
1051                 m_children.push_back(NULL);
1052                 m_children.push_back(NULL);
1053                 m_children.push_back(NULL);
1054                 m_children.push_back(NULL);
1055                 m_pos_ArtifactResolutionService=m_pos_ContactPerson;
1056                 ++m_pos_ArtifactResolutionService;
1057                 m_pos_SingleLogoutService=m_pos_ArtifactResolutionService;
1058                 ++m_pos_SingleLogoutService;
1059                 m_pos_ManageNameIDService=m_pos_SingleLogoutService;
1060                 ++m_pos_ManageNameIDService;
1061                 m_pos_NameIDFormat=m_pos_ManageNameIDService;
1062                 ++m_pos_NameIDFormat;
1063             }
1064         
1065         protected:
1066             list<XMLObject*>::iterator m_pos_ArtifactResolutionService;
1067             list<XMLObject*>::iterator m_pos_SingleLogoutService;
1068             list<XMLObject*>::iterator m_pos_ManageNameIDService;
1069             list<XMLObject*>::iterator m_pos_NameIDFormat;
1070             
1071             SSODescriptorTypeImpl() {
1072                 init();
1073             }
1074         
1075         public:
1076             virtual ~SSODescriptorTypeImpl() {}
1077     
1078             SSODescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1079                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1080                 init();
1081             }
1082                 
1083             SSODescriptorTypeImpl(const SSODescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
1084                 init();
1085                 VectorOf(ArtifactResolutionService) v=getArtifactResolutionServices();
1086                 for (vector<ArtifactResolutionService*>::const_iterator i=src.m_ArtifactResolutionServices.begin(); i!=src.m_ArtifactResolutionServices.end(); i++) {
1087                     if (*i) {
1088                         v.push_back((*i)->cloneArtifactResolutionService());
1089                     }
1090                 }
1091                 VectorOf(SingleLogoutService) w=getSingleLogoutServices();
1092                 for (vector<SingleLogoutService*>::const_iterator j=src.m_SingleLogoutServices.begin(); j!=src.m_SingleLogoutServices.end(); j++) {
1093                     if (*j) {
1094                         w.push_back((*j)->cloneSingleLogoutService());
1095                     }
1096                 }
1097                 VectorOf(ManageNameIDService) x=getManageNameIDServices();
1098                 for (vector<ManageNameIDService*>::const_iterator k=src.m_ManageNameIDServices.begin(); k!=src.m_ManageNameIDServices.end(); k++) {
1099                     if (*k) {
1100                         x.push_back((*k)->cloneManageNameIDService());
1101                     }
1102                 }
1103                 VectorOf(NameIDFormat) y=getNameIDFormats();
1104                 for (vector<NameIDFormat*>::const_iterator m=src.m_NameIDFormats.begin(); m!=src.m_NameIDFormats.end(); m++) {
1105                     if (*m) {
1106                         y.push_back((*m)->cloneNameIDFormat());
1107                     }
1108                 }
1109             }
1110             
1111             IMPL_TYPED_CHILDREN(ArtifactResolutionService,m_pos_ArtifactResolutionService);
1112             IMPL_TYPED_CHILDREN(SingleLogoutService,m_pos_SingleLogoutService);
1113             IMPL_TYPED_CHILDREN(ManageNameIDService,m_pos_ManageNameIDService);
1114             IMPL_TYPED_CHILDREN(NameIDFormat,m_pos_NameIDFormat);
1115
1116         protected:
1117             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1118                 PROC_TYPED_CHILDREN(ArtifactResolutionService,SAMLConstants::SAML20MD_NS,false);
1119                 PROC_TYPED_CHILDREN(SingleLogoutService,SAMLConstants::SAML20MD_NS,false);
1120                 PROC_TYPED_CHILDREN(ManageNameIDService,SAMLConstants::SAML20MD_NS,false);
1121                 PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
1122                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
1123             }
1124         };
1125
1126         class SAML_DLLLOCAL IDPSSODescriptorImpl : public virtual IDPSSODescriptor, public SSODescriptorTypeImpl
1127         {
1128             list<XMLObject*>::iterator m_pos_SingleSignOnService;
1129             list<XMLObject*>::iterator m_pos_NameIDMappingService;
1130             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
1131             list<XMLObject*>::iterator m_pos_AttributeProfile;
1132             
1133             void init() {
1134                 m_WantAuthnRequestsSigned=XMLConstants::XML_BOOL_NULL;
1135                 m_children.push_back(NULL);
1136                 m_children.push_back(NULL);
1137                 m_children.push_back(NULL);
1138                 m_children.push_back(NULL);
1139                 m_pos_SingleSignOnService=m_pos_NameIDFormat;
1140                 ++m_pos_SingleSignOnService;
1141                 m_pos_NameIDMappingService=m_pos_SingleSignOnService;
1142                 ++m_pos_NameIDMappingService;
1143                 m_pos_AssertionIDRequestService=m_pos_NameIDMappingService;
1144                 ++m_pos_AssertionIDRequestService;
1145                 m_pos_AttributeProfile=m_pos_AssertionIDRequestService;
1146                 ++m_pos_AttributeProfile;
1147             }
1148         
1149         public:
1150             virtual ~IDPSSODescriptorImpl() {}
1151     
1152             IDPSSODescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1153                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1154                 init();
1155             }
1156                 
1157             IDPSSODescriptorImpl(const IDPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) {
1158                 init();
1159                 WantAuthnRequestsSigned(src.m_WantAuthnRequestsSigned);
1160                 VectorOf(SingleSignOnService) v=getSingleSignOnServices();
1161                 for (vector<SingleSignOnService*>::const_iterator i=src.m_SingleSignOnServices.begin(); i!=src.m_SingleSignOnServices.end(); i++) {
1162                     if (*i) {
1163                         v.push_back((*i)->cloneSingleSignOnService());
1164                     }
1165                 }
1166                 VectorOf(NameIDMappingService) w=getNameIDMappingServices();
1167                 for (vector<NameIDMappingService*>::const_iterator j=src.m_NameIDMappingServices.begin(); j!=src.m_NameIDMappingServices.end(); j++) {
1168                     if (*j) {
1169                         w.push_back((*j)->cloneNameIDMappingService());
1170                     }
1171                 }
1172                 VectorOf(AssertionIDRequestService) x=getAssertionIDRequestServices();
1173                 for (vector<AssertionIDRequestService*>::const_iterator k=src.m_AssertionIDRequestServices.begin(); k!=src.m_AssertionIDRequestServices.end(); k++) {
1174                     if (*k) {
1175                         x.push_back((*k)->cloneAssertionIDRequestService());
1176                     }
1177                 }
1178                 VectorOf(AttributeProfile) y=getAttributeProfiles();
1179                 for (vector<AttributeProfile*>::const_iterator m=src.m_AttributeProfiles.begin(); m!=src.m_AttributeProfiles.end(); m++) {
1180                     if (*m) {
1181                         y.push_back((*m)->cloneAttributeProfile());
1182                     }
1183                 }
1184                 VectorOf(Attribute) z=getAttributes();
1185                 for (vector<Attribute*>::const_iterator n=src.m_Attributes.begin(); n!=src.m_Attributes.end(); n++) {
1186                     if (*n) {
1187                         z.push_back((*n)->cloneAttribute());
1188                     }
1189                 }
1190             }
1191             
1192             IMPL_XMLOBJECT_CLONE(IDPSSODescriptor);
1193             SSODescriptorType* cloneSSODescriptorType() const {
1194                 return new IDPSSODescriptorImpl(*this);
1195             }
1196             RoleDescriptor* cloneRoleDescriptor() const {
1197                 return new IDPSSODescriptorImpl(*this);
1198             }
1199             
1200             IMPL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned);
1201             IMPL_TYPED_CHILDREN(SingleSignOnService,m_pos_SingleSignOnService);
1202             IMPL_TYPED_CHILDREN(NameIDMappingService,m_pos_NameIDMappingService);
1203             IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService);
1204             IMPL_TYPED_CHILDREN(AttributeProfile,m_pos_AttributeProfile);
1205             IMPL_TYPED_FOREIGN_CHILDREN(Attribute,saml2,m_children.end());
1206
1207             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
1208                 if (!qualifiedName.hasNamespaceURI()) {
1209                     if (XMLString::equals(qualifiedName.getLocalPart(),WANTAUTHNREQUESTSSIGNED_ATTRIB_NAME)) {
1210                         setWantAuthnRequestsSigned(value);
1211                         return;
1212                     }
1213                 }
1214                 RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
1215             }
1216
1217         protected:
1218             void marshallAttributes(DOMElement* domElement) const {
1219                 MARSHALL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED,NULL);
1220                 RoleDescriptorImpl::marshallAttributes(domElement);
1221             }
1222             
1223             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1224                 PROC_TYPED_CHILDREN(SingleSignOnService,SAMLConstants::SAML20MD_NS,false);
1225                 PROC_TYPED_CHILDREN(NameIDMappingService,SAMLConstants::SAML20MD_NS,false);
1226                 PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
1227                 PROC_TYPED_CHILDREN(AttributeProfile,SAMLConstants::SAML20MD_NS,false);
1228                 PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAMLConstants::SAML20_NS,false);
1229                 SSODescriptorTypeImpl::processChildElement(childXMLObject,root);
1230             }
1231         };
1232
1233         class SAML_DLLLOCAL RequestedAttributeImpl : public virtual RequestedAttribute,
1234             public AbstractComplexElement,
1235             public AbstractAttributeExtensibleXMLObject,
1236             public AbstractDOMCachingXMLObject,
1237             public AbstractXMLObjectMarshaller,
1238             public AbstractXMLObjectUnmarshaller
1239         {
1240             void init() {
1241                 m_Name=m_NameFormat=m_FriendlyName=NULL;
1242                 m_isRequired=XMLConstants::XML_BOOL_NULL;
1243             }
1244         public:
1245             virtual ~RequestedAttributeImpl() {
1246                 XMLString::release(&m_Name);
1247                 XMLString::release(&m_NameFormat);
1248                 XMLString::release(&m_FriendlyName);
1249             }
1250     
1251             RequestedAttributeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1252                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1253                 init();
1254             }
1255                 
1256             RequestedAttributeImpl(const RequestedAttributeImpl& src)
1257                     : AbstractXMLObject(src), AbstractComplexElement(src),
1258                         AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
1259                 init();
1260                 setName(src.getName());
1261                 setNameFormat(src.getNameFormat());
1262                 setFriendlyName(src.getFriendlyName());
1263                 isRequired(src.m_isRequired);
1264                 VectorOf(XMLObject) v=getAttributeValues();
1265                 for (vector<XMLObject*>::const_iterator i=src.m_AttributeValues.begin(); i!=src.m_AttributeValues.end(); i++) {
1266                     if (*i) {
1267                         v.push_back((*i)->clone());
1268                     }
1269                 }
1270             }
1271             
1272             IMPL_XMLOBJECT_CLONE(RequestedAttribute);
1273             Attribute* cloneAttribute() const {
1274                 return new RequestedAttributeImpl(*this);
1275             }
1276             
1277             IMPL_STRING_ATTRIB(Name);
1278             IMPL_STRING_ATTRIB(NameFormat);
1279             IMPL_STRING_ATTRIB(FriendlyName);
1280             IMPL_BOOLEAN_ATTRIB(isRequired);
1281             IMPL_XMLOBJECT_CHILDREN(AttributeValue,m_children.end());
1282     
1283             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
1284                 if (!qualifiedName.hasNamespaceURI()) {
1285                     if (XMLString::equals(qualifiedName.getLocalPart(),NAME_ATTRIB_NAME)) {
1286                         setName(value);
1287                         return;
1288                     }
1289                     else if (XMLString::equals(qualifiedName.getLocalPart(),NAMEFORMAT_ATTRIB_NAME)) {
1290                         setNameFormat(value);
1291                         return;
1292                     }
1293                     else if (XMLString::equals(qualifiedName.getLocalPart(),FRIENDLYNAME_ATTRIB_NAME)) {
1294                         setFriendlyName(value);
1295                         return;
1296                     }
1297                     else if (XMLString::equals(qualifiedName.getLocalPart(),ISREQUIRED_ATTRIB_NAME)) {
1298                         setisRequired(value);
1299                         return;
1300                     }
1301                 }
1302                 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
1303             }
1304
1305         protected:
1306             void marshallAttributes(DOMElement* domElement) const {
1307                 MARSHALL_STRING_ATTRIB(Name,NAME,NULL);
1308                 MARSHALL_STRING_ATTRIB(NameFormat,NAMEFORMAT,NULL);
1309                 MARSHALL_STRING_ATTRIB(FriendlyName,FRIENDLYNAME,NULL);
1310                 MARSHALL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED,NULL);
1311                 marshallExtensionAttributes(domElement);
1312             }
1313
1314             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1315                 getAttributeValues().push_back(childXMLObject);
1316             }
1317
1318             void processAttribute(const DOMAttr* attribute) {
1319                 unmarshallExtensionAttribute(attribute);
1320             }
1321         };
1322
1323         class SAML_DLLLOCAL AttributeConsumingServiceImpl : public virtual AttributeConsumingService,
1324             public AbstractComplexElement,
1325             public AbstractDOMCachingXMLObject,
1326             public AbstractXMLObjectMarshaller,
1327             public AbstractXMLObjectUnmarshaller
1328         {
1329             list<XMLObject*>::iterator m_pos_ServiceDescription;
1330             list<XMLObject*>::iterator m_pos_RequestedAttribute;
1331             
1332                 void init() {
1333                 m_Index=NULL;
1334                 m_isDefault=XMLConstants::XML_BOOL_NULL;
1335                 m_children.push_back(NULL);
1336                 m_children.push_back(NULL);
1337                 m_pos_ServiceDescription=m_children.begin();
1338                 m_pos_RequestedAttribute=m_pos_ServiceDescription;
1339                 ++m_pos_RequestedAttribute;
1340             }
1341
1342         public:
1343             virtual ~AttributeConsumingServiceImpl() {
1344                 XMLString::release(&m_Index);
1345             }
1346     
1347             AttributeConsumingServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1348                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1349                 init();
1350             }
1351                 
1352             AttributeConsumingServiceImpl(const AttributeConsumingServiceImpl& src)
1353                     : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
1354                 init();
1355                 setIndex(src.m_Index);
1356                 isDefault(src.m_isDefault);
1357                 VectorOf(ServiceName) v=getServiceNames();
1358                 for (vector<ServiceName*>::const_iterator i=src.m_ServiceNames.begin(); i!=src.m_ServiceNames.end(); i++) {
1359                     if (*i) {
1360                         v.push_back((*i)->cloneServiceName());
1361                     }
1362                 }
1363                 VectorOf(ServiceDescription) w=getServiceDescriptions();
1364                 for (vector<ServiceDescription*>::const_iterator j=src.m_ServiceDescriptions.begin(); j!=src.m_ServiceDescriptions.end(); j++) {
1365                     if (*j) {
1366                         w.push_back((*j)->cloneServiceDescription());
1367                     }
1368                 }
1369                 VectorOf(RequestedAttribute) x=getRequestedAttributes();
1370                 for (vector<RequestedAttribute*>::const_iterator k=src.m_RequestedAttributes.begin(); k!=src.m_RequestedAttributes.end(); k++) {
1371                     if (*k) {
1372                         x.push_back((*k)->cloneRequestedAttribute());
1373                     }
1374                 }
1375             }
1376             
1377             IMPL_XMLOBJECT_CLONE(AttributeConsumingService);
1378             IMPL_INTEGER_ATTRIB(Index);
1379             IMPL_BOOLEAN_ATTRIB(isDefault);
1380             IMPL_TYPED_CHILDREN(ServiceName,m_pos_ServiceDescription);
1381             IMPL_TYPED_CHILDREN(ServiceDescription,m_pos_RequestedAttribute);
1382             IMPL_TYPED_CHILDREN(RequestedAttribute,m_children.end());
1383     
1384         protected:
1385             void marshallAttributes(DOMElement* domElement) const {
1386                 MARSHALL_INTEGER_ATTRIB(Index,INDEX,NULL);
1387                 MARSHALL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,NULL);
1388             }
1389
1390             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1391                 PROC_TYPED_CHILDREN(ServiceName,SAMLConstants::SAML20MD_NS,false);
1392                 PROC_TYPED_CHILDREN(ServiceDescription,SAMLConstants::SAML20MD_NS,false);
1393                 PROC_TYPED_CHILDREN(RequestedAttribute,SAMLConstants::SAML20MD_NS,false);
1394                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
1395             }
1396
1397             void processAttribute(const DOMAttr* attribute) {
1398                 PROC_INTEGER_ATTRIB(Index,INDEX,NULL);
1399                 PROC_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,NULL);
1400                 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
1401             }
1402         };
1403
1404         class SAML_DLLLOCAL SPSSODescriptorImpl : public virtual SPSSODescriptor, public SSODescriptorTypeImpl
1405         {
1406             list<XMLObject*>::iterator m_pos_AssertionConsumerService;
1407             
1408             void init() {
1409                 m_AuthnRequestsSigned=XMLConstants::XML_BOOL_NULL;
1410                 m_WantAssertionsSigned=XMLConstants::XML_BOOL_NULL;
1411                 m_children.push_back(NULL);
1412                 m_pos_AssertionConsumerService=m_pos_NameIDFormat;
1413                 ++m_pos_AssertionConsumerService;
1414             }
1415         
1416         public:
1417             virtual ~SPSSODescriptorImpl() {}
1418     
1419             SPSSODescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1420                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1421                 init();
1422             }
1423                 
1424             SPSSODescriptorImpl(const SPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) {
1425                 init();
1426                 AuthnRequestsSigned(src.m_AuthnRequestsSigned);
1427                 WantAssertionsSigned(src.m_WantAssertionsSigned);
1428                 VectorOf(AssertionConsumerService) v=getAssertionConsumerServices();
1429                 for (vector<AssertionConsumerService*>::const_iterator i=src.m_AssertionConsumerServices.begin(); i!=src.m_AssertionConsumerServices.end(); i++) {
1430                     if (*i) {
1431                         v.push_back((*i)->cloneAssertionConsumerService());
1432                     }
1433                 }
1434                 VectorOf(AttributeConsumingService) w=getAttributeConsumingServices();
1435                 for (vector<AttributeConsumingService*>::const_iterator j=src.m_AttributeConsumingServices.begin(); j!=src.m_AttributeConsumingServices.end(); j++) {
1436                     if (*j) {
1437                         w.push_back((*j)->cloneAttributeConsumingService());
1438                     }
1439                 }
1440             }
1441             
1442             IMPL_XMLOBJECT_CLONE(SPSSODescriptor);
1443             SSODescriptorType* cloneSSODescriptorType() const {
1444                 return cloneSPSSODescriptor();
1445             }
1446             RoleDescriptor* cloneRoleDescriptor() const {
1447                 return cloneSPSSODescriptor();
1448             }
1449             
1450             IMPL_BOOLEAN_ATTRIB(AuthnRequestsSigned);
1451             IMPL_BOOLEAN_ATTRIB(WantAssertionsSigned);
1452             IMPL_TYPED_CHILDREN(AssertionConsumerService,m_pos_AssertionConsumerService);
1453             IMPL_TYPED_CHILDREN(AttributeConsumingService,m_children.end());
1454
1455             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
1456                 if (!qualifiedName.hasNamespaceURI()) {
1457                     if (XMLString::equals(qualifiedName.getLocalPart(),AUTHNREQUESTSSIGNED_ATTRIB_NAME)) {
1458                         setAuthnRequestsSigned(value);
1459                         return;
1460                     }
1461                     else if (XMLString::equals(qualifiedName.getLocalPart(),WANTASSERTIONSSIGNED_ATTRIB_NAME)) {
1462                         setWantAssertionsSigned(value);
1463                         return;
1464                     }
1465                 }
1466                 RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
1467             }
1468
1469         protected:
1470             void marshallAttributes(DOMElement* domElement) const {
1471                 MARSHALL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED,NULL);
1472                 MARSHALL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,NULL);
1473                 RoleDescriptorImpl::marshallAttributes(domElement);
1474             }
1475             
1476             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1477                 PROC_TYPED_CHILDREN(AssertionConsumerService,SAMLConstants::SAML20MD_NS,false);
1478                 PROC_TYPED_CHILDREN(AttributeConsumingService,SAMLConstants::SAML20MD_NS,false);
1479                 SSODescriptorTypeImpl::processChildElement(childXMLObject,root);
1480             }
1481         };
1482
1483         class SAML_DLLLOCAL AuthnAuthorityDescriptorImpl : public virtual AuthnAuthorityDescriptor, public RoleDescriptorImpl
1484         {
1485             list<XMLObject*>::iterator m_pos_AuthnQueryService;
1486             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
1487             
1488             void init() {
1489                 m_children.push_back(NULL);
1490                 m_children.push_back(NULL);
1491                 m_pos_AuthnQueryService=m_pos_ContactPerson;
1492                 ++m_pos_AuthnQueryService;
1493                 m_pos_AssertionIDRequestService=m_pos_AuthnQueryService;
1494                 ++m_pos_AssertionIDRequestService;
1495             }
1496         
1497         public:
1498             virtual ~AuthnAuthorityDescriptorImpl() {}
1499     
1500             AuthnAuthorityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1501                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1502                 init();
1503             }
1504                 
1505             AuthnAuthorityDescriptorImpl(const AuthnAuthorityDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
1506                 init();
1507                 VectorOf(AuthnQueryService) v=getAuthnQueryServices();
1508                 for (vector<AuthnQueryService*>::const_iterator i=src.m_AuthnQueryServices.begin(); i!=src.m_AuthnQueryServices.end(); i++) {
1509                     if (*i) {
1510                         v.push_back((*i)->cloneAuthnQueryService());
1511                     }
1512                 }
1513                 VectorOf(AssertionIDRequestService) w=getAssertionIDRequestServices();
1514                 for (vector<AssertionIDRequestService*>::const_iterator j=src.m_AssertionIDRequestServices.begin(); j!=src.m_AssertionIDRequestServices.end(); j++) {
1515                     if (*j) {
1516                         w.push_back((*j)->cloneAssertionIDRequestService());
1517                     }
1518                 }
1519                 VectorOf(NameIDFormat) x=getNameIDFormats();
1520                 for (vector<NameIDFormat*>::const_iterator k=src.m_NameIDFormats.begin(); k!=src.m_NameIDFormats.end(); k++) {
1521                     if (*k) {
1522                         x.push_back((*k)->cloneNameIDFormat());
1523                     }
1524                 }
1525             }
1526             
1527             IMPL_XMLOBJECT_CLONE(AuthnAuthorityDescriptor);
1528             RoleDescriptor* cloneRoleDescriptor() const {
1529                 return cloneAuthnAuthorityDescriptor();
1530             }
1531             
1532             IMPL_TYPED_CHILDREN(AuthnQueryService,m_pos_AuthnQueryService);
1533             IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService);
1534             IMPL_TYPED_CHILDREN(NameIDFormat,m_children.end());
1535
1536         protected:
1537             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1538                 PROC_TYPED_CHILDREN(AuthnQueryService,SAMLConstants::SAML20MD_NS,false);
1539                 PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
1540                 PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
1541                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
1542             }
1543         };
1544
1545         class SAML_DLLLOCAL PDPDescriptorImpl : public virtual PDPDescriptor, public RoleDescriptorImpl
1546         {
1547             list<XMLObject*>::iterator m_pos_AuthzService;
1548             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
1549             
1550             void init() {
1551                 m_children.push_back(NULL);
1552                 m_children.push_back(NULL);
1553                 m_pos_AuthzService=m_pos_ContactPerson;
1554                 ++m_pos_AuthzService;
1555                 m_pos_AssertionIDRequestService=m_pos_AuthzService;
1556                 ++m_pos_AssertionIDRequestService;
1557             }
1558         
1559         public:
1560             virtual ~PDPDescriptorImpl() {}
1561     
1562             PDPDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1563                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1564                 init();
1565             }
1566                 
1567             PDPDescriptorImpl(const PDPDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
1568                 init();
1569                 VectorOf(AuthzService) v=getAuthzServices();
1570                 for (vector<AuthzService*>::const_iterator i=src.m_AuthzServices.begin(); i!=src.m_AuthzServices.end(); i++) {
1571                     if (*i) {
1572                         v.push_back((*i)->cloneAuthzService());
1573                     }
1574                 }
1575                 VectorOf(AssertionIDRequestService) w=getAssertionIDRequestServices();
1576                 for (vector<AssertionIDRequestService*>::const_iterator j=src.m_AssertionIDRequestServices.begin(); j!=src.m_AssertionIDRequestServices.end(); j++) {
1577                     if (*j) {
1578                         w.push_back((*j)->cloneAssertionIDRequestService());
1579                     }
1580                 }
1581                 VectorOf(NameIDFormat) x=getNameIDFormats();
1582                 for (vector<NameIDFormat*>::const_iterator k=src.m_NameIDFormats.begin(); k!=src.m_NameIDFormats.end(); k++) {
1583                     if (*k) {
1584                         x.push_back((*k)->cloneNameIDFormat());
1585                     }
1586                 }
1587             }
1588             
1589             IMPL_XMLOBJECT_CLONE(PDPDescriptor);
1590             RoleDescriptor* cloneRoleDescriptor() const {
1591                 return clonePDPDescriptor();
1592             }
1593             
1594             IMPL_TYPED_CHILDREN(AuthzService,m_pos_AuthzService);
1595             IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService);
1596             IMPL_TYPED_CHILDREN(NameIDFormat,m_children.end());
1597
1598         protected:
1599             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1600                 PROC_TYPED_CHILDREN(AuthzService,SAMLConstants::SAML20MD_NS,false);
1601                 PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
1602                 PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
1603                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
1604             }
1605         };
1606
1607         class SAML_DLLLOCAL AttributeAuthorityDescriptorImpl : public virtual AttributeAuthorityDescriptor, public RoleDescriptorImpl
1608         {
1609             list<XMLObject*>::iterator m_pos_AttributeService;
1610             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
1611             list<XMLObject*>::iterator m_pos_NameIDFormat;
1612             list<XMLObject*>::iterator m_pos_AttributeProfile;
1613         
1614             void init() {
1615                 m_children.push_back(NULL);
1616                 m_children.push_back(NULL);
1617                 m_children.push_back(NULL);
1618                 m_children.push_back(NULL);
1619                 m_pos_AttributeService=m_pos_ContactPerson;
1620                 ++m_pos_AttributeService;
1621                 m_pos_AssertionIDRequestService=m_pos_AttributeService;
1622                 ++m_pos_AssertionIDRequestService;
1623                 m_pos_NameIDFormat=m_pos_AssertionIDRequestService;
1624                 ++m_pos_NameIDFormat;
1625                 m_pos_AttributeProfile=m_pos_NameIDFormat;
1626                 ++m_pos_AttributeProfile;
1627             }
1628         
1629         public:
1630             virtual ~AttributeAuthorityDescriptorImpl() {}
1631     
1632             AttributeAuthorityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1633                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1634                 init();
1635             }
1636                 
1637             AttributeAuthorityDescriptorImpl(const AttributeAuthorityDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
1638                 init();
1639                 VectorOf(AttributeService) v=getAttributeServices();
1640                 for (vector<AttributeService*>::const_iterator i=src.m_AttributeServices.begin(); i!=src.m_AttributeServices.end(); i++) {
1641                     if (*i) {
1642                         v.push_back((*i)->cloneAttributeService());
1643                     }
1644                 }
1645                 VectorOf(AssertionIDRequestService) w=getAssertionIDRequestServices();
1646                 for (vector<AssertionIDRequestService*>::const_iterator j=src.m_AssertionIDRequestServices.begin(); j!=src.m_AssertionIDRequestServices.end(); j++) {
1647                     if (*j) {
1648                         w.push_back((*j)->cloneAssertionIDRequestService());
1649                     }
1650                 }
1651                 VectorOf(NameIDFormat) x=getNameIDFormats();
1652                 for (vector<NameIDFormat*>::const_iterator k=src.m_NameIDFormats.begin(); k!=src.m_NameIDFormats.end(); k++) {
1653                     if (*k) {
1654                         x.push_back((*k)->cloneNameIDFormat());
1655                     }
1656                 }
1657                 VectorOf(AttributeProfile) y=getAttributeProfiles();
1658                 for (vector<AttributeProfile*>::const_iterator m=src.m_AttributeProfiles.begin(); m!=src.m_AttributeProfiles.end(); m++) {
1659                     if (*m) {
1660                         y.push_back((*m)->cloneAttributeProfile());
1661                     }
1662                 }
1663                 VectorOf(Attribute) z=getAttributes();
1664                 for (vector<Attribute*>::const_iterator n=src.m_Attributes.begin(); n!=src.m_Attributes.end(); n++) {
1665                     if (*n) {
1666                         z.push_back((*n)->cloneAttribute());
1667                     }
1668                 }
1669             }
1670
1671             IMPL_XMLOBJECT_CLONE(AttributeAuthorityDescriptor);
1672             RoleDescriptor* cloneRoleDescriptor() const {
1673                 return cloneAttributeAuthorityDescriptor();
1674             }
1675             
1676             IMPL_TYPED_CHILDREN(AttributeService,m_pos_AttributeService);
1677             IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService);
1678             IMPL_TYPED_CHILDREN(NameIDFormat,m_pos_NameIDFormat);
1679             IMPL_TYPED_CHILDREN(AttributeProfile,m_pos_AttributeProfile);
1680             IMPL_TYPED_FOREIGN_CHILDREN(Attribute,saml2,m_children.end());
1681
1682         protected:
1683             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1684                 PROC_TYPED_CHILDREN(AttributeService,SAMLConstants::SAML20MD_NS,false);
1685                 PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
1686                 PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
1687                 PROC_TYPED_CHILDREN(AttributeProfile,SAMLConstants::SAML20MD_NS,false);
1688                 PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAMLConstants::SAML20_NS,false);
1689                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
1690             }
1691         };
1692
1693         class SAML_DLLLOCAL QueryDescriptorTypeImpl : public virtual QueryDescriptorType, public RoleDescriptorImpl
1694         {
1695             void init() {
1696                 m_WantAssertionsSigned=XMLConstants::XML_BOOL_NULL;
1697                 m_children.push_back(NULL);
1698                 m_pos_NameIDFormat=m_pos_ContactPerson;
1699                 ++m_pos_NameIDFormat;
1700             }
1701         
1702         protected:
1703             list<XMLObject*>::iterator m_pos_NameIDFormat;
1704             
1705             QueryDescriptorTypeImpl() {
1706                 init();
1707             }
1708         
1709         public:
1710             virtual ~QueryDescriptorTypeImpl() {}
1711     
1712             QueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1713                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1714                 init();
1715             }
1716                 
1717             QueryDescriptorTypeImpl(const QueryDescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
1718                 init();
1719                 WantAssertionsSigned(src.m_WantAssertionsSigned);
1720                 VectorOf(NameIDFormat) y=getNameIDFormats();
1721                 for (vector<NameIDFormat*>::const_iterator m=src.m_NameIDFormats.begin(); m!=src.m_NameIDFormats.end(); m++) {
1722                     if (*m) {
1723                         y.push_back((*m)->cloneNameIDFormat());
1724                     }
1725                 }
1726             }
1727             
1728             IMPL_BOOLEAN_ATTRIB(WantAssertionsSigned);
1729             IMPL_TYPED_CHILDREN(NameIDFormat,m_pos_NameIDFormat);
1730
1731             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
1732                 if (!qualifiedName.hasNamespaceURI()) {
1733                     if (XMLString::equals(qualifiedName.getLocalPart(),WANTASSERTIONSSIGNED_ATTRIB_NAME)) {
1734                         setWantAssertionsSigned(value);
1735                         return;
1736                     }
1737                 }
1738                 RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
1739             }
1740
1741         protected:
1742             void marshallAttributes(DOMElement* domElement) const {
1743                 MARSHALL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,NULL);
1744                 RoleDescriptorImpl::marshallAttributes(domElement);
1745             }
1746
1747             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1748                 PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
1749                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
1750             }
1751         };
1752
1753         class SAML_DLLLOCAL AuthnQueryDescriptorTypeImpl : public virtual AuthnQueryDescriptorType, public QueryDescriptorTypeImpl
1754         {
1755         public:
1756             virtual ~AuthnQueryDescriptorTypeImpl() {}
1757     
1758             AuthnQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1759                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
1760                 
1761             AuthnQueryDescriptorTypeImpl(const AuthnQueryDescriptorTypeImpl& src) : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) {}
1762             
1763             IMPL_XMLOBJECT_CLONE(AuthnQueryDescriptorType);
1764             QueryDescriptorType* cloneQueryDescriptorType() const {
1765                 return new AuthnQueryDescriptorTypeImpl(*this);
1766             }
1767             RoleDescriptor* cloneRoleDescriptor() const {
1768                 return new AuthnQueryDescriptorTypeImpl(*this);
1769             }
1770         };
1771
1772         class SAML_DLLLOCAL AttributeQueryDescriptorTypeImpl : public virtual AttributeQueryDescriptorType, public QueryDescriptorTypeImpl
1773         {
1774         public:
1775             virtual ~AttributeQueryDescriptorTypeImpl() {}
1776     
1777             AttributeQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1778                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
1779                 
1780             AttributeQueryDescriptorTypeImpl(const AttributeQueryDescriptorTypeImpl& src)
1781                     : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) {
1782                 VectorOf(AttributeConsumingService) w=getAttributeConsumingServices();
1783                 for (vector<AttributeConsumingService*>::const_iterator j=src.m_AttributeConsumingServices.begin(); j!=src.m_AttributeConsumingServices.end(); j++) {
1784                     if (*j) {
1785                         w.push_back((*j)->cloneAttributeConsumingService());
1786                     }
1787                 }
1788             }
1789             
1790             IMPL_XMLOBJECT_CLONE(AttributeQueryDescriptorType);
1791             QueryDescriptorType* cloneQueryDescriptorType() const {
1792                 return new AttributeQueryDescriptorTypeImpl(*this);
1793             }
1794             RoleDescriptor* cloneRoleDescriptor() const {
1795                 return new AttributeQueryDescriptorTypeImpl(*this);
1796             }
1797             
1798             IMPL_TYPED_CHILDREN(AttributeConsumingService,m_children.end());
1799
1800         protected:
1801             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1802                 PROC_TYPED_CHILDREN(AttributeConsumingService,SAMLConstants::SAML20MD_NS,false);
1803                 QueryDescriptorTypeImpl::processChildElement(childXMLObject,root);
1804             }
1805         };
1806
1807         class SAML_DLLLOCAL AuthzDecisionQueryDescriptorTypeImpl : public virtual AuthzDecisionQueryDescriptorType, public QueryDescriptorTypeImpl
1808         {
1809         public:
1810             virtual ~AuthzDecisionQueryDescriptorTypeImpl() {}
1811     
1812             AuthzDecisionQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1813                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
1814                 
1815             AuthzDecisionQueryDescriptorTypeImpl(const AuthzDecisionQueryDescriptorTypeImpl& src)
1816                     : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) {
1817                 VectorOf(ActionNamespace) w=getActionNamespaces();
1818                 for (vector<ActionNamespace*>::const_iterator j=src.m_ActionNamespaces.begin(); j!=src.m_ActionNamespaces.end(); j++) {
1819                     if (*j) {
1820                         w.push_back((*j)->cloneActionNamespace());
1821                     }
1822                 }
1823             }
1824             
1825             IMPL_XMLOBJECT_CLONE(AuthzDecisionQueryDescriptorType);
1826             QueryDescriptorType* cloneQueryDescriptorType() const {
1827                 return new AuthzDecisionQueryDescriptorTypeImpl(*this);
1828             }
1829             RoleDescriptor* cloneRoleDescriptor() const {
1830                 return new AuthzDecisionQueryDescriptorTypeImpl(*this);
1831             }
1832             
1833             IMPL_TYPED_CHILDREN(ActionNamespace,m_children.end());
1834
1835         protected:
1836             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1837                 PROC_TYPED_CHILDREN(ActionNamespace,SAMLConstants::SAML20MD_QUERY_EXT_NS,false);
1838                 QueryDescriptorTypeImpl::processChildElement(childXMLObject,root);
1839             }
1840         };
1841
1842         class SAML_DLLLOCAL AffiliationDescriptorImpl : public virtual AffiliationDescriptor,
1843             public virtual SignableObject,
1844             public AbstractComplexElement,
1845             public AbstractAttributeExtensibleXMLObject,
1846             public AbstractDOMCachingXMLObject,
1847             public AbstractXMLObjectMarshaller,
1848             public AbstractXMLObjectUnmarshaller
1849         {
1850             list<XMLObject*>::iterator m_pos_AffiliateMember;
1851
1852             void init() {
1853                 m_ID=m_AffiliationOwnerID=NULL;
1854                 m_ValidUntil=m_CacheDuration=NULL;
1855                 m_children.push_back(NULL);
1856                 m_children.push_back(NULL);
1857                 m_children.push_back(NULL);
1858                 m_Signature=NULL;
1859                 m_Extensions=NULL;
1860                 m_pos_Signature=m_children.begin();
1861                 m_pos_Extensions=m_pos_Signature;
1862                 ++m_pos_Extensions;
1863                 m_pos_AffiliateMember=m_pos_Extensions;
1864                 ++m_pos_AffiliateMember;
1865             }
1866             
1867         public:
1868             virtual ~AffiliationDescriptorImpl() {
1869                 XMLString::release(&m_ID);
1870                 XMLString::release(&m_AffiliationOwnerID);
1871                 delete m_ValidUntil;
1872                 delete m_CacheDuration;
1873             }
1874     
1875             AffiliationDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
1876                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
1877                 init();
1878             }
1879                 
1880             AffiliationDescriptorImpl(const AffiliationDescriptorImpl& src)
1881                     : AbstractXMLObject(src), AbstractComplexElement(src),
1882                         AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
1883                 init();
1884                 setID(src.getID());
1885                 setAffiliationOwnerID(src.getAffiliationOwnerID());
1886                 setValidUntil(src.getValidUntil());
1887                 setCacheDuration(src.getCacheDuration());
1888                 if (src.getSignature())
1889                     setSignature(src.getSignature()->cloneSignature());
1890                 if (src.getExtensions())
1891                     setExtensions(src.getExtensions()->cloneExtensions());
1892                 
1893                 VectorOf(KeyDescriptor) v=getKeyDescriptors();
1894                 for (vector<KeyDescriptor*>::const_iterator i=src.m_KeyDescriptors.begin(); i!=src.m_KeyDescriptors.end(); i++) {
1895                     if (*i) {
1896                         v.push_back((*i)->cloneKeyDescriptor());
1897                     }
1898                 }
1899                 VectorOf(AffiliateMember) w=getAffiliateMembers();
1900                 for (vector<AffiliateMember*>::const_iterator j=src.m_AffiliateMembers.begin(); j!=src.m_AffiliateMembers.end(); j++) {
1901                     if (*j) {
1902                         w.push_back((*j)->cloneAffiliateMember());
1903                     }
1904                 }
1905             }
1906
1907             IMPL_XMLOBJECT_CLONE(AffiliationDescriptor);
1908
1909             //IMPL_TYPED_CHILD(Signature);
1910             // Need customized setter.
1911         protected:
1912             Signature* m_Signature;
1913             list<XMLObject*>::iterator m_pos_Signature;
1914         public:
1915             Signature* getSignature() const {
1916                 return m_Signature;
1917             }
1918             
1919             void setSignature(Signature* sig) {
1920                 prepareForAssignment(m_Signature,sig);
1921                 *m_pos_Signature=m_Signature=sig;
1922                 // Sync content reference back up.
1923                 if (m_Signature)
1924                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
1925             }
1926             
1927             IMPL_ID_ATTRIB(ID);
1928             IMPL_STRING_ATTRIB(AffiliationOwnerID);
1929             IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
1930             IMPL_DATETIME_ATTRIB(CacheDuration,0);
1931             IMPL_TYPED_CHILD(Extensions);
1932             IMPL_TYPED_CHILDREN(AffiliateMember,m_pos_AffiliateMember);
1933             IMPL_TYPED_CHILDREN(KeyDescriptor,m_children.end());
1934     
1935             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
1936                 if (!qualifiedName.hasNamespaceURI()) {
1937                     if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
1938                         setID(value);
1939                         return;
1940                     }
1941                     else if (XMLString::equals(qualifiedName.getLocalPart(),AFFILIATIONOWNERID_ATTRIB_NAME)) {
1942                         setAffiliationOwnerID(value);
1943                         return;
1944                     }
1945                     else if (XMLString::equals(qualifiedName.getLocalPart(),VALIDUNTIL_ATTRIB_NAME)) {
1946                         setValidUntil(value);
1947                         return;
1948                     }
1949                     else if (XMLString::equals(qualifiedName.getLocalPart(),CACHEDURATION_ATTRIB_NAME)) {
1950                         setCacheDuration(value);
1951                         return;
1952                     }
1953                 }
1954                 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
1955             }
1956
1957         protected:
1958             void marshallAttributes(DOMElement* domElement) const {
1959                 MARSHALL_ID_ATTRIB(ID,ID,NULL);
1960                 MARSHALL_STRING_ATTRIB(AffiliationOwnerID,AFFILIATIONOWNERID,NULL);
1961                 MARSHALL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
1962                 MARSHALL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
1963                 marshallExtensionAttributes(domElement);
1964             }
1965
1966             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
1967                 PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
1968                 PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
1969                 PROC_TYPED_CHILDREN(AffiliateMember,SAMLConstants::SAML20MD_NS,false);
1970                 PROC_TYPED_CHILDREN(KeyDescriptor,SAMLConstants::SAML20MD_NS,false);
1971                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
1972             }
1973
1974             void processAttribute(const DOMAttr* attribute) {
1975                 PROC_ID_ATTRIB(ID,ID,NULL);
1976                 unmarshallExtensionAttribute(attribute);
1977             }
1978         };
1979
1980         class SAML_DLLLOCAL EntityDescriptorImpl : public virtual EntityDescriptor,
1981             public virtual SignableObject,
1982             public AbstractComplexElement,
1983             public AbstractAttributeExtensibleXMLObject,
1984             public AbstractDOMCachingXMLObject,
1985             public AbstractXMLObjectMarshaller,
1986             public AbstractXMLObjectUnmarshaller
1987         {
1988             list<XMLObject*>::iterator m_pos_ContactPerson;
1989
1990             void init() {
1991                 m_ID=m_EntityID=NULL;
1992                 m_ValidUntil=m_CacheDuration=NULL;
1993                 m_children.push_back(NULL);
1994                 m_children.push_back(NULL);
1995                 m_children.push_back(NULL);
1996                 m_children.push_back(NULL);
1997                 m_children.push_back(NULL);
1998                 m_Signature=NULL;
1999                 m_Extensions=NULL;
2000                 m_AffiliationDescriptor=NULL;
2001                 m_Organization=NULL;
2002                 m_pos_Signature=m_children.begin();
2003                 m_pos_Extensions=m_pos_Signature;
2004                 ++m_pos_Extensions;
2005                 m_pos_AffiliationDescriptor=m_pos_Extensions;
2006                 ++m_pos_AffiliationDescriptor;
2007                 m_pos_Organization=m_pos_AffiliationDescriptor;
2008                 ++m_pos_Organization;
2009                 m_pos_ContactPerson=m_pos_Organization;
2010                 ++m_pos_ContactPerson;
2011             }
2012             
2013         public:
2014             virtual ~EntityDescriptorImpl() {
2015                 XMLString::release(&m_ID);
2016                 XMLString::release(&m_EntityID);
2017                 delete m_ValidUntil;
2018                 delete m_CacheDuration;
2019             }
2020     
2021             EntityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
2022                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
2023                 init();
2024             }
2025                 
2026             EntityDescriptorImpl(const EntityDescriptorImpl& src)
2027                     : AbstractXMLObject(src), AbstractComplexElement(src),
2028                         AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
2029                 init();
2030                 setID(src.getID());
2031                 setEntityID(src.getEntityID());
2032                 setValidUntil(src.getValidUntil());
2033                 setCacheDuration(src.getCacheDuration());
2034                 if (src.getSignature())
2035                     setSignature(src.getSignature()->cloneSignature());
2036                 if (src.getExtensions())
2037                     setExtensions(src.getExtensions()->cloneExtensions());
2038                 if (src.getAffiliationDescriptor())
2039                     setAffiliationDescriptor(src.getAffiliationDescriptor()->cloneAffiliationDescriptor());
2040                 if (src.getOrganization())
2041                     setOrganization(src.getOrganization()->cloneOrganization());
2042                 
2043                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
2044                     if (*i) {
2045                         IDPSSODescriptor* idp=dynamic_cast<IDPSSODescriptor*>(*i);
2046                         if (idp) {
2047                             getIDPSSODescriptors().push_back(idp->cloneIDPSSODescriptor());
2048                             continue;
2049                         }
2050                         
2051                         SPSSODescriptor* sp=dynamic_cast<SPSSODescriptor*>(*i);
2052                         if (sp) {
2053                             getSPSSODescriptors().push_back(sp->cloneSPSSODescriptor());
2054                             continue;
2055                         }
2056
2057                         AuthnAuthorityDescriptor* authn=dynamic_cast<AuthnAuthorityDescriptor*>(*i);
2058                         if (authn) {
2059                             getAuthnAuthorityDescriptors().push_back(authn->cloneAuthnAuthorityDescriptor());
2060                             continue;
2061                         }
2062
2063                         AttributeAuthorityDescriptor* attr=dynamic_cast<AttributeAuthorityDescriptor*>(*i);
2064                         if (attr) {
2065                             getAttributeAuthorityDescriptors().push_back(attr->cloneAttributeAuthorityDescriptor());
2066                             continue;
2067                         }
2068
2069                         PDPDescriptor* pdp=dynamic_cast<PDPDescriptor*>(*i);
2070                         if (pdp) {
2071                             getPDPDescriptors().push_back(pdp->clonePDPDescriptor());
2072                             continue;
2073                         }
2074     
2075                         AuthnQueryDescriptorType* authnq=dynamic_cast<AuthnQueryDescriptorType*>(*i);
2076                         if (authnq) {
2077                             getAuthnQueryDescriptorTypes().push_back(authnq->cloneAuthnQueryDescriptorType());
2078                             continue;
2079                         }
2080
2081                         AttributeQueryDescriptorType* attrq=dynamic_cast<AttributeQueryDescriptorType*>(*i);
2082                         if (attrq) {
2083                             getAttributeQueryDescriptorTypes().push_back(attrq->cloneAttributeQueryDescriptorType());
2084                             continue;
2085                         }
2086
2087                         AuthzDecisionQueryDescriptorType* authzq=dynamic_cast<AuthzDecisionQueryDescriptorType*>(*i);
2088                         if (authzq) {
2089                             getAuthzDecisionQueryDescriptorTypes().push_back(authzq->cloneAuthzDecisionQueryDescriptorType());
2090                             continue;
2091                         }
2092
2093                         RoleDescriptor* role=dynamic_cast<RoleDescriptor*>(*i);
2094                         if (role) {
2095                             getRoleDescriptors().push_back(role->cloneRoleDescriptor());
2096                             continue;
2097                         }
2098                     }
2099                 }
2100
2101                 VectorOf(ContactPerson) v=getContactPersons();
2102                 for (vector<ContactPerson*>::const_iterator j=src.m_ContactPersons.begin(); j!=src.m_ContactPersons.end(); j++) {
2103                     if (*j) {
2104                         v.push_back((*j)->cloneContactPerson());
2105                     }
2106                 }
2107                 VectorOf(AdditionalMetadataLocation) w=getAdditionalMetadataLocations();
2108                 for (vector<AdditionalMetadataLocation*>::const_iterator k=src.m_AdditionalMetadataLocations.begin(); k!=src.m_AdditionalMetadataLocations.end(); k++) {
2109                     if (*k) {
2110                         w.push_back((*k)->cloneAdditionalMetadataLocation());
2111                     }
2112                 }
2113             }
2114
2115             IMPL_XMLOBJECT_CLONE(EntityDescriptor);
2116
2117             //IMPL_TYPED_CHILD(Signature);
2118             // Need customized setter.
2119         protected:
2120             Signature* m_Signature;
2121             list<XMLObject*>::iterator m_pos_Signature;
2122         public:
2123             Signature* getSignature() const {
2124                 return m_Signature;
2125             }
2126             
2127             void setSignature(Signature* sig) {
2128                 prepareForAssignment(m_Signature,sig);
2129                 *m_pos_Signature=m_Signature=sig;
2130                 // Sync content reference back up.
2131                 if (m_Signature)
2132                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
2133             }
2134             
2135             IMPL_ID_ATTRIB(ID);
2136             IMPL_STRING_ATTRIB(EntityID);
2137             IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
2138             IMPL_DATETIME_ATTRIB(CacheDuration,0);
2139             IMPL_TYPED_CHILD(Extensions);
2140             IMPL_TYPED_CHILDREN(RoleDescriptor,m_pos_AffiliationDescriptor);
2141             IMPL_TYPED_CHILDREN(IDPSSODescriptor,m_pos_AffiliationDescriptor);
2142             IMPL_TYPED_CHILDREN(SPSSODescriptor,m_pos_AffiliationDescriptor);
2143             IMPL_TYPED_CHILDREN(AuthnAuthorityDescriptor,m_pos_AffiliationDescriptor);
2144             IMPL_TYPED_CHILDREN(AttributeAuthorityDescriptor,m_pos_AffiliationDescriptor);
2145             IMPL_TYPED_CHILDREN(PDPDescriptor,m_pos_AffiliationDescriptor);
2146             IMPL_TYPED_CHILDREN(AuthnQueryDescriptorType,m_pos_AffiliationDescriptor);
2147             IMPL_TYPED_CHILDREN(AttributeQueryDescriptorType,m_pos_AffiliationDescriptor);
2148             IMPL_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType,m_pos_AffiliationDescriptor);
2149             IMPL_TYPED_CHILD(AffiliationDescriptor);
2150             IMPL_TYPED_CHILD(Organization);
2151             IMPL_TYPED_CHILDREN(ContactPerson,m_pos_ContactPerson);
2152             IMPL_TYPED_CHILDREN(AdditionalMetadataLocation,m_children.end());
2153     
2154             void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
2155                 if (!qualifiedName.hasNamespaceURI()) {
2156                     if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
2157                         setID(value);
2158                         return;
2159                     }
2160                     else if (XMLString::equals(qualifiedName.getLocalPart(),ENTITYID_ATTRIB_NAME)) {
2161                         setEntityID(value);
2162                         return;
2163                     }
2164                     else if (XMLString::equals(qualifiedName.getLocalPart(),VALIDUNTIL_ATTRIB_NAME)) {
2165                         setValidUntil(value);
2166                         return;
2167                     }
2168                     else if (XMLString::equals(qualifiedName.getLocalPart(),CACHEDURATION_ATTRIB_NAME)) {
2169                         setCacheDuration(value);
2170                         return;
2171                     }
2172                 }
2173                 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
2174             }
2175
2176             const IDPSSODescriptor* getIDPSSODescriptor(const XMLCh* protocol) const {
2177                 for (vector<IDPSSODescriptor*>::const_iterator i=m_IDPSSODescriptors.begin(); i!=m_IDPSSODescriptors.end(); i++) {
2178                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2179                         return (*i);
2180                 }
2181                 return NULL;
2182             }
2183             
2184             const SPSSODescriptor* getSPSSODescriptor(const XMLCh* protocol) const {
2185                 for (vector<SPSSODescriptor*>::const_iterator i=m_SPSSODescriptors.begin(); i!=m_SPSSODescriptors.end(); i++) {
2186                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2187                         return (*i);
2188                 }
2189                 return NULL;
2190             }
2191             
2192             const AuthnAuthorityDescriptor* getAuthnAuthorityDescriptor(const XMLCh* protocol) const {
2193                 for (vector<AuthnAuthorityDescriptor*>::const_iterator i=m_AuthnAuthorityDescriptors.begin(); i!=m_AuthnAuthorityDescriptors.end(); i++) {
2194                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2195                         return (*i);
2196                 }
2197                 return NULL;
2198             }
2199             
2200             const AttributeAuthorityDescriptor* getAttributeAuthorityDescriptor(const XMLCh* protocol) const {
2201                 for (vector<AttributeAuthorityDescriptor*>::const_iterator i=m_AttributeAuthorityDescriptors.begin(); i!=m_AttributeAuthorityDescriptors.end(); i++) {
2202                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2203                         return (*i);
2204                 }
2205                 return NULL;
2206             }
2207             
2208             const PDPDescriptor* getPDPDescriptor(const XMLCh* protocol) const {
2209                 for (vector<PDPDescriptor*>::const_iterator i=m_PDPDescriptors.begin(); i!=m_PDPDescriptors.end(); i++) {
2210                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2211                         return (*i);
2212                 }
2213                 return NULL;
2214             }
2215
2216             const AuthnQueryDescriptorType* getAuthnQueryDescriptorType(const XMLCh* protocol) const {
2217                 for (vector<AuthnQueryDescriptorType*>::const_iterator i=m_AuthnQueryDescriptorTypes.begin(); i!=m_AuthnQueryDescriptorTypes.end(); i++) {
2218                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2219                         return (*i);
2220                 }
2221                 return NULL;
2222             }
2223
2224             const AttributeQueryDescriptorType* getAttributeQueryDescriptorType(const XMLCh* protocol) const {
2225                 for (vector<AttributeQueryDescriptorType*>::const_iterator i=m_AttributeQueryDescriptorTypes.begin(); i!=m_AttributeQueryDescriptorTypes.end(); i++) {
2226                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2227                         return (*i);
2228                 }
2229                 return NULL;
2230             }
2231             
2232             const AuthzDecisionQueryDescriptorType* getAuthzDecisionQueryDescriptorType(const XMLCh* protocol) const {
2233                 for (vector<AuthzDecisionQueryDescriptorType*>::const_iterator i=m_AuthzDecisionQueryDescriptorTypes.begin(); i!=m_AuthzDecisionQueryDescriptorTypes.end(); i++) {
2234                     if ((*i)->hasSupport(protocol) && (*i)->isValid())
2235                         return (*i);
2236                 }
2237                 return NULL;
2238             }
2239
2240             const RoleDescriptor* getRoleDescriptor(const xmltooling::QName& qname, const XMLCh* protocol) const {
2241                 // Check for "known" elements/types.
2242                 QName q;
2243                 q.setNamespaceURI(SAMLConstants::SAML20MD_NS);
2244                 q.setLocalPart(IDPSSODescriptor::LOCAL_NAME);
2245                 if (q == qname)
2246                     return getIDPSSODescriptor(protocol);
2247                 q.setLocalPart(SPSSODescriptor::LOCAL_NAME);
2248                 if (q == qname)
2249                     return getSPSSODescriptor(protocol);
2250                 q.setLocalPart(AuthnAuthorityDescriptor::LOCAL_NAME);
2251                 if (q == qname)
2252                     return getAuthnAuthorityDescriptor(protocol);
2253                 q.setLocalPart(AttributeAuthorityDescriptor::LOCAL_NAME);
2254                 if (q == qname)
2255                     return getAttributeAuthorityDescriptor(protocol);
2256                 q.setLocalPart(PDPDescriptor::LOCAL_NAME);
2257                 if (q == qname)
2258                     return getPDPDescriptor(protocol);
2259                 q.setNamespaceURI(SAMLConstants::SAML20MD_QUERY_EXT_NS);
2260                 q.setLocalPart(AuthnQueryDescriptorType::TYPE_NAME);
2261                 if (q == qname)
2262                     return getAuthnQueryDescriptorType(protocol);
2263                 q.setLocalPart(AttributeQueryDescriptorType::TYPE_NAME);
2264                 if (q == qname)
2265                     return getAttributeQueryDescriptorType(protocol);
2266                 q.setLocalPart(AuthzDecisionQueryDescriptorType::TYPE_NAME);
2267                 if (q == qname)
2268                     return getAuthzDecisionQueryDescriptorType(protocol);
2269                 
2270                 for (vector<RoleDescriptor*>::const_iterator i=m_RoleDescriptors.begin(); i!=m_RoleDescriptors.end(); i++) {
2271                     if ((*i)->getSchemaType() && qname==(*((*i)->getSchemaType())) && (*i)->hasSupport(protocol) && (*i)->isValid())
2272                         return (*i);
2273                 }
2274                 return NULL;
2275             }
2276
2277         protected:
2278             void marshallAttributes(DOMElement* domElement) const {
2279                 MARSHALL_ID_ATTRIB(ID,ID,NULL);
2280                 MARSHALL_STRING_ATTRIB(EntityID,ENTITYID,NULL);
2281                 MARSHALL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
2282                 MARSHALL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
2283                 marshallExtensionAttributes(domElement);
2284             }
2285
2286             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
2287                 PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
2288                 PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
2289                 PROC_TYPED_CHILDREN(IDPSSODescriptor,SAMLConstants::SAML20MD_NS,false);
2290                 PROC_TYPED_CHILDREN(SPSSODescriptor,SAMLConstants::SAML20MD_NS,false);
2291                 PROC_TYPED_CHILDREN(AuthnAuthorityDescriptor,SAMLConstants::SAML20MD_NS,false);
2292                 PROC_TYPED_CHILDREN(AttributeAuthorityDescriptor,SAMLConstants::SAML20MD_NS,false);
2293                 PROC_TYPED_CHILDREN(PDPDescriptor,SAMLConstants::SAML20MD_NS,false);
2294                 PROC_TYPED_CHILDREN(AuthnQueryDescriptorType,SAMLConstants::SAML20MD_QUERY_EXT_NS,false);
2295                 PROC_TYPED_CHILDREN(AttributeQueryDescriptorType,SAMLConstants::SAML20MD_QUERY_EXT_NS,false);
2296                 PROC_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType,SAMLConstants::SAML20MD_QUERY_EXT_NS,false);
2297                 PROC_TYPED_CHILDREN(RoleDescriptor,SAMLConstants::SAML20MD_NS,false);
2298                 PROC_TYPED_CHILD(AffiliationDescriptor,SAMLConstants::SAML20MD_NS,false);
2299                 PROC_TYPED_CHILD(Organization,SAMLConstants::SAML20MD_NS,false);
2300                 PROC_TYPED_CHILDREN(ContactPerson,SAMLConstants::SAML20MD_NS,false);
2301                 PROC_TYPED_CHILDREN(AdditionalMetadataLocation,SAMLConstants::SAML20MD_NS,false);
2302                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
2303             }
2304
2305             void processAttribute(const DOMAttr* attribute) {
2306                 PROC_ID_ATTRIB(ID,ID,NULL);
2307                 unmarshallExtensionAttribute(attribute);
2308             }
2309         };
2310
2311         class SAML_DLLLOCAL EntitiesDescriptorImpl : public virtual EntitiesDescriptor,
2312             public virtual SignableObject,
2313             public AbstractComplexElement,
2314             public AbstractDOMCachingXMLObject,
2315             public AbstractXMLObjectMarshaller,
2316             public AbstractXMLObjectUnmarshaller
2317         {
2318             void init() {
2319                 m_ID=m_Name=NULL;
2320                 m_ValidUntil=m_CacheDuration=NULL;
2321                 m_children.push_back(NULL);
2322                 m_children.push_back(NULL);
2323                 m_Signature=NULL;
2324                 m_Extensions=NULL;
2325                 m_pos_Signature=m_children.begin();
2326                 m_pos_Extensions=m_pos_Signature;
2327                 ++m_pos_Extensions;
2328             }
2329             
2330         public:
2331             virtual ~EntitiesDescriptorImpl() {
2332                 XMLString::release(&m_ID);
2333                 XMLString::release(&m_Name);
2334                 delete m_ValidUntil;
2335                 delete m_CacheDuration;
2336             }
2337     
2338             EntitiesDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
2339                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
2340                 init();
2341             }
2342                 
2343             EntitiesDescriptorImpl(const EntitiesDescriptorImpl& src)
2344                     : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
2345                 init();
2346                 setID(src.getID());
2347                 setName(src.getName());
2348                 setValidUntil(src.getValidUntil());
2349                 setCacheDuration(src.getCacheDuration());
2350                 if (src.getSignature())
2351                     setSignature(src.getSignature()->cloneSignature());
2352                 if (src.getExtensions())
2353                     setExtensions(src.getExtensions()->cloneExtensions());
2354                 
2355                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
2356                     if (*i) {
2357                         EntityDescriptor* e=dynamic_cast<EntityDescriptor*>(*i);
2358                         if (e) {
2359                             getEntityDescriptors().push_back(e->cloneEntityDescriptor());
2360                             continue;
2361                         }
2362                         
2363                         EntitiesDescriptor* es=dynamic_cast<EntitiesDescriptor*>(*i);
2364                         if (es) {
2365                             getEntitiesDescriptors().push_back(es->cloneEntitiesDescriptor());
2366                             continue;
2367                         }
2368                     }
2369                 }
2370             }
2371
2372             IMPL_XMLOBJECT_CLONE(EntitiesDescriptor);
2373
2374             //IMPL_TYPED_CHILD(Signature);
2375             // Need customized setter.
2376         protected:
2377             Signature* m_Signature;
2378             list<XMLObject*>::iterator m_pos_Signature;
2379         public:
2380             Signature* getSignature() const {
2381                 return m_Signature;
2382             }
2383             
2384             void setSignature(Signature* sig) {
2385                 prepareForAssignment(m_Signature,sig);
2386                 *m_pos_Signature=m_Signature=sig;
2387                 // Sync content reference back up.
2388                 if (m_Signature)
2389                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
2390             }
2391             
2392             IMPL_ID_ATTRIB(ID);
2393             IMPL_STRING_ATTRIB(Name);
2394             IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
2395             IMPL_DATETIME_ATTRIB(CacheDuration,0);
2396             IMPL_TYPED_CHILD(Extensions);
2397             IMPL_TYPED_CHILDREN(EntityDescriptor,m_children.end());
2398             IMPL_TYPED_CHILDREN(EntitiesDescriptor,m_children.end());
2399     
2400         protected:
2401             void marshallAttributes(DOMElement* domElement) const {
2402                 MARSHALL_ID_ATTRIB(ID,ID,NULL);
2403                 MARSHALL_STRING_ATTRIB(Name,NAME,NULL);
2404                 MARSHALL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
2405                 MARSHALL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
2406             }
2407
2408             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
2409                 PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
2410                 PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
2411                 PROC_TYPED_CHILDREN(EntityDescriptor,SAMLConstants::SAML20MD_NS,false);
2412                 PROC_TYPED_CHILDREN(EntitiesDescriptor,SAMLConstants::SAML20MD_NS,false);
2413                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
2414             }
2415
2416             void processAttribute(const DOMAttr* attribute) {
2417                 PROC_ID_ATTRIB(ID,ID,NULL);
2418                 PROC_STRING_ATTRIB(Name,NAME,NULL);
2419                 PROC_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
2420                 PROC_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
2421             }
2422         };
2423
2424     };
2425 };
2426
2427 #if defined (_MSC_VER)
2428     #pragma warning( pop )
2429 #endif
2430
2431 // Builder Implementations
2432
2433 IMPL_XMLOBJECTBUILDER(AdditionalMetadataLocation);
2434 IMPL_XMLOBJECTBUILDER(AffiliateMember);
2435 IMPL_XMLOBJECTBUILDER(AffiliationDescriptor);
2436 IMPL_XMLOBJECTBUILDER(ArtifactResolutionService);
2437 IMPL_XMLOBJECTBUILDER(AssertionConsumerService);
2438 IMPL_XMLOBJECTBUILDER(AssertionIDRequestService);
2439 IMPL_XMLOBJECTBUILDER(AttributeAuthorityDescriptor);
2440 IMPL_XMLOBJECTBUILDER(AttributeConsumingService);
2441 IMPL_XMLOBJECTBUILDER(AttributeProfile);
2442 IMPL_XMLOBJECTBUILDER(AttributeQueryDescriptorType);
2443 IMPL_XMLOBJECTBUILDER(AttributeService);
2444 IMPL_XMLOBJECTBUILDER(AuthnAuthorityDescriptor);
2445 IMPL_XMLOBJECTBUILDER(AuthnQueryDescriptorType);
2446 IMPL_XMLOBJECTBUILDER(AuthnQueryService);
2447 IMPL_XMLOBJECTBUILDER(AuthzDecisionQueryDescriptorType);
2448 IMPL_XMLOBJECTBUILDER(AuthzService);
2449 IMPL_XMLOBJECTBUILDER(Company);
2450 IMPL_XMLOBJECTBUILDER(ContactPerson);
2451 IMPL_XMLOBJECTBUILDER(EmailAddress);
2452 IMPL_XMLOBJECTBUILDER(EndpointType);
2453 IMPL_XMLOBJECTBUILDER(EntitiesDescriptor);
2454 IMPL_XMLOBJECTBUILDER(EntityDescriptor);
2455 IMPL_XMLOBJECTBUILDER(Extensions);
2456 IMPL_XMLOBJECTBUILDER(GivenName);
2457 IMPL_XMLOBJECTBUILDER(IDPSSODescriptor);
2458 IMPL_XMLOBJECTBUILDER(IndexedEndpointType);
2459 IMPL_XMLOBJECTBUILDER(KeyDescriptor);
2460 IMPL_XMLOBJECTBUILDER(localizedNameType);
2461 IMPL_XMLOBJECTBUILDER(localizedURIType);
2462 IMPL_XMLOBJECTBUILDER(ManageNameIDService);
2463 IMPL_XMLOBJECTBUILDER(NameIDFormat);
2464 IMPL_XMLOBJECTBUILDER(NameIDMappingService);
2465 IMPL_XMLOBJECTBUILDER(Organization);
2466 IMPL_XMLOBJECTBUILDER(OrganizationName);
2467 IMPL_XMLOBJECTBUILDER(OrganizationDisplayName);
2468 IMPL_XMLOBJECTBUILDER(OrganizationURL);
2469 IMPL_XMLOBJECTBUILDER(PDPDescriptor);
2470 IMPL_XMLOBJECTBUILDER(RequestedAttribute);
2471 IMPL_XMLOBJECTBUILDER(ServiceDescription);
2472 IMPL_XMLOBJECTBUILDER(ServiceName);
2473 IMPL_XMLOBJECTBUILDER(SingleLogoutService);
2474 IMPL_XMLOBJECTBUILDER(SingleSignOnService);
2475 IMPL_XMLOBJECTBUILDER(SPSSODescriptor);
2476 IMPL_XMLOBJECTBUILDER(SurName);
2477 IMPL_XMLOBJECTBUILDER(TelephoneNumber);
2478
2479 IMPL_XMLOBJECTBUILDER(ActionNamespace);
2480 IMPL_XMLOBJECTBUILDER(SourceID);
2481
2482 const XMLCh ActionNamespace::LOCAL_NAME[] =             UNICODE_LITERAL_15(A,c,t,i,o,n,N,a,m,e,s,p,a,c,e);
2483 const XMLCh AdditionalMetadataLocation::LOCAL_NAME[] =  UNICODE_LITERAL_26(A,d,d,i,t,i,o,n,a,l,M,e,t,a,d,a,t,a,L,o,c,a,t,i,o,n);
2484 const XMLCh AdditionalMetadataLocation::TYPE_NAME[] =   UNICODE_LITERAL_30(A,d,d,i,t,i,o,n,a,l,M,e,t,a,d,a,t,a,L,o,c,a,t,i,o,n,T,y,p,e);
2485 const XMLCh AdditionalMetadataLocation::NAMESPACE_ATTRIB_NAME[] =   UNICODE_LITERAL_9(n,a,m,e,s,p,a,c,e);
2486 const XMLCh AffiliateMember::LOCAL_NAME[] =             UNICODE_LITERAL_15(A,f,f,i,l,i,a,t,e,M,e,m,b,e,r);
2487 const XMLCh AffiliationDescriptor::LOCAL_NAME[] =       UNICODE_LITERAL_21(A,f,f,i,l,i,a,t,i,o,n,D,e,s,c,r,i,p,t,o,r);
2488 const XMLCh AffiliationDescriptor::TYPE_NAME[] =        UNICODE_LITERAL_25(A,f,f,i,l,i,a,t,i,o,n,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2489 const XMLCh AffiliationDescriptor::ID_ATTRIB_NAME[] =   UNICODE_LITERAL_2(I,D);
2490 const XMLCh AffiliationDescriptor::AFFILIATIONOWNERID_ATTRIB_NAME[] =   UNICODE_LITERAL_18(a,f,f,i,l,i,a,t,i,o,n,O,w,n,e,r,I,D);
2491 const XMLCh ArtifactResolutionService::LOCAL_NAME[] =   UNICODE_LITERAL_25(A,r,t,i,f,a,c,t,R,e,s,o,l,u,t,i,o,n,S,e,r,v,i,c,e);
2492 const XMLCh AssertionConsumerService::LOCAL_NAME[] =    UNICODE_LITERAL_24(A,s,s,e,r,t,i,o,n,C,o,n,s,u,m,e,r,S,e,r,v,i,c,e);
2493 const XMLCh AssertionIDRequestService::LOCAL_NAME[] =   UNICODE_LITERAL_25(A,s,s,e,r,t,i,o,n,I,D,R,e,q,u,e,s,t,S,e,r,v,i,c,e);
2494 const XMLCh AttributeAuthorityDescriptor::LOCAL_NAME[] =UNICODE_LITERAL_28(A,t,t,r,i,b,u,t,e,A,u,t,h,o,r,i,t,y,D,e,s,c,r,i,p,t,o,r);
2495 const XMLCh AttributeAuthorityDescriptor::TYPE_NAME[] = UNICODE_LITERAL_32(A,t,t,r,i,b,u,t,e,A,u,t,h,o,r,i,t,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2496 const XMLCh AttributeConsumingService::LOCAL_NAME[] =   UNICODE_LITERAL_25(A,t,t,r,i,b,u,t,e,C,o,n,s,u,m,i,n,g,S,e,r,v,i,c,e);
2497 const XMLCh AttributeConsumingService::TYPE_NAME[] =    UNICODE_LITERAL_29(A,t,t,r,i,b,u,t,e,C,o,n,s,u,m,i,n,g,S,e,r,v,i,c,e,T,y,p,e);
2498 const XMLCh AttributeConsumingService::INDEX_ATTRIB_NAME[] =    UNICODE_LITERAL_5(i,n,d,e,x);
2499 const XMLCh AttributeConsumingService::ISDEFAULT_ATTRIB_NAME[] =    UNICODE_LITERAL_9(i,s,D,e,f,a,u,l,t);
2500 const XMLCh AttributeProfile::LOCAL_NAME[] =            UNICODE_LITERAL_16(A,t,t,r,i,b,u,t,e,P,r,o,f,i,l,e);
2501 const XMLCh AttributeQueryDescriptorType::LOCAL_NAME[] =UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
2502 const XMLCh AttributeQueryDescriptorType::TYPE_NAME[] = UNICODE_LITERAL_28(A,t,t,r,i,b,u,t,e,Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2503 const XMLCh AttributeService::LOCAL_NAME[] =            UNICODE_LITERAL_16(A,t,t,r,i,b,u,t,e,S,e,r,v,i,c,e);
2504 const XMLCh AuthnAuthorityDescriptor::LOCAL_NAME[] =    UNICODE_LITERAL_24(A,u,t,h,n,A,u,t,h,o,r,i,t,y,D,e,s,c,r,i,p,t,o,r);
2505 const XMLCh AuthnAuthorityDescriptor::TYPE_NAME[] =     UNICODE_LITERAL_28(A,u,t,h,n,A,u,t,h,o,r,i,t,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2506 const XMLCh AuthnQueryDescriptorType::LOCAL_NAME[] =    UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
2507 const XMLCh AuthnQueryDescriptorType::TYPE_NAME[] =     UNICODE_LITERAL_24(A,u,t,h,n,Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2508 const XMLCh AuthnQueryService::LOCAL_NAME[] =           UNICODE_LITERAL_17(A,u,t,h,n,Q,u,e,r,y,S,e,r,v,i,c,e);
2509 const XMLCh AuthzDecisionQueryDescriptorType::LOCAL_NAME[] =    UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
2510 const XMLCh AuthzDecisionQueryDescriptorType::TYPE_NAME[] = UNICODE_LITERAL_32(A,u,t,h,z,D,e,c,i,s,i,o,n,Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2511 const XMLCh AuthzService::LOCAL_NAME[] =                UNICODE_LITERAL_12(A,u,t,h,z,S,e,r,v,i,c,e);
2512 const XMLCh CacheableSAMLObject::CACHEDURATION_ATTRIB_NAME[] =  UNICODE_LITERAL_13(c,a,c,h,e,D,u,r,a,t,i,o,n);
2513 const XMLCh Company::LOCAL_NAME[] =                     UNICODE_LITERAL_7(C,o,m,p,a,n,y);
2514 const XMLCh ContactPerson::LOCAL_NAME[] =               UNICODE_LITERAL_13(C,o,n,t,a,c,t,P,e,r,s,o,n);
2515 const XMLCh ContactPerson::TYPE_NAME[] =                UNICODE_LITERAL_11(C,o,n,t,a,c,t,T,y,p,e);
2516 const XMLCh ContactPerson::CONTACTTYPE_ATTRIB_NAME[] =  UNICODE_LITERAL_11(c,o,n,t,a,c,t,T,y,p,e);
2517 const XMLCh ContactPerson::CONTACT_TECHNICAL[] =        UNICODE_LITERAL_9(t,e,c,h,n,i,c,a,l);
2518 const XMLCh ContactPerson::CONTACT_SUPPORT[] =          UNICODE_LITERAL_7(s,u,p,p,o,r,t);
2519 const XMLCh ContactPerson::CONTACT_ADMINISTRATIVE[] =   UNICODE_LITERAL_14(a,d,m,i,n,i,s,t,r,a,t,i,v,e);
2520 const XMLCh ContactPerson::CONTACT_BILLING[] =          UNICODE_LITERAL_7(b,i,l,l,i,n,g);
2521 const XMLCh ContactPerson::CONTACT_OTHER[] =            UNICODE_LITERAL_5(o,t,h,e,r);
2522 const XMLCh EmailAddress::LOCAL_NAME[] =                UNICODE_LITERAL_12(E,m,a,i,l,A,d,d,r,e,s,s);
2523 const XMLCh EndpointType::LOCAL_NAME[] =                {chNull};
2524 const XMLCh EndpointType::TYPE_NAME[] =                 UNICODE_LITERAL_12(E,n,d,p,o,i,n,t,T,y,p,e);
2525 const XMLCh EndpointType::BINDING_ATTRIB_NAME[] =       UNICODE_LITERAL_7(B,i,n,d,i,n,g);
2526 const XMLCh EndpointType::LOCATION_ATTRIB_NAME[] =      UNICODE_LITERAL_8(L,o,c,a,t,i,o,n);
2527 const XMLCh EndpointType::RESPONSELOCATION_ATTRIB_NAME[] =  UNICODE_LITERAL_16(R,e,s,p,o,n,s,e,L,o,c,a,t,i,o,n);
2528 const XMLCh EntitiesDescriptor::LOCAL_NAME[] =          UNICODE_LITERAL_18(E,n,t,i,t,i,e,s,D,e,s,c,r,i,p,t,o,r);
2529 const XMLCh EntitiesDescriptor::TYPE_NAME[] =           UNICODE_LITERAL_22(E,n,t,i,t,i,e,s,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2530 const XMLCh EntitiesDescriptor::ID_ATTRIB_NAME[] =      UNICODE_LITERAL_2(I,D);
2531 const XMLCh EntitiesDescriptor::NAME_ATTRIB_NAME[] =    UNICODE_LITERAL_4(N,a,m,e);
2532 const XMLCh EntityDescriptor::LOCAL_NAME[] =            UNICODE_LITERAL_16(E,n,t,i,t,y,D,e,s,c,r,i,p,t,o,r);
2533 const XMLCh EntityDescriptor::TYPE_NAME[] =             UNICODE_LITERAL_20(E,n,t,i,t,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2534 const XMLCh EntityDescriptor::ID_ATTRIB_NAME[] =        UNICODE_LITERAL_2(I,D);
2535 const XMLCh EntityDescriptor::ENTITYID_ATTRIB_NAME[] =  UNICODE_LITERAL_8(e,n,t,i,t,y,I,D);
2536 const XMLCh Extensions::LOCAL_NAME[] =                  UNICODE_LITERAL_10(E,x,t,e,n,s,i,o,n,s);
2537 const XMLCh Extensions::TYPE_NAME[] =                   UNICODE_LITERAL_14(E,x,t,e,n,s,i,o,n,s,T,y,p,e);
2538 const XMLCh GivenName::LOCAL_NAME[] =                   UNICODE_LITERAL_9(G,i,v,e,n,N,a,m,e);
2539 const XMLCh IDPSSODescriptor::LOCAL_NAME[] =            UNICODE_LITERAL_16(I,D,P,S,S,O,D,e,s,c,r,i,p,t,o,r);
2540 const XMLCh IDPSSODescriptor::TYPE_NAME[] =             UNICODE_LITERAL_20(I,D,P,S,S,O,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2541 const XMLCh IDPSSODescriptor::WANTAUTHNREQUESTSSIGNED_ATTRIB_NAME[] =   UNICODE_LITERAL_23(W,a,n,t,A,u,t,h,n,R,e,q,u,e,s,t,s,S,i,g,n,e,d);
2542 const XMLCh IndexedEndpointType::LOCAL_NAME[] =         {chNull};
2543 const XMLCh IndexedEndpointType::TYPE_NAME[] =          UNICODE_LITERAL_19(I,n,d,e,x,e,d,E,n,d,p,o,i,n,t,T,y,p,e);
2544 const XMLCh IndexedEndpointType::INDEX_ATTRIB_NAME[] =  UNICODE_LITERAL_5(i,n,d,e,x);
2545 const XMLCh IndexedEndpointType::ISDEFAULT_ATTRIB_NAME[] =  UNICODE_LITERAL_9(i,s,D,e,f,a,u,l,t);
2546 const XMLCh KeyDescriptor::LOCAL_NAME[] =               UNICODE_LITERAL_13(K,e,y,D,e,s,c,r,i,p,t,o,r);
2547 const XMLCh KeyDescriptor::TYPE_NAME[] =                UNICODE_LITERAL_17(K,e,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2548 const XMLCh KeyDescriptor::USE_ATTRIB_NAME[] =          UNICODE_LITERAL_3(u,s,e);
2549 const XMLCh KeyDescriptor::KEYTYPE_ENCRYPTION[] =       UNICODE_LITERAL_10(e,n,c,r,y,p,t,i,o,n);
2550 const XMLCh KeyDescriptor::KEYTYPE_SIGNING[] =          UNICODE_LITERAL_7(s,i,g,n,i,n,g);
2551 const XMLCh localizedNameType::LOCAL_NAME[] =           {chNull};
2552 const XMLCh localizedNameType::TYPE_NAME[] =            UNICODE_LITERAL_17(l,o,c,a,l,i,z,e,d,N,a,m,e,T,y,p,e);
2553 const XMLCh localizedNameType::LANG_ATTRIB_NAME[] =     UNICODE_LITERAL_4(l,a,n,g);
2554 const XMLCh localizedURIType::LOCAL_NAME[] =            {chNull};
2555 const XMLCh localizedURIType::TYPE_NAME[] =             UNICODE_LITERAL_16(l,o,c,a,l,i,z,e,d,U,R,I,T,y,p,e);
2556 const XMLCh localizedURIType::LANG_ATTRIB_NAME[] =      UNICODE_LITERAL_4(l,a,n,g);
2557 const XMLCh ManageNameIDService::LOCAL_NAME[] =         UNICODE_LITERAL_19(M,a,n,a,g,e,N,a,m,e,I,D,S,e,r,v,i,c,e);
2558 const XMLCh NameIDFormat::LOCAL_NAME[] =                UNICODE_LITERAL_12(N,a,m,e,I,D,F,o,r,m,a,t);
2559 const XMLCh NameIDMappingService::LOCAL_NAME[] =        UNICODE_LITERAL_20(N,a,m,e,I,D,M,a,p,p,i,n,g,S,e,r,v,i,c,e);
2560 const XMLCh Organization::LOCAL_NAME[] =                UNICODE_LITERAL_12(O,r,g,a,n,i,z,a,t,i,o,n);
2561 const XMLCh Organization::TYPE_NAME[] =                 UNICODE_LITERAL_16(O,r,g,a,n,i,z,a,t,i,o,n,T,y,p,e);
2562 const XMLCh OrganizationName::LOCAL_NAME[] =            UNICODE_LITERAL_16(O,r,g,a,n,i,z,a,t,i,o,n,N,a,m,e);
2563 const XMLCh OrganizationDisplayName::LOCAL_NAME[] =     UNICODE_LITERAL_23(O,r,g,a,n,i,z,a,t,i,o,n,D,i,s,p,l,a,y,N,a,m,e);
2564 const XMLCh OrganizationURL::LOCAL_NAME[] =             UNICODE_LITERAL_15(O,r,g,a,n,i,z,a,t,i,o,n,U,R,L);
2565 const XMLCh PDPDescriptor::LOCAL_NAME[] =               UNICODE_LITERAL_13(P,D,P,D,e,s,c,r,i,p,t,o,r);
2566 const XMLCh PDPDescriptor::TYPE_NAME[] =                UNICODE_LITERAL_17(P,D,P,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2567 const XMLCh QueryDescriptorType::LOCAL_NAME[] =         {chNull};
2568 const XMLCh QueryDescriptorType::TYPE_NAME[] =          UNICODE_LITERAL_19(Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2569 const XMLCh QueryDescriptorType::WANTASSERTIONSSIGNED_ATTRIB_NAME[] =   UNICODE_LITERAL_20(W,a,n,t,A,s,s,e,r,t,i,o,n,s,S,i,g,n,e,d);
2570 const XMLCh RequestedAttribute::LOCAL_NAME[] =          UNICODE_LITERAL_18(R,e,q,u,e,s,t,e,d,A,t,t,r,i,b,u,t,e);
2571 const XMLCh RequestedAttribute::TYPE_NAME[] =           UNICODE_LITERAL_22(R,e,q,u,e,s,t,e,d,A,t,t,r,i,b,u,t,e,T,y,p,e);
2572 const XMLCh RequestedAttribute::ISREQUIRED_ATTRIB_NAME[] =  UNICODE_LITERAL_10(i,s,R,e,q,u,i,r,e,d);
2573 const XMLCh RoleDescriptor::LOCAL_NAME[] =              UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
2574 const XMLCh RoleDescriptor::ID_ATTRIB_NAME[] =          UNICODE_LITERAL_2(I,D);
2575 const XMLCh RoleDescriptor::PROTOCOLSUPPORTENUMERATION_ATTRIB_NAME[] =  UNICODE_LITERAL_26(p,r,o,t,o,c,o,l,S,u,p,p,o,r,t,E,n,u,m,e,r,a,t,i,o,n);
2576 const XMLCh RoleDescriptor::ERRORURL_ATTRIB_NAME[] =    UNICODE_LITERAL_8(e,r,r,o,r,U,R,L);
2577 const XMLCh ServiceDescription::LOCAL_NAME[] =          UNICODE_LITERAL_18(S,e,r,v,i,c,e,D,e,s,c,r,i,p,t,i,o,n);
2578 const XMLCh ServiceName::LOCAL_NAME[] =                 UNICODE_LITERAL_11(S,e,r,v,i,c,e,N,a,m,e);
2579 const XMLCh SingleLogoutService::LOCAL_NAME[] =         UNICODE_LITERAL_19(S,i,n,g,l,e,L,o,g,o,u,t,S,e,r,v,i,c,e);
2580 const XMLCh SingleSignOnService::LOCAL_NAME[] =         UNICODE_LITERAL_19(S,i,n,g,l,e,S,i,g,n,O,n,S,e,r,v,i,c,e);
2581 const XMLCh SourceID::LOCAL_NAME[] =                    UNICODE_LITERAL_8(S,o,u,r,c,e,I,D);
2582 const XMLCh SPSSODescriptor::LOCAL_NAME[] =             UNICODE_LITERAL_15(S,P,S,S,O,D,e,s,c,r,i,p,t,o,r);
2583 const XMLCh SPSSODescriptor::TYPE_NAME[] =              UNICODE_LITERAL_19(S,P,S,S,O,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2584 const XMLCh SPSSODescriptor::AUTHNREQUESTSSIGNED_ATTRIB_NAME[] =    UNICODE_LITERAL_19(A,u,t,h,n,R,e,q,u,e,s,t,s,S,i,g,n,e,d);
2585 const XMLCh SPSSODescriptor::WANTASSERTIONSSIGNED_ATTRIB_NAME[] =   UNICODE_LITERAL_20(W,a,n,t,A,s,s,e,r,t,i,o,n,s,S,i,g,n,e,d);
2586 const XMLCh SSODescriptorType::LOCAL_NAME[] =           {chNull};
2587 const XMLCh SSODescriptorType::TYPE_NAME[] =            UNICODE_LITERAL_17(S,S,O,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
2588 const XMLCh SurName::LOCAL_NAME[] =                     UNICODE_LITERAL_7(S,u,r,N,a,m,e);
2589 const XMLCh TelephoneNumber::LOCAL_NAME[] =             UNICODE_LITERAL_15(T,e,l,e,p,h,o,n,e,N,u,m,b,e,r);
2590 const XMLCh TimeBoundSAMLObject::VALIDUNTIL_ATTRIB_NAME[] =   UNICODE_LITERAL_10(v,a,l,i,d,U,n,t,i,l);