X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml2%2Fmetadata%2FMetadata.h;h=e609f66671ecaaad84f6f4194744b4d2ef2f978c;hb=e9554c255ad3c91c7c4976e7a1a54905903e66a2;hp=4ea5a5b496f745767dd9ac9486f10c89e7bb2513;hpb=2c99953d441d4a152c9157cd434d1df2e91f85f1;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml2/metadata/Metadata.h b/saml/saml2/metadata/Metadata.h index 4ea5a5b..e609f66 100644 --- a/saml/saml2/metadata/Metadata.h +++ b/saml/saml2/metadata/Metadata.h @@ -1,6 +1,6 @@ /* - * Copyright 2001-2007 Internet2 - * + * Copyright 2001-2010 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 @@ -16,21 +16,27 @@ /** * @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 + #define DECL_SAML2MDOBJECTBUILDER(cname) \ DECL_XMLOBJECTBUILDER(SAML_API,cname,samlconstants::SAML20MD_NS,samlconstants::SAML20MD_PREFIX) +namespace xmlencryption { + class XMLTOOL_API EncryptionMethod; +}; + namespace opensaml { /** @@ -38,7 +44,7 @@ namespace opensaml { * SAML 2.0 metadata namespace */ namespace saml2md { - + /** * Base class for metadata objects that feature a cacheDuration attribute. */ @@ -63,7 +69,7 @@ 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 { @@ -79,7 +85,7 @@ namespace opensaml { DECL_XMLOBJECT_SIMPLE(SAML_API,NameIDFormat,Format,SAML 2.0 NameIDFormat element); DECL_XMLOBJECT_SIMPLE(SAML_API,SurName,Name,SAML 2.0 SurName element); DECL_XMLOBJECT_SIMPLE(SAML_API,TelephoneNumber,Number,SAML 2.0 TelephoneNumber element); - + DECL_XMLOBJECT_SIMPLE(SAML_API,ActionNamespace,Namespace,SAML 2.0 Metadata Extension ActionNamespace element); DECL_XMLOBJECT_SIMPLE(SAML_API,SourceID,ID,SAML 1.x Metadata Profile SourceID element); @@ -106,7 +112,7 @@ namespace opensaml { BEGIN_XMLOBJECT(SAML_API,OrganizationURL,localizedURIType,SAML 2.0 OrganizationURL element); DECL_SIMPLE_CONTENT(URL); END_XMLOBJECT; - + BEGIN_XMLOBJECT(SAML_API,Extensions,xmltooling::ElementExtensibleXMLObject,SAML 2.0 Extensions element); /** ExtensionsType local name */ static const XMLCh TYPE_NAME[]; @@ -177,6 +183,9 @@ namespace opensaml { DECL_TYPED_CHILDREN(ContactPerson); END_XMLOBJECT; + BEGIN_XMLOBJECT2(SAML_API,RoleDescriptorType,RoleDescriptor,xmltooling::ElementExtensibleXMLObject,SAML 2.0 RoleDescriptor extension); + END_XMLOBJECT; + BEGIN_XMLOBJECT(SAML_API,EndpointType,xmltooling::ElementProxy,SAML 2.0 EndpointType type); DECL_STRING_ATTRIB(Binding,BINDING); DECL_STRING_ATTRIB(Location,LOCATION); @@ -379,6 +388,13 @@ namespace opensaml { static const XMLCh TYPE_NAME[]; 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; + /** * Predicate to test a role for validity and protocol support. */ @@ -390,9 +406,9 @@ namespace opensaml { * * @param protocol support constant to test for */ - isValidForProtocol(const XMLCh* protocol) : m_time(time(NULL)), m_protocol(protocol) { + 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. * @@ -402,7 +418,7 @@ namespace opensaml { 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; @@ -423,7 +439,7 @@ namespace opensaml { 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. * @@ -431,7 +447,7 @@ namespace opensaml { * @return result of predicate */ bool operator()(const RoleDescriptor* role) const { - return xmltooling::hasSchemaType::operator()(role) && isValidForProtocol::operator()(role); + return xmltooling::hasSchemaType::operator()(role) && isValidForProtocol::operator()(role); } }; @@ -473,13 +489,14 @@ namespace opensaml { DECL_SAML2MDOBJECTBUILDER(SPSSODescriptor); 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,EntityAttributes,samlconstants::SAML20MD_ENTITY_ATTRIBUTE_NS,samlconstants::SAML20MD_ENTITY_ATTRIBUTE_PREFIX); /** * Builder for localizedNameType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API localizedNameTypeBuilder : public xmltooling::XMLObjectBuilder { @@ -491,11 +508,11 @@ namespace opensaml { #else virtual xmltooling::XMLObject* buildObject( #endif - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + 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)) ); @@ -513,7 +530,7 @@ namespace opensaml { /** * Builder for localizedURIType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API localizedURITypeBuilder : public xmltooling::XMLObjectBuilder { @@ -525,11 +542,11 @@ namespace opensaml { #else virtual xmltooling::XMLObject* buildObject( #endif - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + 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)) ); @@ -547,7 +564,7 @@ namespace opensaml { /** * Builder for EndpointType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API EndpointTypeBuilder : public xmltooling::XMLObjectBuilder { @@ -559,11 +576,11 @@ namespace opensaml { #else virtual xmltooling::XMLObject* buildObject( #endif - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + 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)) ); @@ -581,7 +598,7 @@ namespace opensaml { /** * Builder for IndexedEndpointType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API IndexedEndpointTypeBuilder : public xmltooling::XMLObjectBuilder { @@ -593,11 +610,11 @@ namespace opensaml { #else virtual xmltooling::XMLObject* buildObject( #endif - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + 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)) ); @@ -614,8 +631,41 @@ namespace opensaml { }; /** + * Builder for RoleDescriptor extension objects. + * + * This is customized to force the schema type to be specified. + */ + 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. */ @@ -641,9 +691,9 @@ namespace opensaml { #else virtual xmltooling::XMLObject* buildObject( #endif - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + 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( @@ -662,7 +712,7 @@ namespace opensaml { /** * Builder for AttributeQueryDescriptorType objects. - * + * * This is customized to return a RoleDescriptor element with an * xsi:type of AttributeQueryDescriptorType. */ @@ -688,9 +738,9 @@ namespace opensaml { #else virtual xmltooling::XMLObject* buildObject( #endif - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + 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( @@ -709,7 +759,7 @@ namespace opensaml { /** * Builder for AuthzDecisionQueryDescriptorType objects. - * + * * This is customized to return a RoleDescriptor element with an * xsi:type of AuthzDecisionQueryDescriptorType. */ @@ -735,9 +785,9 @@ namespace opensaml { #else virtual xmltooling::XMLObject* buildObject( #endif - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + 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(