96913292642f9225fd24aa6b60c9aa92ecb19cfe
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / Metadata.h
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  * @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 <xmltooling/util/Predicates.h>
28
29 #include <ctime>
30
31 #define DECL_SAML2MDOBJECTBUILDER(cname) \
32     DECL_XMLOBJECTBUILDER(SAML_API,cname,samlconstants::SAML20MD_NS,samlconstants::SAML20MD_PREFIX)
33
34 namespace opensaml {
35
36     /**
37      * @namespace opensaml::saml2md
38      * SAML 2.0 metadata namespace
39      */
40     namespace saml2md {
41         
42         /**
43          * Base class for metadata objects that feature a cacheDuration attribute.
44          */
45         class SAML_API CacheableSAMLObject : public virtual xmltooling::XMLObject
46         {
47         protected:
48             CacheableSAMLObject() {}
49         public:
50             ~CacheableSAMLObject() {}
51             DECL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION);
52         };
53
54         /**
55          * Base class for metadata objects that feature a validUntil attribute.
56          */
57         class SAML_API TimeBoundSAMLObject : public virtual xmltooling::XMLObject
58         {
59         protected:
60             TimeBoundSAMLObject() {}
61         public:
62             ~TimeBoundSAMLObject() {}
63             DECL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL);
64             /** Returns true iff the object is valid at the current time. */
65             bool isValid() const {
66                 return time(NULL) <= getValidUntilEpoch();
67             }
68             /** Returns true iff the object is valid at the supplied time. */
69             bool isValid(time_t t) const {
70                 return t <= getValidUntilEpoch();
71             }
72         };
73
74         DECL_XMLOBJECT_SIMPLE(SAML_API,AffiliateMember,ID,SAML 2.0 AffiliateMember element);
75         DECL_XMLOBJECT_SIMPLE(SAML_API,AttributeProfile,ProfileURI,SAML 2.0 AttributeProfile element);
76         DECL_XMLOBJECT_SIMPLE(SAML_API,Company,Name,SAML 2.0 Company element);
77         DECL_XMLOBJECT_SIMPLE(SAML_API,EmailAddress,Address,SAML 2.0 EmailAddress element);
78         DECL_XMLOBJECT_SIMPLE(SAML_API,GivenName,Name,SAML 2.0 GivenName element);
79         DECL_XMLOBJECT_SIMPLE(SAML_API,NameIDFormat,Format,SAML 2.0 NameIDFormat element);
80         DECL_XMLOBJECT_SIMPLE(SAML_API,SurName,Name,SAML 2.0 SurName element);
81         DECL_XMLOBJECT_SIMPLE(SAML_API,TelephoneNumber,Number,SAML 2.0 TelephoneNumber element);
82         
83         DECL_XMLOBJECT_SIMPLE(SAML_API,ActionNamespace,Namespace,SAML 2.0 Metadata Extension ActionNamespace element);
84         DECL_XMLOBJECT_SIMPLE(SAML_API,SourceID,ID,SAML 1.x Metadata Profile SourceID element);
85
86         BEGIN_XMLOBJECT(SAML_API,localizedNameType,xmltooling::XMLObject,SAML 2.0 localizedNameType type);
87             DECL_STRING_ATTRIB(Lang,LANG);
88             /** localizedNameType local name */
89             static const XMLCh TYPE_NAME[];
90         END_XMLOBJECT;
91
92         BEGIN_XMLOBJECT(SAML_API,localizedURIType,xmltooling::XMLObject,SAML 2.0 localizedURIType type);
93             DECL_STRING_ATTRIB(Lang,LANG);
94             /** localizedURIType local name */
95             static const XMLCh TYPE_NAME[];
96         END_XMLOBJECT;
97
98         BEGIN_XMLOBJECT(SAML_API,OrganizationName,localizedNameType,SAML 2.0 OrganizationName element);
99             DECL_SIMPLE_CONTENT(Name);
100         END_XMLOBJECT;
101
102         BEGIN_XMLOBJECT(SAML_API,OrganizationDisplayName,localizedNameType,SAML 2.0 OrganizationDisplayName element);
103             DECL_SIMPLE_CONTENT(Name);
104         END_XMLOBJECT;
105
106         BEGIN_XMLOBJECT(SAML_API,OrganizationURL,localizedURIType,SAML 2.0 OrganizationURL element);
107             DECL_SIMPLE_CONTENT(URL);
108         END_XMLOBJECT;
109         
110         BEGIN_XMLOBJECT(SAML_API,Extensions,xmltooling::ElementExtensibleXMLObject,SAML 2.0 Extensions element);
111             /** ExtensionsType local name */
112             static const XMLCh TYPE_NAME[];
113         END_XMLOBJECT;
114
115         BEGIN_XMLOBJECT(SAML_API,Organization,xmltooling::AttributeExtensibleXMLObject,SAML 2.0 Organization element);
116             DECL_TYPED_CHILD(Extensions);
117             DECL_TYPED_CHILDREN(OrganizationName);
118             DECL_TYPED_CHILDREN(OrganizationDisplayName);
119             DECL_TYPED_CHILDREN(OrganizationURL);
120             /** OrganizationType local name */
121             static const XMLCh TYPE_NAME[];
122         END_XMLOBJECT;
123
124         BEGIN_XMLOBJECT(SAML_API,ContactPerson,xmltooling::AttributeExtensibleXMLObject,SAML 2.0 ContactPerson element);
125             DECL_STRING_ATTRIB(ContactType,CONTACTTYPE);
126             DECL_TYPED_CHILD(Extensions);
127             DECL_TYPED_CHILD(Company);
128             DECL_TYPED_CHILD(GivenName);
129             DECL_TYPED_CHILD(SurName);
130             DECL_TYPED_CHILDREN(EmailAddress);
131             DECL_TYPED_CHILDREN(TelephoneNumber);
132             /** ContactType local name */
133             static const XMLCh TYPE_NAME[];
134             /** technical Contact Type */
135             static const XMLCh CONTACT_TECHNICAL[];
136             /** support Contact Type */
137             static const XMLCh CONTACT_SUPPORT[];
138             /** administrative Contact Type */
139             static const XMLCh CONTACT_ADMINISTRATIVE[];
140             /** billing Contact Type */
141             static const XMLCh CONTACT_BILLING[];
142             /** other Contact Type */
143             static const XMLCh CONTACT_OTHER[];
144         END_XMLOBJECT;
145
146         BEGIN_XMLOBJECT(SAML_API,AdditionalMetadataLocation,xmltooling::XMLObject,SAML 2.0 AdditionalMetadataLocation element);
147             DECL_STRING_ATTRIB(Namespace,NAMESPACE);
148             DECL_SIMPLE_CONTENT(Location);
149             /** AdditionalMetadataLocationType local name */
150             static const XMLCh TYPE_NAME[];
151         END_XMLOBJECT;
152
153         BEGIN_XMLOBJECT(SAML_API,KeyDescriptor,xmltooling::XMLObject,SAML 2.0 KeyDescriptor element);
154             DECL_STRING_ATTRIB(Use,USE);
155             DECL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature);
156             DECL_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption);
157             /** KeyDescriptorType local name */
158             static const XMLCh TYPE_NAME[];
159             /** encryption Key Type */
160             static const XMLCh KEYTYPE_ENCRYPTION[];
161             /** signing Key Type */
162             static const XMLCh KEYTYPE_SIGNING[];
163         END_XMLOBJECT;
164
165         BEGIN_XMLOBJECT4(SAML_API,RoleDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
166                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 RoleDescriptor abstract element);
167             DECL_STRING_ATTRIB(ID,ID);
168             DECL_STRING_ATTRIB(ProtocolSupportEnumeration,PROTOCOLSUPPORTENUMERATION);
169             /** Searches the ProtocolSupportEnumeration attribute for the indicated protocol. */
170             virtual bool hasSupport(const XMLCh* protocol) const=0;
171             /** Adds the indicated protocol to the ProtocolSupportEnumeration attribute. */
172             virtual void addSupport(const XMLCh* protocol)=0;
173             DECL_STRING_ATTRIB(ErrorURL,ERRORURL);
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_XMLOBJECT(SAML_API,EndpointType,xmltooling::ElementProxy,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,false);
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,false);
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             DECL_ELEMENT_QNAME;
232         END_XMLOBJECT;
233
234         BEGIN_XMLOBJECT(SAML_API,ServiceName,localizedNameType,SAML 2.0 ServiceName element);
235             DECL_SIMPLE_CONTENT(Name);
236         END_XMLOBJECT;
237
238         BEGIN_XMLOBJECT(SAML_API,ServiceDescription,localizedNameType,SAML 2.0 ServiceDescription element);
239             DECL_SIMPLE_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,false);
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,false);
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,false);
263             DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false);
264             DECL_TYPED_CHILDREN(AssertionConsumerService);
265             DECL_TYPED_CHILDREN(AttributeConsumingService);
266             /** SPSSODescriptorType local name */
267             static const XMLCh TYPE_NAME[];
268             DECL_ELEMENT_QNAME;
269         END_XMLOBJECT;
270
271         BEGIN_XMLOBJECT(SAML_API,AuthnQueryService,EndpointType,SAML 2.0 AuthnQueryService element);
272         END_XMLOBJECT;
273
274         BEGIN_XMLOBJECT(SAML_API,AuthnAuthorityDescriptor,RoleDescriptor,SAML 2.0 AuthnAuthorityDescriptor element);
275             DECL_TYPED_CHILDREN(AuthnQueryService);
276             DECL_TYPED_CHILDREN(AssertionIDRequestService);
277             DECL_TYPED_CHILDREN(NameIDFormat);
278             /** AuthnAuthorityDescriptorType local name */
279             static const XMLCh TYPE_NAME[];
280             DECL_ELEMENT_QNAME;
281         END_XMLOBJECT;
282
283         BEGIN_XMLOBJECT(SAML_API,AuthzService,EndpointType,SAML 2.0 AuthzService element);
284         END_XMLOBJECT;
285
286         BEGIN_XMLOBJECT(SAML_API,PDPDescriptor,RoleDescriptor,SAML 2.0 PDPDescriptor element);
287             DECL_TYPED_CHILDREN(AuthzService);
288             DECL_TYPED_CHILDREN(AssertionIDRequestService);
289             DECL_TYPED_CHILDREN(NameIDFormat);
290             /** PDPDescriptorType local name */
291             static const XMLCh TYPE_NAME[];
292             DECL_ELEMENT_QNAME;
293         END_XMLOBJECT;
294
295         BEGIN_XMLOBJECT(SAML_API,AttributeService,EndpointType,SAML 2.0 AttributeService element);
296         END_XMLOBJECT;
297
298         BEGIN_XMLOBJECT(SAML_API,AttributeAuthorityDescriptor,RoleDescriptor,SAML 2.0 AttributeAuthorityDescriptor element);
299             DECL_TYPED_CHILDREN(AttributeService);
300             DECL_TYPED_CHILDREN(AssertionIDRequestService);
301             DECL_TYPED_CHILDREN(NameIDFormat);
302             DECL_TYPED_CHILDREN(AttributeProfile);
303             DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2);
304             /** AttributeAuthorityDescriptorType local name */
305             static const XMLCh TYPE_NAME[];
306             DECL_ELEMENT_QNAME;
307         END_XMLOBJECT;
308
309         BEGIN_XMLOBJECT(SAML_API,QueryDescriptorType,RoleDescriptor,SAML 2.0 QueryDescriptorType abstract type);
310             DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false);
311             DECL_TYPED_CHILDREN(NameIDFormat);
312             /** QueryDescriptorType local name */
313             static const XMLCh TYPE_NAME[];
314         END_XMLOBJECT;
315
316         BEGIN_XMLOBJECT(SAML_API,AuthnQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthnQueryDescriptorType extension type);
317             /** AuthnQueryDescriptorType local name */
318             static const XMLCh TYPE_NAME[];
319             DECL_TYPE_QNAME;
320         END_XMLOBJECT;
321
322         BEGIN_XMLOBJECT(SAML_API,AttributeQueryDescriptorType,QueryDescriptorType,SAML 2.0 AttributeQueryDescriptorType extension type);
323             DECL_TYPED_CHILDREN(AttributeConsumingService);
324             /** AttributeQueryDescriptorType local name */
325             static const XMLCh TYPE_NAME[];
326             DECL_TYPE_QNAME;
327         END_XMLOBJECT;
328
329         BEGIN_XMLOBJECT(SAML_API,AuthzDecisionQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthzDecisionQueryDescriptorType extension type);
330             DECL_TYPED_CHILDREN(ActionNamespace);
331             /** AuthzDecisionQueryDescriptorType local name */
332             static const XMLCh TYPE_NAME[];
333             DECL_TYPE_QNAME;
334         END_XMLOBJECT;
335
336         BEGIN_XMLOBJECT4(SAML_API,AffiliationDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
337                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 AffiliationDescriptor element);
338             DECL_STRING_ATTRIB(ID,ID);
339             DECL_STRING_ATTRIB(AffiliationOwnerID,AFFILIATIONOWNERID);
340             DECL_TYPED_CHILD(Extensions);
341             DECL_TYPED_CHILDREN(AffiliateMember);
342             DECL_TYPED_CHILDREN(KeyDescriptor);
343             /** AffiliationDescriptorType local name */
344             static const XMLCh TYPE_NAME[];
345         END_XMLOBJECT;
346
347         BEGIN_XMLOBJECT4(SAML_API,EntityDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
348                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 EntityDescriptor element);
349             DECL_STRING_ATTRIB(ID,ID);
350             DECL_STRING_ATTRIB(EntityID,ENTITYID);
351             DECL_TYPED_CHILD(Extensions);
352             DECL_TYPED_CHILD(AffiliationDescriptor);
353             DECL_TYPED_CHILDREN(RoleDescriptor);
354             DECL_TYPED_CHILDREN(IDPSSODescriptor);
355             DECL_TYPED_CHILDREN(SPSSODescriptor);
356             DECL_TYPED_CHILDREN(AuthnAuthorityDescriptor);
357             DECL_TYPED_CHILDREN(AttributeAuthorityDescriptor);
358             DECL_TYPED_CHILDREN(PDPDescriptor);
359             DECL_TYPED_CHILDREN(AuthnQueryDescriptorType);
360             DECL_TYPED_CHILDREN(AttributeQueryDescriptorType);
361             DECL_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType);
362             DECL_TYPED_CHILD(Organization);
363             DECL_TYPED_CHILDREN(ContactPerson);
364             DECL_TYPED_CHILDREN(AdditionalMetadataLocation);
365             /** Finds an arbitrary role type supporting a given protocol. */
366             virtual const RoleDescriptor* getRoleDescriptor(const xmltooling::QName& qname, const XMLCh* protocol) const=0;
367             /** EntityDescriptorType local name */
368             static const XMLCh TYPE_NAME[];
369         END_XMLOBJECT;
370
371         BEGIN_XMLOBJECT3(SAML_API,EntitiesDescriptor,SignableObject,CacheableSAMLObject,
372                 TimeBoundSAMLObject,SAML 2.0 EntitiesDescriptor element);
373             DECL_STRING_ATTRIB(ID,ID);
374             DECL_STRING_ATTRIB(Name,NAME);
375             DECL_TYPED_CHILD(Extensions);
376             DECL_TYPED_CHILDREN(EntityDescriptor);
377             DECL_TYPED_CHILDREN(EntitiesDescriptor);
378             /** EntitiesDescriptorType local name */
379             static const XMLCh TYPE_NAME[];
380         END_XMLOBJECT;
381
382         /**
383          * Predicate to test a role for validity and protocol support.
384          */
385         class isValidForProtocol
386         {
387         public:
388             /**
389              * Constructor.
390              *
391              * @param protocol  support constant to test for
392              */
393             isValidForProtocol(const XMLCh* protocol) : m_time(time(NULL)), m_protocol(protocol) {
394             }
395             
396             /**
397              * Returns true iff the supplied role is valid now and supports the right protocol.
398              *
399              * @param role  role to test
400              * @return  result of predicate
401              */
402             bool operator()(const RoleDescriptor* role) const {
403                 return role ? (role->isValid(m_time) && role->hasSupport(m_protocol)) : false;
404             }
405             
406         private:
407             time_t m_time;
408             const XMLCh* m_protocol;
409         };
410
411         /**
412          * Predicate to test a role for type equivalence, validity, and protocol support.
413          */
414         class ofTypeValidForProtocol : public isValidForProtocol, public xmltooling::hasSchemaType
415         {
416         public:
417             /**
418              * Constructor.
419              *
420              * @param q         schema type to test for
421              * @param protocol  support constant to test for
422              */
423             ofTypeValidForProtocol(const xmltooling::QName& q, const XMLCh* protocol)
424                 : isValidForProtocol(protocol), xmltooling::hasSchemaType(q)  {
425             }
426             
427             /**
428              * Returns true iff the supplied role is of the right type, valid now, and supports the right protocol.
429              *
430              * @param role  role to test
431              * @return  result of predicate
432              */
433             bool operator()(const RoleDescriptor* role) const {
434                 return xmltooling::hasSchemaType::operator()(role) && isValidForProtocol::operator()(role); 
435             }
436         };
437
438         DECL_SAML2MDOBJECTBUILDER(AdditionalMetadataLocation);
439         DECL_SAML2MDOBJECTBUILDER(AffiliateMember);
440         DECL_SAML2MDOBJECTBUILDER(AffiliationDescriptor);
441         DECL_SAML2MDOBJECTBUILDER(ArtifactResolutionService);
442         DECL_SAML2MDOBJECTBUILDER(AssertionConsumerService);
443         DECL_SAML2MDOBJECTBUILDER(AssertionIDRequestService);
444         DECL_SAML2MDOBJECTBUILDER(AttributeAuthorityDescriptor);
445         DECL_SAML2MDOBJECTBUILDER(AttributeConsumingService);
446         DECL_SAML2MDOBJECTBUILDER(AttributeProfile);
447         DECL_SAML2MDOBJECTBUILDER(AttributeService);
448         DECL_SAML2MDOBJECTBUILDER(AuthnAuthorityDescriptor);
449         DECL_SAML2MDOBJECTBUILDER(AuthnQueryService);
450         DECL_SAML2MDOBJECTBUILDER(AuthzService);
451         DECL_SAML2MDOBJECTBUILDER(Company);
452         DECL_SAML2MDOBJECTBUILDER(ContactPerson);
453         DECL_SAML2MDOBJECTBUILDER(EmailAddress);
454         DECL_SAML2MDOBJECTBUILDER(EntitiesDescriptor);
455         DECL_SAML2MDOBJECTBUILDER(EntityDescriptor);
456         DECL_SAML2MDOBJECTBUILDER(Extensions);
457         DECL_SAML2MDOBJECTBUILDER(GivenName);
458         DECL_SAML2MDOBJECTBUILDER(IDPSSODescriptor);
459         DECL_SAML2MDOBJECTBUILDER(KeyDescriptor);
460         DECL_SAML2MDOBJECTBUILDER(ManageNameIDService);
461         DECL_SAML2MDOBJECTBUILDER(NameIDFormat);
462         DECL_SAML2MDOBJECTBUILDER(NameIDMappingService);
463         DECL_SAML2MDOBJECTBUILDER(Organization);
464         DECL_SAML2MDOBJECTBUILDER(OrganizationName);
465         DECL_SAML2MDOBJECTBUILDER(OrganizationDisplayName);
466         DECL_SAML2MDOBJECTBUILDER(OrganizationURL);
467         DECL_SAML2MDOBJECTBUILDER(PDPDescriptor);
468         DECL_SAML2MDOBJECTBUILDER(RequestedAttribute);
469         DECL_SAML2MDOBJECTBUILDER(ServiceDescription);
470         DECL_SAML2MDOBJECTBUILDER(ServiceName);
471         DECL_SAML2MDOBJECTBUILDER(SingleLogoutService);
472         DECL_SAML2MDOBJECTBUILDER(SingleSignOnService);
473         DECL_SAML2MDOBJECTBUILDER(SPSSODescriptor);
474         DECL_SAML2MDOBJECTBUILDER(SurName);
475         DECL_SAML2MDOBJECTBUILDER(TelephoneNumber);
476         
477         DECL_XMLOBJECTBUILDER(SAML_API,ActionNamespace,samlconstants::SAML20MD_QUERY_EXT_NS,samlconstants::SAML20MD_QUERY_EXT_PREFIX);
478         DECL_XMLOBJECTBUILDER(SAML_API,SourceID,samlconstants::SAML1MD_NS,samlconstants::SAML1MD_PREFIX);
479
480         /**
481          * Builder for localizedNameType objects.
482          * 
483          * This is customized to force the element name to be specified.
484          */
485         class SAML_API localizedNameTypeBuilder : public xmltooling::XMLObjectBuilder {
486         public:
487             virtual ~localizedNameTypeBuilder() {}
488             /** Builder that allows element/type override. */
489 #ifdef HAVE_COVARIANT_RETURNS
490             virtual localizedNameType* buildObject(
491 #else
492             virtual xmltooling::XMLObject* buildObject(
493 #endif
494                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
495                 ) const;
496         
497             /** Singleton builder. */
498             static localizedNameType* buildlocalizedNameType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
499                 const localizedNameTypeBuilder* b = dynamic_cast<const localizedNameTypeBuilder*>(
500                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,localizedNameType::TYPE_NAME))
501                     );
502                 if (b) {
503                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,localizedNameType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
504 #ifdef HAVE_COVARIANT_RETURNS
505                     return b->buildObject(nsURI, localName, prefix, &schemaType);
506 #else
507                     return dynamic_cast<localizedNameType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
508 #endif
509                 }
510                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedNameType.");
511             }
512         };
513
514         /**
515          * Builder for localizedURIType objects.
516          * 
517          * This is customized to force the element name to be specified.
518          */
519         class SAML_API localizedURITypeBuilder : public xmltooling::XMLObjectBuilder {
520         public:
521             virtual ~localizedURITypeBuilder() {}
522             /** Builder that allows element/type override. */
523 #ifdef HAVE_COVARIANT_RETURNS
524             virtual localizedURIType* buildObject(
525 #else
526             virtual xmltooling::XMLObject* buildObject(
527 #endif
528                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
529                 ) const;
530         
531             /** Singleton builder. */
532             static localizedURIType* buildlocalizedURIType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
533                 const localizedURITypeBuilder* b = dynamic_cast<const localizedURITypeBuilder*>(
534                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,localizedURIType::TYPE_NAME))
535                     );
536                 if (b) {
537                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,localizedURIType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
538 #ifdef HAVE_COVARIANT_RETURNS
539                     return b->buildObject(nsURI, localName, prefix, &schemaType);
540 #else
541                     return dynamic_cast<localizedURIType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
542 #endif
543                 }
544                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedURIType.");
545             }
546         };
547
548         /**
549          * Builder for EndpointType objects.
550          * 
551          * This is customized to force the element name to be specified.
552          */
553         class SAML_API EndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
554         public:
555             virtual ~EndpointTypeBuilder() {}
556             /** Builder that allows element/type override. */
557 #ifdef HAVE_COVARIANT_RETURNS
558             virtual EndpointType* buildObject(
559 #else
560             virtual xmltooling::XMLObject* buildObject(
561 #endif
562                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
563                 ) const;
564         
565             /** Singleton builder. */
566             static EndpointType* buildEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
567                 const EndpointTypeBuilder* b = dynamic_cast<const EndpointTypeBuilder*>(
568                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,EndpointType::TYPE_NAME))
569                     );
570                 if (b) {
571                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,EndpointType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
572 #ifdef HAVE_COVARIANT_RETURNS
573                     return b->buildObject(nsURI, localName, prefix, &schemaType);
574 #else
575                     return dynamic_cast<EndpointType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
576 #endif
577                 }
578                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for EndpointType.");
579             }
580         };
581
582         /**
583          * Builder for IndexedEndpointType objects.
584          * 
585          * This is customized to force the element name to be specified.
586          */
587         class SAML_API IndexedEndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
588         public:
589             virtual ~IndexedEndpointTypeBuilder() {}
590             /** Builder that allows element/type override. */
591 #ifdef HAVE_COVARIANT_RETURNS
592             virtual IndexedEndpointType* buildObject(
593 #else
594             virtual xmltooling::XMLObject* buildObject(
595 #endif
596                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
597                 ) const;
598         
599             /** Singleton builder. */
600             static IndexedEndpointType* buildIndexedEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
601                 const IndexedEndpointTypeBuilder* b = dynamic_cast<const IndexedEndpointTypeBuilder*>(
602                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME))
603                     );
604                 if (b) {
605                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
606 #ifdef HAVE_COVARIANT_RETURNS
607                     return b->buildObject(nsURI, localName, prefix, &schemaType);
608 #else
609                     return dynamic_cast<IndexedEndpointType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
610 #endif
611                 }
612                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for IndexedEndpointType.");
613             }
614         };
615
616         /**
617          * Builder for AuthnQueryDescriptorType objects.
618          * 
619          * This is customized to return a RoleDescriptor element with an
620          * xsi:type of AuthnQueryDescriptorType.
621          */
622         class SAML_API AuthnQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder {
623         public:
624             virtual ~AuthnQueryDescriptorTypeBuilder() {}
625             /** Default builder. */
626 #ifdef HAVE_COVARIANT_RETURNS
627             virtual AuthnQueryDescriptorType* buildObject() const {
628 #else
629             virtual xmltooling::XMLObject* buildObject() const {
630 #endif
631                 xmltooling::QName schemaType(
632                     samlconstants::SAML20MD_QUERY_EXT_NS,AuthnQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX
633                     );
634                 return buildObject(
635                     samlconstants::SAML20MD_NS,AuthnQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType
636                     );
637             }
638             /** Builder that allows element/type override. */
639 #ifdef HAVE_COVARIANT_RETURNS
640             virtual AuthnQueryDescriptorType* buildObject(
641 #else
642             virtual xmltooling::XMLObject* buildObject(
643 #endif
644                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
645                 ) const;
646         
647             /** Singleton builder. */
648             static AuthnQueryDescriptorType* buildAuthnQueryDescriptorType() {
649                 const AuthnQueryDescriptorTypeBuilder* b = dynamic_cast<const AuthnQueryDescriptorTypeBuilder*>(
650                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AuthnQueryDescriptorType::TYPE_NAME))
651                     );
652                 if (b) {
653 #ifdef HAVE_COVARIANT_RETURNS
654                     return b->buildObject();
655 #else
656                     return dynamic_cast<AuthnQueryDescriptorType*>(b->buildObject());
657 #endif
658                 }
659                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthnQueryDescriptorType.");
660             }
661         };
662
663         /**
664          * Builder for AttributeQueryDescriptorType objects.
665          * 
666          * This is customized to return a RoleDescriptor element with an
667          * xsi:type of AttributeQueryDescriptorType.
668          */
669         class SAML_API AttributeQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder {
670         public:
671             virtual ~AttributeQueryDescriptorTypeBuilder() {}
672             /** Default builder. */
673 #ifdef HAVE_COVARIANT_RETURNS
674             virtual AttributeQueryDescriptorType* buildObject() const {
675 #else
676             virtual xmltooling::XMLObject* buildObject() const {
677 #endif
678                 xmltooling::QName schemaType(
679                     samlconstants::SAML20MD_QUERY_EXT_NS,AttributeQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX
680                     );
681                 return buildObject(
682                     samlconstants::SAML20MD_NS,AttributeQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType
683                     );
684             }
685             /** Builder that allows element/type override. */
686 #ifdef HAVE_COVARIANT_RETURNS
687             virtual AttributeQueryDescriptorType* buildObject(
688 #else
689             virtual xmltooling::XMLObject* buildObject(
690 #endif
691                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
692                 ) const;
693         
694             /** Singleton builder. */
695             static AttributeQueryDescriptorType* buildAttributeQueryDescriptorType() {
696                 const AttributeQueryDescriptorTypeBuilder* b = dynamic_cast<const AttributeQueryDescriptorTypeBuilder*>(
697                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AttributeQueryDescriptorType::TYPE_NAME))
698                     );
699                 if (b) {
700 #ifdef HAVE_COVARIANT_RETURNS
701                     return b->buildObject();
702 #else
703                     return dynamic_cast<AttributeQueryDescriptorType*>(b->buildObject());
704 #endif
705                 }
706                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AttributeQueryDescriptorType.");
707             }
708         };
709
710         /**
711          * Builder for AuthzDecisionQueryDescriptorType objects.
712          * 
713          * This is customized to return a RoleDescriptor element with an
714          * xsi:type of AuthzDecisionQueryDescriptorType.
715          */
716         class SAML_API AuthzDecisionQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder {
717         public:
718             virtual ~AuthzDecisionQueryDescriptorTypeBuilder() {}
719             /** Default builder. */
720 #ifdef HAVE_COVARIANT_RETURNS
721             virtual AuthzDecisionQueryDescriptorType* buildObject() const {
722 #else
723             virtual xmltooling::XMLObject* buildObject() const {
724 #endif
725                 xmltooling::QName schemaType(
726                     samlconstants::SAML20MD_QUERY_EXT_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX
727                     );
728                 return buildObject(
729                     samlconstants::SAML20MD_NS,AuthzDecisionQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType
730                     );
731             }
732             /** Builder that allows element/type override. */
733 #ifdef HAVE_COVARIANT_RETURNS
734             virtual AuthzDecisionQueryDescriptorType* buildObject(
735 #else
736             virtual xmltooling::XMLObject* buildObject(
737 #endif
738                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
739                 ) const;
740         
741             /** Singleton builder. */
742             static AuthzDecisionQueryDescriptorType* buildAuthzDecisionQueryDescriptorType() {
743                 const AuthzDecisionQueryDescriptorTypeBuilder* b = dynamic_cast<const AuthzDecisionQueryDescriptorTypeBuilder*>(
744                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME))
745                     );
746                 if (b) {
747 #ifdef HAVE_COVARIANT_RETURNS
748                     return b->buildObject();
749 #else
750                     return dynamic_cast<AuthzDecisionQueryDescriptorType*>(b->buildObject());
751 #endif
752                 }
753                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthzDecisionQueryDescriptorType.");
754             }
755         };
756
757         /**
758          * Registers builders and validators for SAML 2.0 Metadata classes into the runtime.
759          */
760         void SAML_API registerMetadataClasses();
761     };
762 };
763
764 #endif /* __saml2_metadata_h__ */