Add XML objects for DelegationRestriction and EntityAttributes extensions.
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / Metadata.h
1 /*
2  *  Copyright 2001-2009 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_XMLOBJECT2(SAML_API,RoleDescriptorType,RoleDescriptor,xmltooling::ElementExtensibleXMLObject,SAML 2.0 RoleDescriptor extension);
181         END_XMLOBJECT;
182
183         BEGIN_XMLOBJECT(SAML_API,EndpointType,xmltooling::ElementProxy,SAML 2.0 EndpointType type);
184             DECL_STRING_ATTRIB(Binding,BINDING);
185             DECL_STRING_ATTRIB(Location,LOCATION);
186             DECL_STRING_ATTRIB(ResponseLocation,RESPONSELOCATION);
187             /** EndpointType local name */
188             static const XMLCh TYPE_NAME[];
189         END_XMLOBJECT;
190
191         BEGIN_XMLOBJECT(SAML_API,IndexedEndpointType,EndpointType,SAML 2.0 IndexedEndpointType type);
192             DECL_INTEGER_ATTRIB(Index,INDEX);
193             DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,false);
194             /** IndexedEndpointType local name */
195             static const XMLCh TYPE_NAME[];
196         END_XMLOBJECT;
197
198         BEGIN_XMLOBJECT(SAML_API,ArtifactResolutionService,IndexedEndpointType,SAML 2.0 ArtifactResolutionService element);
199         END_XMLOBJECT;
200
201         BEGIN_XMLOBJECT(SAML_API,SingleLogoutService,EndpointType,SAML 2.0 SingleLogoutService element);
202         END_XMLOBJECT;
203
204         BEGIN_XMLOBJECT(SAML_API,ManageNameIDService,EndpointType,SAML 2.0 ManageNameIDService element);
205         END_XMLOBJECT;
206
207         BEGIN_XMLOBJECT(SAML_API,SSODescriptorType,RoleDescriptor,SAML 2.0 SSODescriptorType abstract type);
208             DECL_TYPED_CHILDREN(ArtifactResolutionService);
209             DECL_TYPED_CHILDREN(SingleLogoutService);
210             DECL_TYPED_CHILDREN(ManageNameIDService);
211             DECL_TYPED_CHILDREN(NameIDFormat);
212             /** SSODescriptorType local name */
213             static const XMLCh TYPE_NAME[];
214         END_XMLOBJECT;
215
216         BEGIN_XMLOBJECT(SAML_API,SingleSignOnService,EndpointType,SAML 2.0 SingleSignOnService element);
217         END_XMLOBJECT;
218
219         BEGIN_XMLOBJECT(SAML_API,NameIDMappingService,EndpointType,SAML 2.0 NameIDMappingService element);
220         END_XMLOBJECT;
221
222         BEGIN_XMLOBJECT(SAML_API,AssertionIDRequestService,EndpointType,SAML 2.0 AssertionIDRequestService element);
223         END_XMLOBJECT;
224
225         BEGIN_XMLOBJECT(SAML_API,IDPSSODescriptor,SSODescriptorType,SAML 2.0 IDPSSODescriptor element);
226             DECL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED,false);
227             DECL_TYPED_CHILDREN(SingleSignOnService);
228             DECL_TYPED_CHILDREN(NameIDMappingService);
229             DECL_TYPED_CHILDREN(AssertionIDRequestService);
230             DECL_TYPED_CHILDREN(AttributeProfile);
231             DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2);
232             /** IDPSSODescriptorType local name */
233             static const XMLCh TYPE_NAME[];
234             DECL_ELEMENT_QNAME;
235         END_XMLOBJECT;
236
237         BEGIN_XMLOBJECT(SAML_API,ServiceName,localizedNameType,SAML 2.0 ServiceName element);
238             DECL_SIMPLE_CONTENT(Name);
239         END_XMLOBJECT;
240
241         BEGIN_XMLOBJECT(SAML_API,ServiceDescription,localizedNameType,SAML 2.0 ServiceDescription element);
242             DECL_SIMPLE_CONTENT(Description);
243         END_XMLOBJECT;
244
245         BEGIN_XMLOBJECT(SAML_API,RequestedAttribute,saml2::Attribute,SAML 2.0 RequestedAttribute element);
246             DECL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED,false);
247             /** RequestedAttributeType local name */
248             static const XMLCh TYPE_NAME[];
249         END_XMLOBJECT;
250
251         BEGIN_XMLOBJECT(SAML_API,AttributeConsumingService,xmltooling::XMLObject,SAML 2.0 AttributeConsumingService element);
252             DECL_INTEGER_ATTRIB(Index,INDEX);
253             DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,false);
254             DECL_TYPED_CHILDREN(ServiceName);
255             DECL_TYPED_CHILDREN(ServiceDescription);
256             DECL_TYPED_CHILDREN(RequestedAttribute);
257             /** AttributeConsumingServiceType local name */
258             static const XMLCh TYPE_NAME[];
259         END_XMLOBJECT;
260
261         BEGIN_XMLOBJECT(SAML_API,AssertionConsumerService,IndexedEndpointType,SAML 2.0 AssertionConsumerService element);
262         END_XMLOBJECT;
263
264         BEGIN_XMLOBJECT(SAML_API,SPSSODescriptor,SSODescriptorType,SAML 2.0 SPSSODescriptor element);
265             DECL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED,false);
266             DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false);
267             DECL_TYPED_CHILDREN(AssertionConsumerService);
268             DECL_TYPED_CHILDREN(AttributeConsumingService);
269             /** SPSSODescriptorType local name */
270             static const XMLCh TYPE_NAME[];
271             DECL_ELEMENT_QNAME;
272         END_XMLOBJECT;
273
274         BEGIN_XMLOBJECT(SAML_API,AuthnQueryService,EndpointType,SAML 2.0 AuthnQueryService element);
275         END_XMLOBJECT;
276
277         BEGIN_XMLOBJECT(SAML_API,AuthnAuthorityDescriptor,RoleDescriptor,SAML 2.0 AuthnAuthorityDescriptor element);
278             DECL_TYPED_CHILDREN(AuthnQueryService);
279             DECL_TYPED_CHILDREN(AssertionIDRequestService);
280             DECL_TYPED_CHILDREN(NameIDFormat);
281             /** AuthnAuthorityDescriptorType local name */
282             static const XMLCh TYPE_NAME[];
283             DECL_ELEMENT_QNAME;
284         END_XMLOBJECT;
285
286         BEGIN_XMLOBJECT(SAML_API,AuthzService,EndpointType,SAML 2.0 AuthzService element);
287         END_XMLOBJECT;
288
289         BEGIN_XMLOBJECT(SAML_API,PDPDescriptor,RoleDescriptor,SAML 2.0 PDPDescriptor element);
290             DECL_TYPED_CHILDREN(AuthzService);
291             DECL_TYPED_CHILDREN(AssertionIDRequestService);
292             DECL_TYPED_CHILDREN(NameIDFormat);
293             /** PDPDescriptorType local name */
294             static const XMLCh TYPE_NAME[];
295             DECL_ELEMENT_QNAME;
296         END_XMLOBJECT;
297
298         BEGIN_XMLOBJECT(SAML_API,AttributeService,EndpointType,SAML 2.0 AttributeService element);
299         END_XMLOBJECT;
300
301         BEGIN_XMLOBJECT(SAML_API,AttributeAuthorityDescriptor,RoleDescriptor,SAML 2.0 AttributeAuthorityDescriptor element);
302             DECL_TYPED_CHILDREN(AttributeService);
303             DECL_TYPED_CHILDREN(AssertionIDRequestService);
304             DECL_TYPED_CHILDREN(NameIDFormat);
305             DECL_TYPED_CHILDREN(AttributeProfile);
306             DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2);
307             /** AttributeAuthorityDescriptorType local name */
308             static const XMLCh TYPE_NAME[];
309             DECL_ELEMENT_QNAME;
310         END_XMLOBJECT;
311
312         BEGIN_XMLOBJECT(SAML_API,QueryDescriptorType,RoleDescriptor,SAML 2.0 QueryDescriptorType abstract type);
313             DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false);
314             DECL_TYPED_CHILDREN(NameIDFormat);
315             /** QueryDescriptorType local name */
316             static const XMLCh TYPE_NAME[];
317         END_XMLOBJECT;
318
319         BEGIN_XMLOBJECT(SAML_API,AuthnQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthnQueryDescriptorType extension type);
320             /** AuthnQueryDescriptorType local name */
321             static const XMLCh TYPE_NAME[];
322             DECL_TYPE_QNAME;
323         END_XMLOBJECT;
324
325         BEGIN_XMLOBJECT(SAML_API,AttributeQueryDescriptorType,QueryDescriptorType,SAML 2.0 AttributeQueryDescriptorType extension type);
326             DECL_TYPED_CHILDREN(AttributeConsumingService);
327             /** AttributeQueryDescriptorType local name */
328             static const XMLCh TYPE_NAME[];
329             DECL_TYPE_QNAME;
330         END_XMLOBJECT;
331
332         BEGIN_XMLOBJECT(SAML_API,AuthzDecisionQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthzDecisionQueryDescriptorType extension type);
333             DECL_TYPED_CHILDREN(ActionNamespace);
334             /** AuthzDecisionQueryDescriptorType local name */
335             static const XMLCh TYPE_NAME[];
336             DECL_TYPE_QNAME;
337         END_XMLOBJECT;
338
339         BEGIN_XMLOBJECT4(SAML_API,AffiliationDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
340                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 AffiliationDescriptor element);
341             DECL_STRING_ATTRIB(ID,ID);
342             DECL_STRING_ATTRIB(AffiliationOwnerID,AFFILIATIONOWNERID);
343             DECL_TYPED_CHILD(Extensions);
344             DECL_TYPED_CHILDREN(AffiliateMember);
345             DECL_TYPED_CHILDREN(KeyDescriptor);
346             /** AffiliationDescriptorType local name */
347             static const XMLCh TYPE_NAME[];
348         END_XMLOBJECT;
349
350         BEGIN_XMLOBJECT4(SAML_API,EntityDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
351                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 EntityDescriptor element);
352             DECL_STRING_ATTRIB(ID,ID);
353             DECL_STRING_ATTRIB(EntityID,ENTITYID);
354             DECL_TYPED_CHILD(Extensions);
355             DECL_TYPED_CHILD(AffiliationDescriptor);
356             DECL_TYPED_CHILDREN(RoleDescriptor);
357             DECL_TYPED_CHILDREN(IDPSSODescriptor);
358             DECL_TYPED_CHILDREN(SPSSODescriptor);
359             DECL_TYPED_CHILDREN(AuthnAuthorityDescriptor);
360             DECL_TYPED_CHILDREN(AttributeAuthorityDescriptor);
361             DECL_TYPED_CHILDREN(PDPDescriptor);
362             DECL_TYPED_CHILDREN(AuthnQueryDescriptorType);
363             DECL_TYPED_CHILDREN(AttributeQueryDescriptorType);
364             DECL_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType);
365             DECL_TYPED_CHILD(Organization);
366             DECL_TYPED_CHILDREN(ContactPerson);
367             DECL_TYPED_CHILDREN(AdditionalMetadataLocation);
368             /** Finds an arbitrary role type supporting a given protocol. */
369             virtual const RoleDescriptor* getRoleDescriptor(const xmltooling::QName& qname, const XMLCh* protocol) const=0;
370             /** EntityDescriptorType local name */
371             static const XMLCh TYPE_NAME[];
372         END_XMLOBJECT;
373
374         BEGIN_XMLOBJECT3(SAML_API,EntitiesDescriptor,SignableObject,CacheableSAMLObject,
375                 TimeBoundSAMLObject,SAML 2.0 EntitiesDescriptor element);
376             DECL_STRING_ATTRIB(ID,ID);
377             DECL_STRING_ATTRIB(Name,NAME);
378             DECL_TYPED_CHILD(Extensions);
379             DECL_TYPED_CHILDREN(EntityDescriptor);
380             DECL_TYPED_CHILDREN(EntitiesDescriptor);
381             /** EntitiesDescriptorType local name */
382             static const XMLCh TYPE_NAME[];
383         END_XMLOBJECT;
384
385         BEGIN_XMLOBJECT(SAML_API,EntityAttributes,xmltooling::XMLObject,SAML Metadata Extension for Entity Attributes element);
386             DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2);
387             DECL_TYPED_FOREIGN_CHILDREN(Assertion,saml2);
388             /** EntityAttributesType local name */
389             static const XMLCh TYPE_NAME[];
390         END_XMLOBJECT;
391
392         /**
393          * Predicate to test a role for validity and protocol support.
394          */
395         class isValidForProtocol
396         {
397         public:
398             /**
399              * Constructor.
400              *
401              * @param protocol  support constant to test for
402              */
403             isValidForProtocol(const XMLCh* protocol) : m_time(time(NULL)), m_protocol(protocol) {
404             }
405
406             /**
407              * Returns true iff the supplied role is valid now and supports the right protocol.
408              *
409              * @param role  role to test
410              * @return  result of predicate
411              */
412             bool operator()(const RoleDescriptor* role) const {
413                 return role ? (role->isValid(m_time) && role->hasSupport(m_protocol)) : false;
414             }
415
416         private:
417             time_t m_time;
418             const XMLCh* m_protocol;
419         };
420
421         /**
422          * Predicate to test a role for type equivalence, validity, and protocol support.
423          */
424         class ofTypeValidForProtocol : public isValidForProtocol, public xmltooling::hasSchemaType
425         {
426         public:
427             /**
428              * Constructor.
429              *
430              * @param q         schema type to test for
431              * @param protocol  support constant to test for
432              */
433             ofTypeValidForProtocol(const xmltooling::QName& q, const XMLCh* protocol)
434                 : isValidForProtocol(protocol), xmltooling::hasSchemaType(q)  {
435             }
436
437             /**
438              * Returns true iff the supplied role is of the right type, valid now, and supports the right protocol.
439              *
440              * @param role  role to test
441              * @return  result of predicate
442              */
443             bool operator()(const RoleDescriptor* role) const {
444                 return xmltooling::hasSchemaType::operator()(role) && isValidForProtocol::operator()(role);
445             }
446         };
447
448         DECL_SAML2MDOBJECTBUILDER(AdditionalMetadataLocation);
449         DECL_SAML2MDOBJECTBUILDER(AffiliateMember);
450         DECL_SAML2MDOBJECTBUILDER(AffiliationDescriptor);
451         DECL_SAML2MDOBJECTBUILDER(ArtifactResolutionService);
452         DECL_SAML2MDOBJECTBUILDER(AssertionConsumerService);
453         DECL_SAML2MDOBJECTBUILDER(AssertionIDRequestService);
454         DECL_SAML2MDOBJECTBUILDER(AttributeAuthorityDescriptor);
455         DECL_SAML2MDOBJECTBUILDER(AttributeConsumingService);
456         DECL_SAML2MDOBJECTBUILDER(AttributeProfile);
457         DECL_SAML2MDOBJECTBUILDER(AttributeService);
458         DECL_SAML2MDOBJECTBUILDER(AuthnAuthorityDescriptor);
459         DECL_SAML2MDOBJECTBUILDER(AuthnQueryService);
460         DECL_SAML2MDOBJECTBUILDER(AuthzService);
461         DECL_SAML2MDOBJECTBUILDER(Company);
462         DECL_SAML2MDOBJECTBUILDER(ContactPerson);
463         DECL_SAML2MDOBJECTBUILDER(EmailAddress);
464         DECL_SAML2MDOBJECTBUILDER(EntitiesDescriptor);
465         DECL_SAML2MDOBJECTBUILDER(EntityDescriptor);
466         DECL_SAML2MDOBJECTBUILDER(Extensions);
467         DECL_SAML2MDOBJECTBUILDER(GivenName);
468         DECL_SAML2MDOBJECTBUILDER(IDPSSODescriptor);
469         DECL_SAML2MDOBJECTBUILDER(KeyDescriptor);
470         DECL_SAML2MDOBJECTBUILDER(ManageNameIDService);
471         DECL_SAML2MDOBJECTBUILDER(NameIDFormat);
472         DECL_SAML2MDOBJECTBUILDER(NameIDMappingService);
473         DECL_SAML2MDOBJECTBUILDER(Organization);
474         DECL_SAML2MDOBJECTBUILDER(OrganizationName);
475         DECL_SAML2MDOBJECTBUILDER(OrganizationDisplayName);
476         DECL_SAML2MDOBJECTBUILDER(OrganizationURL);
477         DECL_SAML2MDOBJECTBUILDER(PDPDescriptor);
478         DECL_SAML2MDOBJECTBUILDER(RequestedAttribute);
479         DECL_SAML2MDOBJECTBUILDER(ServiceDescription);
480         DECL_SAML2MDOBJECTBUILDER(ServiceName);
481         DECL_SAML2MDOBJECTBUILDER(SingleLogoutService);
482         DECL_SAML2MDOBJECTBUILDER(SingleSignOnService);
483         DECL_SAML2MDOBJECTBUILDER(SPSSODescriptor);
484         DECL_SAML2MDOBJECTBUILDER(SurName);
485         DECL_SAML2MDOBJECTBUILDER(TelephoneNumber);
486
487         DECL_XMLOBJECTBUILDER(SAML_API,ActionNamespace,samlconstants::SAML20MD_QUERY_EXT_NS,samlconstants::SAML20MD_QUERY_EXT_PREFIX);
488         DECL_XMLOBJECTBUILDER(SAML_API,SourceID,samlconstants::SAML1MD_NS,samlconstants::SAML1MD_PREFIX);
489         DECL_XMLOBJECTBUILDER(SAML_API,EntityAttributes,samlconstants::SAML20MD_ENTITY_ATTRIBUTE_NS,samlconstants::SAML20MD_ENTITY_ATTRIBUTE_PREFIX);
490
491         /**
492          * Builder for localizedNameType objects.
493          *
494          * This is customized to force the element name to be specified.
495          */
496         class SAML_API localizedNameTypeBuilder : public xmltooling::XMLObjectBuilder {
497         public:
498             virtual ~localizedNameTypeBuilder() {}
499             /** Builder that allows element/type override. */
500 #ifdef HAVE_COVARIANT_RETURNS
501             virtual localizedNameType* buildObject(
502 #else
503             virtual xmltooling::XMLObject* buildObject(
504 #endif
505                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
506                 ) const;
507
508             /** Singleton builder. */
509             static localizedNameType* buildlocalizedNameType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
510                 const localizedNameTypeBuilder* b = dynamic_cast<const localizedNameTypeBuilder*>(
511                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,localizedNameType::TYPE_NAME))
512                     );
513                 if (b) {
514                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,localizedNameType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
515 #ifdef HAVE_COVARIANT_RETURNS
516                     return b->buildObject(nsURI, localName, prefix, &schemaType);
517 #else
518                     return dynamic_cast<localizedNameType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
519 #endif
520                 }
521                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedNameType.");
522             }
523         };
524
525         /**
526          * Builder for localizedURIType objects.
527          *
528          * This is customized to force the element name to be specified.
529          */
530         class SAML_API localizedURITypeBuilder : public xmltooling::XMLObjectBuilder {
531         public:
532             virtual ~localizedURITypeBuilder() {}
533             /** Builder that allows element/type override. */
534 #ifdef HAVE_COVARIANT_RETURNS
535             virtual localizedURIType* buildObject(
536 #else
537             virtual xmltooling::XMLObject* buildObject(
538 #endif
539                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
540                 ) const;
541
542             /** Singleton builder. */
543             static localizedURIType* buildlocalizedURIType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
544                 const localizedURITypeBuilder* b = dynamic_cast<const localizedURITypeBuilder*>(
545                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,localizedURIType::TYPE_NAME))
546                     );
547                 if (b) {
548                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,localizedURIType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
549 #ifdef HAVE_COVARIANT_RETURNS
550                     return b->buildObject(nsURI, localName, prefix, &schemaType);
551 #else
552                     return dynamic_cast<localizedURIType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
553 #endif
554                 }
555                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedURIType.");
556             }
557         };
558
559         /**
560          * Builder for EndpointType objects.
561          *
562          * This is customized to force the element name to be specified.
563          */
564         class SAML_API EndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
565         public:
566             virtual ~EndpointTypeBuilder() {}
567             /** Builder that allows element/type override. */
568 #ifdef HAVE_COVARIANT_RETURNS
569             virtual EndpointType* buildObject(
570 #else
571             virtual xmltooling::XMLObject* buildObject(
572 #endif
573                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
574                 ) const;
575
576             /** Singleton builder. */
577             static EndpointType* buildEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
578                 const EndpointTypeBuilder* b = dynamic_cast<const EndpointTypeBuilder*>(
579                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,EndpointType::TYPE_NAME))
580                     );
581                 if (b) {
582                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,EndpointType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
583 #ifdef HAVE_COVARIANT_RETURNS
584                     return b->buildObject(nsURI, localName, prefix, &schemaType);
585 #else
586                     return dynamic_cast<EndpointType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
587 #endif
588                 }
589                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for EndpointType.");
590             }
591         };
592
593         /**
594          * Builder for IndexedEndpointType objects.
595          *
596          * This is customized to force the element name to be specified.
597          */
598         class SAML_API IndexedEndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
599         public:
600             virtual ~IndexedEndpointTypeBuilder() {}
601             /** Builder that allows element/type override. */
602 #ifdef HAVE_COVARIANT_RETURNS
603             virtual IndexedEndpointType* buildObject(
604 #else
605             virtual xmltooling::XMLObject* buildObject(
606 #endif
607                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
608                 ) const;
609
610             /** Singleton builder. */
611             static IndexedEndpointType* buildIndexedEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
612                 const IndexedEndpointTypeBuilder* b = dynamic_cast<const IndexedEndpointTypeBuilder*>(
613                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME))
614                     );
615                 if (b) {
616                     xmltooling::QName schemaType(samlconstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME,samlconstants::SAML20MD_PREFIX);
617 #ifdef HAVE_COVARIANT_RETURNS
618                     return b->buildObject(nsURI, localName, prefix, &schemaType);
619 #else
620                     return dynamic_cast<IndexedEndpointType*>(b->buildObject(nsURI, localName, prefix, &schemaType));
621 #endif
622                 }
623                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for IndexedEndpointType.");
624             }
625         };
626
627         /**
628          * Builder for RoleDescriptor extension objects.
629          *
630          * This is customized to force the schema type to be specified.
631          */
632         class SAML_API RoleDescriptorBuilder : public xmltooling::XMLObjectBuilder {
633         public:
634             virtual ~RoleDescriptorBuilder() {}
635             /** Builder that allows element/type override. */
636 #ifdef HAVE_COVARIANT_RETURNS
637             virtual RoleDescriptor* buildObject(
638 #else
639             virtual xmltooling::XMLObject* buildObject(
640 #endif
641                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
642                 ) const;
643
644             /** Singleton builder. */
645             static RoleDescriptor* buildRoleDescriptor(const xmltooling::QName& schemaType) {
646                 const RoleDescriptorBuilder* b = dynamic_cast<const RoleDescriptorBuilder*>(
647                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,RoleDescriptor::LOCAL_NAME))
648                     );
649                 if (b) {
650 #ifdef HAVE_COVARIANT_RETURNS
651                     return b->buildObject(samlconstants::SAML20MD_NS, RoleDescriptor::LOCAL_NAME, samlconstants::SAML20MD_PREFIX, &schemaType);
652 #else
653                     return dynamic_cast<RoleDescriptor*>(b->buildObject(samlconstants::SAML20MD_NS, RoleDescriptor::LOCAL_NAME, samlconstants::SAML20MD_PREFIX, &schemaType));
654 #endif
655                 }
656                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for RoleDescriptor.");
657             }
658         };
659
660         /**
661          * Builder for AuthnQueryDescriptorType objects.
662          *
663          * This is customized to return a RoleDescriptor element with an
664          * xsi:type of AuthnQueryDescriptorType.
665          */
666         class SAML_API AuthnQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder {
667         public:
668             virtual ~AuthnQueryDescriptorTypeBuilder() {}
669             /** Default builder. */
670 #ifdef HAVE_COVARIANT_RETURNS
671             virtual AuthnQueryDescriptorType* buildObject() const {
672 #else
673             virtual xmltooling::XMLObject* buildObject() const {
674 #endif
675                 xmltooling::QName schemaType(
676                     samlconstants::SAML20MD_QUERY_EXT_NS,AuthnQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX
677                     );
678                 return buildObject(
679                     samlconstants::SAML20MD_NS,AuthnQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType
680                     );
681             }
682             /** Builder that allows element/type override. */
683 #ifdef HAVE_COVARIANT_RETURNS
684             virtual AuthnQueryDescriptorType* buildObject(
685 #else
686             virtual xmltooling::XMLObject* buildObject(
687 #endif
688                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
689                 ) const;
690
691             /** Singleton builder. */
692             static AuthnQueryDescriptorType* buildAuthnQueryDescriptorType() {
693                 const AuthnQueryDescriptorTypeBuilder* b = dynamic_cast<const AuthnQueryDescriptorTypeBuilder*>(
694                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AuthnQueryDescriptorType::TYPE_NAME))
695                     );
696                 if (b) {
697 #ifdef HAVE_COVARIANT_RETURNS
698                     return b->buildObject();
699 #else
700                     return dynamic_cast<AuthnQueryDescriptorType*>(b->buildObject());
701 #endif
702                 }
703                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthnQueryDescriptorType.");
704             }
705         };
706
707         /**
708          * Builder for AttributeQueryDescriptorType objects.
709          *
710          * This is customized to return a RoleDescriptor element with an
711          * xsi:type of AttributeQueryDescriptorType.
712          */
713         class SAML_API AttributeQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder {
714         public:
715             virtual ~AttributeQueryDescriptorTypeBuilder() {}
716             /** Default builder. */
717 #ifdef HAVE_COVARIANT_RETURNS
718             virtual AttributeQueryDescriptorType* buildObject() const {
719 #else
720             virtual xmltooling::XMLObject* buildObject() const {
721 #endif
722                 xmltooling::QName schemaType(
723                     samlconstants::SAML20MD_QUERY_EXT_NS,AttributeQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX
724                     );
725                 return buildObject(
726                     samlconstants::SAML20MD_NS,AttributeQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType
727                     );
728             }
729             /** Builder that allows element/type override. */
730 #ifdef HAVE_COVARIANT_RETURNS
731             virtual AttributeQueryDescriptorType* buildObject(
732 #else
733             virtual xmltooling::XMLObject* buildObject(
734 #endif
735                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
736                 ) const;
737
738             /** Singleton builder. */
739             static AttributeQueryDescriptorType* buildAttributeQueryDescriptorType() {
740                 const AttributeQueryDescriptorTypeBuilder* b = dynamic_cast<const AttributeQueryDescriptorTypeBuilder*>(
741                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AttributeQueryDescriptorType::TYPE_NAME))
742                     );
743                 if (b) {
744 #ifdef HAVE_COVARIANT_RETURNS
745                     return b->buildObject();
746 #else
747                     return dynamic_cast<AttributeQueryDescriptorType*>(b->buildObject());
748 #endif
749                 }
750                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AttributeQueryDescriptorType.");
751             }
752         };
753
754         /**
755          * Builder for AuthzDecisionQueryDescriptorType objects.
756          *
757          * This is customized to return a RoleDescriptor element with an
758          * xsi:type of AuthzDecisionQueryDescriptorType.
759          */
760         class SAML_API AuthzDecisionQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder {
761         public:
762             virtual ~AuthzDecisionQueryDescriptorTypeBuilder() {}
763             /** Default builder. */
764 #ifdef HAVE_COVARIANT_RETURNS
765             virtual AuthzDecisionQueryDescriptorType* buildObject() const {
766 #else
767             virtual xmltooling::XMLObject* buildObject() const {
768 #endif
769                 xmltooling::QName schemaType(
770                     samlconstants::SAML20MD_QUERY_EXT_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX
771                     );
772                 return buildObject(
773                     samlconstants::SAML20MD_NS,AuthzDecisionQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType
774                     );
775             }
776             /** Builder that allows element/type override. */
777 #ifdef HAVE_COVARIANT_RETURNS
778             virtual AuthzDecisionQueryDescriptorType* buildObject(
779 #else
780             virtual xmltooling::XMLObject* buildObject(
781 #endif
782                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
783                 ) const;
784
785             /** Singleton builder. */
786             static AuthzDecisionQueryDescriptorType* buildAuthzDecisionQueryDescriptorType() {
787                 const AuthzDecisionQueryDescriptorTypeBuilder* b = dynamic_cast<const AuthzDecisionQueryDescriptorTypeBuilder*>(
788                     XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME))
789                     );
790                 if (b) {
791 #ifdef HAVE_COVARIANT_RETURNS
792                     return b->buildObject();
793 #else
794                     return dynamic_cast<AuthzDecisionQueryDescriptorType*>(b->buildObject());
795 #endif
796                 }
797                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthzDecisionQueryDescriptorType.");
798             }
799         };
800
801         /**
802          * Registers builders and validators for SAML 2.0 Metadata classes into the runtime.
803          */
804         void SAML_API registerMetadataClasses();
805     };
806 };
807
808 #endif /* __saml2_metadata_h__ */