From 549ab1cbc7fd4dc82afff0f517adab5a5292689c Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Wed, 23 Jul 2008 17:45:36 +0000 Subject: [PATCH] https://issues.shibboleth.net/jira/browse/SSPCPP-126 --- saml/saml1/core/Assertions.h | 82 +++++- saml/saml1/core/Protocols.h | 43 ++- saml/saml1/core/impl/AssertionsImpl.cpp | 256 ++++++++++-------- .../saml1/core/impl/AssertionsSchemaValidators.cpp | 12 +- saml/saml1/core/impl/ProtocolsImpl.cpp | 137 +++++----- saml/saml1/core/impl/ProtocolsSchemaValidators.cpp | 15 +- saml/saml2/core/Assertions.h | 100 +++++-- saml/saml2/core/impl/Assertions20Impl.cpp | 296 ++++++++++++--------- .../core/impl/Assertions20SchemaValidators.cpp | 14 +- saml/saml2/metadata/Metadata.h | 84 ++++-- saml/saml2/metadata/impl/MetadataImpl.cpp | 39 +++ .../metadata/impl/MetadataSchemaValidators.cpp | 21 +- .../saml2/core/impl/AssertionChildElements.xml | Bin 874 -> 1132 bytes .../saml2/core/impl/ConditionsChildElements.xml | Bin 566 -> 822 bytes samltest/saml2/core/impl/Assertion20Test.h | 16 +- samltest/saml2/core/impl/Conditions20Test.h | 13 +- 16 files changed, 728 insertions(+), 400 deletions(-) diff --git a/saml/saml1/core/Assertions.h b/saml/saml1/core/Assertions.h index bd0a770..5a4ef8d 100644 --- a/saml/saml1/core/Assertions.h +++ b/saml/saml1/core/Assertions.h @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * @file saml/saml1/core/Assertions.h - * + * * XMLObjects representing the SAML 1.x Assertions schema */ @@ -42,17 +42,17 @@ namespace opensaml { * SAML 1.x assertion namespace */ namespace saml1 { - + // Forward references class SAML_API Assertion; - + DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionIDReference,AssertionID,SAML 1.x AssertionIDReference element); DECL_XMLOBJECT_SIMPLE(SAML_API,Audience,AudienceURI,SAML 1.x Audience element); DECL_XMLOBJECT_SIMPLE(SAML_API,ConfirmationMethod,Method,SAML 1.x ConfirmationMethod element); - + BEGIN_XMLOBJECT(SAML_API,Condition,xmltooling::XMLObject,SAML 1.x Condition element); END_XMLOBJECT; - + BEGIN_XMLOBJECT(SAML_API,AudienceRestrictionCondition,Condition,SAML 1.x AudienceRestrictionCondition element); DECL_TYPED_CHILDREN(Audience); /** AudienceRestrictionConditionType local name */ @@ -92,7 +92,7 @@ namespace opensaml { BEGIN_XMLOBJECT(SAML_API,SubjectConfirmationData,xmltooling::ElementProxy,SAML 1.x SubjectConfirmationData element); END_XMLOBJECT; - + BEGIN_XMLOBJECT(SAML_API,SubjectConfirmation,xmltooling::XMLObject,SAML 1.x SubjectConfirmation element); DECL_TYPED_CHILDREN(ConfirmationMethod); DECL_XMLOBJECT_CHILD(SubjectConfirmationData); @@ -253,7 +253,73 @@ namespace opensaml { DECL_SAML1OBJECTBUILDER(SubjectConfirmation); DECL_SAML1OBJECTBUILDER(SubjectConfirmationData); DECL_SAML1OBJECTBUILDER(SubjectLocality); - + + /** + * Builder for Condition extension objects. + * + * This is customized to force the schema type to be specified. + */ + class SAML_API ConditionBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~ConditionBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual Condition* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static Condition* buildCondition(const xmltooling::QName& schemaType) { + const ConditionBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML1_NS,Condition::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML1_NS, Condition::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML1_NS, Condition::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for Condition."); + } + }; + + /** + * Builder for Statement extension objects. + * + * This is customized to force the schema type to be specified. + */ + class SAML_API StatementBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~StatementBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual Statement* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static Statement* buildStatement(const xmltooling::QName& schemaType) { + const StatementBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML1_NS,Statement::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML1_NS, Statement::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML1_NS, Statement::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for Statement."); + } + }; + /** * Registers builders and validators for SAML 1.x Assertion classes into the runtime. */ diff --git a/saml/saml1/core/Protocols.h b/saml/saml1/core/Protocols.h index a63d209..5731522 100644 --- a/saml/saml1/core/Protocols.h +++ b/saml/saml1/core/Protocols.h @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * @file saml/saml1/core/Protocols.h - * + * * XMLObjects representing the SAML 1.x Protocols schema */ @@ -50,10 +50,10 @@ namespace opensaml { * SAML 1.x protocol namespace */ namespace saml1p { - + DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionArtifact,Artifact,SAML 1.x AssertionArtifact element); DECL_XMLOBJECT_SIMPLE(SAML_API,StatusMessage,Message,SAML 1.x StatusMessage element); - + BEGIN_XMLOBJECT(SAML_API,RespondWith,xmltooling::XMLObject,SAML 1.x RespondWith element); /** Gets the QName content of the element. */ virtual xmltooling::QName* getQName() const=0; @@ -166,7 +166,40 @@ namespace opensaml { DECL_SAML1POBJECTBUILDER(StatusCode); DECL_SAML1POBJECTBUILDER(StatusDetail); DECL_SAML1POBJECTBUILDER(StatusMessage); - + + /** + * Builder for Query extension objects. + * + * This is customized to force the schema type to be specified. + */ + class SAML_API QueryBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~QueryBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual Query* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static Query* buildQuery(const xmltooling::QName& schemaType) { + const QueryBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML1P_NS,Query::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML1P_NS, Query::LOCAL_NAME, samlconstants::SAML1P_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML1P_NS, Query::LOCAL_NAME, samlconstants::SAML1P_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for Query."); + } + }; + /** * Registers builders and validators for SAML 1.x Protocol classes into the runtime. */ diff --git a/saml/saml1/core/impl/AssertionsImpl.cpp b/saml/saml1/core/impl/AssertionsImpl.cpp index fa14c35..acf9e16 100644 --- a/saml/saml1/core/impl/AssertionsImpl.cpp +++ b/saml/saml1/core/impl/AssertionsImpl.cpp @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * AssertionsImpl.cpp - * + * * Implementation classes for SAML 1.x Assertions schema */ @@ -50,11 +50,25 @@ using samlconstants::SAML1_NS; namespace opensaml { namespace saml1 { - + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AssertionIDReference); DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,Audience); DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,ConfirmationMethod); - + + class SAML_DLLLOCAL ConditionImpl : public virtual Condition, public AnyElementImpl + { + public: + virtual ~ConditionImpl() {} + + ConditionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + ConditionImpl(const ConditionImpl& src) : AnyElementImpl(src) {} + + IMPL_XMLOBJECT_CLONE(Condition); + }; + class SAML_DLLLOCAL AudienceRestrictionConditionImpl : public virtual AudienceRestrictionCondition, public AbstractComplexElement, public AbstractDOMCachingXMLObject, @@ -63,11 +77,11 @@ namespace opensaml { { public: virtual ~AudienceRestrictionConditionImpl() {} - + AudienceRestrictionConditionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AudienceRestrictionConditionImpl(const AudienceRestrictionConditionImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOf(Audience) v=getAudiences(); @@ -77,13 +91,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AudienceRestrictionCondition); Condition* cloneCondition() const { return cloneAudienceRestrictionCondition(); } IMPL_TYPED_CHILDREN(Audience,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(Audience,SAML1_NS,false); @@ -99,15 +113,15 @@ namespace opensaml { { public: virtual ~DoNotCacheConditionImpl() {} - + DoNotCacheConditionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + DoNotCacheConditionImpl(const DoNotCacheConditionImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { } - + IMPL_XMLOBJECT_CLONE(DoNotCacheCondition); Condition* cloneCondition() const { return cloneDoNotCacheCondition(); @@ -125,12 +139,12 @@ namespace opensaml { delete m_NotBefore; delete m_NotOnOrAfter; } - + ConditionsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + ConditionsImpl(const ConditionsImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -144,13 +158,13 @@ namespace opensaml { getAudienceRestrictionConditions().push_back(arc->cloneAudienceRestrictionCondition()); continue; } - + DoNotCacheCondition* dncc=dynamic_cast(*i); if (dncc) { getDoNotCacheConditions().push_back(dncc->cloneDoNotCacheCondition()); continue; } - + Condition* c=dynamic_cast(*i); if (c) { getConditions().push_back(c->cloneCondition()); @@ -159,31 +173,31 @@ namespace opensaml { } } } - + void init() { m_NotBefore=m_NotOnOrAfter=NULL; } - + IMPL_XMLOBJECT_CLONE(Conditions); IMPL_DATETIME_ATTRIB(NotBefore,0); IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); IMPL_TYPED_CHILDREN(AudienceRestrictionCondition, m_children.end()); IMPL_TYPED_CHILDREN(DoNotCacheCondition,m_children.end()); IMPL_TYPED_CHILDREN(Condition,m_children.end()); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); MARSHALL_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AudienceRestrictionCondition,SAML1_NS,true); PROC_TYPED_CHILDREN(DoNotCacheCondition,SAML1_NS,true); PROC_TYPED_CHILDREN(Condition,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); @@ -201,27 +215,27 @@ namespace opensaml { XMLString::release(&m_Format); XMLString::release(&m_NameQualifier); } - + NameIdentifierImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + NameIdentifierImpl(const NameIdentifierImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setFormat(src.getFormat()); setNameQualifier(src.getNameQualifier()); } - + void init() { m_Format=m_NameQualifier=NULL; } - + IMPL_XMLOBJECT_CLONE(NameIdentifier); IMPL_STRING_ATTRIB(Format); IMPL_STRING_ATTRIB(NameQualifier); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Format,FORMAT,NULL); @@ -238,14 +252,14 @@ namespace opensaml { { public: virtual ~SubjectConfirmationDataImpl() {} - + SubjectConfirmationDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : AnyElementImpl(src) { } - + IMPL_XMLOBJECT_CLONE(SubjectConfirmationData); }; @@ -257,12 +271,12 @@ namespace opensaml { { public: virtual ~SubjectConfirmationImpl() {} - + SubjectConfirmationImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectConfirmationImpl(const SubjectConfirmationImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -277,7 +291,7 @@ namespace opensaml { } } } - + void init() { m_SubjectConfirmationData=NULL; m_KeyInfo=NULL; @@ -292,12 +306,12 @@ namespace opensaml { IMPL_TYPED_CHILDREN(ConfirmationMethod,m_pos_SubjectConfirmationData); IMPL_XMLOBJECT_CHILD(SubjectConfirmationData); IMPL_TYPED_CHILD(KeyInfo); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(ConfirmationMethod,SAML1_NS,false); PROC_TYPED_CHILD(KeyInfo,XMLSIG_NS,false); - + // Anything else we'll assume is the data. if (getSubjectConfirmationData()) throw UnmarshallingException("Invalid child element: $1",params(1,childXMLObject->getElementQName().toString().c_str())); @@ -313,12 +327,12 @@ namespace opensaml { { public: virtual ~SubjectImpl() {} - + SubjectImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectImpl(const SubjectImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -327,7 +341,7 @@ namespace opensaml { if (src.getSubjectConfirmation()) setSubjectConfirmation(src.getSubjectConfirmation()->cloneSubjectConfirmation()); } - + void init() { m_NameIdentifier=NULL; m_SubjectConfirmation=NULL; @@ -341,7 +355,7 @@ namespace opensaml { IMPL_XMLOBJECT_CLONE(Subject); IMPL_TYPED_CHILD(NameIdentifier); IMPL_TYPED_CHILD(SubjectConfirmation); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(NameIdentifier,SAML1_NS,true); @@ -350,6 +364,20 @@ namespace opensaml { } }; + class SAML_DLLLOCAL StatementImpl : public virtual Statement, public AnyElementImpl + { + public: + virtual ~StatementImpl() {} + + StatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + StatementImpl(const StatementImpl& src) : AnyElementImpl(src) {} + + IMPL_XMLOBJECT_CLONE(Statement); + }; + class SAML_DLLLOCAL SubjectStatementImpl : public virtual SubjectStatement, public AbstractComplexElement, public AbstractDOMCachingXMLObject, @@ -367,21 +395,21 @@ namespace opensaml { } public: virtual ~SubjectStatementImpl() {} - + SubjectStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectStatementImpl(const SubjectStatementImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); } - + IMPL_TYPED_CHILD(Subject); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Subject,SAML1_NS,true); @@ -400,33 +428,33 @@ namespace opensaml { XMLString::release(&m_IPAddress); XMLString::release(&m_DNSAddress); } - + SubjectLocalityImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectLocalityImpl(const SubjectLocalityImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setIPAddress(src.getIPAddress()); setDNSAddress(src.getDNSAddress()); } - + void init() { m_IPAddress=m_DNSAddress=NULL; } - + IMPL_XMLOBJECT_CLONE(SubjectLocality); IMPL_STRING_ATTRIB(IPAddress); IMPL_STRING_ATTRIB(DNSAddress); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(IPAddress,IPADDRESS,NULL); MARSHALL_STRING_ATTRIB(DNSAddress,DNSADDRESS,NULL); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(IPAddress,IPADDRESS,NULL); PROC_STRING_ATTRIB(DNSAddress,DNSADDRESS,NULL); @@ -445,12 +473,12 @@ namespace opensaml { XMLString::release(&m_Location); XMLString::release(&m_Binding); } - + AuthorityBindingImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthorityBindingImpl(const AuthorityBindingImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -458,24 +486,24 @@ namespace opensaml { setLocation(src.getLocation()); setBinding(src.getBinding()); } - + void init() { m_AuthorityKind=NULL; m_Location=m_Binding=NULL; } - + IMPL_XMLOBJECT_CLONE(AuthorityBinding); IMPL_XMLOBJECT_ATTRIB(AuthorityKind,QName); IMPL_STRING_ATTRIB(Location); IMPL_STRING_ATTRIB(Binding); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_QNAME_ATTRIB(AuthorityKind,AUTHORITYKIND,NULL); MARSHALL_STRING_ATTRIB(Location,LOCATION,NULL); MARSHALL_STRING_ATTRIB(Binding,BINDING,NULL); } - + void processAttribute(const DOMAttr* attribute) { PROC_QNAME_ATTRIB(AuthorityKind,AUTHORITYKIND,NULL); PROC_STRING_ATTRIB(Location,LOCATION,NULL); @@ -490,12 +518,12 @@ namespace opensaml { XMLString::release(&m_AuthenticationMethod); delete m_AuthenticationInstant; } - + AuthenticationStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthenticationStatementImpl(const AuthenticationStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); setAuthenticationMethod(src.getAuthenticationMethod()); @@ -509,7 +537,7 @@ namespace opensaml { } } } - + void init() { m_AuthenticationMethod=NULL; m_AuthenticationInstant=NULL; @@ -518,7 +546,7 @@ namespace opensaml { m_pos_SubjectLocality=m_pos_Subject; ++m_pos_SubjectLocality; } - + IMPL_XMLOBJECT_CLONE(AuthenticationStatement); SubjectStatement* cloneSubjectStatement() const { return cloneAuthenticationStatement(); @@ -530,20 +558,20 @@ namespace opensaml { IMPL_DATETIME_ATTRIB(AuthenticationInstant,0); IMPL_TYPED_CHILD(SubjectLocality); IMPL_TYPED_CHILDREN(AuthorityBinding, m_children.end()); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); MARSHALL_DATETIME_ATTRIB(AuthenticationInstant,AUTHENTICATIONINSTANT,NULL); SubjectStatementImpl::marshallAttributes(domElement); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(SubjectLocality,SAML1_NS,false); PROC_TYPED_CHILDREN(AuthorityBinding,SAML1_NS,false); SubjectStatementImpl::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); PROC_DATETIME_ATTRIB(AuthenticationInstant,AUTHENTICATIONINSTANT,NULL); @@ -561,18 +589,18 @@ namespace opensaml { virtual ~ActionImpl() { XMLString::release(&m_Namespace); } - + ActionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Namespace(NULL) { } - + ActionImpl(const ActionImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { setNamespace(src.getNamespace()); } - + IMPL_XMLOBJECT_CLONE(Action); IMPL_STRING_ATTRIB(Namespace); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Namespace,NAMESPACE,NULL); @@ -591,11 +619,11 @@ namespace opensaml { { public: virtual ~EvidenceImpl() {} - + EvidenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + EvidenceImpl(const EvidenceImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { @@ -605,7 +633,7 @@ namespace opensaml { getAssertionIDReferences().push_back(ref->cloneAssertionIDReference()); continue; } - + Assertion* assertion=dynamic_cast(*i); if (assertion) { getAssertions().push_back(assertion->cloneAssertion()); @@ -614,11 +642,11 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Evidence); IMPL_TYPED_CHILDREN(AssertionIDReference,m_children.end()); IMPL_TYPED_CHILDREN(Assertion,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AssertionIDReference,SAML1_NS,false); @@ -635,12 +663,12 @@ namespace opensaml { XMLString::release(&m_Resource); XMLString::release(&m_Decision); } - + AuthorizationDecisionStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthorizationDecisionStatementImpl(const AuthorizationDecisionStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); @@ -655,7 +683,7 @@ namespace opensaml { } } } - + void init() { m_Resource=NULL; m_Decision=NULL; @@ -664,7 +692,7 @@ namespace opensaml { m_pos_Evidence=m_pos_Subject; ++m_pos_Evidence; } - + IMPL_XMLOBJECT_CLONE(AuthorizationDecisionStatement); SubjectStatement* cloneSubjectStatement() const { return cloneAuthorizationDecisionStatement(); @@ -676,20 +704,20 @@ namespace opensaml { IMPL_STRING_ATTRIB(Decision); IMPL_TYPED_CHILD(Evidence); IMPL_TYPED_CHILDREN(Action, m_pos_Evidence); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); MARSHALL_STRING_ATTRIB(Decision,DECISION,NULL); SubjectStatementImpl::marshallAttributes(domElement); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Evidence,SAML1_NS,false); PROC_TYPED_CHILDREN(Action,SAML1_NS,false); SubjectStatementImpl::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); PROC_STRING_ATTRIB(Decision,DECISION,NULL); @@ -708,33 +736,33 @@ namespace opensaml { XMLString::release(&m_AttributeName); XMLString::release(&m_AttributeNamespace); } - + AttributeDesignatorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AttributeDesignatorImpl(const AttributeDesignatorImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setAttributeName(src.getAttributeName()); setAttributeNamespace(src.getAttributeNamespace()); } - + void init() { m_AttributeName=m_AttributeNamespace=NULL; } - + IMPL_XMLOBJECT_CLONE(AttributeDesignator); IMPL_STRING_ATTRIB(AttributeName); IMPL_STRING_ATTRIB(AttributeNamespace); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,NULL); MARSHALL_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,NULL); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,NULL); PROC_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,NULL); @@ -752,12 +780,12 @@ namespace opensaml { XMLString::release(&m_AttributeName); XMLString::release(&m_AttributeNamespace); } - + AttributeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AttributeImpl(const AttributeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -770,11 +798,11 @@ namespace opensaml { } } } - + void init() { m_AttributeName=m_AttributeNamespace=NULL; } - + IMPL_XMLOBJECT_CLONE(Attribute); AttributeDesignator* cloneAttributeDesignator() const { return cloneAttribute(); @@ -782,7 +810,7 @@ namespace opensaml { IMPL_STRING_ATTRIB(AttributeName); IMPL_STRING_ATTRIB(AttributeNamespace); IMPL_XMLOBJECT_CHILDREN(AttributeValue,m_children.end()); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,NULL); @@ -803,13 +831,13 @@ namespace opensaml { { public: virtual ~AttributeValueImpl() {} - + AttributeValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AttributeValueImpl(const AttributeValueImpl& src) : AnyElementImpl(src) {} - + IMPL_XMLOBJECT_CLONE(AttributeValue); }; @@ -817,11 +845,11 @@ namespace opensaml { { public: virtual ~AttributeStatementImpl() {} - + AttributeStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AttributeStatementImpl(const AttributeStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { VectorOf(Attribute) v=getAttributes(); @@ -831,7 +859,7 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AttributeStatement); SubjectStatement* cloneSubjectStatement() const { return cloneAttributeStatement(); @@ -840,7 +868,7 @@ namespace opensaml { return cloneAttributeStatement(); } IMPL_TYPED_CHILDREN(Attribute, m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(Attribute,SAML1_NS,true); @@ -856,11 +884,11 @@ namespace opensaml { { public: virtual ~AdviceImpl() {} - + AdviceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AdviceImpl(const AdviceImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { @@ -870,35 +898,35 @@ namespace opensaml { getAssertionIDReferences().push_back(ref->cloneAssertionIDReference()); continue; } - + Assertion* assertion=dynamic_cast(*i); if (assertion) { getAssertions().push_back(assertion->cloneAssertion()); continue; } - + getUnknownXMLObjects().push_back((*i)->clone()); } } } - + IMPL_XMLOBJECT_CLONE(Advice); IMPL_TYPED_CHILDREN(AssertionIDReference,m_children.end()); IMPL_TYPED_CHILDREN(Assertion,m_children.end()); IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AssertionIDReference,SAML1_NS,false); PROC_TYPED_CHILDREN(Assertion,SAML1_NS,true); - + // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,SAML1_NS) && nsURI && *nsURI) { getUnknownXMLObjects().push_back(childXMLObject); return; } - + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; @@ -933,12 +961,12 @@ namespace opensaml { XMLString::release(&m_Issuer); delete m_IssueInstant; } - + AssertionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AssertionImpl(const AssertionImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -971,13 +999,13 @@ namespace opensaml { getAuthorizationDecisionStatements().push_back(authzst->cloneAuthorizationDecisionStatement()); continue; } - + SubjectStatement* subst=dynamic_cast(*i); if (subst) { getSubjectStatements().push_back(subst->cloneSubjectStatement()); continue; } - + Statement* st=dynamic_cast(*i); if (st) { getStatements().push_back(st->cloneStatement()); @@ -986,7 +1014,7 @@ namespace opensaml { } } } - + //IMPL_TYPED_CHILD(Signature); // Need customized setter. protected: @@ -996,7 +1024,7 @@ namespace opensaml { Signature* getSignature() const { return m_Signature; } - + void setSignature(Signature* sig) { prepareForAssignment(m_Signature,sig); *m_pos_Signature=m_Signature=sig; @@ -1004,7 +1032,7 @@ namespace opensaml { if (m_Signature) m_Signature->setContentReference(new opensaml::ContentReference(*this)); } - + IMPL_XMLOBJECT_CLONE(Assertion); IMPL_INTEGER_ATTRIB(MinorVersion); IMPL_STRING_ATTRIB(AssertionID); // have to special-case getXMLID @@ -1024,7 +1052,7 @@ namespace opensaml { IMPL_TYPED_CHILDREN(AuthenticationStatement, m_pos_Signature); IMPL_TYPED_CHILDREN(AttributeStatement, m_pos_Signature); IMPL_TYPED_CHILDREN(AuthorizationDecisionStatement, m_pos_Signature); - + protected: void marshallAttributes(DOMElement* domElement) const { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); @@ -1044,7 +1072,7 @@ namespace opensaml { } MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Conditions,SAML1_NS,false); PROC_TYPED_CHILD(Advice,SAML1_NS,false); @@ -1056,7 +1084,7 @@ namespace opensaml { PROC_TYPED_CHILDREN(Statement,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } - + void unmarshallAttributes(const DOMElement* domElement) { // Standard processing, but then we check IDness. AbstractXMLObjectUnmarshaller::unmarshallAttributes(domElement); @@ -1076,7 +1104,7 @@ namespace opensaml { PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); } }; - + }; }; @@ -1099,11 +1127,13 @@ IMPL_XMLOBJECTBUILDER(AudienceRestrictionCondition); IMPL_XMLOBJECTBUILDER(AuthenticationStatement); IMPL_XMLOBJECTBUILDER(AuthorizationDecisionStatement); IMPL_XMLOBJECTBUILDER(AuthorityBinding); +IMPL_XMLOBJECTBUILDER(Condition); IMPL_XMLOBJECTBUILDER(Conditions); IMPL_XMLOBJECTBUILDER(ConfirmationMethod); IMPL_XMLOBJECTBUILDER(DoNotCacheCondition); IMPL_XMLOBJECTBUILDER(Evidence); IMPL_XMLOBJECTBUILDER(NameIdentifier); +IMPL_XMLOBJECTBUILDER(Statement); IMPL_XMLOBJECTBUILDER(Subject); IMPL_XMLOBJECTBUILDER(SubjectConfirmation); IMPL_XMLOBJECTBUILDER(SubjectConfirmationData); diff --git a/saml/saml1/core/impl/AssertionsSchemaValidators.cpp b/saml/saml1/core/impl/AssertionsSchemaValidators.cpp index 0b7e7b9..58f2f4d 100644 --- a/saml/saml1/core/impl/AssertionsSchemaValidators.cpp +++ b/saml/saml1/core/impl/AssertionsSchemaValidators.cpp @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * AssertionsSchemaValidators.cpp - * + * * Schema-based validators for SAML 1.x Assertions classes */ @@ -34,7 +34,7 @@ using samlconstants::SAML1_NS; namespace opensaml { namespace saml1 { - + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,Action); XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,AssertionIDReference); XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,Audience); @@ -148,7 +148,7 @@ namespace opensaml { q=QName(SAML1_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ SchemaValidators.registerValidator(q,new cname##SchemaValidator()) - + #define REGISTER_TYPE(cname) \ q=QName(SAML1_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ @@ -157,7 +157,7 @@ namespace opensaml { #define REGISTER_ELEMENT_NOVAL(cname) \ q=QName(SAML1_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); - + #define REGISTER_TYPE_NOVAL(cname) \ q=QName(SAML1_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); @@ -177,11 +177,13 @@ void opensaml::saml1::registerAssertionClasses() { REGISTER_ELEMENT(AuthenticationStatement); REGISTER_ELEMENT(AuthorityBinding); REGISTER_ELEMENT(AuthorizationDecisionStatement); + REGISTER_ELEMENT_NOVAL(Condition); REGISTER_ELEMENT(Conditions); REGISTER_ELEMENT(ConfirmationMethod); REGISTER_ELEMENT_NOVAL(DoNotCacheCondition); REGISTER_ELEMENT(Evidence); REGISTER_ELEMENT(NameIdentifier); + REGISTER_ELEMENT_NOVAL(Statement); REGISTER_ELEMENT(Subject); REGISTER_ELEMENT(SubjectConfirmation); REGISTER_ELEMENT_NOVAL(SubjectConfirmationData); diff --git a/saml/saml1/core/impl/ProtocolsImpl.cpp b/saml/saml1/core/impl/ProtocolsImpl.cpp index dc40986..118ff98 100644 --- a/saml/saml1/core/impl/ProtocolsImpl.cpp +++ b/saml/saml1/core/impl/ProtocolsImpl.cpp @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * ProtocolsImpl.cpp - * + * * Implementation classes for SAML 1.x Protocols schema */ @@ -53,7 +53,7 @@ using samlconstants::SAML1P_PREFIX; namespace opensaml { namespace saml1p { - + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AssertionArtifact); DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,StatusMessage); @@ -68,20 +68,20 @@ namespace opensaml { virtual ~RespondWithImpl() { delete m_qname; } - + RespondWithImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_qname(NULL) { } - + RespondWithImpl(const RespondWithImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), m_qname(NULL) { setQName(src.getQName()); } - + QName* getQName() const { return m_qname; } - + void setQName(const QName* qname) { m_qname=prepareForAssignment(m_qname,qname); if (m_qname) { @@ -91,10 +91,24 @@ namespace opensaml { else setTextContent(NULL); } - + IMPL_XMLOBJECT_CLONE(RespondWith); }; + class SAML_DLLLOCAL QueryImpl : public virtual Query, public AnyElementImpl + { + public: + virtual ~QueryImpl() {} + + QueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + QueryImpl(const QueryImpl& src) : AnyElementImpl(src) {} + + IMPL_XMLOBJECT_CLONE(Query); + }; + class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, public AbstractComplexElement, public AbstractDOMCachingXMLObject, @@ -112,21 +126,21 @@ namespace opensaml { } public: virtual ~SubjectQueryImpl() {} - + SubjectQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); } - + IMPL_TYPED_CHILD(Subject); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Subject,SAML1_NS,true); @@ -143,17 +157,17 @@ namespace opensaml { virtual ~AuthenticationQueryImpl() { XMLString::release(&m_AuthenticationMethod); } - + AuthenticationQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthenticationQueryImpl(const AuthenticationQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); setAuthenticationMethod(src.getAuthenticationMethod()); } - + IMPL_XMLOBJECT_CLONE(AuthenticationQuery); SubjectQuery* cloneSubjectQuery() const { return cloneAuthenticationQuery(); @@ -162,13 +176,13 @@ namespace opensaml { return cloneAuthenticationQuery(); } IMPL_STRING_ATTRIB(AuthenticationMethod); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); SubjectQueryImpl::marshallAttributes(domElement); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); SubjectQueryImpl::processAttribute(attribute); @@ -184,12 +198,12 @@ namespace opensaml { virtual ~AttributeQueryImpl() { XMLString::release(&m_Resource); } - + AttributeQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AttributeQueryImpl(const AttributeQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); setResource(src.getResource()); @@ -200,7 +214,7 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AttributeQuery); SubjectQuery* cloneSubjectQuery() const { return cloneAttributeQuery(); @@ -210,18 +224,18 @@ namespace opensaml { } IMPL_STRING_ATTRIB(Resource); IMPL_TYPED_CHILDREN(AttributeDesignator,m_children.end()); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); SubjectQueryImpl::marshallAttributes(domElement); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AttributeDesignator,SAML1_NS,true); SubjectQueryImpl::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); SubjectQueryImpl::processAttribute(attribute); @@ -241,12 +255,12 @@ namespace opensaml { virtual ~AuthorizationDecisionQueryImpl() { XMLString::release(&m_Resource); } - + AuthorizationDecisionQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthorizationDecisionQueryImpl(const AuthorizationDecisionQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); setResource(src.getResource()); @@ -259,7 +273,7 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AuthorizationDecisionQuery); SubjectQuery* cloneSubjectQuery() const { return cloneAuthorizationDecisionQuery(); @@ -270,19 +284,19 @@ namespace opensaml { IMPL_STRING_ATTRIB(Resource); IMPL_TYPED_CHILD(Evidence); IMPL_TYPED_CHILDREN(Action, m_pos_Evidence); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); SubjectQueryImpl::marshallAttributes(domElement); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Evidence,SAML1_NS,false); PROC_TYPED_CHILDREN(Action,SAML1_NS,false); SubjectQueryImpl::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); SubjectQueryImpl::processAttribute(attribute); @@ -313,12 +327,12 @@ namespace opensaml { XMLString::release(&m_RequestID); delete m_IssueInstant; } - + RequestAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -334,7 +348,7 @@ namespace opensaml { } } } - + //IMPL_TYPED_CHILD(Signature); // Need customized setter. protected: @@ -344,7 +358,7 @@ namespace opensaml { Signature* getSignature() const { return m_Signature; } - + void setSignature(Signature* sig) { prepareForAssignment(m_Signature,sig); *m_pos_Signature=m_Signature=sig; @@ -364,7 +378,7 @@ namespace opensaml { } IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_TYPED_CHILDREN(RespondWith,m_pos_Signature); - + protected: void marshallAttributes(DOMElement* domElement) const { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); @@ -419,12 +433,12 @@ namespace opensaml { } public: virtual ~RequestImpl() {} - + RequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + RequestImpl(const RequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); if (src.getQuery()) @@ -442,13 +456,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Request); RequestAbstractType* cloneRequestAbstractType() const { return cloneRequest(); } IMPL_TYPED_CHILD(Query); - + SubjectQuery* getSubjectQuery() const { return dynamic_cast(getQuery()); } @@ -474,10 +488,10 @@ namespace opensaml { void setAuthorizationDecisionQuery(AuthorizationDecisionQuery* q) { setQuery(q); } - + IMPL_TYPED_CHILDREN(AssertionIDReference, m_children.end()); IMPL_TYPED_CHILDREN(AssertionArtifact, m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Query,SAML1P_NS,true); @@ -503,12 +517,12 @@ namespace opensaml { virtual ~StatusCodeImpl() { delete m_Value; } - + StatusCodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + StatusCodeImpl(const StatusCodeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -516,11 +530,11 @@ namespace opensaml { if (src.getStatusCode()) setStatusCode(src.getStatusCode()->cloneStatusCode()); } - + IMPL_XMLOBJECT_CLONE(StatusCode); IMPL_XMLOBJECT_ATTRIB(Value,QName); IMPL_TYPED_CHILD(StatusCode); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_QNAME_ATTRIB(Value,VALUE,NULL); @@ -544,21 +558,21 @@ namespace opensaml { { public: virtual ~StatusDetailImpl() {} - + StatusDetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + StatusDetailImpl(const StatusDetailImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOf(XMLObject) v=getUnknownXMLObjects(); for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) v.push_back((*i)->clone()); } - + IMPL_XMLOBJECT_CLONE(StatusDetail); IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { getUnknownXMLObjects().push_back(childXMLObject); @@ -586,12 +600,12 @@ namespace opensaml { } public: virtual ~StatusImpl() {} - + StatusImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + StatusImpl(const StatusImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -602,12 +616,12 @@ namespace opensaml { if (src.getStatusDetail()) setStatusDetail(src.getStatusDetail()->cloneStatusDetail()); } - + IMPL_XMLOBJECT_CLONE(Status); IMPL_TYPED_CHILD(StatusCode); IMPL_TYPED_CHILD(StatusMessage); IMPL_TYPED_CHILD(StatusDetail); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(StatusCode,SAML1P_NS,false); @@ -645,12 +659,12 @@ namespace opensaml { XMLString::release(&m_Recipient); delete m_IssueInstant; } - + ResponseAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + ResponseAbstractTypeImpl(const ResponseAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -672,7 +686,7 @@ namespace opensaml { Signature* getSignature() const { return m_Signature; } - + void setSignature(Signature* sig) { prepareForAssignment(m_Signature,sig); *m_pos_Signature=m_Signature=sig; @@ -693,7 +707,7 @@ namespace opensaml { IMPL_STRING_ATTRIB(InResponseTo); IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_STRING_ATTRIB(Recipient); - + protected: void marshallAttributes(DOMElement* domElement) const { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); @@ -751,12 +765,12 @@ namespace opensaml { } public: virtual ~ResponseImpl() {} - + ResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + ResponseImpl(const ResponseImpl& src) : AbstractXMLObject(src), ResponseAbstractTypeImpl(src) { init(); if (src.getStatus()) @@ -768,14 +782,14 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Response); ResponseAbstractType* cloneResponseAbstractType() const { return cloneResponse(); } IMPL_TYPED_CHILD(Status); IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml1,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Status,SAML1P_NS,false); @@ -797,6 +811,7 @@ IMPL_XMLOBJECTBUILDER(AssertionArtifact); IMPL_XMLOBJECTBUILDER(AttributeQuery); IMPL_XMLOBJECTBUILDER(AuthenticationQuery); IMPL_XMLOBJECTBUILDER(AuthorizationDecisionQuery); +IMPL_XMLOBJECTBUILDER(Query); IMPL_XMLOBJECTBUILDER(Request); IMPL_XMLOBJECTBUILDER(RespondWith); IMPL_XMLOBJECTBUILDER(Response); @@ -851,7 +866,7 @@ const XMLCh _SUCCESS[] = UNICODE_LITERAL_7(S, const XMLCh _REQUESTER[] = UNICODE_LITERAL_9(R,e,q,u,e,s,t,e,r); const XMLCh _RESPONDER[] = UNICODE_LITERAL_9(R,e,s,p,o,n,d,e,r); const XMLCh _VERSIONMISMATCH[] = UNICODE_LITERAL_15(V,e,r,s,i,o,n,M,i,s,m,a,t,c,h); - + QName StatusCode::SUCCESS(SAML1P_NS,_SUCCESS,SAML1P_PREFIX); QName StatusCode::REQUESTER(SAML1P_NS,_REQUESTER,SAML1P_PREFIX); QName StatusCode::RESPONDER(SAML1P_NS,_RESPONDER,SAML1P_PREFIX); diff --git a/saml/saml1/core/impl/ProtocolsSchemaValidators.cpp b/saml/saml1/core/impl/ProtocolsSchemaValidators.cpp index 21c27f1..dda4ec2 100644 --- a/saml/saml1/core/impl/ProtocolsSchemaValidators.cpp +++ b/saml/saml1/core/impl/ProtocolsSchemaValidators.cpp @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * ProtocolsSchemaValidators.cpp - * + * * Schema-based validators for SAML 1.x Protocols classes */ @@ -35,10 +35,10 @@ using samlconstants::SAML1P_NS; namespace opensaml { namespace saml1p { - + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,AssertionArtifact); XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,StatusMessage); - + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,RespondWith); XMLOBJECTVALIDATOR_REQUIRE(RespondWith,QName); END_XMLOBJECTVALIDATOR; @@ -84,7 +84,7 @@ namespace opensaml { const QName* value=ptr->getStatusCode()->getValue(); if (!value || (*value!=StatusCode::SUCCESS && *value!=StatusCode::REQUESTER && *value!=StatusCode::RESPONDER && *value!=StatusCode::VERSIONMISMATCH)) - throw ValidationException("Top-level status code not one of the allowable values."); + throw ValidationException("Top-level status code not one of the allowable values."); END_XMLOBJECTVALIDATOR; BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,Response); @@ -102,7 +102,7 @@ namespace opensaml { q=QName(SAML1P_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ SchemaValidators.registerValidator(q,new cname##SchemaValidator()) - + #define REGISTER_TYPE(cname) \ q=QName(SAML1P_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ @@ -111,7 +111,7 @@ namespace opensaml { #define REGISTER_ELEMENT_NOVAL(cname) \ q=QName(SAML1P_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); - + #define REGISTER_TYPE_NOVAL(cname) \ q=QName(SAML1P_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); @@ -122,6 +122,7 @@ void opensaml::saml1p::registerProtocolClasses() { REGISTER_ELEMENT(AttributeQuery); REGISTER_ELEMENT(AuthenticationQuery); REGISTER_ELEMENT(AuthorizationDecisionQuery); + REGISTER_ELEMENT_NOVAL(Query); REGISTER_ELEMENT(Request); REGISTER_ELEMENT(RespondWith); REGISTER_ELEMENT(Response); diff --git a/saml/saml2/core/Assertions.h b/saml/saml2/core/Assertions.h index 91ac1fe..fb5c7d0 100644 --- a/saml/saml2/core/Assertions.h +++ b/saml/saml2/core/Assertions.h @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * @file saml/saml2/core/Assertions.h - * + * * XMLObjects representing the SAML 2.0 Assertions schema */ @@ -48,7 +48,7 @@ namespace opensaml { * SAML 2.0 assertion namespace */ namespace saml2 { - + // Forward references class SAML_API Assertion; class SAML_API EncryptedAssertion; @@ -62,7 +62,7 @@ namespace opensaml { EncryptableObject() {} virtual ~EncryptableObject() {} }; - + DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionIDRef,AssertionID,SAML 2.0 AssertionIDRef element); DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionURIRef,AssertionURI,SAML 2.0 AssertionURIRef element); DECL_XMLOBJECT_SIMPLE(SAML_API,Audience,AudienceURI,SAML 2.0 Audience element); @@ -75,10 +75,10 @@ namespace opensaml { DECL_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption); /** EncryptedElementType local name */ static const XMLCh TYPE_NAME[]; - + /** * Encrypts an object to a single recipient using this object as a container. - * + * * @param xmlObject object to encrypt * @param metadataProvider a locked MetadataProvider to supply encryption keys * @param criteria metadata-based CredentialCriteria to use @@ -96,7 +96,7 @@ namespace opensaml { /** * Encrypts an object to multiple recipients using this object as a container. - * + * * @param xmlObject object to encrypt * @param recipients pairs containing a locked MetadataProvider to supply encryption keys, * and a metadata-based CredentialCriteria to use @@ -116,7 +116,7 @@ namespace opensaml { * *

The object returned will be unmarshalled around the decrypted DOM element in a * new Document owned by the object. - * + * * @param credResolver locked resolver supplying decryption keys * @param recipient identifier naming the recipient (the entity performing the decryption) * @param criteria optional external criteria to use with resolver @@ -169,7 +169,7 @@ namespace opensaml { BEGIN_XMLOBJECT(SAML_API,Condition,xmltooling::XMLObject,SAML 2.0 Condition element); END_XMLOBJECT; - + BEGIN_XMLOBJECT(SAML_API,AudienceRestriction,Condition,SAML 2.0 AudienceRestriction element); DECL_TYPED_CHILDREN(Audience); /** AudienceRestrictionType local name */ @@ -216,7 +216,7 @@ namespace opensaml { /** KeyInfoConfirmationDataType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - + BEGIN_XMLOBJECT(SAML_API,SubjectConfirmation,xmltooling::XMLObject,SAML 2.0 SubjectConfirmation element); DECL_STRING_ATTRIB(Method,METHOD); DECL_TYPED_CHILD(BaseID); @@ -362,10 +362,10 @@ namespace opensaml { RootObject() {} public: virtual ~RootObject() {} - + /** Gets the Version attribute. */ virtual const XMLCh* getVersion() const=0; - + /** Gets the Issuer. */ virtual Issuer* getIssuer() const=0; }; @@ -416,10 +416,10 @@ namespace opensaml { DECL_SAML2OBJECTBUILDER(SubjectConfirmation); DECL_SAML2OBJECTBUILDER(SubjectConfirmationData); DECL_SAML2OBJECTBUILDER(SubjectLocality); - + /** * Builder for NameIDType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API NameIDTypeBuilder : public xmltooling::XMLObjectBuilder { @@ -433,7 +433,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static NameIDType* buildNameIDType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { const NameIDTypeBuilder* b = dynamic_cast( @@ -452,8 +452,41 @@ namespace opensaml { }; /** + * Builder for Condition extension objects. + * + * This is customized to force the schema type to be specified. + */ + class SAML_API ConditionBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~ConditionBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual Condition* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static Condition* buildCondition(const xmltooling::QName& schemaType) { + const ConditionBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20_NS,Condition::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML20_NS, Condition::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML20_NS, Condition::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for Condition."); + } + }; + + /** * Builder for KeyInfoConfirmationDataType objects. - * + * * This is customized to return a SubjectConfirmationData element with an * xsi:type of KeyInfoConfirmationDataType. */ @@ -481,7 +514,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static KeyInfoConfirmationDataType* buildKeyInfoConfirmationDataType() { const KeyInfoConfirmationDataTypeBuilder* b = dynamic_cast( @@ -498,6 +531,39 @@ namespace opensaml { }; /** + * Builder for Statement extension objects. + * + * This is customized to force the schema type to be specified. + */ + class SAML_API StatementBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~StatementBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual Statement* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static Statement* buildStatement(const xmltooling::QName& schemaType) { + const StatementBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20_NS,Statement::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML20_NS, Statement::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML20_NS, Statement::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for Statement."); + } + }; + + /** * Registers builders and validators for SAML 2.0 Assertion classes into the runtime. */ void SAML_API registerAssertionClasses(); diff --git a/saml/saml2/core/impl/Assertions20Impl.cpp b/saml/saml2/core/impl/Assertions20Impl.cpp index 00c90b4..18f0776 100644 --- a/saml/saml2/core/impl/Assertions20Impl.cpp +++ b/saml/saml2/core/impl/Assertions20Impl.cpp @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * Assertions20Impl.cpp - * + * * Implementation classes for SAML 2.0 Assertions schema */ @@ -71,12 +71,12 @@ namespace opensaml { void init() { m_Format=m_SPProvidedID=m_NameQualifier=m_SPNameQualifier=NULL; } - + protected: NameIDTypeImpl() { init(); } - + public: virtual ~NameIDTypeImpl() { XMLString::release(&m_NameQualifier); @@ -84,12 +84,12 @@ namespace opensaml { XMLString::release(&m_Format); XMLString::release(&m_SPProvidedID); } - + NameIDTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + NameIDTypeImpl(const NameIDTypeImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -98,13 +98,13 @@ namespace opensaml { setFormat(src.getFormat()); setSPProvidedID(src.getSPProvidedID()); } - + IMPL_XMLOBJECT_CLONE(NameIDType); IMPL_STRING_ATTRIB(NameQualifier); IMPL_STRING_ATTRIB(SPNameQualifier); IMPL_STRING_ATTRIB(Format); IMPL_STRING_ATTRIB(SPProvidedID); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(NameQualifier,NAMEQUALIFIER,NULL); @@ -126,12 +126,12 @@ namespace opensaml { { public: virtual ~NameIDImpl() {} - + NameIDImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - + NameIDImpl(const NameIDImpl& src) : AbstractXMLObject(src), NameIDTypeImpl(src) {} - + IMPL_XMLOBJECT_CLONE(NameID); NameIDType* cloneNameIDType() const { return new NameIDImpl(*this); @@ -142,12 +142,12 @@ namespace opensaml { { public: virtual ~IssuerImpl() {} - + IssuerImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - + IssuerImpl(const IssuerImpl& src) : AbstractXMLObject(src), NameIDTypeImpl(src) {} - + IMPL_XMLOBJECT_CLONE(Issuer); NameIDType* cloneNameIDType() const { return new IssuerImpl(*this); @@ -167,20 +167,20 @@ namespace opensaml { m_children.push_back(NULL); m_pos_EncryptedData=m_children.begin(); } - + protected: EncryptedElementTypeImpl() { init(); } - + public: virtual ~EncryptedElementTypeImpl() {} - + EncryptedElementTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + EncryptedElementTypeImpl(const EncryptedElementTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -193,11 +193,11 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(EncryptedElementType); IMPL_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption); IMPL_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption,XMLENC_NS,false); @@ -210,18 +210,32 @@ namespace opensaml { { public: virtual ~EncryptedIDImpl() {} - + EncryptedIDImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - + EncryptedIDImpl(const EncryptedIDImpl& src) : AbstractXMLObject(src), EncryptedElementTypeImpl(src) {} - + IMPL_XMLOBJECT_CLONE(EncryptedID); EncryptedElementType* cloneEncryptedElementType() const { return new EncryptedIDImpl(*this); } }; + class SAML_DLLLOCAL ConditionImpl : public virtual Condition, public AnyElementImpl + { + public: + virtual ~ConditionImpl() {} + + ConditionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + ConditionImpl(const ConditionImpl& src) : AnyElementImpl(src) {} + + IMPL_XMLOBJECT_CLONE(Condition); + }; + class SAML_DLLLOCAL AudienceRestrictionImpl : public virtual AudienceRestriction, public AbstractComplexElement, public AbstractDOMCachingXMLObject, @@ -230,11 +244,11 @@ namespace opensaml { { public: virtual ~AudienceRestrictionImpl() {} - + AudienceRestrictionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AudienceRestrictionImpl(const AudienceRestrictionImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOf(Audience) v=getAudiences(); @@ -244,13 +258,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AudienceRestriction); Condition* cloneCondition() const { return cloneAudienceRestriction(); } IMPL_TYPED_CHILDREN(Audience,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(Audience,SAML20_NS,false); @@ -266,15 +280,15 @@ namespace opensaml { { public: virtual ~OneTimeUseImpl() {} - + OneTimeUseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + OneTimeUseImpl(const OneTimeUseImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { } - + IMPL_XMLOBJECT_CLONE(OneTimeUse); Condition* cloneCondition() const { return cloneOneTimeUse(); @@ -291,12 +305,12 @@ namespace opensaml { virtual ~ProxyRestrictionImpl() { XMLString::release(&m_Count); } - + ProxyRestrictionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { m_Count=NULL; } - + ProxyRestrictionImpl(const ProxyRestrictionImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { setCount(src.m_Count); @@ -307,14 +321,14 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(ProxyRestriction); Condition* cloneCondition() const { return cloneProxyRestriction(); } IMPL_TYPED_CHILDREN(Audience,m_children.end()); IMPL_INTEGER_ATTRIB(Count); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_INTEGER_ATTRIB(Count,COUNT,NULL); @@ -346,12 +360,12 @@ namespace opensaml { delete m_NotBefore; delete m_NotOnOrAfter; } - + ConditionsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + ConditionsImpl(const ConditionsImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -365,13 +379,13 @@ namespace opensaml { getAudienceRestrictions().push_back(arc->cloneAudienceRestriction()); continue; } - + OneTimeUse* dncc=dynamic_cast(*i); if (dncc) { getOneTimeUses().push_back(dncc->cloneOneTimeUse()); continue; } - + ProxyRestriction* prc=dynamic_cast(*i); if (prc) { getProxyRestrictions().push_back(prc->cloneProxyRestriction()); @@ -386,7 +400,7 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Conditions); IMPL_DATETIME_ATTRIB(NotBefore,0); IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); @@ -394,13 +408,13 @@ namespace opensaml { IMPL_TYPED_CHILDREN(OneTimeUse,m_children.end()); IMPL_TYPED_CHILDREN(ProxyRestriction, m_children.end()); IMPL_TYPED_CHILDREN(Condition,m_children.end()); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); MARSHALL_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AudienceRestriction,SAML20_NS,false); PROC_TYPED_CHILDREN(OneTimeUse,SAML20_NS,false); @@ -408,7 +422,7 @@ namespace opensaml { PROC_TYPED_CHILDREN(Condition,SAML20_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); @@ -436,12 +450,12 @@ namespace opensaml { XMLString::release(&m_InResponseTo); XMLString::release(&m_Address); } - + SubjectConfirmationDataTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectConfirmationDataTypeImpl(const SubjectConfirmationDataTypeImpl& src) : AbstractXMLObject(src) { init(); setNotBefore(src.getNotBefore()); @@ -450,13 +464,13 @@ namespace opensaml { setInResponseTo(src.getInResponseTo()); setAddress(src.getAddress()); } - + IMPL_DATETIME_ATTRIB(NotBefore,0); IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); IMPL_STRING_ATTRIB(Recipient); IMPL_STRING_ATTRIB(InResponseTo); IMPL_STRING_ATTRIB(Address); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); @@ -465,7 +479,7 @@ namespace opensaml { MARSHALL_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); MARSHALL_STRING_ATTRIB(Address,ADDRESS,NULL); } - + void processAttribute(const DOMAttr* attribute) { PROC_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); @@ -480,11 +494,11 @@ namespace opensaml { { public: virtual ~SubjectConfirmationDataImpl() {} - + SubjectConfirmationDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : SubjectConfirmationDataTypeImpl(src), AnyElementImpl(src) { } @@ -546,11 +560,11 @@ namespace opensaml { { public: virtual ~KeyInfoConfirmationDataTypeImpl() {} - + KeyInfoConfirmationDataTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + KeyInfoConfirmationDataTypeImpl(const KeyInfoConfirmationDataTypeImpl& src) : AbstractXMLObject(src), SubjectConfirmationDataTypeImpl(src), AbstractComplexElement(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { @@ -558,14 +572,14 @@ namespace opensaml { for (vector::const_iterator i=src.m_KeyInfos.begin(); i!=src.m_KeyInfos.end(); ++i) v.push_back((*i)->cloneKeyInfo()); } - + IMPL_XMLOBJECT_CLONE(KeyInfoConfirmationDataType); SubjectConfirmationDataType* cloneSubjectConfirmationDataType() const { return new KeyInfoConfirmationDataTypeImpl(*this); } IMPL_TYPED_CHILDREN(KeyInfo,m_children.end()); - + public: void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) { if (!qualifiedName.hasNamespaceURI()) { @@ -598,7 +612,7 @@ namespace opensaml { SubjectConfirmationDataTypeImpl::marshallAttributes(domElement); marshallExtensionAttributes(domElement); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(KeyInfo,XMLSIG_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); @@ -635,12 +649,12 @@ namespace opensaml { } public: virtual ~SubjectConfirmationImpl() {} - + SubjectConfirmationImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectConfirmationImpl(const SubjectConfirmationImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -654,14 +668,14 @@ namespace opensaml { if (src.getSubjectConfirmationData()) setSubjectConfirmationData(src.getSubjectConfirmationData()->clone()); } - + IMPL_XMLOBJECT_CLONE(SubjectConfirmation); IMPL_STRING_ATTRIB(Method); IMPL_TYPED_CHILD(BaseID); IMPL_TYPED_CHILD(NameID); IMPL_TYPED_CHILD(EncryptedID); IMPL_XMLOBJECT_CHILD(SubjectConfirmationData); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Method,METHOD,NULL); @@ -702,12 +716,12 @@ namespace opensaml { } public: virtual ~SubjectImpl() {} - + SubjectImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectImpl(const SubjectImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -724,13 +738,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Subject); IMPL_TYPED_CHILD(NameID); IMPL_TYPED_CHILD(BaseID); IMPL_TYPED_CHILD(EncryptedID); IMPL_TYPED_CHILDREN(SubjectConfirmation,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(BaseID,SAML20_NS,false); @@ -755,29 +769,29 @@ namespace opensaml { XMLString::release(&m_Address); XMLString::release(&m_DNSName); } - + SubjectLocalityImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectLocalityImpl(const SubjectLocalityImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setAddress(src.getAddress()); setDNSName(src.getDNSName()); } - + IMPL_XMLOBJECT_CLONE(SubjectLocality); IMPL_STRING_ATTRIB(Address); IMPL_STRING_ATTRIB(DNSName); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Address,ADDRESS,NULL); MARSHALL_STRING_ATTRIB(DNSName,DNSNAME,NULL); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(Address,ADDRESS,NULL); PROC_STRING_ATTRIB(DNSName,DNSNAME,NULL); @@ -785,19 +799,33 @@ namespace opensaml { } }; + class SAML_DLLLOCAL StatementImpl : public virtual Statement, public AnyElementImpl + { + public: + virtual ~StatementImpl() {} + + StatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + StatementImpl(const StatementImpl& src) : AnyElementImpl(src) {} + + IMPL_XMLOBJECT_CLONE(Statement); + }; + //TODO need unit test for this class SAML_DLLLOCAL AuthnContextDeclImpl : public virtual AuthnContextDecl, public AnyElementImpl { public: virtual ~AuthnContextDeclImpl() {} - + AuthnContextDeclImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AuthnContextDeclImpl(const AuthnContextDeclImpl& src) : AnyElementImpl(src) { } - + IMPL_XMLOBJECT_CLONE(AuthnContextDecl); }; @@ -822,12 +850,12 @@ namespace opensaml { } public: virtual ~AuthnContextImpl() {} - + AuthnContextImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthnContextImpl(const AuthnContextImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -844,13 +872,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AuthnContext); IMPL_TYPED_CHILD(AuthnContextClassRef); IMPL_XMLOBJECT_CHILD(AuthnContextDecl); IMPL_TYPED_CHILD(AuthnContextDeclRef); IMPL_TYPED_CHILDREN(AuthenticatingAuthority,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(AuthnContextClassRef,SAML20_NS,false); @@ -885,12 +913,12 @@ namespace opensaml { XMLString::release(&m_SessionIndex); delete m_SessionNotOnOrAfter; } - + AuthnStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthnStatementImpl(const AuthnStatementImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -902,7 +930,7 @@ namespace opensaml { if (src.getAuthnContext()) setAuthnContext(src.getAuthnContext()->cloneAuthnContext()); } - + IMPL_XMLOBJECT_CLONE(AuthnStatement); Statement* cloneStatement() const { return cloneAuthnStatement(); @@ -912,20 +940,20 @@ namespace opensaml { IMPL_DATETIME_ATTRIB(SessionNotOnOrAfter,SAMLTIME_MAX); IMPL_TYPED_CHILD(SubjectLocality); IMPL_TYPED_CHILD(AuthnContext); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_DATETIME_ATTRIB(AuthnInstant,AUTHNINSTANT,NULL); MARSHALL_STRING_ATTRIB(SessionIndex,SESSIONINDEX,NULL); MARSHALL_DATETIME_ATTRIB(SessionNotOnOrAfter,SESSIONNOTONORAFTER,NULL); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(SubjectLocality,SAML20_NS,false); PROC_TYPED_CHILD(AuthnContext,SAML20_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_DATETIME_ATTRIB(AuthnInstant,AUTHNINSTANT,NULL); PROC_STRING_ATTRIB(SessionIndex,SESSIONINDEX,NULL); @@ -944,19 +972,19 @@ namespace opensaml { virtual ~ActionImpl() { XMLString::release(&m_Namespace); } - + ActionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Namespace(NULL) { } - + ActionImpl(const ActionImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { setNamespace(src.getNamespace()); } - + IMPL_XMLOBJECT_CLONE(Action); IMPL_STRING_ATTRIB(Namespace); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Namespace,NAMESPACE,NULL); @@ -976,11 +1004,11 @@ namespace opensaml { { public: virtual ~EvidenceImpl() {} - + EvidenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + EvidenceImpl(const EvidenceImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { @@ -990,7 +1018,7 @@ namespace opensaml { getAssertionIDRefs().push_back(ref->cloneAssertionIDRef()); continue; } - + AssertionURIRef* uri=dynamic_cast(*i); if (uri) { getAssertionURIRefs().push_back(uri->cloneAssertionURIRef()); @@ -1002,7 +1030,7 @@ namespace opensaml { getAssertions().push_back(assertion->cloneAssertion()); continue; } - + EncryptedAssertion* enc=dynamic_cast(*i); if (enc) { getEncryptedAssertions().push_back(enc->cloneEncryptedAssertion()); @@ -1011,13 +1039,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Evidence); IMPL_TYPED_CHILDREN(AssertionIDRef,m_children.end()); IMPL_TYPED_CHILDREN(AssertionURIRef,m_children.end()); IMPL_TYPED_CHILDREN(Assertion,m_children.end()); IMPL_TYPED_CHILDREN(EncryptedAssertion,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AssertionIDRef,SAML20_NS,false); @@ -1046,12 +1074,12 @@ namespace opensaml { XMLString::release(&m_Resource); XMLString::release(&m_Decision); } - + AuthzDecisionStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthzDecisionStatementImpl(const AuthzDecisionStatementImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -1066,7 +1094,7 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AuthzDecisionStatement); Statement* cloneStatement() const { return cloneAuthzDecisionStatement(); @@ -1075,19 +1103,19 @@ namespace opensaml { IMPL_STRING_ATTRIB(Decision); IMPL_TYPED_CHILD(Evidence); IMPL_TYPED_CHILDREN(Action, m_pos_Evidence); - + protected: void marshallAttributes(DOMElement* domElement) const { MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); MARSHALL_STRING_ATTRIB(Decision,DECISION,NULL); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Evidence,SAML20_NS,false); PROC_TYPED_CHILDREN(Action,SAML20_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); PROC_STRING_ATTRIB(Decision,DECISION,NULL); @@ -1099,14 +1127,14 @@ namespace opensaml { { public: virtual ~AttributeValueImpl() {} - + AttributeValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AttributeValueImpl(const AttributeValueImpl& src) : AnyElementImpl(src) { } - + IMPL_XMLOBJECT_CLONE(AttributeValue); }; @@ -1127,12 +1155,12 @@ namespace opensaml { XMLString::release(&m_NameFormat); XMLString::release(&m_FriendlyName); } - + AttributeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AttributeImpl(const AttributeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { @@ -1147,13 +1175,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Attribute); IMPL_STRING_ATTRIB(Name); IMPL_STRING_ATTRIB(NameFormat); IMPL_STRING_ATTRIB(FriendlyName); IMPL_XMLOBJECT_CHILDREN(AttributeValue,m_children.end()); - + void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) { if (!qualifiedName.hasNamespaceURI()) { if (XMLString::equals(qualifiedName.getLocalPart(),NAME_ATTRIB_NAME)) { @@ -1189,17 +1217,17 @@ namespace opensaml { } }; - //TODO unit test for this + //TODO unit test for this class SAML_DLLLOCAL EncryptedAttributeImpl : public virtual EncryptedAttribute, public EncryptedElementTypeImpl { public: virtual ~EncryptedAttributeImpl() {} - + EncryptedAttributeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - + EncryptedAttributeImpl(const EncryptedAttributeImpl& src) : AbstractXMLObject(src), EncryptedElementTypeImpl(src) {} - + IMPL_XMLOBJECT_CLONE(EncryptedAttribute); EncryptedElementType* cloneEncryptedElementType() const { return new EncryptedAttributeImpl(*this); @@ -1214,11 +1242,11 @@ namespace opensaml { { public: virtual ~AttributeStatementImpl() {} - + AttributeStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AttributeStatementImpl(const AttributeStatementImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { @@ -1228,7 +1256,7 @@ namespace opensaml { getAttributes().push_back(attribute->cloneAttribute()); continue; } - + EncryptedAttribute* enc=dynamic_cast(*i); if (enc) { getEncryptedAttributes().push_back(enc->cloneEncryptedAttribute()); @@ -1237,14 +1265,14 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AttributeStatement); Statement* cloneStatement() const { return cloneAttributeStatement(); } IMPL_TYPED_CHILDREN(Attribute, m_children.end()); IMPL_TYPED_CHILDREN(EncryptedAttribute, m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(Attribute,SAML20_NS,false); @@ -1261,11 +1289,11 @@ namespace opensaml { { public: virtual ~AdviceImpl() {} - + AdviceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + AdviceImpl(const AdviceImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { @@ -1275,7 +1303,7 @@ namespace opensaml { getAssertionIDRefs().push_back(ref->cloneAssertionIDRef()); continue; } - + AssertionURIRef* uri=dynamic_cast(*i); if (uri) { getAssertionURIRefs().push_back(uri->cloneAssertionURIRef()); @@ -1287,7 +1315,7 @@ namespace opensaml { getAssertions().push_back(assertion->cloneAssertion()); continue; } - + EncryptedAssertion* enc=dynamic_cast(*i); if (enc) { getEncryptedAssertions().push_back(enc->cloneEncryptedAssertion()); @@ -1298,43 +1326,43 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Advice); IMPL_TYPED_CHILDREN(AssertionIDRef,m_children.end()); IMPL_TYPED_CHILDREN(AssertionURIRef,m_children.end()); IMPL_TYPED_CHILDREN(Assertion,m_children.end()); IMPL_TYPED_CHILDREN(EncryptedAssertion,m_children.end()); IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AssertionIDRef,SAML20_NS,false); PROC_TYPED_CHILDREN(AssertionURIRef,SAML20_NS,false); PROC_TYPED_CHILDREN(Assertion,SAML20_NS,false); PROC_TYPED_CHILDREN(EncryptedAssertion,SAML20_NS,false); - + // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); if (!XMLString::equals(nsURI,SAML20_NS) && nsURI && *nsURI) { getUnknownXMLObjects().push_back(childXMLObject); return; } - + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; - //TODO unit test for this + //TODO unit test for this class SAML_DLLLOCAL EncryptedAssertionImpl : public virtual EncryptedAssertion, public EncryptedElementTypeImpl { public: virtual ~EncryptedAssertionImpl() {} - + EncryptedAssertionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - + EncryptedAssertionImpl(const EncryptedAssertionImpl& src) : AbstractXMLObject(src), EncryptedElementTypeImpl(src) {} - + IMPL_XMLOBJECT_CLONE(EncryptedAssertion); EncryptedElementType* cloneEncryptedElementType() const { return new EncryptedAssertionImpl(*this); @@ -1377,12 +1405,12 @@ namespace opensaml { XMLString::release(&m_Version); delete m_IssueInstant; } - + AssertionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AssertionImpl(const AssertionImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -1418,7 +1446,7 @@ namespace opensaml { getAuthzDecisionStatements().push_back(authzst->cloneAuthzDecisionStatement()); continue; } - + Statement* st=dynamic_cast(*i); if (st) { getStatements().push_back(st->cloneStatement()); @@ -1427,7 +1455,7 @@ namespace opensaml { } } } - + //IMPL_TYPED_CHILD(Signature); // Need customized setter. protected: @@ -1437,7 +1465,7 @@ namespace opensaml { Signature* getSignature() const { return m_Signature; } - + void setSignature(Signature* sig) { prepareForAssignment(m_Signature,sig); *m_pos_Signature=m_Signature=sig; @@ -1445,7 +1473,7 @@ namespace opensaml { if (m_Signature) m_Signature->setContentReference(new opensaml::ContentReference(*this)); } - + IMPL_XMLOBJECT_CLONE(Assertion); IMPL_STRING_ATTRIB(Version); IMPL_ID_ATTRIB(ID); @@ -1458,7 +1486,7 @@ namespace opensaml { IMPL_TYPED_CHILDREN(AuthnStatement, m_children.end()); IMPL_TYPED_CHILDREN(AttributeStatement, m_children.end()); IMPL_TYPED_CHILDREN(AuthzDecisionStatement, m_children.end()); - + protected: void marshallAttributes(DOMElement* domElement) const { if (!m_Version) @@ -1473,7 +1501,7 @@ namespace opensaml { } MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Issuer,SAML20_NS,false); PROC_TYPED_CHILD(Signature,XMLSIG_NS,false); @@ -1486,7 +1514,7 @@ namespace opensaml { PROC_TYPED_CHILDREN(Statement,SAML20_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { PROC_STRING_ATTRIB(Version,VER,NULL); PROC_ID_ATTRIB(ID,ID,NULL); @@ -1521,6 +1549,7 @@ IMPL_XMLOBJECTBUILDER(AuthnContextDecl); IMPL_XMLOBJECTBUILDER(AuthnContextDeclRef); IMPL_XMLOBJECTBUILDER(AuthnStatement); IMPL_XMLOBJECTBUILDER(AuthzDecisionStatement); +IMPL_XMLOBJECTBUILDER(Condition); IMPL_XMLOBJECTBUILDER(Conditions); IMPL_XMLOBJECTBUILDER(EncryptedAssertion); IMPL_XMLOBJECTBUILDER(EncryptedAttribute); @@ -1532,6 +1561,7 @@ IMPL_XMLOBJECTBUILDER(NameID); IMPL_XMLOBJECTBUILDER(NameIDType); IMPL_XMLOBJECTBUILDER(OneTimeUse); IMPL_XMLOBJECTBUILDER(ProxyRestriction); +IMPL_XMLOBJECTBUILDER(Statement); IMPL_XMLOBJECTBUILDER(Subject); IMPL_XMLOBJECTBUILDER(SubjectConfirmation); IMPL_XMLOBJECTBUILDER(SubjectConfirmationData); diff --git a/saml/saml2/core/impl/Assertions20SchemaValidators.cpp b/saml/saml2/core/impl/Assertions20SchemaValidators.cpp index 7591ad0..34c29e9 100644 --- a/saml/saml2/core/impl/Assertions20SchemaValidators.cpp +++ b/saml/saml2/core/impl/Assertions20SchemaValidators.cpp @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * Assertions20SchemaValidators.cpp - * + * * Schema-based validators for SAML 2.0 Assertions classes */ @@ -34,7 +34,7 @@ using samlconstants::SAML20_NS; namespace opensaml { namespace saml2 { - + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,Action); XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,AssertionIDRef); XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,AssertionURIRef); @@ -49,7 +49,7 @@ namespace opensaml { BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,EncryptedElementType); XMLOBJECTVALIDATOR_REQUIRE(EncryptedElementType,EncryptedData); END_XMLOBJECTVALIDATOR; - + BEGIN_XMLOBJECTVALIDATOR_SUB(SAML_DLLLOCAL,EncryptedID,EncryptedElementType); EncryptedElementTypeSchemaValidator::validate(xmlObject); END_XMLOBJECTVALIDATOR; @@ -183,7 +183,7 @@ namespace opensaml { q=QName(SAML20_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ SchemaValidators.registerValidator(q,new cname##SchemaValidator()) - + #define REGISTER_TYPE(cname) \ q=QName(SAML20_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ @@ -192,7 +192,7 @@ namespace opensaml { #define REGISTER_ELEMENT_NOVAL(cname) \ q=QName(SAML20_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); - + #define REGISTER_TYPE_NOVAL(cname) \ q=QName(SAML20_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); @@ -216,6 +216,7 @@ void opensaml::saml2::registerAssertionClasses() { REGISTER_ELEMENT(AuthnContextDeclRef); REGISTER_ELEMENT(AuthnStatement); REGISTER_ELEMENT(AuthzDecisionStatement); + REGISTER_ELEMENT_NOVAL(Condition); REGISTER_ELEMENT(Conditions); REGISTER_ELEMENT(EncryptedAssertion); REGISTER_ELEMENT(EncryptedAttribute); @@ -225,6 +226,7 @@ void opensaml::saml2::registerAssertionClasses() { REGISTER_ELEMENT(NameID); REGISTER_ELEMENT_NOVAL(OneTimeUse); REGISTER_ELEMENT(ProxyRestriction); + REGISTER_ELEMENT_NOVAL(Statement); REGISTER_ELEMENT(Subject); REGISTER_ELEMENT(SubjectConfirmation); REGISTER_ELEMENT_NOVAL(SubjectConfirmationData); diff --git a/saml/saml2/metadata/Metadata.h b/saml/saml2/metadata/Metadata.h index 4ea5a5b..79f94dc 100644 --- a/saml/saml2/metadata/Metadata.h +++ b/saml/saml2/metadata/Metadata.h @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * @file saml/saml2/metadata/Metadata.h - * + * * XMLObjects representing the SAML 2.0 Metadata schema */ @@ -38,7 +38,7 @@ namespace opensaml { * SAML 2.0 metadata namespace */ namespace saml2md { - + /** * Base class for metadata objects that feature a cacheDuration attribute. */ @@ -79,7 +79,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 +106,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 +177,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); @@ -392,7 +395,7 @@ namespace opensaml { */ isValidForProtocol(const XMLCh* protocol) : m_time(time(NULL)), m_protocol(protocol) { } - + /** * Returns true iff the supplied role is valid now and supports the right protocol. * @@ -402,7 +405,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 +426,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 +434,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 +476,13 @@ 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); /** * Builder for localizedNameType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API localizedNameTypeBuilder : public xmltooling::XMLObjectBuilder { @@ -493,7 +496,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static localizedNameType* buildlocalizedNameType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { const localizedNameTypeBuilder* b = dynamic_cast( @@ -513,7 +516,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 { @@ -527,7 +530,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static localizedURIType* buildlocalizedURIType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { const localizedURITypeBuilder* b = dynamic_cast( @@ -547,7 +550,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 { @@ -561,7 +564,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static EndpointType* buildEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { const EndpointTypeBuilder* b = dynamic_cast( @@ -581,7 +584,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 { @@ -595,7 +598,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static IndexedEndpointType* buildIndexedEndpointType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { const IndexedEndpointTypeBuilder* b = dynamic_cast( @@ -614,8 +617,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=NULL, const xmltooling::QName* schemaType=NULL + ) 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. */ @@ -643,7 +679,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static AuthnQueryDescriptorType* buildAuthnQueryDescriptorType() { const AuthnQueryDescriptorTypeBuilder* b = dynamic_cast( @@ -662,7 +698,7 @@ namespace opensaml { /** * Builder for AttributeQueryDescriptorType objects. - * + * * This is customized to return a RoleDescriptor element with an * xsi:type of AttributeQueryDescriptorType. */ @@ -690,7 +726,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static AttributeQueryDescriptorType* buildAttributeQueryDescriptorType() { const AttributeQueryDescriptorTypeBuilder* b = dynamic_cast( @@ -709,7 +745,7 @@ namespace opensaml { /** * Builder for AuthzDecisionQueryDescriptorType objects. - * + * * This is customized to return a RoleDescriptor element with an * xsi:type of AuthzDecisionQueryDescriptorType. */ @@ -737,7 +773,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static AuthzDecisionQueryDescriptorType* buildAuthzDecisionQueryDescriptorType() { const AuthzDecisionQueryDescriptorTypeBuilder* b = dynamic_cast( diff --git a/saml/saml2/metadata/impl/MetadataImpl.cpp b/saml/saml2/metadata/impl/MetadataImpl.cpp index 9917cad..87553b5 100644 --- a/saml/saml2/metadata/impl/MetadataImpl.cpp +++ b/saml/saml2/metadata/impl/MetadataImpl.cpp @@ -1071,6 +1071,34 @@ namespace opensaml { } }; + class SAML_DLLLOCAL RoleDescriptorTypeImpl : public virtual RoleDescriptorType, public RoleDescriptorImpl + { + public: + virtual ~RoleDescriptorTypeImpl() {} + + RoleDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + RoleDescriptorTypeImpl(const RoleDescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) { + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); + } + + IMPL_XMLOBJECT_CLONE(RoleDescriptorType); + RoleDescriptor* cloneRoleDescriptor() const { + return new RoleDescriptorTypeImpl(*this); + } + + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + getUnknownXMLObjects().push_back(childXMLObject); + } + }; + class SAML_DLLLOCAL SSODescriptorTypeImpl : public virtual SSODescriptorType, public RoleDescriptorImpl { void init() { @@ -2437,6 +2465,17 @@ IMPL_XMLOBJECTBUILDER(TelephoneNumber); IMPL_XMLOBJECTBUILDER(ActionNamespace); IMPL_XMLOBJECTBUILDER(SourceID); +#ifdef HAVE_COVARIANT_RETURNS +RoleDescriptor* RoleDescriptorBuilder::buildObject( +#else +xmltooling::XMLObject* RoleDescriptorBuilder::buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType + ) const +{ + return new RoleDescriptorTypeImpl(nsURI,localName,prefix,schemaType); +} + const XMLCh ActionNamespace::LOCAL_NAME[] = UNICODE_LITERAL_15(A,c,t,i,o,n,N,a,m,e,s,p,a,c,e); const XMLCh AdditionalMetadataLocation::LOCAL_NAME[] = UNICODE_LITERAL_26(A,d,d,i,t,i,o,n,a,l,M,e,t,a,d,a,t,a,L,o,c,a,t,i,o,n); const XMLCh AdditionalMetadataLocation::TYPE_NAME[] = UNICODE_LITERAL_30(A,d,d,i,t,i,o,n,a,l,M,e,t,a,d,a,t,a,L,o,c,a,t,i,o,n,T,y,p,e); diff --git a/saml/saml2/metadata/impl/MetadataSchemaValidators.cpp b/saml/saml2/metadata/impl/MetadataSchemaValidators.cpp index 79cf31e..daaba6b 100644 --- a/saml/saml2/metadata/impl/MetadataSchemaValidators.cpp +++ b/saml/saml2/metadata/impl/MetadataSchemaValidators.cpp @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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,7 +16,7 @@ /** * MetadataSchemaValidators.cpp - * + * * Schema-based validators for SAML 2.0 Metadata classes */ @@ -36,7 +36,7 @@ using samlconstants::SAML20MD_QUERY_EXT_NS; namespace opensaml { namespace saml2md { - + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,ActionNamespace); XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,AffiliateMember); XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,AttributeProfile); @@ -57,7 +57,7 @@ namespace opensaml { XMLOBJECTVALIDATOR_REQUIRE(localizedNameType,TextContent); XMLOBJECTVALIDATOR_REQUIRE(localizedURIType,Lang); END_XMLOBJECTVALIDATOR; - + BEGIN_XMLOBJECTVALIDATOR_SUB(SAML_DLLLOCAL,OrganizationName,localizedNameType); localizedNameTypeSchemaValidator::validate(xmlObject); END_XMLOBJECTVALIDATOR; @@ -89,7 +89,7 @@ namespace opensaml { const vector& anys=ptr->getUnknownXMLObjects(); for_each(anys.begin(),anys.end(),checkWildcardNS()); END_XMLOBJECTVALIDATOR; - + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,Organization); XMLOBJECTVALIDATOR_NONEMPTY(Organization,OrganizationName); XMLOBJECTVALIDATOR_NONEMPTY(Organization,OrganizationDisplayName); @@ -232,7 +232,7 @@ namespace opensaml { ptr->getAuthnAuthorityDescriptors().empty() && ptr->getAttributeAuthorityDescriptors().empty() && ptr->getPDPDescriptors().empty()) { - + if (!ptr->getAffiliationDescriptor()) throw ValidationException("EntityDescriptor must have at least one child role or affiliation descriptor."); } @@ -243,7 +243,7 @@ namespace opensaml { BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,EntitiesDescriptor); if (ptr->getEntityDescriptors().empty() && ptr->getEntitiesDescriptors().empty()) - throw ValidationException("EntitiesDescriptor must contain at least one child descriptor."); + throw ValidationException("EntitiesDescriptor must contain at least one child descriptor."); END_XMLOBJECTVALIDATOR; }; }; @@ -252,7 +252,7 @@ namespace opensaml { q=QName(SAML20MD_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ SchemaValidators.registerValidator(q,new cname##SchemaValidator()) - + #define REGISTER_TYPE(cname) \ q=QName(SAML20MD_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ @@ -261,7 +261,7 @@ namespace opensaml { #define REGISTER_ELEMENT_NOVAL(cname) \ q=QName(SAML20MD_NS,cname::LOCAL_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); - + #define REGISTER_TYPE_NOVAL(cname) \ q=QName(SAML20MD_NS,cname::TYPE_NAME); \ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); @@ -299,6 +299,7 @@ void opensaml::saml2md::registerMetadataClasses() { REGISTER_ELEMENT(OrganizationURL); REGISTER_ELEMENT(PDPDescriptor); REGISTER_ELEMENT(RequestedAttribute); + REGISTER_ELEMENT(RoleDescriptor); REGISTER_ELEMENT(ServiceDescription); REGISTER_ELEMENT(ServiceName); REGISTER_ELEMENT(SingleLogoutService); @@ -328,7 +329,7 @@ void opensaml::saml2md::registerMetadataClasses() { q=QName(SAML20MD_NS,xmlencryption::EncryptionMethod::LOCAL_NAME); XMLObjectBuilder::registerBuilder(q,new xmlencryption::EncryptionMethodBuilder()); - + q=QName(samlconstants::SAML1MD_NS,SourceID::LOCAL_NAME); XMLObjectBuilder::registerBuilder(q,new SourceIDBuilder()); SchemaValidators.registerValidator(q,new SourceIDSchemaValidator()); diff --git a/samltest/data/saml2/core/impl/AssertionChildElements.xml b/samltest/data/saml2/core/impl/AssertionChildElements.xml index 238a6b8843eb8352a595255b9282fa72587cd5d1..6d42adc624edfaafeadb605ed42885f219ffef8b 100644 GIT binary patch delta 271 zcmaKmJqp4=5QQHGL;@Z`4EDyqE~uq8rb=TQB&eW?n1EX45V?rw5)a`wQ4kv$W_dHa z`@Q#QK3n&tQ*|3|8L3cACpyw8%F`8nK<5h3x%Qf=ryX~NPV5HMr7oXyB43%#+Oi#M zNR3cyg<2`nhJVJ6)rVtD^Gn$$Fun4}EMY4Cm}S^o$Q*=4{2GJ$L=7O^>US3UO$@Xk SV#eH-OSrkFoJOfar}F~L;4x7E delta 11 ScmaFE@rrGOJM&~u7G(e&!~^00 diff --git a/samltest/data/saml2/core/impl/ConditionsChildElements.xml b/samltest/data/saml2/core/impl/ConditionsChildElements.xml index f32c3f0ee52f7fffd5ace2c4487e129e3f0246b0..e427644da0effb0ebfb0d771ef222f553430dc20 100644 GIT binary patch delta 271 zcmaKmJqp4=5QRUYSVRvYDFqXMxJFsKRo=AJKcp+obO87#MP;VsJ`!S1USN<`}WglBc8~parseDateTime(); - + singleElementFile = data_path + "saml2/core/impl/Assertion.xml"; singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AssertionOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AssertionChildElements.xml"; + childElementsFile = data_path + "saml2/core/impl/AssertionChildElements.xml"; SAMLObjectBaseTestCase::setUp(); } - + void tearDown() { delete expectedIssueInstant; XMLString::release(&expectedID); @@ -81,7 +81,7 @@ public: TS_ASSERT(assertion->getConditions()!=NULL); TS_ASSERT(assertion->getAdvice()!=NULL); - TSM_ASSERT_EQUALS("# of Statement child elements", 0, assertion->getStatements().size()); + TSM_ASSERT_EQUALS("# of Statement child elements", 1, assertion->getStatements().size()); TSM_ASSERT_EQUALS("# of AuthnStatement child elements", 1, assertion->getAuthnStatements().size()); TSM_ASSERT_EQUALS("# of AttributeStatement child elements", 3, assertion->getAttributeStatements().size()); TSM_ASSERT_EQUALS("# of AuthzDecisionStatement child elements", 2, assertion->getAuthzDecisionStatements().size()); @@ -95,6 +95,8 @@ public: } void testChildElementsMarshall() { + QName qext("http://www.opensaml.org/", "Foo", "ext"); + Assertion* assertion=AssertionBuilder::buildAssertion(); assertion->setID(expectedID); assertion->setIssueInstant(expectedIssueInstant); @@ -103,13 +105,14 @@ public: assertion->setConditions(ConditionsBuilder::buildConditions()); assertion->setAdvice(AdviceBuilder::buildAdvice()); - //Test storing children as their direct type + //Test storing children as their direct type assertion->getAuthnStatements().push_back(AuthnStatementBuilder::buildAuthnStatement()); assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getStatements().push_back(StatementBuilder::buildStatement(qext)); assertEquals(expectedChildElementsDOM, assertion); // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed @@ -129,6 +132,7 @@ public: assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getStatements().push_back(StatementBuilder::buildStatement(qext)); assertEquals(expectedChildElementsDOM, assertion); } diff --git a/samltest/saml2/core/impl/Conditions20Test.h b/samltest/saml2/core/impl/Conditions20Test.h index 121283a..32e2e46 100644 --- a/samltest/saml2/core/impl/Conditions20Test.h +++ b/samltest/saml2/core/impl/Conditions20Test.h @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 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 @@ -33,10 +33,10 @@ public: singleElementFile = data_path + "saml2/core/impl/Conditions.xml"; singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ConditionsOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ConditionsChildElements.xml"; + childElementsFile = data_path + "saml2/core/impl/ConditionsChildElements.xml"; SAMLObjectBaseTestCase::setUp(); } - + void tearDown() { delete expectedNotBefore; delete expectedNotOnOrAfter; @@ -80,7 +80,7 @@ public: TS_ASSERT(conditions->getNotBefore()==NULL); TS_ASSERT(conditions->getNotOnOrAfter()==NULL); - TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); + TSM_ASSERT_EQUALS("# of Condition child elements", 1, conditions->getConditions().size()); TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 3, conditions->getAudienceRestrictions().size()); TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 1, conditions->getOneTimeUses().size()); TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 2, conditions->getProxyRestrictions().size()); @@ -99,15 +99,17 @@ public: } void testChildElementsMarshall() { + QName qext("http://www.opensaml.org/", "Foo", "ext"); Conditions* conditions=ConditionsBuilder::buildConditions(); - //Test storing children as their direct type + //Test storing children as their direct type conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); conditions->getOneTimeUses().push_back(OneTimeUseBuilder::buildOneTimeUse()); conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + conditions->getConditions().push_back(ConditionBuilder::buildCondition(qext)); assertEquals(expectedChildElementsDOM, conditions); // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed @@ -121,6 +123,7 @@ public: conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); conditions->getConditions().push_back(OneTimeUseBuilder::buildOneTimeUse()); conditions->getConditions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + conditions->getConditions().push_back(ConditionBuilder::buildCondition(qext)); assertEquals(expectedChildElementsDOM, conditions); } -- 2.1.4