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