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