Revise boolean attribute methods to handle defaults.
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / Metadata.h
1 /*
2  *  Copyright 2001-2006 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file 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 <saml/util/SAMLConstants.h>
28
29 #include <ctime>
30 #include <xmltooling/AttributeExtensibleXMLObject.h>
31 #include <xmltooling/ElementProxy.h>
32 #include <xmltooling/SimpleElement.h>
33 #include <xmltooling/XMLObjectBuilder.h>
34 #include <xmltooling/encryption/Encryption.h>
35 #include <xmltooling/signature/KeyInfo.h>
36 #include <xmltooling/signature/Signature.h>
37 #include <xmltooling/util/DateTime.h>
38
39 #define DECL_SAML2MDOBJECTBUILDER(cname) \
40     DECL_XMLOBJECTBUILDER(SAML_API,cname,opensaml::SAMLConstants::SAML20MD_NS,opensaml::SAMLConstants::SAML20MD_PREFIX)
41
42 namespace opensaml {
43
44     /**
45      * @namespace opensaml::saml2md
46      * SAML 2.0 metadata namespace
47      */
48     namespace saml2md {
49         
50         /**
51          * Base class for metadata objects that feature a cacheDuration attribute.
52          */
53         class SAML_API CacheableSAMLObject : public virtual xmltooling::XMLObject
54         {
55         protected:
56             CacheableSAMLObject() {}
57         public:
58             ~CacheableSAMLObject() {}
59             DECL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION);
60         };
61
62         /**
63          * Base class for metadata objects that feature a validUntil attribute.
64          */
65         class SAML_API TimeBoundSAMLObject : public virtual xmltooling::XMLObject
66         {
67         protected:
68             TimeBoundSAMLObject() {}
69         public:
70             ~TimeBoundSAMLObject() {}
71             DECL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL);
72             /** Returns true iff the object is valid at the current time. */
73             bool isValid() const {
74                 return time(NULL) <= 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::SimpleElement,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::SimpleElement,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_XMLOBJECT_CONTENT(Name);
104         END_XMLOBJECT;
105
106         BEGIN_XMLOBJECT(SAML_API,OrganizationDisplayName,localizedNameType,SAML 2.0 OrganizationDisplayName element);
107             DECL_XMLOBJECT_CONTENT(Name);
108         END_XMLOBJECT;
109
110         BEGIN_XMLOBJECT(SAML_API,OrganizationURL,localizedURIType,SAML 2.0 OrganizationURL element);
111             DECL_XMLOBJECT_CONTENT(URL);
112         END_XMLOBJECT;
113         
114         BEGIN_XMLOBJECT(SAML_API,Extensions,xmltooling::ElementProxy,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::SimpleElement,SAML 2.0 AdditionalMetadataLocation element);
151             DECL_STRING_ATTRIB(Namespace,NAMESPACE);
152             DECL_XMLOBJECT_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             DECL_STRING_ATTRIB(ErrorURL,ERRORURL);
176             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
177             DECL_TYPED_CHILD(Extensions);
178             DECL_TYPED_CHILDREN(KeyDescriptor);
179             DECL_TYPED_CHILD(Organization);
180             DECL_TYPED_CHILDREN(ContactPerson);
181         END_XMLOBJECT;
182
183         BEGIN_XMLOBJECT2(SAML_API,EndpointType,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,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         END_XMLOBJECT;
235
236         BEGIN_XMLOBJECT(SAML_API,ServiceName,localizedNameType,SAML 2.0 ServiceName element);
237             DECL_XMLOBJECT_CONTENT(Name);
238         END_XMLOBJECT;
239
240         BEGIN_XMLOBJECT(SAML_API,ServiceDescription,localizedNameType,SAML 2.0 ServiceDescription element);
241             DECL_XMLOBJECT_CONTENT(Description);
242         END_XMLOBJECT;
243
244         BEGIN_XMLOBJECT(SAML_API,RequestedAttribute,saml2::Attribute,SAML 2.0 RequestedAttribute element);
245             DECL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED,false);
246             /** RequestedAttributeType local name */
247             static const XMLCh TYPE_NAME[];
248         END_XMLOBJECT;
249
250         BEGIN_XMLOBJECT(SAML_API,AttributeConsumingService,xmltooling::XMLObject,SAML 2.0 AttributeConsumingService element);
251             DECL_INTEGER_ATTRIB(Index,INDEX);
252             DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,false);
253             DECL_TYPED_CHILDREN(ServiceName);
254             DECL_TYPED_CHILDREN(ServiceDescription);
255             DECL_TYPED_CHILDREN(RequestedAttribute);
256             /** AttributeConsumingServiceType local name */
257             static const XMLCh TYPE_NAME[];
258         END_XMLOBJECT;
259
260         BEGIN_XMLOBJECT(SAML_API,AssertionConsumerService,IndexedEndpointType,SAML 2.0 AssertionConsumerService element);
261         END_XMLOBJECT;
262
263         BEGIN_XMLOBJECT(SAML_API,SPSSODescriptor,SSODescriptorType,SAML 2.0 SPSSODescriptor element);
264             DECL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED,false);
265             DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false);
266             DECL_TYPED_CHILDREN(AssertionConsumerService);
267             DECL_TYPED_CHILDREN(AttributeConsumingService);
268             /** SPSSODescriptorType local name */
269             static const XMLCh TYPE_NAME[];
270         END_XMLOBJECT;
271
272         BEGIN_XMLOBJECT(SAML_API,AuthnQueryService,EndpointType,SAML 2.0 AuthnQueryService element);
273         END_XMLOBJECT;
274
275         BEGIN_XMLOBJECT(SAML_API,AuthnAuthorityDescriptor,RoleDescriptor,SAML 2.0 AuthnAuthorityDescriptor element);
276             DECL_TYPED_CHILDREN(AuthnQueryService);
277             DECL_TYPED_CHILDREN(AssertionIDRequestService);
278             DECL_TYPED_CHILDREN(NameIDFormat);
279             /** AuthnAuthorityDescriptorType local name */
280             static const XMLCh TYPE_NAME[];
281         END_XMLOBJECT;
282
283         BEGIN_XMLOBJECT(SAML_API,AuthzService,EndpointType,SAML 2.0 AuthzService element);
284         END_XMLOBJECT;
285
286         BEGIN_XMLOBJECT(SAML_API,PDPDescriptor,RoleDescriptor,SAML 2.0 PDPDescriptor element);
287             DECL_TYPED_CHILDREN(AuthzService);
288             DECL_TYPED_CHILDREN(AssertionIDRequestService);
289             DECL_TYPED_CHILDREN(NameIDFormat);
290             /** PDPDescriptorType local name */
291             static const XMLCh TYPE_NAME[];
292         END_XMLOBJECT;
293
294         BEGIN_XMLOBJECT(SAML_API,AttributeService,EndpointType,SAML 2.0 AttributeService element);
295         END_XMLOBJECT;
296
297         BEGIN_XMLOBJECT(SAML_API,AttributeAuthorityDescriptor,RoleDescriptor,SAML 2.0 AttributeAuthorityDescriptor element);
298             DECL_TYPED_CHILDREN(AttributeService);
299             DECL_TYPED_CHILDREN(AssertionIDRequestService);
300             DECL_TYPED_CHILDREN(NameIDFormat);
301             DECL_TYPED_CHILDREN(AttributeProfile);
302             DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2);
303             /** AttributeAuthorityDescriptorType local name */
304             static const XMLCh TYPE_NAME[];
305         END_XMLOBJECT;
306
307         BEGIN_XMLOBJECT(SAML_API,QueryDescriptorType,RoleDescriptor,SAML 2.0 QueryDescriptorType abstract type);
308             DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false);
309             DECL_TYPED_CHILDREN(NameIDFormat);
310             /** QueryDescriptorType local name */
311             static const XMLCh TYPE_NAME[];
312         END_XMLOBJECT;
313
314         BEGIN_XMLOBJECT(SAML_API,AuthnQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthnQueryDescriptorType extension type);
315             /** AuthnQueryDescriptorType local name */
316             static const XMLCh TYPE_NAME[];
317         END_XMLOBJECT;
318
319         BEGIN_XMLOBJECT(SAML_API,AttributeQueryDescriptorType,QueryDescriptorType,SAML 2.0 AttributeQueryDescriptorType extension type);
320             DECL_TYPED_CHILDREN(AttributeConsumingService);
321             /** AttributeQueryDescriptorType local name */
322             static const XMLCh TYPE_NAME[];
323         END_XMLOBJECT;
324
325         BEGIN_XMLOBJECT(SAML_API,AuthzDecisionQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthzDecisionQueryDescriptorType extension type);
326             DECL_TYPED_CHILDREN(ActionNamespace);
327             /** AuthzDecisionQueryDescriptorType local name */
328             static const XMLCh TYPE_NAME[];
329         END_XMLOBJECT;
330
331         BEGIN_XMLOBJECT4(SAML_API,AffiliationDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
332                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 AffiliationDescriptor element);
333             DECL_STRING_ATTRIB(ID,ID);
334             DECL_STRING_ATTRIB(AffiliationOwnerID,AFFILIATIONOWNERID);
335             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
336             DECL_TYPED_CHILD(Extensions);
337             DECL_TYPED_CHILDREN(AffiliateMember);
338             DECL_TYPED_CHILDREN(KeyDescriptor);
339             /** AffiliationDescriptorType local name */
340             static const XMLCh TYPE_NAME[];
341         END_XMLOBJECT;
342
343         BEGIN_XMLOBJECT4(SAML_API,EntityDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject,
344                 CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 EntityDescriptor element);
345             DECL_STRING_ATTRIB(ID,ID);
346             DECL_STRING_ATTRIB(EntityID,ENTITYID);
347             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
348             DECL_TYPED_CHILD(Extensions);
349             DECL_TYPED_CHILD(AffiliationDescriptor);
350             DECL_TYPED_CHILDREN(RoleDescriptor);
351             DECL_TYPED_CHILDREN(IDPSSODescriptor);
352             DECL_TYPED_CHILDREN(SPSSODescriptor);
353             DECL_TYPED_CHILDREN(AuthnAuthorityDescriptor);
354             DECL_TYPED_CHILDREN(AttributeAuthorityDescriptor);
355             DECL_TYPED_CHILDREN(PDPDescriptor);
356             DECL_TYPED_CHILDREN(AuthnQueryDescriptorType);
357             DECL_TYPED_CHILDREN(AttributeQueryDescriptorType);
358             DECL_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType);
359             /** Finds an IDP role supporting a given protocol. */
360             virtual const IDPSSODescriptor* getIDPSSODescriptor(const XMLCh* protocol) const=0;
361             /** Finds an SP role supporting a given protocol. */
362             virtual const SPSSODescriptor* getSPSSODescriptor(const XMLCh* protocol) const=0;
363             /** Finds an Authn Authority role supporting a given protocol. */
364             virtual const AuthnAuthorityDescriptor* getAuthnAuthorityDescriptor(const XMLCh* protocol) const=0;
365             /** Finds an Attribute Authority role supporting a given protocol. */
366             virtual const AttributeAuthorityDescriptor* getAttributeAuthorityDescriptor(const XMLCh* protocol) const=0;
367             /** Finds a PDP role supporting a given protocol. */
368             virtual const PDPDescriptor* getPDPDescriptor(const XMLCh* protocol) const=0;
369             /** Finds an AuthnQuery role supporting a given protocol. */
370             virtual const AuthnQueryDescriptorType* getAuthnQueryDescriptorType(const XMLCh* protocol) const=0;
371             /** Finds an AttributeQuery role supporting a given protocol. */
372             virtual const AttributeQueryDescriptorType* getAttributeQueryDescriptorType(const XMLCh* protocol) const=0;
373             /** Finds an AuthzDecisionQuery role supporting a given protocol. */
374             virtual const AuthzDecisionQueryDescriptorType* getAuthzDecisionQueryDescriptorType(const XMLCh* protocol) const=0;
375             /** Finds an extension role supporting a given protocol. */
376             virtual const RoleDescriptor* getRoleDescriptor(xmltooling::QName& qname, const XMLCh* protocol) const=0;
377             /** EntityDescriptorType local name */
378             static const XMLCh TYPE_NAME[];
379         END_XMLOBJECT;
380
381         BEGIN_XMLOBJECT3(SAML_API,EntitiesDescriptor,SignableObject,CacheableSAMLObject,
382                 TimeBoundSAMLObject,SAML 2.0 EntitiesDescriptor element);
383             DECL_STRING_ATTRIB(ID,ID);
384             DECL_STRING_ATTRIB(Name,NAME);
385             DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
386             DECL_TYPED_CHILD(Extensions);
387             DECL_TYPED_CHILDREN(EntityDescriptor);
388             DECL_TYPED_CHILDREN(EntitiesDescriptor);
389             /** EntitiesDescriptorType local name */
390             static const XMLCh TYPE_NAME[];
391         END_XMLOBJECT;
392
393         DECL_SAML2MDOBJECTBUILDER(AdditionalMetadataLocation);
394         DECL_SAML2MDOBJECTBUILDER(AffiliateMember);
395         DECL_SAML2MDOBJECTBUILDER(AffiliationDescriptor);
396         DECL_SAML2MDOBJECTBUILDER(ArtifactResolutionService);
397         DECL_SAML2MDOBJECTBUILDER(AssertionConsumerService);
398         DECL_SAML2MDOBJECTBUILDER(AssertionIDRequestService);
399         DECL_SAML2MDOBJECTBUILDER(AttributeAuthorityDescriptor);
400         DECL_SAML2MDOBJECTBUILDER(AttributeConsumingService);
401         DECL_SAML2MDOBJECTBUILDER(AttributeProfile);
402         DECL_SAML2MDOBJECTBUILDER(AttributeService);
403         DECL_SAML2MDOBJECTBUILDER(AuthnAuthorityDescriptor);
404         DECL_SAML2MDOBJECTBUILDER(AuthnQueryService);
405         DECL_SAML2MDOBJECTBUILDER(AuthzService);
406         DECL_SAML2MDOBJECTBUILDER(Company);
407         DECL_SAML2MDOBJECTBUILDER(ContactPerson);
408         DECL_SAML2MDOBJECTBUILDER(EmailAddress);
409         DECL_SAML2MDOBJECTBUILDER(EntitiesDescriptor);
410         DECL_SAML2MDOBJECTBUILDER(EntityDescriptor);
411         DECL_SAML2MDOBJECTBUILDER(Extensions);
412         DECL_SAML2MDOBJECTBUILDER(GivenName);
413         DECL_SAML2MDOBJECTBUILDER(IDPSSODescriptor);
414         DECL_SAML2MDOBJECTBUILDER(KeyDescriptor);
415         DECL_SAML2MDOBJECTBUILDER(ManageNameIDService);
416         DECL_SAML2MDOBJECTBUILDER(NameIDFormat);
417         DECL_SAML2MDOBJECTBUILDER(NameIDMappingService);
418         DECL_SAML2MDOBJECTBUILDER(Organization);
419         DECL_SAML2MDOBJECTBUILDER(OrganizationName);
420         DECL_SAML2MDOBJECTBUILDER(OrganizationDisplayName);
421         DECL_SAML2MDOBJECTBUILDER(OrganizationURL);
422         DECL_SAML2MDOBJECTBUILDER(PDPDescriptor);
423         DECL_SAML2MDOBJECTBUILDER(RequestedAttribute);
424         DECL_SAML2MDOBJECTBUILDER(ServiceDescription);
425         DECL_SAML2MDOBJECTBUILDER(ServiceName);
426         DECL_SAML2MDOBJECTBUILDER(SingleLogoutService);
427         DECL_SAML2MDOBJECTBUILDER(SingleSignOnService);
428         DECL_SAML2MDOBJECTBUILDER(SPSSODescriptor);
429         DECL_SAML2MDOBJECTBUILDER(SurName);
430         DECL_SAML2MDOBJECTBUILDER(TelephoneNumber);
431         
432         DECL_XMLOBJECTBUILDER(SAML_API,ActionNamespace,opensaml::SAMLConstants::SAML20MD_QUERY_EXT_NS,opensaml::SAMLConstants::SAML20MD_QUERY_EXT_PREFIX);
433         DECL_XMLOBJECTBUILDER(SAML_API,SourceID,opensaml::SAMLConstants::SAML1MD_NS,opensaml::SAMLConstants::SAML1MD_PREFIX);
434
435         /**
436          * Builder for localizedNameType objects.
437          * 
438          * This is customized to force the element name to be specified.
439          */
440         class SAML_API localizedNameTypeBuilder : public xmltooling::XMLObjectBuilder {
441         public:
442             virtual ~localizedNameTypeBuilder() {}
443             /** Builder that allows element/type override. */
444             virtual localizedNameType* buildObject(
445                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
446                 ) const;
447         
448             /** Singleton builder. */
449             static localizedNameType* buildlocalizedNameType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
450                 const localizedNameTypeBuilder* b = dynamic_cast<const localizedNameTypeBuilder*>(
451                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,localizedNameType::TYPE_NAME))
452                     );
453                 if (b) {
454                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,localizedNameType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
455                     return b->buildObject(nsURI, localName, prefix, &schemaType);
456                 }
457                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedNameType.");
458             }
459         };
460
461         /**
462          * Builder for localizedURIType objects.
463          * 
464          * This is customized to force the element name to be specified.
465          */
466         class SAML_API localizedURITypeBuilder : public xmltooling::XMLObjectBuilder {
467         public:
468             virtual ~localizedURITypeBuilder() {}
469             /** Builder that allows element/type override. */
470             virtual localizedURIType* buildObject(
471                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
472                 ) const;
473         
474             /** Singleton builder. */
475             static localizedURIType* buildlocalizedURIType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
476                 const localizedURITypeBuilder* b = dynamic_cast<const localizedURITypeBuilder*>(
477                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,localizedURIType::TYPE_NAME))
478                     );
479                 if (b) {
480                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,localizedURIType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
481                     return b->buildObject(nsURI, localName, prefix, &schemaType);
482                 }
483                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedURIType.");
484             }
485         };
486
487         /**
488          * Builder for EndpointType objects.
489          * 
490          * This is customized to force the element name to be specified.
491          */
492         class SAML_API EndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
493         public:
494             virtual ~EndpointTypeBuilder() {}
495             /** Builder that allows element/type override. */
496             virtual EndpointType* buildObject(
497                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
498                 ) const;
499         
500             /** Singleton builder. */
501             static EndpointType* buildEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
502                 const EndpointTypeBuilder* b = dynamic_cast<const EndpointTypeBuilder*>(
503                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,EndpointType::TYPE_NAME))
504                     );
505                 if (b) {
506                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,EndpointType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
507                     return b->buildObject(nsURI, localName, prefix, &schemaType);
508                 }
509                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for EndpointType.");
510             }
511         };
512
513         /**
514          * Builder for IndexedEndpointType objects.
515          * 
516          * This is customized to force the element name to be specified.
517          */
518         class SAML_API IndexedEndpointTypeBuilder : public xmltooling::XMLObjectBuilder {
519         public:
520             virtual ~IndexedEndpointTypeBuilder() {}
521             /** Builder that allows element/type override. */
522             virtual IndexedEndpointType* buildObject(
523                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
524                 ) const;
525         
526             /** Singleton builder. */
527             static IndexedEndpointType* buildIndexedEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) {
528                 const IndexedEndpointTypeBuilder* b = dynamic_cast<const IndexedEndpointTypeBuilder*>(
529                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME))
530                     );
531                 if (b) {
532                     xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX);
533                     return b->buildObject(nsURI, localName, prefix, &schemaType);
534                 }
535                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for IndexedEndpointType.");
536             }
537         };
538
539         /**
540          * Builder for AuthnQueryDescriptorType objects.
541          * 
542          * This is customized to return a RoleDescriptor element with an
543          * xsi:type of AuthnQueryDescriptorType.
544          */
545         class SAML_API AuthnQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder {
546         public:
547             virtual ~AuthnQueryDescriptorTypeBuilder() {}
548             /** Default builder. */
549             virtual AuthnQueryDescriptorType* buildObject() const {
550                 xmltooling::QName schemaType(
551                     SAMLConstants::SAML20_NS,AuthnQueryDescriptorType::TYPE_NAME,SAMLConstants::SAML20MD_QUERY_EXT_PREFIX
552                     );
553                 return buildObject(
554                     SAMLConstants::SAML20_NS,AuthnQueryDescriptorType::LOCAL_NAME,SAMLConstants::SAML20_PREFIX,&schemaType
555                     );
556             }
557             /** Builder that allows element/type override. */
558             virtual AuthnQueryDescriptorType* buildObject(
559                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
560                 ) const;
561         
562             /** Singleton builder. */
563             static AuthnQueryDescriptorType* buildAuthnQueryDescriptorType() {
564                 const AuthnQueryDescriptorTypeBuilder* b = dynamic_cast<const AuthnQueryDescriptorTypeBuilder*>(
565                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_QUERY_EXT_NS,AuthnQueryDescriptorType::TYPE_NAME))
566                     );
567                 if (b)
568                     return b->buildObject();
569                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthnQueryDescriptorType.");
570             }
571         };
572
573         /**
574          * Builder for AttributeQueryDescriptorType objects.
575          * 
576          * This is customized to return a RoleDescriptor element with an
577          * xsi:type of AttributeQueryDescriptorType.
578          */
579         class SAML_API AttributeQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder {
580         public:
581             virtual ~AttributeQueryDescriptorTypeBuilder() {}
582             /** Default builder. */
583             virtual AttributeQueryDescriptorType* buildObject() const {
584                 xmltooling::QName schemaType(
585                     SAMLConstants::SAML20_NS,AttributeQueryDescriptorType::TYPE_NAME,SAMLConstants::SAML20MD_QUERY_EXT_PREFIX
586                     );
587                 return buildObject(
588                     SAMLConstants::SAML20_NS,AttributeQueryDescriptorType::LOCAL_NAME,SAMLConstants::SAML20_PREFIX,&schemaType
589                     );
590             }
591             /** Builder that allows element/type override. */
592             virtual AttributeQueryDescriptorType* buildObject(
593                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
594                 ) const;
595         
596             /** Singleton builder. */
597             static AttributeQueryDescriptorType* buildAttributeQueryDescriptorType() {
598                 const AttributeQueryDescriptorTypeBuilder* b = dynamic_cast<const AttributeQueryDescriptorTypeBuilder*>(
599                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_QUERY_EXT_NS,AttributeQueryDescriptorType::TYPE_NAME))
600                     );
601                 if (b)
602                     return b->buildObject();
603                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AttributeQueryDescriptorType.");
604             }
605         };
606
607         /**
608          * Builder for AuthzDecisionQueryDescriptorType objects.
609          * 
610          * This is customized to return a RoleDescriptor element with an
611          * xsi:type of AuthzDecisionQueryDescriptorType.
612          */
613         class SAML_API AuthzDecisionQueryDescriptorTypeBuilder : public xmltooling::XMLObjectBuilder {
614         public:
615             virtual ~AuthzDecisionQueryDescriptorTypeBuilder() {}
616             /** Default builder. */
617             virtual AuthzDecisionQueryDescriptorType* buildObject() const {
618                 xmltooling::QName schemaType(
619                     SAMLConstants::SAML20_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME,SAMLConstants::SAML20MD_QUERY_EXT_PREFIX
620                     );
621                 return buildObject(
622                     SAMLConstants::SAML20_NS,AuthzDecisionQueryDescriptorType::LOCAL_NAME,SAMLConstants::SAML20_PREFIX,&schemaType
623                     );
624             }
625             /** Builder that allows element/type override. */
626             virtual AuthzDecisionQueryDescriptorType* buildObject(
627                 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL
628                 ) const;
629         
630             /** Singleton builder. */
631             static AuthzDecisionQueryDescriptorType* buildAuthzDecisionQueryDescriptorType() {
632                 const AuthzDecisionQueryDescriptorTypeBuilder* b = dynamic_cast<const AuthzDecisionQueryDescriptorTypeBuilder*>(
633                     XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_QUERY_EXT_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME))
634                     );
635                 if (b)
636                     return b->buildObject();
637                 throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthzDecisionQueryDescriptorType.");
638             }
639         };
640
641         /**
642          * Registers builders and validators for SAML 2.0 Metadata classes into the runtime.
643          */
644         void SAML_API registerMetadataClasses();
645
646         /**
647          * Validator suite for SAML 2.0 Metadata schema validation.
648          */
649         extern SAML_API xmltooling::ValidatorSuite MetadataSchemaValidators;
650     };
651 };
652
653 #endif /* __saml2_metadata_h__ */