X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml2%2Fmetadata%2FMetadata.h;h=ffaadc8c016929479c562868d1cc856da90da1e2;hb=04482c5c0e5fac5b688b0d23713526a15c51bd31;hp=2fc3e8c76b2a548fc7c064c6858f0eaeb7d779f8;hpb=b3aabf197d42b5766d2abcd745a66e3f6e00b7a2;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml2/metadata/Metadata.h b/saml/saml2/metadata/Metadata.h index 2fc3e8c..ffaadc8 100644 --- a/saml/saml2/metadata/Metadata.h +++ b/saml/saml2/metadata/Metadata.h @@ -1,43 +1,50 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + * + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. */ /** * @file saml/saml2/metadata/Metadata.h - * - * XMLObjects representing the SAML 2.0 Metadata schema + * + * XMLObjects representing the SAML 2.0 Metadata schema. */ #ifndef __saml2_metadata_h__ #define __saml2_metadata_h__ #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + #define DECL_SAML2MDOBJECTBUILDER(cname) \ - DECL_XMLOBJECTBUILDER(SAML_API,cname,opensaml::SAMLConstants::SAML20MD_NS,opensaml::SAMLConstants::SAML20MD_PREFIX) + DECL_XMLOBJECTBUILDER(SAML_API,cname,samlconstants::SAML20MD_NS,samlconstants::SAML20MD_PREFIX) + +namespace xmltooling { + class XMLTOOL_API Credential; + class XMLTOOL_API CredentialResolver; +} + +namespace xmlencryption { + class XMLTOOL_API EncryptionMethod; +}; namespace opensaml { @@ -46,7 +53,10 @@ namespace opensaml { * SAML 2.0 metadata namespace */ namespace saml2md { - + + class SAML_API DigestMethod; + class SAML_API SigningMethod; + /** * Base class for metadata objects that feature a cacheDuration attribute. */ @@ -71,7 +81,11 @@ namespace opensaml { DECL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL); /** Returns true iff the object is valid at the current time. */ bool isValid() const { - return time(NULL) <= getValidUntilEpoch(); + return time(nullptr) <= getValidUntilEpoch(); + } + /** Returns true iff the object is valid at the supplied time. */ + bool isValid(time_t t) const { + return t <= getValidUntilEpoch(); } }; @@ -84,31 +98,33 @@ namespace opensaml { DECL_XMLOBJECT_SIMPLE(SAML_API,SurName,Name,SAML 2.0 SurName element); DECL_XMLOBJECT_SIMPLE(SAML_API,TelephoneNumber,Number,SAML 2.0 TelephoneNumber element); - BEGIN_XMLOBJECT(SAML_API,localizedNameType,xmltooling::SimpleElement,SAML 2.0 localizedNameType type); + DECL_XMLOBJECT_SIMPLE(SAML_API,ActionNamespace,Namespace,SAML 2.0 Metadata Extension ActionNamespace element); + + BEGIN_XMLOBJECT(SAML_API,localizedNameType,xmltooling::XMLObject,SAML 2.0 localizedNameType type); DECL_STRING_ATTRIB(Lang,LANG); /** localizedNameType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(SAML_API,localizedURIType,xmltooling::SimpleElement,SAML 2.0 localizedURIType type); + BEGIN_XMLOBJECT(SAML_API,localizedURIType,xmltooling::XMLObject,SAML 2.0 localizedURIType type); DECL_STRING_ATTRIB(Lang,LANG); /** localizedURIType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,OrganizationName,localizedNameType,SAML 2.0 OrganizationName element); - DECL_XMLOBJECT_CONTENT(Name); + DECL_SIMPLE_CONTENT(Name); END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,OrganizationDisplayName,localizedNameType,SAML 2.0 OrganizationDisplayName element); - DECL_XMLOBJECT_CONTENT(Name); + DECL_SIMPLE_CONTENT(Name); END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,OrganizationURL,localizedURIType,SAML 2.0 OrganizationURL element); - DECL_XMLOBJECT_CONTENT(URL); + DECL_SIMPLE_CONTENT(URL); END_XMLOBJECT; - - BEGIN_XMLOBJECT(SAML_API,Extensions,xmltooling::ElementProxy,SAML 2.0 Extensions element); + + BEGIN_XMLOBJECT(SAML_API,Extensions,xmltooling::ElementExtensibleXMLObject,SAML 2.0 Extensions element); /** ExtensionsType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -144,9 +160,9 @@ namespace opensaml { static const XMLCh CONTACT_OTHER[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(SAML_API,AdditionalMetadataLocation,xmltooling::SimpleElement,SAML 2.0 AdditionalMetadataLocation element); + BEGIN_XMLOBJECT(SAML_API,AdditionalMetadataLocation,xmltooling::XMLObject,SAML 2.0 AdditionalMetadataLocation element); DECL_STRING_ATTRIB(Namespace,NAMESPACE); - DECL_XMLOBJECT_CONTENT(Location); + DECL_SIMPLE_CONTENT(Location); /** AdditionalMetadataLocationType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -169,15 +185,25 @@ namespace opensaml { DECL_STRING_ATTRIB(ProtocolSupportEnumeration,PROTOCOLSUPPORTENUMERATION); /** Searches the ProtocolSupportEnumeration attribute for the indicated protocol. */ virtual bool hasSupport(const XMLCh* protocol) const=0; + /** Adds the indicated protocol to the ProtocolSupportEnumeration attribute. */ + virtual void addSupport(const XMLCh* protocol)=0; DECL_STRING_ATTRIB(ErrorURL,ERRORURL); - DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature); DECL_TYPED_CHILD(Extensions); DECL_TYPED_CHILDREN(KeyDescriptor); DECL_TYPED_CHILD(Organization); DECL_TYPED_CHILDREN(ContactPerson); + /** Returns the first digest method supported by the role and the underlying implementation, if any. */ + virtual const DigestMethod* getDigestMethod() const; + /** Returns the first signing method supported by the role and the underlying implementation, if any, along with a matching credential. */ + virtual std::pair getSigningMethod( + const xmltooling::CredentialResolver& resolver, xmltooling::CredentialCriteria& cc + ) const; + END_XMLOBJECT; + + BEGIN_XMLOBJECT2(SAML_API,RoleDescriptorType,RoleDescriptor,xmltooling::ElementExtensibleXMLObject,SAML 2.0 RoleDescriptor extension); END_XMLOBJECT; - BEGIN_XMLOBJECT2(SAML_API,EndpointType,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SAML 2.0 EndpointType type); + BEGIN_XMLOBJECT(SAML_API,EndpointType,xmltooling::ElementProxy,SAML 2.0 EndpointType type); DECL_STRING_ATTRIB(Binding,BINDING); DECL_STRING_ATTRIB(Location,LOCATION); DECL_STRING_ATTRIB(ResponseLocation,RESPONSELOCATION); @@ -187,7 +213,7 @@ namespace opensaml { BEGIN_XMLOBJECT(SAML_API,IndexedEndpointType,EndpointType,SAML 2.0 IndexedEndpointType type); DECL_INTEGER_ATTRIB(Index,INDEX); - DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT); + DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,false); /** IndexedEndpointType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -220,7 +246,7 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,IDPSSODescriptor,SSODescriptorType,SAML 2.0 IDPSSODescriptor element); - DECL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED); + DECL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED,false); DECL_TYPED_CHILDREN(SingleSignOnService); DECL_TYPED_CHILDREN(NameIDMappingService); DECL_TYPED_CHILDREN(AssertionIDRequestService); @@ -228,25 +254,26 @@ namespace opensaml { DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2); /** IDPSSODescriptorType local name */ static const XMLCh TYPE_NAME[]; + DECL_ELEMENT_QNAME; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,ServiceName,localizedNameType,SAML 2.0 ServiceName element); - DECL_XMLOBJECT_CONTENT(Name); + DECL_SIMPLE_CONTENT(Name); END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,ServiceDescription,localizedNameType,SAML 2.0 ServiceDescription element); - DECL_XMLOBJECT_CONTENT(Description); + DECL_SIMPLE_CONTENT(Description); END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,RequestedAttribute,saml2::Attribute,SAML 2.0 RequestedAttribute element); - DECL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED); + DECL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED,false); /** RequestedAttributeType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AttributeConsumingService,xmltooling::XMLObject,SAML 2.0 AttributeConsumingService element); DECL_INTEGER_ATTRIB(Index,INDEX); - DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT); + DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,false); DECL_TYPED_CHILDREN(ServiceName); DECL_TYPED_CHILDREN(ServiceDescription); DECL_TYPED_CHILDREN(RequestedAttribute); @@ -258,12 +285,13 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,SPSSODescriptor,SSODescriptorType,SAML 2.0 SPSSODescriptor element); - DECL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED); - DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED); + DECL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED,false); + DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false); DECL_TYPED_CHILDREN(AssertionConsumerService); DECL_TYPED_CHILDREN(AttributeConsumingService); /** SPSSODescriptorType local name */ static const XMLCh TYPE_NAME[]; + DECL_ELEMENT_QNAME; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AuthnQueryService,EndpointType,SAML 2.0 AuthnQueryService element); @@ -275,6 +303,7 @@ namespace opensaml { DECL_TYPED_CHILDREN(NameIDFormat); /** AuthnAuthorityDescriptorType local name */ static const XMLCh TYPE_NAME[]; + DECL_ELEMENT_QNAME; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AuthzService,EndpointType,SAML 2.0 AuthzService element); @@ -286,6 +315,7 @@ namespace opensaml { DECL_TYPED_CHILDREN(NameIDFormat); /** PDPDescriptorType local name */ static const XMLCh TYPE_NAME[]; + DECL_ELEMENT_QNAME; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AttributeService,EndpointType,SAML 2.0 AttributeService element); @@ -299,13 +329,40 @@ namespace opensaml { DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2); /** AttributeAuthorityDescriptorType local name */ static const XMLCh TYPE_NAME[]; + DECL_ELEMENT_QNAME; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,QueryDescriptorType,RoleDescriptor,SAML 2.0 QueryDescriptorType abstract type); + DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false); + DECL_TYPED_CHILDREN(NameIDFormat); + /** QueryDescriptorType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,AuthnQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthnQueryDescriptorType extension type); + /** AuthnQueryDescriptorType local name */ + static const XMLCh TYPE_NAME[]; + DECL_TYPE_QNAME; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,AttributeQueryDescriptorType,QueryDescriptorType,SAML 2.0 AttributeQueryDescriptorType extension type); + DECL_TYPED_CHILDREN(AttributeConsumingService); + /** AttributeQueryDescriptorType local name */ + static const XMLCh TYPE_NAME[]; + DECL_TYPE_QNAME; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,AuthzDecisionQueryDescriptorType,QueryDescriptorType,SAML 2.0 AuthzDecisionQueryDescriptorType extension type); + DECL_TYPED_CHILDREN(ActionNamespace); + /** AuthzDecisionQueryDescriptorType local name */ + static const XMLCh TYPE_NAME[]; + DECL_TYPE_QNAME; END_XMLOBJECT; BEGIN_XMLOBJECT4(SAML_API,AffiliationDescriptor,xmltooling::AttributeExtensibleXMLObject,SignableObject, CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 AffiliationDescriptor element); DECL_STRING_ATTRIB(ID,ID); DECL_STRING_ATTRIB(AffiliationOwnerID,AFFILIATIONOWNERID); - DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature); DECL_TYPED_CHILD(Extensions); DECL_TYPED_CHILDREN(AffiliateMember); DECL_TYPED_CHILDREN(KeyDescriptor); @@ -317,7 +374,6 @@ namespace opensaml { CacheableSAMLObject,TimeBoundSAMLObject,SAML 2.0 EntityDescriptor element); DECL_STRING_ATTRIB(ID,ID); DECL_STRING_ATTRIB(EntityID,ENTITYID); - DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature); DECL_TYPED_CHILD(Extensions); DECL_TYPED_CHILD(AffiliationDescriptor); DECL_TYPED_CHILDREN(RoleDescriptor); @@ -326,18 +382,14 @@ namespace opensaml { DECL_TYPED_CHILDREN(AuthnAuthorityDescriptor); DECL_TYPED_CHILDREN(AttributeAuthorityDescriptor); DECL_TYPED_CHILDREN(PDPDescriptor); - /** Finds an IDP role supporting a given protocol. */ - virtual const IDPSSODescriptor* getIDPSSODescriptor(const XMLCh* protocol) const=0; - /** Finds an SP role supporting a given protocol. */ - virtual const SPSSODescriptor* getSPSSODescriptor(const XMLCh* protocol) const=0; - /** Finds an Authn Authority role supporting a given protocol. */ - virtual const AuthnAuthorityDescriptor* getAuthnAuthorityDescriptor(const XMLCh* protocol) const=0; - /** Finds an Attribute Authority role supporting a given protocol. */ - virtual const AttributeAuthorityDescriptor* getAttributeAuthorityDescriptor(const XMLCh* protocol) const=0; - /** Finds a PDP role supporting a given protocol. */ - virtual const PDPDescriptor* getPDPDescriptor(const XMLCh* protocol) const=0; - /** Finds an extension role supporting a given protocol. */ - virtual const RoleDescriptor* getRoleDescriptor(xmltooling::QName& qname, const XMLCh* protocol) const=0; + DECL_TYPED_CHILDREN(AuthnQueryDescriptorType); + DECL_TYPED_CHILDREN(AttributeQueryDescriptorType); + DECL_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType); + DECL_TYPED_CHILD(Organization); + DECL_TYPED_CHILDREN(ContactPerson); + DECL_TYPED_CHILDREN(AdditionalMetadataLocation); + /** Finds an arbitrary role type supporting a given protocol. */ + virtual const RoleDescriptor* getRoleDescriptor(const xmltooling::QName& qname, const XMLCh* protocol) const=0; /** EntityDescriptorType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -346,7 +398,6 @@ namespace opensaml { TimeBoundSAMLObject,SAML 2.0 EntitiesDescriptor element); DECL_STRING_ATTRIB(ID,ID); DECL_STRING_ATTRIB(Name,NAME); - DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature); DECL_TYPED_CHILD(Extensions); DECL_TYPED_CHILDREN(EntityDescriptor); DECL_TYPED_CHILDREN(EntitiesDescriptor); @@ -354,6 +405,148 @@ namespace opensaml { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; + // Known Metadata Extensions + + DECL_XMLOBJECT_SIMPLE(SAML_API,SourceID,ID,SAML 1.x Metadata Profile SourceID element); + + BEGIN_XMLOBJECT(SAML_API,DiscoveryResponse,IndexedEndpointType,Identity Provider Discovery Protocol DiscoveryResponse element); + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,RequestInitiator,EndpointType,Service Provider Request Initiation RequestInitiator element); + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,EntityAttributes,xmltooling::XMLObject,SAML Metadata Extension for Entity Attributes element); + DECL_TYPED_FOREIGN_CHILDREN(Attribute,saml2); + DECL_TYPED_FOREIGN_CHILDREN(Assertion,saml2); + /** EntityAttributesType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,DigestMethod,xmltooling::ElementExtensibleXMLObject,SAML Metadata Extension for Algorithm Support DigestMethod element); + DECL_STRING_ATTRIB(Algorithm,ALGORITHM); + /** DigestMethodType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,SigningMethod,xmltooling::ElementExtensibleXMLObject,SAML Metadata Extension for Algorithm Support SigningMethod element); + DECL_STRING_ATTRIB(Algorithm,ALGORITHM); + DECL_INTEGER_ATTRIB(MinKeySize,MINKEYSIZE); + DECL_INTEGER_ATTRIB(MaxKeySize,MAXKEYSIZE); + /** SigningMethodType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,DisplayName,localizedNameType,SAML Metadata Extension for Login UI DisplayName element); + DECL_SIMPLE_CONTENT(Name); + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,Description,localizedNameType,SAML Metadata Extension for Login UI Description element); + DECL_SIMPLE_CONTENT(Description); + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,Keywords,xmltooling::XMLObject,SAML Metadata Extension for Login UI Keywords element); + DECL_STRING_ATTRIB(Lang,LANG); + DECL_SIMPLE_CONTENT(Values); + /** KeywordsType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,Logo,xmltooling::XMLObject,SAML Metadata Extension for Login UI Logo element); + DECL_STRING_ATTRIB(Lang,LANG); + DECL_INTEGER_ATTRIB(Height,HEIGHT); + DECL_INTEGER_ATTRIB(Width,WIDTH); + DECL_SIMPLE_CONTENT(URL); + /** LogoType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,InformationURL,localizedURIType,SAML Metadata Extension for Login UI InformationURL element); + DECL_SIMPLE_CONTENT(URL); + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,PrivacyStatementURL,localizedURIType,SAML Metadata Extension for Login UI PrivacyStatementURL element); + DECL_SIMPLE_CONTENT(URL); + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,UIInfo,xmltooling::ElementExtensibleXMLObject,SAML Metadata Extension for Login UI UIInfo element); + DECL_TYPED_CHILDREN(DisplayName); + DECL_TYPED_CHILDREN(Description); + DECL_TYPED_CHILDREN(Keywords); + DECL_TYPED_CHILDREN(Logo); + DECL_TYPED_CHILDREN(InformationURL); + DECL_TYPED_CHILDREN(PrivacyStatementURL); + /** UIInfoType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + DECL_XMLOBJECT_SIMPLE(SAML_API,IPHint,Hint,SAML Metadata Extension for Login UI IPHint element); + DECL_XMLOBJECT_SIMPLE(SAML_API,DomainHint,Hint,SAML Metadata Extension for Login UI DomainHint element); + DECL_XMLOBJECT_SIMPLE(SAML_API,GeolocationHint,Hint,SAML Metadata Extension for Login UI GeolocationHint element); + + BEGIN_XMLOBJECT(SAML_API,DiscoHints,xmltooling::ElementExtensibleXMLObject,SAML Metadata Extension for Login UI DiscoHints element); + DECL_TYPED_CHILDREN(IPHint); + DECL_TYPED_CHILDREN(DomainHint); + DECL_TYPED_CHILDREN(GeolocationHint); + /** DiscoHintsType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + /** + * Predicate to test a role for validity and protocol support. + */ + class isValidForProtocol + { + public: + /** + * Constructor. + * + * @param protocol support constant to test for + */ + isValidForProtocol(const XMLCh* protocol) : m_time(time(nullptr)), m_protocol(protocol) { + } + + /** + * Returns true iff the supplied role is valid now and supports the right protocol. + * + * @param role role to test + * @return result of predicate + */ + bool operator()(const RoleDescriptor* role) const { + return role ? (role->isValid(m_time) && role->hasSupport(m_protocol)) : false; + } + + private: + time_t m_time; + const XMLCh* m_protocol; + }; + + /** + * Predicate to test a role for type equivalence, validity, and protocol support. + */ + class ofTypeValidForProtocol : public isValidForProtocol, public xmltooling::hasSchemaType + { + public: + /** + * Constructor. + * + * @param q schema type to test for + * @param protocol support constant to test for + */ + ofTypeValidForProtocol(const xmltooling::QName& q, const XMLCh* protocol) + : isValidForProtocol(protocol), xmltooling::hasSchemaType(q) { + } + + /** + * Returns true iff the supplied role is of the right type, valid now, and supports the right protocol. + * + * @param role role to test + * @return result of predicate + */ + bool operator()(const RoleDescriptor* role) const { + return xmltooling::hasSchemaType::operator()(role) && isValidForProtocol::operator()(role); + } + }; + DECL_SAML2MDOBJECTBUILDER(AdditionalMetadataLocation); DECL_SAML2MDOBJECTBUILDER(AffiliateMember); DECL_SAML2MDOBJECTBUILDER(AffiliationDescriptor); @@ -393,27 +586,55 @@ namespace opensaml { DECL_SAML2MDOBJECTBUILDER(SurName); DECL_SAML2MDOBJECTBUILDER(TelephoneNumber); + DECL_XMLOBJECTBUILDER(SAML_API,ActionNamespace,samlconstants::SAML20MD_QUERY_EXT_NS,samlconstants::SAML20MD_QUERY_EXT_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,SourceID,samlconstants::SAML1MD_NS,samlconstants::SAML1MD_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,DiscoveryResponse,samlconstants::IDP_DISCOVERY_PROTOCOL_NS,samlconstants::IDP_DISCOVERY_PROTOCOL_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,RequestInitiator,samlconstants::SP_REQUEST_INIT_NS,samlconstants::SP_REQUEST_INIT_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,EntityAttributes,samlconstants::SAML20MD_ENTITY_ATTRIBUTE_NS,samlconstants::SAML20MD_ENTITY_ATTRIBUTE_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,DigestMethod,samlconstants::SAML20MD_ALGSUPPORT_NS,samlconstants::SAML20MD_ALGSUPPORT_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,SigningMethod,samlconstants::SAML20MD_ALGSUPPORT_NS,samlconstants::SAML20MD_ALGSUPPORT_PREFIX); + + DECL_XMLOBJECTBUILDER(SAML_API,UIInfo,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,DisplayName,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,Description,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,Keywords,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,Logo,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,InformationURL,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,PrivacyStatementURL,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,DiscoHints,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,IPHint,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,DomainHint,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + DECL_XMLOBJECTBUILDER(SAML_API,GeolocationHint,samlconstants::SAML20MD_UI_NS,samlconstants::SAML20MD_UI_PREFIX); + /** * Builder for localizedNameType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API localizedNameTypeBuilder : public xmltooling::XMLObjectBuilder { public: virtual ~localizedNameTypeBuilder() {} /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS virtual localizedNameType* buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr ) const; - + /** Singleton builder. */ - static localizedNameType* buildlocalizedNameType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { + static localizedNameType* buildlocalizedNameType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr) { const localizedNameTypeBuilder* b = dynamic_cast( - XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,localizedNameType::TYPE_NAME)) + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,localizedNameType::TYPE_NAME)) ); if (b) { - xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,localizedNameType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX); + xmltooling::QName schemaType(samlconstants::SAML20MD_NS,localizedNameType::TYPE_NAME,samlconstants::SAML20MD_PREFIX); +#ifdef HAVE_COVARIANT_RETURNS return b->buildObject(nsURI, localName, prefix, &schemaType); +#else + return dynamic_cast(b->buildObject(nsURI, localName, prefix, &schemaType)); +#endif } throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedNameType."); } @@ -421,25 +642,33 @@ namespace opensaml { /** * Builder for localizedURIType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API localizedURITypeBuilder : public xmltooling::XMLObjectBuilder { public: virtual ~localizedURITypeBuilder() {} /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS virtual localizedURIType* buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr ) const; - + /** Singleton builder. */ - static localizedURIType* buildlocalizedURIType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { + static localizedURIType* buildlocalizedURIType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr) { const localizedURITypeBuilder* b = dynamic_cast( - XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,localizedURIType::TYPE_NAME)) + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,localizedURIType::TYPE_NAME)) ); if (b) { - xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,localizedURIType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX); + xmltooling::QName schemaType(samlconstants::SAML20MD_NS,localizedURIType::TYPE_NAME,samlconstants::SAML20MD_PREFIX); +#ifdef HAVE_COVARIANT_RETURNS return b->buildObject(nsURI, localName, prefix, &schemaType); +#else + return dynamic_cast(b->buildObject(nsURI, localName, prefix, &schemaType)); +#endif } throw xmltooling::XMLObjectException("Unable to obtain typed builder for localizedURIType."); } @@ -447,25 +676,33 @@ namespace opensaml { /** * Builder for EndpointType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API EndpointTypeBuilder : public xmltooling::XMLObjectBuilder { public: virtual ~EndpointTypeBuilder() {} /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS virtual EndpointType* buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr ) const; - + /** Singleton builder. */ - static EndpointType* buildEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { + static EndpointType* buildEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr) { const EndpointTypeBuilder* b = dynamic_cast( - XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,EndpointType::TYPE_NAME)) + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,EndpointType::TYPE_NAME)) ); if (b) { - xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,EndpointType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX); + xmltooling::QName schemaType(samlconstants::SAML20MD_NS,EndpointType::TYPE_NAME,samlconstants::SAML20MD_PREFIX); +#ifdef HAVE_COVARIANT_RETURNS return b->buildObject(nsURI, localName, prefix, &schemaType); +#else + return dynamic_cast(b->buildObject(nsURI, localName, prefix, &schemaType)); +#endif } throw xmltooling::XMLObjectException("Unable to obtain typed builder for EndpointType."); } @@ -473,39 +710,216 @@ namespace opensaml { /** * Builder for IndexedEndpointType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API IndexedEndpointTypeBuilder : public xmltooling::XMLObjectBuilder { public: virtual ~IndexedEndpointTypeBuilder() {} /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS virtual IndexedEndpointType* buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr ) const; - + /** Singleton builder. */ - static IndexedEndpointType* buildIndexedEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { + static IndexedEndpointType* buildIndexedEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr) { const IndexedEndpointTypeBuilder* b = dynamic_cast( - XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME)) + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME)) ); if (b) { - xmltooling::QName schemaType(SAMLConstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME,SAMLConstants::SAML20MD_PREFIX); + xmltooling::QName schemaType(samlconstants::SAML20MD_NS,IndexedEndpointType::TYPE_NAME,samlconstants::SAML20MD_PREFIX); +#ifdef HAVE_COVARIANT_RETURNS return b->buildObject(nsURI, localName, prefix, &schemaType); +#else + return dynamic_cast(b->buildObject(nsURI, localName, prefix, &schemaType)); +#endif } throw xmltooling::XMLObjectException("Unable to obtain typed builder for IndexedEndpointType."); } }; /** - * Registers builders and validators for SAML 2.0 Metadata classes into the runtime. + * Builder for RoleDescriptor extension objects. + * + * This is customized to force the schema type to be specified. */ - void SAML_API registerMetadataClasses(); + class SAML_API RoleDescriptorBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~RoleDescriptorBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual RoleDescriptor* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr + ) const; + + /** Singleton builder. */ + static RoleDescriptor* buildRoleDescriptor(const xmltooling::QName& schemaType) { + const RoleDescriptorBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_NS,RoleDescriptor::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML20MD_NS, RoleDescriptor::LOCAL_NAME, samlconstants::SAML20MD_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML20MD_NS, RoleDescriptor::LOCAL_NAME, samlconstants::SAML20MD_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for RoleDescriptor."); + } + }; + + /** + * Builder for AuthnQueryDescriptorType objects. + * + * This is customized to return a RoleDescriptor element with an + * xsi:type of AuthnQueryDescriptorType. + */ + class SAML_API AuthnQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { + public: + virtual ~AuthnQueryDescriptorTypeBuilder() {} + /** Default builder. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual AuthnQueryDescriptorType* buildObject() const { +#else + virtual xmltooling::XMLObject* buildObject() const { +#endif + xmltooling::QName schemaType( + samlconstants::SAML20MD_QUERY_EXT_NS,AuthnQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX + ); + return buildObject( + samlconstants::SAML20MD_NS,AuthnQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType + ); + } + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual AuthnQueryDescriptorType* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr + ) const; + + /** Singleton builder. */ + static AuthnQueryDescriptorType* buildAuthnQueryDescriptorType() { + const AuthnQueryDescriptorTypeBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AuthnQueryDescriptorType::TYPE_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(); +#else + return dynamic_cast(b->buildObject()); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthnQueryDescriptorType."); + } + }; /** - * Validator suite for SAML 2.0 Metadata schema validation. + * Builder for AttributeQueryDescriptorType objects. + * + * This is customized to return a RoleDescriptor element with an + * xsi:type of AttributeQueryDescriptorType. */ - extern SAML_API xmltooling::ValidatorSuite MetadataSchemaValidators; + class SAML_API AttributeQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { + public: + virtual ~AttributeQueryDescriptorTypeBuilder() {} + /** Default builder. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual AttributeQueryDescriptorType* buildObject() const { +#else + virtual xmltooling::XMLObject* buildObject() const { +#endif + xmltooling::QName schemaType( + samlconstants::SAML20MD_QUERY_EXT_NS,AttributeQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX + ); + return buildObject( + samlconstants::SAML20MD_NS,AttributeQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType + ); + } + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual AttributeQueryDescriptorType* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr + ) const; + + /** Singleton builder. */ + static AttributeQueryDescriptorType* buildAttributeQueryDescriptorType() { + const AttributeQueryDescriptorTypeBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AttributeQueryDescriptorType::TYPE_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(); +#else + return dynamic_cast(b->buildObject()); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for AttributeQueryDescriptorType."); + } + }; + + /** + * Builder for AuthzDecisionQueryDescriptorType objects. + * + * This is customized to return a RoleDescriptor element with an + * xsi:type of AuthzDecisionQueryDescriptorType. + */ + class SAML_API AuthzDecisionQueryDescriptorTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { + public: + virtual ~AuthzDecisionQueryDescriptorTypeBuilder() {} + /** Default builder. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual AuthzDecisionQueryDescriptorType* buildObject() const { +#else + virtual xmltooling::XMLObject* buildObject() const { +#endif + xmltooling::QName schemaType( + samlconstants::SAML20MD_QUERY_EXT_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME,samlconstants::SAML20MD_QUERY_EXT_PREFIX + ); + return buildObject( + samlconstants::SAML20MD_NS,AuthzDecisionQueryDescriptorType::LOCAL_NAME,samlconstants::SAML20MD_PREFIX,&schemaType + ); + } + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual AuthzDecisionQueryDescriptorType* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr + ) const; + + /** Singleton builder. */ + static AuthzDecisionQueryDescriptorType* buildAuthzDecisionQueryDescriptorType() { + const AuthzDecisionQueryDescriptorTypeBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20MD_QUERY_EXT_NS,AuthzDecisionQueryDescriptorType::TYPE_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(); +#else + return dynamic_cast(b->buildObject()); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for AuthzDecisionQueryDescriptorType."); + } + }; + + /** + * Registers builders and validators for SAML 2.0 Metadata classes into the runtime. + */ + void SAML_API registerMetadataClasses(); }; };