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