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