Removed ValidatingXMLObject interface and implementations, first draft of metadata...
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / Metadata.h
1 /*
2  *  Copyright 2001-2006 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file saml/saml2/metadata/Metadata.h
19  * 
20  * XMLObjects representing the SAML 2.0 Metadata schema
21  */
22
23 #ifndef __saml2_metadata_h__
24 #define __saml2_metadata_h__
25
26 #include <saml/saml2/core/Assertions.h>
27 #include <saml/util/SAMLConstants.h>
28
29 #include <ctime>
30 #include <xmltooling/AttributeExtensibleXMLObject.h>
31 #include <xmltooling/ElementProxy.h>
32 #include <xmltooling/SimpleElement.h>
33 #include <xmltooling/XMLObjectBuilder.h>
34 #include <xmltooling/encryption/Encryption.h>
35 #include <xmltooling/signature/KeyInfo.h>
36 #include <xmltooling/signature/Signature.h>
37 #include <xmltooling/util/DateTime.h>
38
39 #define DECL_SAML2MDOBJECTBUILDER(cname) \
40     DECL_XMLOBJECTBUILDER(SAML_API,cname,opensaml::SAMLConstants::SAML20MD_NS,opensaml::SAMLConstants::SAML20MD_PREFIX)
41
42 namespace opensaml {
43
44     /**
45      * @namespace opensaml::saml2md
46      * SAML 2.0 metadata namespace
47      */
48     namespace saml2md {
49         
50         /**
51          * Base class for metadata objects that feature a cacheDuration attribute.
52          */
53         class SAML_API CacheableSAMLObject : public virtual xmltooling::XMLObject
54         {
55         protected:
56             CacheableSAMLObject() {}
57         public:
58             ~CacheableSAMLObject() {}
59             DECL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION);
60         };
61
62         /**
63          * Base class for metadata objects that feature a validUntil attribute.
64          */
65         class SAML_API TimeBoundSAMLObject : public virtual xmltooling::XMLObject
66         {
67         protected:
68             TimeBoundSAMLObject() {}
69         public:
70             ~TimeBoundSAMLObject() {}
71             DECL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL);
72             /** Returns true iff the object is valid at the current time. */
73             bool isValid() const {
74                 return time(NULL) <= getValidUntilEpoch();
75             }
76         };
77
78         DECL_XMLOBJECT_SIMPLE(SAML_API,AffiliateMember,ID,SAML 2.0 AffiliateMember element);
79         DECL_XMLOBJECT_SIMPLE(SAML_API,AttributeProfile,ProfileURI,SAML 2.0 AttributeProfile element);
80         DECL_XMLOBJECT_SIMPLE(SAML_API,Company,Name,SAML 2.0 Company element);
81         DECL_XMLOBJECT_SIMPLE(SAML_API,EmailAddress,Address,SAML 2.0 EmailAddress element);
82         DECL_XMLOBJECT_SIMPLE(SAML_API,GivenName,Name,SAML 2.0 GivenName element);
83         DECL_XMLOBJECT_SIMPLE(SAML_API,NameIDFormat,Format,SAML 2.0 NameIDFormat element);
84         DECL_XMLOBJECT_SIMPLE(SAML_API,SurName,Name,SAML 2.0 SurName element);
85         DECL_XMLOBJECT_SIMPLE(SAML_API,TelephoneNumber,Number,SAML 2.0 TelephoneNumber element);
86
87         BEGIN_XMLOBJECT(SAML_API,localizedNameType,xmltooling::SimpleElement,SAML 2.0 localizedNameType type);
88             DECL_STRING_ATTRIB(Lang,LANG);
89             /** localizedNameType local name */
90             static const XMLCh TYPE_NAME[];
91         END_XMLOBJECT;
92
93         BEGIN_XMLOBJECT(SAML_API,localizedURIType,xmltooling::SimpleElement,SAML 2.0 localizedURIType type);
94             DECL_STRING_ATTRIB(Lang,LANG);
95             /** localizedURIType local name */
96             static const XMLCh TYPE_NAME[];
97         END_XMLOBJECT;
98
99         BEGIN_XMLOBJECT(SAML_API,OrganizationName,localizedNameType,SAML 2.0 OrganizationName element);
100             DECL_XMLOBJECT_CONTENT(Name);
101         END_XMLOBJECT;
102
103         BEGIN_XMLOBJECT(SAML_API,OrganizationDisplayName,localizedNameType,SAML 2.0 OrganizationDisplayName element);
104             DECL_XMLOBJECT_CONTENT(Name);
105         END_XMLOBJECT;
106
107         BEGIN_XMLOBJECT(SAML_API,OrganizationURL,localizedURIType,SAML 2.0 OrganizationURL element);
108             DECL_XMLOBJECT_CONTENT(URL);
109         END_XMLOBJECT;
110         
111         BEGIN_XMLOBJECT(SAML_API,Extensions,xmltooling::ElementProxy,SAML 2.0 Extensions element);
112             /** ExtensionsType local name */
113             static const XMLCh TYPE_NAME[];
114         END_XMLOBJECT;
115
116         BEGIN_XMLOBJECT(SAML_API,Organization,xmltooling::AttributeExtensibleXMLObject,SAML 2.0 Organization element);
117             DECL_TYPED_CHILD(Extensions);
118             DECL_TYPED_CHILDREN(OrganizationName);
119             DECL_TYPED_CHILDREN(OrganizationDisplayName);
120             DECL_TYPED_CHILDREN(OrganizationURL);
121             /** OrganizationType local name */
122             static const XMLCh TYPE_NAME[];
123         END_XMLOBJECT;
124
125         BEGIN_XMLOBJECT(SAML_API,ContactPerson,xmltooling::AttributeExtensibleXMLObject,SAML 2.0 ContactPerson element);
126             DECL_STRING_ATTRIB(ContactType,CONTACTTYPE);
127             DECL_TYPED_CHILD(Extensions);
128             DECL_TYPED_CHILD(Company);
129             DECL_TYPED_CHILD(GivenName);
130             DECL_TYPED_CHILD(SurName);
131             DECL_TYPED_CHILDREN(EmailAddress);
132             DECL_TYPED_CHILDREN(TelephoneNumber);
133             /** ContactType local name */
134             static const XMLCh TYPE_NAME[];
135             /** technical Contact Type */
136             static const XMLCh CONTACT_TECHNICAL[];
137             /** support Contact Type */
138             static const XMLCh CONTACT_SUPPORT[];
139             /** administrative Contact Type */
140             static const XMLCh CONTACT_ADMINISTRATIVE[];
141             /** billing Contact Type */
142             static const XMLCh CONTACT_BILLING[];
143             /** other Contact Type */
144             static const XMLCh CONTACT_OTHER[];
145         END_XMLOBJECT;
146
147         BEGIN_XMLOBJECT(SAML_API,AdditionalMetadataLocation,xmltooling::SimpleElement,SAML 2.0 AdditionalMetadataLocation element);
148             DECL_STRING_ATTRIB(Namespace,NAMESPACE);
149             DECL_XMLOBJECT_CONTENT(Location);
150             /** AdditionalMetadataLocationType local name */
151             static const XMLCh TYPE_NAME[];
152         END_XMLOBJECT;
153
154         BEGIN_XMLOBJECT(SAML_API,KeyDescriptor,xmltooling::XMLObject,SAML 2.0 KeyDescriptor element);
155             DECL_STRING_ATTRIB(Use,USE);
156             DECL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature);
157             DECL_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption);
158             /** KeyDescriptorType local name */
159             static const XMLCh TYPE_NAME[];
160             /** encryption Key Type */
161             static const XMLCh KEYTYPE_ENCRYPTION[];
162             /** signing Key Type */
163             static const XMLCh KEYTYPE_SIGNING[];
164         END_XMLOBJECT;
165
166         BEGIN_XMLOBJECT4(SAML_API,RoleDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
167                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 RoleDescriptor abstract element);
168             DECL_STRING_ATTRIB(ID,ID);
169             DECL_STRING_ATTRIB(ProtocolSupportEnumeration,PROTOCOLSUPPORTENUMERATION);
170             /** Searches the ProtocolSupportEnumeration attribute for the indicated protocol. */
171             virtual bool hasSupport(const XMLCh* protocol) const=0;
172             DECL_STRING_ATTRIB(ErrorURL,ERRORURL);
173             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
174             DECL_TYPED_CHILD(Extensions);
175             DECL_TYPED_CHILDREN(KeyDescriptor);
176             DECL_TYPED_CHILD(Organization);
177             DECL_TYPED_CHILDREN(ContactPerson);
178         END_XMLOBJECT;
179
180         BEGIN_XMLOBJECT2(SAML_API,EndpointType,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SAML 2.0 EndpointType type);
181             DECL_STRING_ATTRIB(Binding,BINDING);
182             DECL_STRING_ATTRIB(Location,LOCATION);
183             DECL_STRING_ATTRIB(ResponseLocation,RESPONSELOCATION);
184             /** EndpointType local name */
185             static const XMLCh TYPE_NAME[];
186         END_XMLOBJECT;
187
188         BEGIN_XMLOBJECT(SAML_API,IndexedEndpointType,EndpointType,SAML 2.0 IndexedEndpointType type);
189             DECL_INTEGER_ATTRIB(Index,INDEX);
190             DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT);
191             /** IndexedEndpointType local name */
192             static const XMLCh TYPE_NAME[];
193         END_XMLOBJECT;
194
195         BEGIN_XMLOBJECT(SAML_API,ArtifactResolutionService,IndexedEndpointType,SAML 2.0 ArtifactResolutionService element);
196         END_XMLOBJECT;
197
198         BEGIN_XMLOBJECT(SAML_API,SingleLogoutService,EndpointType,SAML 2.0 SingleLogoutService element);
199         END_XMLOBJECT;
200
201         BEGIN_XMLOBJECT(SAML_API,ManageNameIDService,EndpointType,SAML 2.0 ManageNameIDService element);
202         END_XMLOBJECT;
203
204         BEGIN_XMLOBJECT(SAML_API,SSODescriptorType,RoleDescriptor,SAML 2.0 SSODescriptorType abstract type);
205             DECL_TYPED_CHILDREN(ArtifactResolutionService);
206             DECL_TYPED_CHILDREN(SingleLogoutService);
207             DECL_TYPED_CHILDREN(ManageNameIDService);
208             DECL_TYPED_CHILDREN(NameIDFormat);
209             /** SSODescriptorType local name */
210             static const XMLCh TYPE_NAME[];
211         END_XMLOBJECT;
212
213         BEGIN_XMLOBJECT(SAML_API,SingleSignOnService,EndpointType,SAML 2.0 SingleSignOnService element);
214         END_XMLOBJECT;
215
216         BEGIN_XMLOBJECT(SAML_API,NameIDMappingService,EndpointType,SAML 2.0 NameIDMappingService element);
217         END_XMLOBJECT;
218
219         BEGIN_XMLOBJECT(SAML_API,AssertionIDRequestService,EndpointType,SAML 2.0 AssertionIDRequestService element);
220         END_XMLOBJECT;
221
222         BEGIN_XMLOBJECT(SAML_API,IDPSSODescriptor,SSODescriptorType,SAML 2.0 IDPSSODescriptor element);
223             DECL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED);
224             DECL_TYPED_CHILDREN(SingleSignOnService);
225             DECL_TYPED_CHILDREN(NameIDMappingService);
226             DECL_TYPED_CHILDREN(AssertionIDRequestService);
227             DECL_TYPED_CHILDREN(AttributeProfile);
228             DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2);
229             /** IDPSSODescriptorType local name */
230             static const XMLCh TYPE_NAME[];
231         END_XMLOBJECT;
232
233         BEGIN_XMLOBJECT(SAML_API,ServiceName,localizedNameType,SAML 2.0 ServiceName element);
234             DECL_XMLOBJECT_CONTENT(Name);
235         END_XMLOBJECT;
236
237         BEGIN_XMLOBJECT(SAML_API,ServiceDescription,localizedNameType,SAML 2.0 ServiceDescription element);
238             DECL_XMLOBJECT_CONTENT(Description);
239         END_XMLOBJECT;
240
241         BEGIN_XMLOBJECT(SAML_API,RequestedAttribute,saml2::Attribute,SAML 2.0 RequestedAttribute element);
242             DECL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED);
243             /** RequestedAttributeType local name */
244             static const XMLCh TYPE_NAME[];
245         END_XMLOBJECT;
246
247         BEGIN_XMLOBJECT(SAML_API,AttributeConsumingService,xmltooling::XMLObject,SAML 2.0 AttributeConsumingService element);
248             DECL_INTEGER_ATTRIB(Index,INDEX);
249             DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT);
250             DECL_TYPED_CHILDREN(ServiceName);
251             DECL_TYPED_CHILDREN(ServiceDescription);
252             DECL_TYPED_CHILDREN(RequestedAttribute);
253             /** AttributeConsumingServiceType local name */
254             static const XMLCh TYPE_NAME[];
255         END_XMLOBJECT;
256
257         BEGIN_XMLOBJECT(SAML_API,AssertionConsumerService,IndexedEndpointType,SAML 2.0 AssertionConsumerService element);
258         END_XMLOBJECT;
259
260         BEGIN_XMLOBJECT(SAML_API,SPSSODescriptor,SSODescriptorType,SAML 2.0 SPSSODescriptor element);
261             DECL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED);
262             DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED);
263             DECL_TYPED_CHILDREN(AssertionConsumerService);
264             DECL_TYPED_CHILDREN(AttributeConsumingService);
265             /** SPSSODescriptorType local name */
266             static const XMLCh TYPE_NAME[];
267         END_XMLOBJECT;
268
269         BEGIN_XMLOBJECT(SAML_API,AuthnQueryService,EndpointType,SAML 2.0 AuthnQueryService element);
270         END_XMLOBJECT;
271
272         BEGIN_XMLOBJECT(SAML_API,AuthnAuthorityDescriptor,RoleDescriptor,SAML 2.0 AuthnAuthorityDescriptor element);
273             DECL_TYPED_CHILDREN(AuthnQueryService);
274             DECL_TYPED_CHILDREN(AssertionIDRequestService);
275             DECL_TYPED_CHILDREN(NameIDFormat);
276             /** AuthnAuthorityDescriptorType local name */
277             static const XMLCh TYPE_NAME[];
278         END_XMLOBJECT;
279
280         BEGIN_XMLOBJECT(SAML_API,AuthzService,EndpointType,SAML 2.0 AuthzService element);
281         END_XMLOBJECT;
282
283         BEGIN_XMLOBJECT(SAML_API,PDPDescriptor,RoleDescriptor,SAML 2.0 PDPDescriptor element);
284             DECL_TYPED_CHILDREN(AuthzService);
285             DECL_TYPED_CHILDREN(AssertionIDRequestService);
286             DECL_TYPED_CHILDREN(NameIDFormat);
287             /** PDPDescriptorType local name */
288             static const XMLCh TYPE_NAME[];
289         END_XMLOBJECT;
290
291         BEGIN_XMLOBJECT(SAML_API,AttributeService,EndpointType,SAML 2.0 AttributeService element);
292         END_XMLOBJECT;
293
294         BEGIN_XMLOBJECT(SAML_API,AttributeAuthorityDescriptor,RoleDescriptor,SAML 2.0 AttributeAuthorityDescriptor element);
295             DECL_TYPED_CHILDREN(AttributeService);
296             DECL_TYPED_CHILDREN(AssertionIDRequestService);
297             DECL_TYPED_CHILDREN(NameIDFormat);
298             DECL_TYPED_CHILDREN(AttributeProfile);
299             DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2);
300             /** AttributeAuthorityDescriptorType local name */
301             static const XMLCh TYPE_NAME[];
302         END_XMLOBJECT;
303
304         BEGIN_XMLOBJECT4(SAML_API,AffiliationDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
305                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 AffiliationDescriptor element);
306             DECL_STRING_ATTRIB(ID,ID);
307             DECL_STRING_ATTRIB(AffiliationOwnerID,AFFILIATIONOWNERID);
308             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
309             DECL_TYPED_CHILD(Extensions);
310             DECL_TYPED_CHILDREN(AffiliateMember);
311             DECL_TYPED_CHILDREN(KeyDescriptor);
312             /** AffiliationDescriptorType local name */
313             static const XMLCh TYPE_NAME[];
314         END_XMLOBJECT;
315
316         BEGIN_XMLOBJECT4(SAML_API,EntityDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
317                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 EntityDescriptor element);
318             DECL_STRING_ATTRIB(ID,ID);
319             DECL_STRING_ATTRIB(EntityID,ENTITYID);
320             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
321             DECL_TYPED_CHILD(Extensions);
322             DECL_TYPED_CHILD(AffiliationDescriptor);
323             DECL_TYPED_CHILDREN(RoleDescriptor);
324             DECL_TYPED_CHILDREN(IDPSSODescriptor);
325             DECL_TYPED_CHILDREN(SPSSODescriptor);
326             DECL_TYPED_CHILDREN(AuthnAuthorityDescriptor);
327             DECL_TYPED_CHILDREN(AttributeAuthorityDescriptor);
328             DECL_TYPED_CHILDREN(PDPDescriptor);
329             /** EntityDescriptorType local name */
330             static const XMLCh TYPE_NAME[];
331         END_XMLOBJECT;
332
333         BEGIN_XMLOBJECT3(SAML_API,EntitiesDescriptor,SignableObject,CacheableSAMLObject,
334                 TimeBoundSAMLObject,SAML 2.0 EntitiesDescriptor element);
335             DECL_STRING_ATTRIB(ID,ID);
336             DECL_STRING_ATTRIB(Name,NAME);
337             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
338             DECL_TYPED_CHILD(Extensions);
339             DECL_TYPED_CHILDREN(EntityDescriptor);
340             DECL_TYPED_CHILDREN(EntitiesDescriptor);
341             /** EntitiesDescriptorType local name */
342             static const XMLCh TYPE_NAME[];
343         END_XMLOBJECT;
344
345         DECL_SAML2MDOBJECTBUILDER(AdditionalMetadataLocation);
346         DECL_SAML2MDOBJECTBUILDER(AffiliateMember);
347         DECL_SAML2MDOBJECTBUILDER(AffiliationDescriptor);
348         DECL_SAML2MDOBJECTBUILDER(ArtifactResolutionService);
349         DECL_SAML2MDOBJECTBUILDER(AssertionConsumerService);
350         DECL_SAML2MDOBJECTBUILDER(AssertionIDRequestService);
351         DECL_SAML2MDOBJECTBUILDER(AttributeAuthorityDescriptor);
352         DECL_SAML2MDOBJECTBUILDER(AttributeConsumingService);
353         DECL_SAML2MDOBJECTBUILDER(AttributeProfile);
354         DECL_SAML2MDOBJECTBUILDER(AttributeService);
355         DECL_SAML2MDOBJECTBUILDER(AuthnAuthorityDescriptor);
356         DECL_SAML2MDOBJECTBUILDER(AuthnQueryService);
357         DECL_SAML2MDOBJECTBUILDER(AuthzService);
358         DECL_SAML2MDOBJECTBUILDER(Company);
359         DECL_SAML2MDOBJECTBUILDER(ContactPerson);
360         DECL_SAML2MDOBJECTBUILDER(EmailAddress);
361         DECL_SAML2MDOBJECTBUILDER(EntitiesDescriptor);
362         DECL_SAML2MDOBJECTBUILDER(EntityDescriptor);
363         DECL_SAML2MDOBJECTBUILDER(Extensions);
364         DECL_SAML2MDOBJECTBUILDER(GivenName);
365         DECL_SAML2MDOBJECTBUILDER(IDPSSODescriptor);
366         DECL_SAML2MDOBJECTBUILDER(KeyDescriptor);
367         DECL_SAML2MDOBJECTBUILDER(ManageNameIDService);
368         DECL_SAML2MDOBJECTBUILDER(NameIDFormat);
369         DECL_SAML2MDOBJECTBUILDER(NameIDMappingService);
370         DECL_SAML2MDOBJECTBUILDER(Organization);
371         DECL_SAML2MDOBJECTBUILDER(OrganizationName);
372         DECL_SAML2MDOBJECTBUILDER(OrganizationDisplayName);
373         DECL_SAML2MDOBJECTBUILDER(OrganizationURL);
374         DECL_SAML2MDOBJECTBUILDER(PDPDescriptor);
375         DECL_SAML2MDOBJECTBUILDER(RequestedAttribute);
376         DECL_SAML2MDOBJECTBUILDER(ServiceDescription);
377         DECL_SAML2MDOBJECTBUILDER(ServiceName);
378         DECL_SAML2MDOBJECTBUILDER(SingleLogoutService);
379         DECL_SAML2MDOBJECTBUILDER(SingleSignOnService);
380         DECL_SAML2MDOBJECTBUILDER(SPSSODescriptor);
381         DECL_SAML2MDOBJECTBUILDER(SurName);
382         DECL_SAML2MDOBJECTBUILDER(TelephoneNumber);
383
384         /**
385          * Builder for localizedNameType objects.
386          * 
387          * This is customized to force the element name to be specified.
388          */
389         class SAML_API localizedNameTypeBuilder : public xmltooling::XMLObjectBuilder {
390         public:
391             virtual ~localizedNameTypeBuilder() {}
392             /** Builder that allows element/type override. */
393             virtual localizedNameType* buildObject(
394                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
395                 ) const;
396         
397             /** Singleton builder. */
398             static localizedNameType* buildlocalizedNameType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
399                 const localizedNameTypeBuilder* b = dynamic_cast<const localizedNameTypeBuilder*>(
400                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,localizedNameType::TYPE_NAME))
401                     );
402                 if (b) {
403                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,localizedNameType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
404                     return b->buildObject(nsURI, localName, prefix, &schemaType);
405                 }
406                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedNameType.");
407             }
408         };
409
410         /**
411          * Builder for localizedURIType objects.
412          * 
413          * This is customized to force the element name to be specified.
414          */
415         class SAML_API localizedURITypeBuilder : public xmltooling::XMLObjectBuilder {
416         public:
417             virtual ~localizedURITypeBuilder() {}
418             /** Builder that allows element/type override. */
419             virtual localizedURIType* buildObject(
420                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
421                 ) const;
422         
423             /** Singleton builder. */
424             static localizedURIType* buildlocalizedURIType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
425                 const localizedURITypeBuilder* b = dynamic_cast<const localizedURITypeBuilder*>(
426                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,localizedURIType::TYPE_NAME))
427                     );
428                 if (b) {
429                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,localizedURIType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
430                     return b->buildObject(nsURI, localName, prefix, &schemaType);
431                 }
432                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedURIType.");
433             }
434         };
435
436         /**
437          * Builder for EndpointType objects.
438          * 
439          * This is customized to force the element name to be specified.
440          */
441         class SAML_API EndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
442         public:
443             virtual ~EndpointTypeBuilder() {}
444             /** Builder that allows element/type override. */
445             virtual EndpointType* buildObject(
446                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
447                 ) const;
448         
449             /** Singleton builder. */
450             static EndpointType* buildEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
451                 const EndpointTypeBuilder* b = dynamic_cast<const EndpointTypeBuilder*>(
452                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,EndpointType::TYPE_NAME))
453                     );
454                 if (b) {
455                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,EndpointType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
456                     return b->buildObject(nsURI, localName, prefix, &schemaType);
457                 }
458                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for EndpointType.");
459             }
460         };
461
462         /**
463          * Builder for IndexedEndpointType objects.
464          * 
465          * This is customized to force the element name to be specified.
466          */
467         class SAML_API IndexedEndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
468         public:
469             virtual ~IndexedEndpointTypeBuilder() {}
470             /** Builder that allows element/type override. */
471             virtual IndexedEndpointType* buildObject(
472                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
473                 ) const;
474         
475             /** Singleton builder. */
476             static IndexedEndpointType* buildIndexedEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
477                 const IndexedEndpointTypeBuilder* b = dynamic_cast<const IndexedEndpointTypeBuilder*>(
478                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME))
479                     );
480                 if (b) {
481                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
482                     return b->buildObject(nsURI, localName, prefix, &schemaType);
483                 }
484                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for IndexedEndpointType.");
485             }
486         };
487
488         /**
489          * Registers builders and validators for SAML 2.0 Metadata classes into the runtime.
490          */
491         void SAML_API registerMetadataClasses();
492
493         /**
494          * Validator suite for SAML 2.0 Metadata schema validation.
495          */
496         extern SAML_API xmltooling::ValidatorSuite MetadataSchemaValidators;
497     };
498 };
499
500 #endif /* __saml2_metadata_h__ */