From 3fe2b35dc5b5866e3ce7bde70faab0815acfa5b6 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Mon, 21 Nov 2011 21:46:19 +0000 Subject: [PATCH] https://issues.shibboleth.net/jira/browse/CPPOST-70 --- saml/saml1/core/impl/AssertionsImpl.cpp | 124 ++++++------- saml/saml1/core/impl/ProtocolsImpl.cpp | 115 ++++++++---- saml/saml2/core/impl/Assertions20Impl.cpp | 110 +++++------ saml/saml2/core/impl/Protocols20Impl.cpp | 226 ++++++++++------------ saml/saml2/metadata/impl/MetadataImpl.cpp | 298 ++++++++++++------------------ samltest/internal.h | 3 + 6 files changed, 400 insertions(+), 476 deletions(-) diff --git a/saml/saml1/core/impl/AssertionsImpl.cpp b/saml/saml1/core/impl/AssertionsImpl.cpp index e6b7051..d741354 100644 --- a/saml/saml1/core/impl/AssertionsImpl.cpp +++ b/saml/saml1/core/impl/AssertionsImpl.cpp @@ -74,7 +74,7 @@ namespace opensaml { ConditionImpl(const ConditionImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(Condition); + IMPL_XMLOBJECT_CLONE_EX(Condition); }; class SAML_DLLLOCAL AudienceRestrictionConditionImpl : public virtual AudienceRestrictionCondition, @@ -100,10 +100,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AudienceRestrictionCondition); - Condition* cloneCondition() const { - return cloneAudienceRestrictionCondition(); - } + IMPL_XMLOBJECT_CLONE2(AudienceRestrictionCondition,Condition); IMPL_TYPED_CHILDREN(Audience,m_children.end()); protected: @@ -130,10 +127,7 @@ namespace opensaml { : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { } - IMPL_XMLOBJECT_CLONE(DoNotCacheCondition); - Condition* cloneCondition() const { - return cloneDoNotCacheCondition(); - } + IMPL_XMLOBJECT_CLONE2(DoNotCacheCondition,Condition); }; class SAML_DLLLOCAL ConditionsImpl : public virtual Conditions, @@ -268,7 +262,7 @@ namespace opensaml { SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) { } - IMPL_XMLOBJECT_CLONE(SubjectConfirmationData); + IMPL_XMLOBJECT_CLONE_EX(SubjectConfirmationData); }; class SAML_DLLLOCAL SubjectConfirmationImpl : public virtual SubjectConfirmation, @@ -383,7 +377,7 @@ namespace opensaml { StatementImpl(const StatementImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(Statement); + IMPL_XMLOBJECT_CLONE_EX(Statement); }; class SAML_DLLLOCAL SubjectStatementImpl : public virtual SubjectStatement, @@ -412,10 +406,21 @@ namespace opensaml { SubjectStatementImpl(const SubjectStatementImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const SubjectStatementImpl& src) { if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); } + Statement* cloneStatement() const { + return dynamic_cast(clone()); + } + + SubjectStatement* cloneSubjectStatement() const { + return dynamic_cast(clone()); + } + IMPL_TYPED_CHILD(Subject); protected: @@ -521,6 +526,15 @@ namespace opensaml { class SAML_DLLLOCAL AuthenticationStatementImpl : public virtual AuthenticationStatement, public SubjectStatementImpl { + void init() { + m_AuthenticationMethod=nullptr; + m_AuthenticationInstant=nullptr; + m_SubjectLocality=nullptr; + m_children.push_back(nullptr); + m_pos_SubjectLocality=m_pos_Subject; + ++m_pos_SubjectLocality; + } + public: virtual ~AuthenticationStatementImpl() { XMLString::release(&m_AuthenticationMethod); @@ -534,6 +548,10 @@ namespace opensaml { AuthenticationStatementImpl(const AuthenticationStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); + } + + void _clone(const AuthenticationStatementImpl& src) { + SubjectStatementImpl::_clone(src); setAuthenticationMethod(src.getAuthenticationMethod()); setAuthenticationInstant(src.getAuthenticationInstant()); if (src.getSubjectLocality()) @@ -546,22 +564,7 @@ namespace opensaml { } } - void init() { - m_AuthenticationMethod=nullptr; - m_AuthenticationInstant=nullptr; - m_SubjectLocality=nullptr; - m_children.push_back(nullptr); - m_pos_SubjectLocality=m_pos_Subject; - ++m_pos_SubjectLocality; - } - - IMPL_XMLOBJECT_CLONE(AuthenticationStatement); - SubjectStatement* cloneSubjectStatement() const { - return cloneAuthenticationStatement(); - } - Statement* cloneStatement() const { - return cloneAuthenticationStatement(); - } + IMPL_XMLOBJECT_CLONE_EX(AuthenticationStatement); IMPL_STRING_ATTRIB(AuthenticationMethod); IMPL_DATETIME_ATTRIB(AuthenticationInstant,0); IMPL_TYPED_CHILD(SubjectLocality); @@ -666,6 +669,15 @@ namespace opensaml { class SAML_DLLLOCAL AuthorizationDecisionStatementImpl : public virtual AuthorizationDecisionStatement, public SubjectStatementImpl { + void init() { + m_Resource=nullptr; + m_Decision=nullptr; + m_Evidence=nullptr; + m_children.push_back(nullptr); + m_pos_Evidence=m_pos_Subject; + ++m_pos_Evidence; + } + public: virtual ~AuthorizationDecisionStatementImpl() { XMLString::release(&m_Resource); @@ -680,6 +692,10 @@ namespace opensaml { AuthorizationDecisionStatementImpl(const AuthorizationDecisionStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); + } + + void _clone(const AuthorizationDecisionStatementImpl& src) { + SubjectStatementImpl::_clone(src); setResource(src.getResource()); setDecision(src.getDecision()); if (src.getEvidence()) @@ -692,22 +708,7 @@ namespace opensaml { } } - void init() { - m_Resource=nullptr; - m_Decision=nullptr; - m_Evidence=nullptr; - m_children.push_back(nullptr); - m_pos_Evidence=m_pos_Subject; - ++m_pos_Evidence; - } - - IMPL_XMLOBJECT_CLONE(AuthorizationDecisionStatement); - SubjectStatement* cloneSubjectStatement() const { - return cloneAuthorizationDecisionStatement(); - } - Statement* cloneStatement() const { - return cloneAuthorizationDecisionStatement(); - } + IMPL_XMLOBJECT_CLONE_EX(AuthorizationDecisionStatement); IMPL_STRING_ATTRIB(Resource); IMPL_STRING_ATTRIB(Decision); IMPL_TYPED_CHILD(Evidence); @@ -739,6 +740,10 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_AttributeName=m_AttributeNamespace=nullptr; + } + public: virtual ~AttributeDesignatorImpl() { XMLString::release(&m_AttributeName); @@ -757,10 +762,6 @@ namespace opensaml { setAttributeNamespace(src.getAttributeNamespace()); } - void init() { - m_AttributeName=m_AttributeNamespace=nullptr; - } - IMPL_XMLOBJECT_CLONE(AttributeDesignator); IMPL_STRING_ATTRIB(AttributeName); IMPL_STRING_ATTRIB(AttributeNamespace); @@ -783,6 +784,9 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_AttributeName=m_AttributeNamespace=nullptr; + } public: virtual ~AttributeImpl() { XMLString::release(&m_AttributeName); @@ -807,14 +811,7 @@ namespace opensaml { } } - void init() { - m_AttributeName=m_AttributeNamespace=nullptr; - } - - IMPL_XMLOBJECT_CLONE(Attribute); - AttributeDesignator* cloneAttributeDesignator() const { - return cloneAttribute(); - } + IMPL_XMLOBJECT_CLONE2(Attribute,AttributeDesignator); IMPL_STRING_ATTRIB(AttributeName); IMPL_STRING_ATTRIB(AttributeNamespace); IMPL_XMLOBJECT_CHILDREN(AttributeValue,m_children.end()); @@ -846,7 +843,7 @@ namespace opensaml { AttributeValueImpl(const AttributeValueImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(AttributeValue); + IMPL_XMLOBJECT_CLONE_EX(AttributeValue); }; class SAML_DLLLOCAL AttributeStatementImpl : public virtual AttributeStatement, public SubjectStatementImpl @@ -858,8 +855,11 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - AttributeStatementImpl(const AttributeStatementImpl& src) - : AbstractXMLObject(src), SubjectStatementImpl(src) { + AttributeStatementImpl(const AttributeStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { + } + + void _clone(const AttributeStatementImpl& src) { + SubjectStatementImpl::_clone(src); VectorOf(Attribute) v=getAttributes(); for (vector::const_iterator i=src.m_Attributes.begin(); i!=src.m_Attributes.end(); i++) { if (*i) { @@ -868,13 +868,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AttributeStatement); - SubjectStatement* cloneSubjectStatement() const { - return cloneAttributeStatement(); - } - Statement* cloneStatement() const { - return cloneAttributeStatement(); - } + IMPL_XMLOBJECT_CLONE_EX(AttributeStatement); IMPL_TYPED_CHILDREN(Attribute, m_children.end()); protected: diff --git a/saml/saml1/core/impl/ProtocolsImpl.cpp b/saml/saml1/core/impl/ProtocolsImpl.cpp index 33d3b5d..9911c18 100644 --- a/saml/saml1/core/impl/ProtocolsImpl.cpp +++ b/saml/saml1/core/impl/ProtocolsImpl.cpp @@ -117,7 +117,7 @@ namespace opensaml { QueryImpl(const QueryImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(Query); + IMPL_XMLOBJECT_CLONE_EX(Query); }; class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, @@ -131,10 +131,12 @@ namespace opensaml { m_children.push_back(nullptr); m_pos_Subject=m_children.begin(); } + protected: SubjectQueryImpl() { init(); } + public: virtual ~SubjectQueryImpl() {} @@ -146,10 +148,21 @@ namespace opensaml { SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const SubjectQueryImpl& src) { if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); } + SubjectQuery* cloneSubjectQuery() const { + return dynamic_cast(clone()); + } + + Query* cloneQuery() const { + return dynamic_cast(clone()); + } + IMPL_TYPED_CHILD(Subject); protected: @@ -164,28 +177,27 @@ namespace opensaml { void init() { m_AuthenticationMethod=nullptr; } + public: virtual ~AuthenticationQueryImpl() { XMLString::release(&m_AuthenticationMethod); } AuthenticationQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, 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(); - } - Query* cloneQuery() const { - return cloneAuthenticationQuery(); + void _clone(const AuthenticationQueryImpl& src) { + SubjectQueryImpl::_clone(src); + setAuthenticationMethod(src.getAuthenticationMethod()); } + + IMPL_XMLOBJECT_CLONE_EX(AuthenticationQuery); IMPL_STRING_ATTRIB(AuthenticationMethod); protected: @@ -205,18 +217,23 @@ namespace opensaml { void init() { m_Resource=nullptr; } + public: virtual ~AttributeQueryImpl() { XMLString::release(&m_Resource); } AttributeQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } AttributeQueryImpl(const AttributeQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); + } + + void _clone(const AttributeQueryImpl& src) { + SubjectQueryImpl::_clone(src); setResource(src.getResource()); VectorOf(AttributeDesignator) v=getAttributeDesignators(); for (vector::const_iterator i=src.m_AttributeDesignators.begin(); i!=src.m_AttributeDesignators.end(); i++) { @@ -226,13 +243,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AttributeQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAttributeQuery(); - } - Query* cloneQuery() const { - return cloneAttributeQuery(); - } + IMPL_XMLOBJECT_CLONE_EX(AttributeQuery); IMPL_STRING_ATTRIB(Resource); IMPL_TYPED_CHILDREN(AttributeDesignator,m_children.end()); @@ -262,18 +273,23 @@ namespace opensaml { m_pos_Evidence=m_pos_Subject; ++m_pos_Evidence; } + public: virtual ~AuthorizationDecisionQueryImpl() { XMLString::release(&m_Resource); } AuthorizationDecisionQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } AuthorizationDecisionQueryImpl(const AuthorizationDecisionQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); + } + + void _clone(const AuthorizationDecisionQueryImpl& src) { + SubjectQueryImpl::_clone(src); setResource(src.getResource()); if (src.getEvidence()) setEvidence(src.getEvidence()->cloneEvidence()); @@ -285,13 +301,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AuthorizationDecisionQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAuthorizationDecisionQuery(); - } - Query* cloneQuery() const { - return cloneAuthorizationDecisionQuery(); - } + IMPL_XMLOBJECT_CLONE_EX(AuthorizationDecisionQuery); IMPL_STRING_ATTRIB(Resource); IMPL_TYPED_CHILD(Evidence); IMPL_TYPED_CHILDREN(Action, m_pos_Evidence); @@ -328,6 +338,7 @@ namespace opensaml { m_Signature=nullptr; m_pos_Signature=m_children.begin(); } + protected: RequestAbstractTypeImpl() { init(); @@ -347,6 +358,13 @@ namespace opensaml { RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + //IMPL_TYPED_CHILD(Signature); + // Need customized setter. + + protected: + void _clone(const RequestAbstractTypeImpl& src) { setMinorVersion(src.m_MinorVersion); setRequestID(src.getRequestID()); setIssueInstant(src.getIssueInstant()); @@ -360,11 +378,9 @@ namespace opensaml { } } - //IMPL_TYPED_CHILD(Signature); - // Need customized setter. - protected: Signature* m_Signature; list::iterator m_pos_Signature; + public: Signature* getSignature() const { return m_Signature; @@ -378,6 +394,10 @@ namespace opensaml { m_Signature->setContentReference(new opensaml::ContentReference(*this)); } + RequestAbstractType* cloneRequestAbstractType() const { + return dynamic_cast(clone()); + } + IMPL_INTEGER_ATTRIB(MinorVersion); IMPL_STRING_ATTRIB(RequestID); // have to special-case getXMLID const XMLCh* getXMLID() const { @@ -462,6 +482,7 @@ namespace opensaml { m_pos_Query=m_pos_Signature; ++m_pos_Query; } + public: virtual ~RequestImpl() {} @@ -472,6 +493,10 @@ namespace opensaml { RequestImpl(const RequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); + } + + void _clone(const RequestImpl& src) { + RequestAbstractTypeImpl::_clone(src); if (src.getQuery()) setQuery(src.getQuery()->cloneQuery()); VectorOf(AssertionIDReference) v=getAssertionIDReferences(); @@ -488,10 +513,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(Request); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneRequest(); - } + IMPL_XMLOBJECT_CLONE_EX(Request); IMPL_TYPED_CHILD(Query); SubjectQuery* getSubjectQuery() const { @@ -678,10 +700,12 @@ namespace opensaml { m_Signature=nullptr; m_pos_Signature=m_children.begin(); } + protected: ResponseAbstractTypeImpl() { init(); } + public: virtual ~ResponseAbstractTypeImpl() { XMLString::release(&m_MinorVersion); @@ -692,13 +716,19 @@ namespace opensaml { } ResponseAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } ResponseAbstractTypeImpl(const ResponseAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + //IMPL_TYPED_CHILD(Signature); + // Need customized setter. + protected: + void _clone(const ResponseAbstractTypeImpl& src) { setMinorVersion(src.m_MinorVersion); setResponseID(src.getResponseID()); setInResponseTo(src.getInResponseTo()); @@ -708,9 +738,6 @@ namespace opensaml { setSignature(src.getSignature()->cloneSignature()); } - //IMPL_TYPED_CHILD(Signature); - // Need customized setter. - protected: Signature* m_Signature; list::iterator m_pos_Signature; public: @@ -726,6 +753,10 @@ namespace opensaml { m_Signature->setContentReference(new opensaml::ContentReference(*this)); } + ResponseAbstractType* cloneResponseAbstractType() const { + return dynamic_cast(clone()); + } + IMPL_INTEGER_ATTRIB(MinorVersion); IMPL_STRING_ATTRIB(ResponseID); // have to special-case getXMLID const XMLCh* getXMLID() const { @@ -814,16 +845,21 @@ namespace opensaml { m_pos_Status=m_pos_Signature; ++m_pos_Status; } + public: virtual ~ResponseImpl() {} ResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } ResponseImpl(const ResponseImpl& src) : AbstractXMLObject(src), ResponseAbstractTypeImpl(src) { init(); + } + + void _clone(const ResponseImpl& src) { + ResponseAbstractTypeImpl::_clone(src); if (src.getStatus()) setStatus(src.getStatus()->cloneStatus()); VectorOf(saml1::Assertion) v=getAssertions(); @@ -834,10 +870,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(Response); - ResponseAbstractType* cloneResponseAbstractType() const { - return cloneResponse(); - } + IMPL_XMLOBJECT_CLONE_EX(Response); IMPL_TYPED_CHILD(Status); IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml1,m_children.end()); diff --git a/saml/saml2/core/impl/Assertions20Impl.cpp b/saml/saml2/core/impl/Assertions20Impl.cpp index 9c743c8..a827715 100644 --- a/saml/saml2/core/impl/Assertions20Impl.cpp +++ b/saml/saml2/core/impl/Assertions20Impl.cpp @@ -102,13 +102,16 @@ namespace opensaml { NameIDTypeImpl(const NameIDTypeImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const NameIDTypeImpl& src) { setNameQualifier(src.getNameQualifier()); setSPNameQualifier(src.getSPNameQualifier()); setFormat(src.getFormat()); setSPProvidedID(src.getSPProvidedID()); } - IMPL_XMLOBJECT_CLONE(NameIDType); + IMPL_XMLOBJECT_CLONE_EX(NameIDType); IMPL_STRING_ATTRIB(NameQualifier); IMPL_STRING_ATTRIB(SPNameQualifier); IMPL_STRING_ATTRIB(Format); @@ -139,12 +142,10 @@ namespace opensaml { NameIDImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::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); + NameIDImpl(const NameIDImpl& src) : AbstractXMLObject(src), NameIDTypeImpl(src) { } + + IMPL_XMLOBJECT_CLONE_EX(NameID); }; class SAML_DLLLOCAL IssuerImpl : public virtual Issuer, public NameIDTypeImpl @@ -155,12 +156,10 @@ namespace opensaml { IssuerImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::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); + IssuerImpl(const IssuerImpl& src) : AbstractXMLObject(src), NameIDTypeImpl(src) { } + + IMPL_XMLOBJECT_CLONE_EX(Issuer); }; //TODO unit test for this @@ -193,6 +192,9 @@ namespace opensaml { EncryptedElementTypeImpl(const EncryptedElementTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const EncryptedElementTypeImpl& src) { if (src.getEncryptedData()) setEncryptedData(src.getEncryptedData()->cloneEncryptedData()); VectorOf(EncryptedKey) v=getEncryptedKeys(); @@ -203,7 +205,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(EncryptedElementType); + IMPL_XMLOBJECT_CLONE_EX(EncryptedElementType); IMPL_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption); IMPL_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption,m_children.end()); @@ -223,12 +225,10 @@ namespace opensaml { EncryptedIDImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::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); + EncryptedIDImpl(const EncryptedIDImpl& src) : AbstractXMLObject(src), EncryptedElementTypeImpl(src) { } + + IMPL_XMLOBJECT_CLONE_EX(EncryptedID); }; class SAML_DLLLOCAL ConditionImpl : public virtual Condition, public AnyElementImpl @@ -268,10 +268,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AudienceRestriction); - Condition* cloneCondition() const { - return cloneAudienceRestriction(); - } + IMPL_XMLOBJECT_CLONE2(AudienceRestriction,Condition); IMPL_TYPED_CHILDREN(Audience,m_children.end()); protected: @@ -298,10 +295,7 @@ namespace opensaml { : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { } - IMPL_XMLOBJECT_CLONE(OneTimeUse); - Condition* cloneCondition() const { - return cloneOneTimeUse(); - } + IMPL_XMLOBJECT_CLONE2(OneTimeUse,Condition); }; class SAML_DLLLOCAL ProxyRestrictionImpl : public virtual ProxyRestriction, @@ -331,10 +325,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(ProxyRestriction); - Condition* cloneCondition() const { - return cloneProxyRestriction(); - } + IMPL_XMLOBJECT_CLONE2(ProxyRestriction,Condition); IMPL_TYPED_CHILDREN(Audience,m_children.end()); IMPL_INTEGER_ATTRIB(Count); @@ -449,10 +440,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(DelegationRestrictionType); - Condition* cloneCondition() const { - return cloneDelegationRestrictionType(); - } + IMPL_XMLOBJECT_CLONE2(DelegationRestrictionType,Condition); IMPL_TYPED_CHILDREN(Delegate,m_children.end()); protected: @@ -574,6 +562,9 @@ namespace opensaml { SubjectConfirmationDataTypeImpl(const SubjectConfirmationDataTypeImpl& src) : AbstractXMLObject(src) { init(); + } + + void _clone(const SubjectConfirmationDataTypeImpl& src) { setNotBefore(src.getNotBefore()); setNotOnOrAfter(src.getNotOnOrAfter()); setRecipient(src.getRecipient()); @@ -581,6 +572,10 @@ namespace opensaml { setAddress(src.getAddress()); } + SubjectConfirmationDataType* cloneSubjectConfirmationDataType() const { + return dynamic_cast(clone()); + } + IMPL_DATETIME_ATTRIB(NotBefore,0); IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); IMPL_STRING_ATTRIB(Recipient); @@ -619,11 +614,13 @@ namespace opensaml { : AbstractXMLObject(src), SubjectConfirmationDataTypeImpl(src), AnyElementImpl(src) { } - IMPL_XMLOBJECT_CLONE(SubjectConfirmationData); - SubjectConfirmationDataType* cloneSubjectConfirmationDataType() const { - return new SubjectConfirmationDataImpl(*this); + void _clone(const SubjectConfirmationDataImpl& src) { + SubjectConfirmationDataTypeImpl::_clone(src); + AnyElementImpl::_clone(src); } + IMPL_XMLOBJECT_CLONE_EX(SubjectConfirmationData); + void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) { if (!qualifiedName.hasNamespaceURI()) { if (XMLString::equals(qualifiedName.getLocalPart(),NOTBEFORE_ATTRIB_NAME)) { @@ -684,16 +681,16 @@ namespace opensaml { KeyInfoConfirmationDataTypeImpl(const KeyInfoConfirmationDataTypeImpl& src) : AbstractXMLObject(src), SubjectConfirmationDataTypeImpl(src), AbstractComplexElement(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { + } + + void _clone(const KeyInfoConfirmationDataTypeImpl& src) { + SubjectConfirmationDataTypeImpl::_clone(src); VectorOf(KeyInfo) v=getKeyInfos(); 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_XMLOBJECT_CLONE_EX(KeyInfoConfirmationDataType); IMPL_TYPED_CHILDREN(KeyInfo,m_children.end()); public: @@ -928,7 +925,7 @@ namespace opensaml { StatementImpl(const StatementImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(Statement); + IMPL_XMLOBJECT_CLONE_EX(Statement); }; //TODO need unit test for this @@ -944,7 +941,7 @@ namespace opensaml { AuthnContextDeclImpl(const AuthnContextDeclImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) { } - IMPL_XMLOBJECT_CLONE(AuthnContextDecl); + IMPL_XMLOBJECT_CLONE_EX(AuthnContextDecl); }; class SAML_DLLLOCAL AuthnContextImpl : public virtual AuthnContext, @@ -1049,10 +1046,7 @@ namespace opensaml { setAuthnContext(src.getAuthnContext()->cloneAuthnContext()); } - IMPL_XMLOBJECT_CLONE(AuthnStatement); - Statement* cloneStatement() const { - return cloneAuthnStatement(); - } + IMPL_XMLOBJECT_CLONE2(AuthnStatement,Statement); IMPL_DATETIME_ATTRIB(AuthnInstant,0); IMPL_STRING_ATTRIB(SessionIndex); IMPL_DATETIME_ATTRIB(SessionNotOnOrAfter,SAMLTIME_MAX); @@ -1213,10 +1207,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AuthzDecisionStatement); - Statement* cloneStatement() const { - return cloneAuthzDecisionStatement(); - } + IMPL_XMLOBJECT_CLONE2(AuthzDecisionStatement,Statement); IMPL_STRING_ATTRIB(Resource); IMPL_STRING_ATTRIB(Decision); IMPL_TYPED_CHILD(Evidence); @@ -1253,7 +1244,7 @@ namespace opensaml { AttributeValueImpl(const AttributeValueImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) { } - IMPL_XMLOBJECT_CLONE(AttributeValue); + IMPL_XMLOBJECT_CLONE_EX(AttributeValue); }; @@ -1346,10 +1337,7 @@ namespace opensaml { EncryptedAttributeImpl(const EncryptedAttributeImpl& src) : AbstractXMLObject(src), EncryptedElementTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(EncryptedAttribute); - EncryptedElementType* cloneEncryptedElementType() const { - return new EncryptedAttributeImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(EncryptedAttribute); }; class SAML_DLLLOCAL AttributeStatementImpl : public virtual AttributeStatement, @@ -1384,10 +1372,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AttributeStatement); - Statement* cloneStatement() const { - return cloneAttributeStatement(); - } + IMPL_XMLOBJECT_CLONE2(AttributeStatement,Statement); IMPL_TYPED_CHILDREN(Attribute, m_children.end()); IMPL_TYPED_CHILDREN(EncryptedAttribute, m_children.end()); @@ -1481,10 +1466,7 @@ namespace opensaml { EncryptedAssertionImpl(const EncryptedAssertionImpl& src) : AbstractXMLObject(src), EncryptedElementTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(EncryptedAssertion); - EncryptedElementType* cloneEncryptedElementType() const { - return new EncryptedAssertionImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(EncryptedAssertion); }; class SAML_DLLLOCAL AssertionImpl : public virtual Assertion, diff --git a/saml/saml2/core/impl/Protocols20Impl.cpp b/saml/saml2/core/impl/Protocols20Impl.cpp index 37dfd9a..e663161 100644 --- a/saml/saml2/core/impl/Protocols20Impl.cpp +++ b/saml/saml2/core/impl/Protocols20Impl.cpp @@ -126,8 +126,7 @@ namespace opensaml { } StatusCodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -170,7 +169,8 @@ namespace opensaml { virtual ~StatusDetailImpl() {} StatusDetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } StatusDetailImpl(const StatusDetailImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { @@ -233,14 +233,12 @@ namespace opensaml { IMPL_TYPED_CHILD(StatusDetail); protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(StatusCode,SAML20P_NS,false); PROC_TYPED_CHILD(StatusMessage,SAML20P_NS,false); PROC_TYPED_CHILD(StatusDetail,SAML20P_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } - }; @@ -289,6 +287,9 @@ namespace opensaml { RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const RequestAbstractTypeImpl& src) { setID(src.getID()); setVersion(src.getVersion()); setIssueInstant(src.getIssueInstant()); @@ -319,6 +320,10 @@ namespace opensaml { if (m_Signature) m_Signature->setContentReference(new opensaml::ContentReference(*this)); } + + RequestAbstractType* cloneRequestAbstractType() const { + return dynamic_cast(clone()); + } IMPL_STRING_ATTRIB(Version); IMPL_ID_ATTRIB_EX(ID,ID,nullptr); @@ -377,20 +382,19 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } AssertionIDRequestImpl(const AssertionIDRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + } + + void _clone(const AssertionIDRequestImpl& src) { + RequestAbstractTypeImpl::_clone(src); VectorOf(AssertionIDRef) v=getAssertionIDRefs(); for (vector::const_iterator i=src.m_AssertionIDRefs.begin(); i!=src.m_AssertionIDRefs.end(); i++) { if (*i) { v.push_back((*i)->cloneAssertionIDRef()); } } - } - IMPL_XMLOBJECT_CLONE(AssertionIDRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAssertionIDRequest(); - } - + IMPL_XMLOBJECT_CLONE_EX(AssertionIDRequest); IMPL_TYPED_FOREIGN_CHILDREN(AssertionIDRef,saml2,m_children.end()); protected: @@ -402,8 +406,7 @@ namespace opensaml { class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, public RequestAbstractTypeImpl { - void init() - { + void init() { m_Subject = nullptr; m_children.push_back(nullptr); m_pos_Subject = m_pos_Extensions; @@ -417,17 +420,24 @@ namespace opensaml { virtual ~SubjectQueryImpl() { } SubjectQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); + } + + void _clone(const SubjectQueryImpl& src) { + RequestAbstractTypeImpl::_clone(src); if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); } + SubjectQuery* cloneSubjectQuery() const { + return dynamic_cast(clone()); + } + IMPL_TYPED_FOREIGN_CHILD(Subject,saml2); protected: @@ -437,7 +447,6 @@ namespace opensaml { } }; - class SAML_DLLLOCAL RequestedAuthnContextImpl : public virtual RequestedAuthnContext, public AbstractComplexElement, public AbstractDOMCachingXMLObject, @@ -500,7 +509,6 @@ namespace opensaml { } }; - class SAML_DLLLOCAL AuthnQueryImpl : public virtual AuthnQuery, public SubjectQueryImpl { void init() { @@ -517,26 +525,22 @@ namespace opensaml { } AuthnQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } AuthnQueryImpl(const AuthnQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); + } + + void _clone(const AuthnQueryImpl& src) { + SubjectQueryImpl::_clone(src); setSessionIndex(src.getSessionIndex()); if (src.getRequestedAuthnContext()) setRequestedAuthnContext(src.getRequestedAuthnContext()->cloneRequestedAuthnContext()); } - IMPL_XMLOBJECT_CLONE(AuthnQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAuthnQuery(); - } - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAuthnQuery(); - } - + IMPL_XMLOBJECT_CLONE_EX(AuthnQuery); IMPL_STRING_ATTRIB(SessionIndex); IMPL_TYPED_CHILD(RequestedAuthnContext); @@ -565,6 +569,10 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } AttributeQueryImpl(const AttributeQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { + } + + void _clone(const AttributeQueryImpl& src) { + SubjectQueryImpl::_clone(src); for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { if (*i) { Attribute* attrib=dynamic_cast(*i); @@ -574,17 +582,9 @@ namespace opensaml { } } } - } - IMPL_XMLOBJECT_CLONE(AttributeQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAttributeQuery(); - } - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAttributeQuery(); - } - + IMPL_XMLOBJECT_CLONE_EX(AttributeQuery); IMPL_TYPED_FOREIGN_CHILDREN(Attribute,saml2,m_children.end()); protected: @@ -616,6 +616,10 @@ namespace opensaml { AuthzDecisionQueryImpl(const AuthzDecisionQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); + } + + void _clone(const AuthzDecisionQueryImpl& src) { + SubjectQueryImpl::_clone(src); setResource(src.getResource()); if (src.getEvidence()) setEvidence(src.getEvidence()->cloneEvidence()); @@ -630,14 +634,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AuthzDecisionQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAuthzDecisionQuery(); - } - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAuthzDecisionQuery(); - } - + IMPL_XMLOBJECT_CLONE_EX(AuthzDecisionQuery); IMPL_STRING_ATTRIB(Resource); IMPL_TYPED_FOREIGN_CHILDREN(Action,saml2,m_pos_Evidence); IMPL_TYPED_FOREIGN_CHILD(Evidence,saml2); @@ -920,14 +917,16 @@ namespace opensaml { } AuthnRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } AuthnRequestImpl(const AuthnRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); + } + void _clone(const AuthnRequestImpl& src) { + RequestAbstractTypeImpl::_clone(src); ForceAuthn(m_ForceAuthn); IsPassive(m_IsPassive); setProtocolBinding(src.getProtocolBinding()); @@ -935,7 +934,6 @@ namespace opensaml { setAssertionConsumerServiceURL(src.getAssertionConsumerServiceURL()); setAttributeConsumingServiceIndex(m_AttributeConsumingServiceIndex); setProviderName(src.getProviderName()); - if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); if (src.getNameIDPolicy()) @@ -948,10 +946,7 @@ namespace opensaml { setScoping(src.getScoping()->cloneScoping()); } - IMPL_XMLOBJECT_CLONE(AuthnRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAuthnRequest(); - } + IMPL_XMLOBJECT_CLONE_EX(AuthnRequest); IMPL_BOOLEAN_ATTRIB(ForceAuthn); IMPL_BOOLEAN_ATTRIB(IsPassive); @@ -1043,14 +1038,16 @@ namespace opensaml { } StatusResponseTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } StatusResponseTypeImpl(const StatusResponseTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const StatusResponseTypeImpl& src) { setID(src.getID()); setInResponseTo(src.getInResponseTo()); setVersion(src.getVersion()); @@ -1085,6 +1082,10 @@ namespace opensaml { m_Signature->setContentReference(new opensaml::ContentReference(*this)); } + StatusResponseType* cloneStatusResponseType() const { + return dynamic_cast(clone()); + } + IMPL_STRING_ATTRIB(Version); IMPL_ID_ATTRIB_EX(ID,ID,nullptr); IMPL_STRING_ATTRIB(InResponseTo); @@ -1146,6 +1147,10 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } ResponseImpl(const ResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { + } + + void _clone(const ResponseImpl& src) { + StatusResponseTypeImpl::_clone(src); for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { if (*i) { saml2::Assertion* assertion=dynamic_cast(*i); @@ -1160,13 +1165,9 @@ namespace opensaml { } } } - } - IMPL_XMLOBJECT_CLONE(Response); - StatusResponseType* cloneStatusResponseType() const { - return cloneResponse(); - } + IMPL_XMLOBJECT_CLONE_EX(Response); IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml2,m_children.end()); IMPL_TYPED_FOREIGN_CHILDREN(EncryptedAssertion,saml2,m_children.end()); @@ -1191,22 +1192,21 @@ namespace opensaml { virtual ~ArtifactResolveImpl() { } ArtifactResolveImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } ArtifactResolveImpl(const ArtifactResolveImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); + } + + void _clone(const ArtifactResolveImpl& src) { + RequestAbstractTypeImpl::_clone(src); if(src.getArtifact()) setArtifact(src.getArtifact()->cloneArtifact()); } - IMPL_XMLOBJECT_CLONE(ArtifactResolve); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneArtifactResolve(); - } - + IMPL_XMLOBJECT_CLONE_EX(ArtifactResolve); IMPL_TYPED_CHILD(Artifact); protected: @@ -1228,36 +1228,31 @@ namespace opensaml { virtual ~ArtifactResponseImpl() { } ArtifactResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } ArtifactResponseImpl(const ArtifactResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { init(); + } + + void _clone(const ArtifactResponseImpl& src) { + StatusResponseTypeImpl::_clone(src); if (src.getPayload()) setPayload(getPayload()->clone()); - } - IMPL_XMLOBJECT_CLONE(ArtifactResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneArtifactResponse(); - } - + IMPL_XMLOBJECT_CLONE_EX(ArtifactResponse); IMPL_XMLOBJECT_CHILD(Payload); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { // These are valid elements for the parent StatusResponseType, so don't process these. // If not one of these, then it must be the payload. - if ( - ! XMLHelper::isNodeNamed(root,SAML20_NS,saml2::Issuer::LOCAL_NAME) && - ! XMLHelper::isNodeNamed(root,XMLSIG_NS,xmlsignature::Signature::LOCAL_NAME) && - ! XMLHelper::isNodeNamed(root,SAML20P_NS,saml2p::Extensions::LOCAL_NAME) && - ! XMLHelper::isNodeNamed(root,SAML20P_NS,saml2p::Status::LOCAL_NAME) - ) - { + if (!XMLHelper::isNodeNamed(root,SAML20_NS,saml2::Issuer::LOCAL_NAME) && + !XMLHelper::isNodeNamed(root,XMLSIG_NS,xmlsignature::Signature::LOCAL_NAME) && + !XMLHelper::isNodeNamed(root,SAML20P_NS,saml2p::Extensions::LOCAL_NAME) && + !XMLHelper::isNodeNamed(root,SAML20P_NS,saml2p::Status::LOCAL_NAME)) { setPayload(childXMLObject); return; } @@ -1279,8 +1274,7 @@ namespace opensaml { } protected: - NewEncryptedIDImpl() - { + NewEncryptedIDImpl() { init(); } @@ -1288,8 +1282,7 @@ namespace opensaml { virtual ~NewEncryptedIDImpl() {} NewEncryptedIDImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -1308,7 +1301,7 @@ namespace opensaml { IMPL_XMLOBJECT_CLONE(NewEncryptedID); EncryptedElementType* cloneEncryptedElementType() const { - return new NewEncryptedIDImpl(*this); + return cloneNewEncryptedID(); } IMPL_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption); @@ -1373,14 +1366,16 @@ namespace opensaml { virtual ~ManageNameIDRequestImpl() { } ManageNameIDRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } ManageNameIDRequestImpl(const ManageNameIDRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); + } + void _clone(const ManageNameIDRequestImpl& src) { + RequestAbstractTypeImpl::_clone(src); if (src.getNameID()) setNameID(src.getNameID()->cloneNameID()); if (src.getEncryptedID()) @@ -1391,14 +1386,9 @@ namespace opensaml { setNewEncryptedID(src.getNewEncryptedID()->cloneNewEncryptedID()); if (src.getTerminate()) setTerminate(src.getTerminate()->cloneTerminate()); - } - IMPL_XMLOBJECT_CLONE(ManageNameIDRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneManageNameIDRequest(); - } - + IMPL_XMLOBJECT_CLONE_EX(ManageNameIDRequest); IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); IMPL_TYPED_CHILD(NewID); @@ -1427,10 +1417,7 @@ namespace opensaml { ManageNameIDResponseImpl(const ManageNameIDResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { } - IMPL_XMLOBJECT_CLONE(ManageNameIDResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneManageNameIDResponse(); - } + IMPL_XMLOBJECT_CLONE_EX(ManageNameIDResponse); }; class SAML_DLLLOCAL LogoutRequestImpl : public virtual LogoutRequest, public RequestAbstractTypeImpl @@ -1438,7 +1425,6 @@ namespace opensaml { void init() { m_Reason=nullptr; m_NotOnOrAfter=nullptr; - m_BaseID=nullptr; m_NameID=nullptr; m_EncryptedID=nullptr; @@ -1460,17 +1446,18 @@ namespace opensaml { } LogoutRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } LogoutRequestImpl(const LogoutRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); + } + void _clone(const LogoutRequestImpl& src) { + RequestAbstractTypeImpl::_clone(src); setReason(src.getReason()); setNotOnOrAfter(src.getNotOnOrAfter()); - if (src.getBaseID()) setBaseID(src.getBaseID()->cloneBaseID()); if (src.getNameID()) @@ -1489,11 +1476,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(LogoutRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneLogoutRequest(); - } - + IMPL_XMLOBJECT_CLONE_EX(LogoutRequest); IMPL_STRING_ATTRIB(Reason); IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); IMPL_TYPED_FOREIGN_CHILD(BaseID,saml2); @@ -1533,10 +1516,7 @@ namespace opensaml { LogoutResponseImpl(const LogoutResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { } - IMPL_XMLOBJECT_CLONE(LogoutResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneLogoutResponse(); - } + IMPL_XMLOBJECT_CLONE_EX(LogoutResponse); }; @@ -1565,14 +1545,16 @@ namespace opensaml { virtual ~NameIDMappingRequestImpl() { } NameIDMappingRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } NameIDMappingRequestImpl(const NameIDMappingRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); + } + void _clone(const NameIDMappingRequestImpl& src) { + RequestAbstractTypeImpl::_clone(src); if (src.getBaseID()) setBaseID(src.getBaseID()->cloneBaseID()); if (src.getNameID()) @@ -1581,14 +1563,9 @@ namespace opensaml { setEncryptedID(src.getEncryptedID()->cloneEncryptedID()); if (src.getNameIDPolicy()) setNameIDPolicy(src.getNameIDPolicy()->cloneNameIDPolicy()); - } - IMPL_XMLOBJECT_CLONE(NameIDMappingRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneNameIDMappingRequest(); - } - + IMPL_XMLOBJECT_CLONE_EX(NameIDMappingRequest); IMPL_TYPED_FOREIGN_CHILD(BaseID,saml2); IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); @@ -1620,26 +1597,23 @@ namespace opensaml { virtual ~NameIDMappingResponseImpl() { } NameIDMappingResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } NameIDMappingResponseImpl(const NameIDMappingResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { init(); + } + void _clone(const NameIDMappingResponseImpl& src) { + StatusResponseTypeImpl::_clone(src); if (src.getNameID()) setNameID(getNameID()->cloneNameID()); if (src.getEncryptedID()) setEncryptedID(getEncryptedID()->cloneEncryptedID()); - } - IMPL_XMLOBJECT_CLONE(NameIDMappingResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneNameIDMappingResponse(); - } - + IMPL_XMLOBJECT_CLONE_EX(NameIDMappingResponse); IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); diff --git a/saml/saml2/metadata/impl/MetadataImpl.cpp b/saml/saml2/metadata/impl/MetadataImpl.cpp index 0eba500..ecef5e3 100644 --- a/saml/saml2/metadata/impl/MetadataImpl.cpp +++ b/saml/saml2/metadata/impl/MetadataImpl.cpp @@ -110,12 +110,15 @@ namespace opensaml { localizedNameTypeImpl(const localizedNameTypeImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const localizedNameTypeImpl& src) { setLang(src.getLang()); if (src.m_LangPrefix) m_LangPrefix = XMLString::replicate(src.m_LangPrefix); } - IMPL_XMLOBJECT_CLONE(localizedNameType); + IMPL_XMLOBJECT_CLONE_EX(localizedNameType); IMPL_XMLOBJECT_FOREIGN_ATTRIB(Lang,XMLCh); protected: @@ -173,12 +176,15 @@ namespace opensaml { localizedURITypeImpl(const localizedURITypeImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const localizedURITypeImpl& src) { setLang(src.getLang()); if (src.m_LangPrefix) m_LangPrefix = XMLString::replicate(src.m_LangPrefix); } - IMPL_XMLOBJECT_CLONE(localizedURIType); + IMPL_XMLOBJECT_CLONE_EX(localizedURIType); IMPL_XMLOBJECT_FOREIGN_ATTRIB(Lang,XMLCh); protected: @@ -216,10 +222,7 @@ namespace opensaml { OrganizationNameImpl(const OrganizationNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(OrganizationName); - localizedNameType* clonelocalizedNameType() const { - return new OrganizationNameImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(OrganizationName); }; class SAML_DLLLOCAL OrganizationDisplayNameImpl : public virtual OrganizationDisplayName, public localizedNameTypeImpl @@ -232,10 +235,7 @@ namespace opensaml { OrganizationDisplayNameImpl(const OrganizationDisplayNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(OrganizationDisplayName); - localizedNameType* clonelocalizedNameType() const { - return new OrganizationDisplayNameImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(OrganizationDisplayName); }; class SAML_DLLLOCAL OrganizationURLImpl : public virtual OrganizationURL, public localizedURITypeImpl @@ -248,10 +248,7 @@ namespace opensaml { OrganizationURLImpl(const OrganizationURLImpl& src) : AbstractXMLObject(src), localizedURITypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(OrganizationURL); - localizedURIType* clonelocalizedURIType() const { - return new OrganizationURLImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(OrganizationURL); }; class SAML_DLLLOCAL ServiceNameImpl : public virtual ServiceName, public localizedNameTypeImpl @@ -264,10 +261,7 @@ namespace opensaml { ServiceNameImpl(const ServiceNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(ServiceName); - localizedNameType* clonelocalizedNameType() const { - return new ServiceNameImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(ServiceName); }; class SAML_DLLLOCAL ServiceDescriptionImpl : public virtual ServiceDescription, public localizedNameTypeImpl @@ -280,10 +274,7 @@ namespace opensaml { ServiceDescriptionImpl(const ServiceDescriptionImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(ServiceDescription); - localizedNameType* clonelocalizedNameType() const { - return new ServiceDescriptionImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(ServiceDescription); }; class SAML_DLLLOCAL ExtensionsImpl : public virtual Extensions, @@ -629,7 +620,8 @@ namespace opensaml { } EndpointTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); } EndpointTypeImpl(const EndpointTypeImpl& src) @@ -637,6 +629,10 @@ namespace opensaml { AbstractAttributeExtensibleXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + } + + void _clone(const EndpointTypeImpl& src) { setBinding(src.getBinding()); setLocation(src.getLocation()); setResponseLocation(src.getResponseLocation()); @@ -645,7 +641,7 @@ namespace opensaml { v.push_back((*i)->clone()); } - IMPL_XMLOBJECT_CLONE(EndpointType); + IMPL_XMLOBJECT_CLONE_EX(EndpointType); IMPL_STRING_ATTRIB(Binding); IMPL_STRING_ATTRIB(Location); IMPL_STRING_ATTRIB(ResponseLocation); @@ -708,18 +704,21 @@ namespace opensaml { } IndexedEndpointTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } IndexedEndpointTypeImpl(const IndexedEndpointTypeImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) { - setIndex(src.m_Index); - isDefault(src.m_isDefault); + init(); } - IMPL_XMLOBJECT_CLONE(IndexedEndpointType); - EndpointType* cloneEndpointType() const { - return new IndexedEndpointTypeImpl(*this); + void _clone(const IndexedEndpointTypeImpl& src) { + EndpointTypeImpl::_clone(src); + setIndex(src.m_Index); + isDefault(src.m_isDefault); } + IMPL_XMLOBJECT_CLONE_EX(IndexedEndpointType); IMPL_INTEGER_ATTRIB(Index); IMPL_BOOLEAN_ATTRIB(isDefault); @@ -755,13 +754,7 @@ namespace opensaml { ArtifactResolutionServiceImpl(const ArtifactResolutionServiceImpl& src) : AbstractXMLObject(src), IndexedEndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(ArtifactResolutionService); - IndexedEndpointType* cloneIndexedEndpointType() const { - return new ArtifactResolutionServiceImpl(*this); - } - EndpointType* cloneEndpointType() const { - return new ArtifactResolutionServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(ArtifactResolutionService); }; class SAML_DLLLOCAL SingleLogoutServiceImpl : public virtual SingleLogoutService, public EndpointTypeImpl @@ -774,10 +767,7 @@ namespace opensaml { SingleLogoutServiceImpl(const SingleLogoutServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(SingleLogoutService); - EndpointType* cloneEndpointType() const { - return new SingleLogoutServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(SingleLogoutService); }; class SAML_DLLLOCAL ManageNameIDServiceImpl : public virtual ManageNameIDService, public EndpointTypeImpl @@ -790,10 +780,7 @@ namespace opensaml { ManageNameIDServiceImpl(const ManageNameIDServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(ManageNameIDService); - EndpointType* cloneEndpointType() const { - return new ManageNameIDServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(ManageNameIDService); }; class SAML_DLLLOCAL SingleSignOnServiceImpl : public virtual SingleSignOnService, public EndpointTypeImpl @@ -806,10 +793,7 @@ namespace opensaml { SingleSignOnServiceImpl(const SingleSignOnServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(SingleSignOnService); - EndpointType* cloneEndpointType() const { - return new SingleSignOnServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(SingleSignOnService); }; class SAML_DLLLOCAL NameIDMappingServiceImpl : public virtual NameIDMappingService, public EndpointTypeImpl @@ -822,10 +806,7 @@ namespace opensaml { NameIDMappingServiceImpl(const NameIDMappingServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(NameIDMappingService); - EndpointType* cloneEndpointType() const { - return new NameIDMappingServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(NameIDMappingService); }; class SAML_DLLLOCAL AssertionIDRequestServiceImpl : public virtual AssertionIDRequestService, public EndpointTypeImpl @@ -838,10 +819,7 @@ namespace opensaml { AssertionIDRequestServiceImpl(const AssertionIDRequestServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(AssertionIDRequestService); - EndpointType* cloneEndpointType() const { - return new AssertionIDRequestServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(AssertionIDRequestService); }; class SAML_DLLLOCAL AssertionConsumerServiceImpl : public virtual AssertionConsumerService, public IndexedEndpointTypeImpl @@ -854,13 +832,7 @@ namespace opensaml { AssertionConsumerServiceImpl(const AssertionConsumerServiceImpl& src) : AbstractXMLObject(src), IndexedEndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(AssertionConsumerService); - EndpointType* cloneEndpointType() const { - return new AssertionConsumerServiceImpl(*this); - } - IndexedEndpointType* cloneIndexedEndpointType() const { - return new AssertionConsumerServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(AssertionConsumerService); }; class SAML_DLLLOCAL AuthnQueryServiceImpl : public virtual AuthnQueryService, public EndpointTypeImpl @@ -873,10 +845,7 @@ namespace opensaml { AuthnQueryServiceImpl(const AuthnQueryServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(AuthnQueryService); - EndpointType* cloneEndpointType() const { - return new AuthnQueryServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(AuthnQueryService); }; class SAML_DLLLOCAL AuthzServiceImpl : public virtual AuthzService, public EndpointTypeImpl @@ -889,10 +858,7 @@ namespace opensaml { AuthzServiceImpl(const AuthzServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(AuthzService); - EndpointType* cloneEndpointType() const { - return new AuthzServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(AuthzService); }; class SAML_DLLLOCAL AttributeServiceImpl : public virtual AttributeService, public EndpointTypeImpl @@ -905,10 +871,7 @@ namespace opensaml { AttributeServiceImpl(const AttributeServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(AttributeService); - EndpointType* cloneEndpointType() const { - return new AttributeServiceImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(AttributeService); }; class SAML_DLLLOCAL RoleDescriptorImpl : public virtual RoleDescriptor, @@ -963,6 +926,9 @@ namespace opensaml { : AbstractXMLObject(src), AbstractComplexElement(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { init(); + } + + void _clone(const RoleDescriptorImpl& src) { setID(src.getID()); setProtocolSupportEnumeration(src.getProtocolSupportEnumeration()); setErrorURL(src.getErrorURL()); @@ -1007,6 +973,10 @@ namespace opensaml { m_Signature->setContentReference(new opensaml::ContentReference(*this)); } + RoleDescriptor* cloneRoleDescriptor() const { + return dynamic_cast(clone()); + } + IMPL_ID_ATTRIB_EX(ID,ID,nullptr); IMPL_STRING_ATTRIB(ProtocolSupportEnumeration); IMPL_STRING_ATTRIB(ErrorURL); @@ -1139,16 +1109,16 @@ namespace opensaml { } RoleDescriptorTypeImpl(const RoleDescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) { + } + + void _clone(const RoleDescriptorTypeImpl& src) { + RoleDescriptorImpl::_clone(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_CLONE_EX(RoleDescriptorType); IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: @@ -1194,6 +1164,10 @@ namespace opensaml { SSODescriptorTypeImpl(const SSODescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) { init(); + } + + void _clone(const SSODescriptorTypeImpl& src) { + RoleDescriptorImpl::_clone(src); VectorOf(ArtifactResolutionService) v=getArtifactResolutionServices(); for (vector::const_iterator i=src.m_ArtifactResolutionServices.begin(); i!=src.m_ArtifactResolutionServices.end(); i++) { if (*i) { @@ -1220,6 +1194,10 @@ namespace opensaml { } } + SSODescriptorType* cloneSSODescriptorType() const { + return dynamic_cast(clone()); + } + IMPL_TYPED_CHILDREN(ArtifactResolutionService,m_pos_ArtifactResolutionService); IMPL_TYPED_CHILDREN(SingleLogoutService,m_pos_SingleLogoutService); IMPL_TYPED_CHILDREN(ManageNameIDService,m_pos_ManageNameIDService); @@ -1268,6 +1246,10 @@ namespace opensaml { IDPSSODescriptorImpl(const IDPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) { init(); + } + + void _clone(const IDPSSODescriptorImpl& src) { + SSODescriptorTypeImpl::_clone(src); WantAuthnRequestsSigned(src.m_WantAuthnRequestsSigned); VectorOf(SingleSignOnService) v=getSingleSignOnServices(); for (vector::const_iterator i=src.m_SingleSignOnServices.begin(); i!=src.m_SingleSignOnServices.end(); i++) { @@ -1301,14 +1283,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(IDPSSODescriptor); - SSODescriptorType* cloneSSODescriptorType() const { - return new IDPSSODescriptorImpl(*this); - } - RoleDescriptor* cloneRoleDescriptor() const { - return new IDPSSODescriptorImpl(*this); - } - + IMPL_XMLOBJECT_CLONE_EX(IDPSSODescriptor); IMPL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned); IMPL_TYPED_CHILDREN(SingleSignOnService,m_pos_SingleSignOnService); IMPL_TYPED_CHILDREN(NameIDMappingService,m_pos_NameIDMappingService); @@ -1381,11 +1356,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(RequestedAttribute); - Attribute* cloneAttribute() const { - return new RequestedAttributeImpl(*this); - } - + IMPL_XMLOBJECT_CLONE2(RequestedAttribute,Attribute); IMPL_STRING_ATTRIB(Name); IMPL_STRING_ATTRIB(NameFormat); IMPL_STRING_ATTRIB(FriendlyName); @@ -1535,6 +1506,10 @@ namespace opensaml { SPSSODescriptorImpl(const SPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) { init(); + } + + void _clone(const SPSSODescriptorImpl& src) { + SSODescriptorTypeImpl::_clone(src); AuthnRequestsSigned(src.m_AuthnRequestsSigned); WantAssertionsSigned(src.m_WantAssertionsSigned); VectorOf(AssertionConsumerService) v=getAssertionConsumerServices(); @@ -1551,14 +1526,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(SPSSODescriptor); - SSODescriptorType* cloneSSODescriptorType() const { - return cloneSPSSODescriptor(); - } - RoleDescriptor* cloneRoleDescriptor() const { - return cloneSPSSODescriptor(); - } - + IMPL_XMLOBJECT_CLONE_EX(SPSSODescriptor); IMPL_BOOLEAN_ATTRIB(AuthnRequestsSigned); IMPL_BOOLEAN_ATTRIB(WantAssertionsSigned); IMPL_TYPED_CHILDREN(AssertionConsumerService,m_pos_AssertionConsumerService); @@ -1610,12 +1578,16 @@ namespace opensaml { virtual ~AuthnAuthorityDescriptorImpl() {} AuthnAuthorityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } AuthnAuthorityDescriptorImpl(const AuthnAuthorityDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) { init(); + } + + void _clone(const AuthnAuthorityDescriptorImpl& src) { + RoleDescriptorImpl::_clone(src); VectorOf(AuthnQueryService) v=getAuthnQueryServices(); for (vector::const_iterator i=src.m_AuthnQueryServices.begin(); i!=src.m_AuthnQueryServices.end(); i++) { if (*i) { @@ -1636,11 +1608,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AuthnAuthorityDescriptor); - RoleDescriptor* cloneRoleDescriptor() const { - return cloneAuthnAuthorityDescriptor(); - } - + IMPL_XMLOBJECT_CLONE_EX(AuthnAuthorityDescriptor); IMPL_TYPED_CHILDREN(AuthnQueryService,m_pos_AuthnQueryService); IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService); IMPL_TYPED_CHILDREN(NameIDFormat,m_children.end()); @@ -1672,12 +1640,16 @@ namespace opensaml { virtual ~PDPDescriptorImpl() {} PDPDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } PDPDescriptorImpl(const PDPDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) { init(); + } + + void _clone(const PDPDescriptorImpl& src) { + RoleDescriptorImpl::_clone(src); VectorOf(AuthzService) v=getAuthzServices(); for (vector::const_iterator i=src.m_AuthzServices.begin(); i!=src.m_AuthzServices.end(); i++) { if (*i) { @@ -1698,11 +1670,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(PDPDescriptor); - RoleDescriptor* cloneRoleDescriptor() const { - return clonePDPDescriptor(); - } - + IMPL_XMLOBJECT_CLONE_EX(PDPDescriptor); IMPL_TYPED_CHILDREN(AuthzService,m_pos_AuthzService); IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService); IMPL_TYPED_CHILDREN(NameIDFormat,m_children.end()); @@ -1742,12 +1710,16 @@ namespace opensaml { virtual ~AttributeAuthorityDescriptorImpl() {} AttributeAuthorityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } AttributeAuthorityDescriptorImpl(const AttributeAuthorityDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) { init(); + } + + void _clone(const AttributeAuthorityDescriptorImpl& src) { + RoleDescriptorImpl::_clone(src); VectorOf(AttributeService) v=getAttributeServices(); for (vector::const_iterator i=src.m_AttributeServices.begin(); i!=src.m_AttributeServices.end(); i++) { if (*i) { @@ -1780,11 +1752,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AttributeAuthorityDescriptor); - RoleDescriptor* cloneRoleDescriptor() const { - return cloneAttributeAuthorityDescriptor(); - } - + IMPL_XMLOBJECT_CLONE_EX(AttributeAuthorityDescriptor); IMPL_TYPED_CHILDREN(AttributeService,m_pos_AttributeService); IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService); IMPL_TYPED_CHILDREN(NameIDFormat,m_pos_NameIDFormat); @@ -1822,12 +1790,16 @@ namespace opensaml { virtual ~QueryDescriptorTypeImpl() {} QueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } QueryDescriptorTypeImpl(const QueryDescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) { init(); + } + + void _clone(const QueryDescriptorTypeImpl& src) { + RoleDescriptorImpl::_clone(src); WantAssertionsSigned(src.m_WantAssertionsSigned); VectorOf(NameIDFormat) y=getNameIDFormats(); for (vector::const_iterator m=src.m_NameIDFormats.begin(); m!=src.m_NameIDFormats.end(); m++) { @@ -1837,6 +1809,10 @@ namespace opensaml { } } + QueryDescriptorType* cloneQueryDescriptorType() const { + return dynamic_cast(clone()); + } + IMPL_BOOLEAN_ATTRIB(WantAssertionsSigned); IMPL_TYPED_CHILDREN(NameIDFormat,m_pos_NameIDFormat); @@ -1872,13 +1848,7 @@ namespace opensaml { AuthnQueryDescriptorTypeImpl(const AuthnQueryDescriptorTypeImpl& src) : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(AuthnQueryDescriptorType); - QueryDescriptorType* cloneQueryDescriptorType() const { - return new AuthnQueryDescriptorTypeImpl(*this); - } - RoleDescriptor* cloneRoleDescriptor() const { - return new AuthnQueryDescriptorTypeImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(AuthnQueryDescriptorType); }; class SAML_DLLLOCAL AttributeQueryDescriptorTypeImpl : public virtual AttributeQueryDescriptorType, public QueryDescriptorTypeImpl @@ -1889,8 +1859,11 @@ namespace opensaml { AttributeQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - AttributeQueryDescriptorTypeImpl(const AttributeQueryDescriptorTypeImpl& src) - : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) { + AttributeQueryDescriptorTypeImpl(const AttributeQueryDescriptorTypeImpl& src) : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) { + } + + void _clone(const AttributeQueryDescriptorTypeImpl& src) { + QueryDescriptorTypeImpl::_clone(src); VectorOf(AttributeConsumingService) w=getAttributeConsumingServices(); for (vector::const_iterator j=src.m_AttributeConsumingServices.begin(); j!=src.m_AttributeConsumingServices.end(); j++) { if (*j) { @@ -1899,14 +1872,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AttributeQueryDescriptorType); - QueryDescriptorType* cloneQueryDescriptorType() const { - return new AttributeQueryDescriptorTypeImpl(*this); - } - RoleDescriptor* cloneRoleDescriptor() const { - return new AttributeQueryDescriptorTypeImpl(*this); - } - + IMPL_XMLOBJECT_CLONE_EX(AttributeQueryDescriptorType); IMPL_TYPED_CHILDREN(AttributeConsumingService,m_children.end()); protected: @@ -1924,8 +1890,11 @@ namespace opensaml { AuthzDecisionQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - AuthzDecisionQueryDescriptorTypeImpl(const AuthzDecisionQueryDescriptorTypeImpl& src) - : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) { + AuthzDecisionQueryDescriptorTypeImpl(const AuthzDecisionQueryDescriptorTypeImpl& src) : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) { + } + + void _clone(const AuthzDecisionQueryDescriptorTypeImpl& src) { + QueryDescriptorTypeImpl::_clone(src); VectorOf(ActionNamespace) w=getActionNamespaces(); for (vector::const_iterator j=src.m_ActionNamespaces.begin(); j!=src.m_ActionNamespaces.end(); j++) { if (*j) { @@ -1934,14 +1903,7 @@ namespace opensaml { } } - IMPL_XMLOBJECT_CLONE(AuthzDecisionQueryDescriptorType); - QueryDescriptorType* cloneQueryDescriptorType() const { - return new AuthzDecisionQueryDescriptorTypeImpl(*this); - } - RoleDescriptor* cloneRoleDescriptor() const { - return new AuthzDecisionQueryDescriptorTypeImpl(*this); - } - + IMPL_XMLOBJECT_CLONE_EX(AuthzDecisionQueryDescriptorType); IMPL_TYPED_CHILDREN(ActionNamespace,m_children.end()); protected: @@ -2481,13 +2443,7 @@ namespace opensaml { DiscoveryResponseImpl(const DiscoveryResponseImpl& src) : AbstractXMLObject(src), IndexedEndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(DiscoveryResponse); - IndexedEndpointType* cloneIndexedEndpointType() const { - return new DiscoveryResponseImpl(*this); - } - EndpointType* cloneEndpointType() const { - return new DiscoveryResponseImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(DiscoveryResponse); }; class SAML_DLLLOCAL RequestInitiatorImpl : public virtual RequestInitiator, public EndpointTypeImpl @@ -2500,10 +2456,7 @@ namespace opensaml { RequestInitiatorImpl(const RequestInitiatorImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(RequestInitiator); - EndpointType* cloneEndpointType() const { - return new RequestInitiatorImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(RequestInitiator); }; class SAML_DLLLOCAL EntityAttributesImpl : public virtual EntityAttributes, @@ -2539,7 +2492,6 @@ namespace opensaml { } IMPL_XMLOBJECT_CLONE(EntityAttributes); - IMPL_TYPED_FOREIGN_CHILDREN(Attribute,saml2,m_children.end()); IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml2,m_children.end()); @@ -2575,9 +2527,8 @@ namespace opensaml { v.push_back((*i)->clone()); } - IMPL_STRING_ATTRIB(Algorithm); - IMPL_XMLOBJECT_CLONE(DigestMethod); + IMPL_STRING_ATTRIB(Algorithm); IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: @@ -2626,11 +2577,10 @@ namespace opensaml { } IMPL_XMLOBJECT_CLONE(SigningMethod); - IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); - IMPL_STRING_ATTRIB(Algorithm); IMPL_INTEGER_ATTRIB(MinKeySize); IMPL_INTEGER_ATTRIB(MaxKeySize); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void marshallAttributes(DOMElement* domElement) const { @@ -2661,10 +2611,7 @@ namespace opensaml { DisplayNameImpl(const DisplayNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(DisplayName); - localizedNameType* clonelocalizedNameType() const { - return new DisplayNameImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(DisplayName); }; class SAML_DLLLOCAL DescriptionImpl : public virtual Description, public localizedNameTypeImpl @@ -2677,10 +2624,7 @@ namespace opensaml { DescriptionImpl(const DescriptionImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(Description); - localizedNameType* clonelocalizedNameType() const { - return new DescriptionImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(Description); }; class SAML_DLLLOCAL InformationURLImpl : public virtual InformationURL, public localizedURITypeImpl @@ -2693,10 +2637,7 @@ namespace opensaml { InformationURLImpl(const InformationURLImpl& src) : AbstractXMLObject(src), localizedURITypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(InformationURL); - localizedURIType* clonelocalizedURIType() const { - return new InformationURLImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(InformationURL); }; class SAML_DLLLOCAL PrivacyStatementURLImpl : public virtual PrivacyStatementURL, public localizedURITypeImpl @@ -2709,10 +2650,7 @@ namespace opensaml { PrivacyStatementURLImpl(const PrivacyStatementURLImpl& src) : AbstractXMLObject(src), localizedURITypeImpl(src) {} - IMPL_XMLOBJECT_CLONE(PrivacyStatementURL); - localizedURIType* clonelocalizedURIType() const { - return new PrivacyStatementURLImpl(*this); - } + IMPL_XMLOBJECT_CLONE_EX(PrivacyStatementURL); }; class SAML_DLLLOCAL KeywordsImpl : public virtual Keywords, diff --git a/samltest/internal.h b/samltest/internal.h index a05f1a5..f1abd88 100644 --- a/samltest/internal.h +++ b/samltest/internal.h @@ -106,6 +106,9 @@ protected: void assertEquals(DOMDocument* expectedDOM, XMLObject* xmlObject, bool canMarshall=true) { assertEquals("Marshalled DOM was not the same as the expected DOM", expectedDOM, xmlObject, canMarshall); + // Test a clone operation before destroying the original. + xmlObject->releaseThisAndChildrenDOM(); + delete xmlObject->clone(); delete xmlObject; } -- 2.1.4