X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml1%2Fcore%2Fimpl%2FAssertionsImpl.cpp;h=035cf3c9cead71eb4249754ef08d15eb6151bde7;hb=ecc9f2def78a53386e33f330147b80f3316a4b35;hp=ac0fde17ec8e383b9d6735f4232a47da781e0c43;hpb=60dec4389c6f9ff4207819bb1978177214acc008;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml1/core/impl/AssertionsImpl.cpp b/saml/saml1/core/impl/AssertionsImpl.cpp index ac0fde1..035cf3c 100644 --- a/saml/saml1/core/impl/AssertionsImpl.cpp +++ b/saml/saml1/core/impl/AssertionsImpl.cpp @@ -1,42 +1,53 @@ -/* - * Copyright 2001-2009 Internet2 +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. * - * 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 + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. */ /** * AssertionsImpl.cpp * - * Implementation classes for SAML 1.x Assertions schema + * Implementation classes for SAML 1.x Assertions schema. */ #include "internal.h" #include "exceptions.h" #include "saml1/core/Assertions.h" +#include "signature/ContentReference.h" #include #include #include #include #include +#include +#include +#include #include #include #include +#include +#include +#include +#include #include using namespace opensaml::saml1; -using namespace xmlsignature; using namespace xmltooling; using namespace std; using xmlconstants::XMLSIG_NS; @@ -61,12 +72,11 @@ namespace opensaml { virtual ~ConditionImpl() {} ConditionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} ConditionImpl(const ConditionImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(Condition); + IMPL_XMLOBJECT_CLONE_EX(Condition); }; class SAML_DLLLOCAL AudienceRestrictionConditionImpl : public virtual AudienceRestrictionCondition, @@ -79,23 +89,14 @@ namespace opensaml { virtual ~AudienceRestrictionConditionImpl() {} AudienceRestrictionConditionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} AudienceRestrictionConditionImpl(const AudienceRestrictionConditionImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - VectorOf(Audience) v=getAudiences(); - for (vector::const_iterator i=src.m_Audiences.begin(); i!=src.m_Audiences.end(); i++) { - if (*i) { - v.push_back((*i)->cloneAudience()); - } - } + IMPL_CLONE_TYPED_CHILDREN(Audience); } - IMPL_XMLOBJECT_CLONE(AudienceRestrictionCondition); - Condition* cloneCondition() const { - return cloneAudienceRestrictionCondition(); - } + IMPL_XMLOBJECT_CLONE2(AudienceRestrictionCondition,Condition); IMPL_TYPED_CHILDREN(Audience,m_children.end()); protected: @@ -115,17 +116,12 @@ namespace opensaml { virtual ~DoNotCacheConditionImpl() {} DoNotCacheConditionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} DoNotCacheConditionImpl(const DoNotCacheConditionImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { - } + : 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, @@ -134,6 +130,10 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_NotBefore=m_NotOnOrAfter=nullptr; + } + public: virtual ~ConditionsImpl() { delete m_NotBefore; @@ -148,34 +148,13 @@ namespace opensaml { ConditionsImpl(const ConditionsImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); - setNotBefore(src.getNotBefore()); - setNotOnOrAfter(src.getNotOnOrAfter()); - - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - AudienceRestrictionCondition* arc=dynamic_cast(*i); - if (arc) { - 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()); - continue; - } - } - } - } - - void init() { - m_NotBefore=m_NotOnOrAfter=NULL; + IMPL_CLONE_ATTRIB(NotBefore); + IMPL_CLONE_ATTRIB(NotOnOrAfter); + IMPL_CLONE_CHILDBAG_BEGIN; + IMPL_CLONE_TYPED_CHILD_IN_BAG(AudienceRestrictionCondition); + IMPL_CLONE_TYPED_CHILD_IN_BAG(DoNotCacheCondition); + IMPL_CLONE_TYPED_CHILD_IN_BAG(Condition); + IMPL_CLONE_CHILDBAG_END; } IMPL_XMLOBJECT_CLONE(Conditions); @@ -187,8 +166,8 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); - MARSHALL_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); + MARSHALL_DATETIME_ATTRIB(NotBefore,NOTBEFORE,nullptr); + MARSHALL_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -199,8 +178,8 @@ namespace opensaml { } void processAttribute(const DOMAttr* attribute) { - PROC_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); - PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); + PROC_DATETIME_ATTRIB(NotBefore,NOTBEFORE,nullptr); + PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,nullptr); } }; @@ -210,6 +189,10 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_Format=m_NameQualifier=nullptr; + } + public: virtual ~NameIdentifierImpl() { XMLString::release(&m_Format); @@ -224,12 +207,8 @@ namespace opensaml { 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_CLONE_ATTRIB(Format); + IMPL_CLONE_ATTRIB(NameQualifier); } IMPL_XMLOBJECT_CLONE(NameIdentifier); @@ -238,13 +217,13 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Format,FORMAT,NULL); - MARSHALL_STRING_ATTRIB(NameQualifier,NAMEQUALIFIER,NULL); + MARSHALL_STRING_ATTRIB(Format,FORMAT,nullptr); + MARSHALL_STRING_ATTRIB(NameQualifier,NAMEQUALIFIER,nullptr); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Format,FORMAT,NULL); - PROC_STRING_ATTRIB(NameQualifier,NAMEQUALIFIER,NULL); + PROC_STRING_ATTRIB(Format,FORMAT,nullptr); + PROC_STRING_ATTRIB(NameQualifier,NAMEQUALIFIER,nullptr); } }; @@ -254,13 +233,11 @@ namespace opensaml { virtual ~SubjectConfirmationDataImpl() {} SubjectConfirmationDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) { - } + SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(SubjectConfirmationData); + IMPL_XMLOBJECT_CLONE_EX(SubjectConfirmationData); }; class SAML_DLLLOCAL SubjectConfirmationImpl : public virtual SubjectConfirmation, @@ -269,6 +246,16 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_SubjectConfirmationData=nullptr; + m_KeyInfo=nullptr; + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_pos_SubjectConfirmationData=m_children.begin(); + m_pos_KeyInfo=m_pos_SubjectConfirmationData; + ++m_pos_KeyInfo; + } + public: virtual ~SubjectConfirmationImpl() {} @@ -280,37 +267,20 @@ namespace opensaml { SubjectConfirmationImpl(const SubjectConfirmationImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); - if (src.getSubjectConfirmationData()) - setSubjectConfirmationData(src.getSubjectConfirmationData()->clone()); - if (src.getKeyInfo()) - setKeyInfo(src.getKeyInfo()->cloneKeyInfo()); - VectorOf(ConfirmationMethod) v=getConfirmationMethods(); - for (vector::const_iterator i=src.m_ConfirmationMethods.begin(); i!=src.m_ConfirmationMethods.end(); i++) { - if (*i) { - v.push_back((*i)->cloneConfirmationMethod()); - } - } - } - - void init() { - m_SubjectConfirmationData=NULL; - m_KeyInfo=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_SubjectConfirmationData=m_children.begin(); - m_pos_KeyInfo=m_pos_SubjectConfirmationData; - ++m_pos_KeyInfo; + IMPL_CLONE_TYPED_CHILDREN(ConfirmationMethod); + IMPL_CLONE_XMLOBJECT_CHILD(SubjectConfirmationData); + IMPL_CLONE_TYPED_CHILD(KeyInfo); } IMPL_XMLOBJECT_CLONE(SubjectConfirmation); IMPL_TYPED_CHILDREN(ConfirmationMethod,m_pos_SubjectConfirmationData); IMPL_XMLOBJECT_CHILD(SubjectConfirmationData); - IMPL_TYPED_CHILD(KeyInfo); + IMPL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(ConfirmationMethod,SAML1_NS,false); - PROC_TYPED_CHILD(KeyInfo,XMLSIG_NS,false); + PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLSIG_NS,false); // Anything else we'll assume is the data. if (getSubjectConfirmationData()) @@ -325,6 +295,16 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_NameIdentifier=nullptr; + m_SubjectConfirmation=nullptr; + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_pos_NameIdentifier=m_children.begin(); + m_pos_SubjectConfirmation=m_pos_NameIdentifier; + ++m_pos_SubjectConfirmation; + } + public: virtual ~SubjectImpl() {} @@ -336,20 +316,8 @@ namespace opensaml { SubjectImpl(const SubjectImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); - if (src.getNameIdentifier()) - setNameIdentifier(src.getNameIdentifier()->cloneNameIdentifier()); - if (src.getSubjectConfirmation()) - setSubjectConfirmation(src.getSubjectConfirmation()->cloneSubjectConfirmation()); - } - - void init() { - m_NameIdentifier=NULL; - m_SubjectConfirmation=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_NameIdentifier=m_children.begin(); - m_pos_SubjectConfirmation=m_pos_NameIdentifier; - ++m_pos_SubjectConfirmation; + IMPL_CLONE_TYPED_CHILD(NameIdentifier); + IMPL_CLONE_TYPED_CHILD(SubjectConfirmation); } IMPL_XMLOBJECT_CLONE(Subject); @@ -370,12 +338,11 @@ namespace opensaml { virtual ~StatementImpl() {} StatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} StatementImpl(const StatementImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} - IMPL_XMLOBJECT_CLONE(Statement); + IMPL_XMLOBJECT_CLONE_EX(Statement); }; class SAML_DLLLOCAL SubjectStatementImpl : public virtual SubjectStatement, @@ -385,10 +352,11 @@ namespace opensaml { public AbstractXMLObjectUnmarshaller { void init() { - m_Subject=NULL; - m_children.push_back(NULL); + m_Subject=nullptr; + m_children.push_back(nullptr); m_pos_Subject=m_children.begin(); } + protected: SubjectStatementImpl() { init(); @@ -404,8 +372,18 @@ namespace opensaml { SubjectStatementImpl(const SubjectStatementImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); - if (src.getSubject()) - setSubject(src.getSubject()->cloneSubject()); + } + + void _clone(const SubjectStatementImpl& src) { + IMPL_CLONE_TYPED_CHILD(Subject); + } + + Statement* cloneStatement() const { + return dynamic_cast(clone()); + } + + SubjectStatement* cloneSubjectStatement() const { + return dynamic_cast(clone()); } IMPL_TYPED_CHILD(Subject); @@ -423,6 +401,10 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_IPAddress=m_DNSAddress=nullptr; + } + public: virtual ~SubjectLocalityImpl() { XMLString::release(&m_IPAddress); @@ -437,12 +419,8 @@ namespace opensaml { 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_CLONE_ATTRIB(IPAddress); + IMPL_CLONE_ATTRIB(DNSAddress); } IMPL_XMLOBJECT_CLONE(SubjectLocality); @@ -451,13 +429,13 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(IPAddress,IPADDRESS,NULL); - MARSHALL_STRING_ATTRIB(DNSAddress,DNSADDRESS,NULL); + MARSHALL_STRING_ATTRIB(IPAddress,IPADDRESS,nullptr); + MARSHALL_STRING_ATTRIB(DNSAddress,DNSADDRESS,nullptr); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(IPAddress,IPADDRESS,NULL); - PROC_STRING_ATTRIB(DNSAddress,DNSADDRESS,NULL); + PROC_STRING_ATTRIB(IPAddress,IPADDRESS,nullptr); + PROC_STRING_ATTRIB(DNSAddress,DNSADDRESS,nullptr); } }; @@ -467,6 +445,11 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_AuthorityKind=nullptr; + m_Location=m_Binding=nullptr; + } + public: virtual ~AuthorityBindingImpl() { delete m_AuthorityKind; @@ -482,14 +465,9 @@ namespace opensaml { AuthorityBindingImpl(const AuthorityBindingImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); - setAuthorityKind(src.getAuthorityKind()); - setLocation(src.getLocation()); - setBinding(src.getBinding()); - } - - void init() { - m_AuthorityKind=NULL; - m_Location=m_Binding=NULL; + IMPL_CLONE_ATTRIB(AuthorityKind); + IMPL_CLONE_ATTRIB(Location); + IMPL_CLONE_ATTRIB(Binding); } IMPL_XMLOBJECT_CLONE(AuthorityBinding); @@ -499,20 +477,29 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_QNAME_ATTRIB(AuthorityKind,AUTHORITYKIND,NULL); - MARSHALL_STRING_ATTRIB(Location,LOCATION,NULL); - MARSHALL_STRING_ATTRIB(Binding,BINDING,NULL); + MARSHALL_QNAME_ATTRIB(AuthorityKind,AUTHORITYKIND,nullptr); + MARSHALL_STRING_ATTRIB(Location,LOCATION,nullptr); + MARSHALL_STRING_ATTRIB(Binding,BINDING,nullptr); } void processAttribute(const DOMAttr* attribute) { - PROC_QNAME_ATTRIB(AuthorityKind,AUTHORITYKIND,NULL); - PROC_STRING_ATTRIB(Location,LOCATION,NULL); - PROC_STRING_ATTRIB(Binding,BINDING,NULL); + PROC_QNAME_ATTRIB(AuthorityKind,AUTHORITYKIND,nullptr); + PROC_STRING_ATTRIB(Location,LOCATION,nullptr); + PROC_STRING_ATTRIB(Binding,BINDING,nullptr); } }; 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); @@ -526,34 +513,17 @@ namespace opensaml { AuthenticationStatementImpl(const AuthenticationStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); - setAuthenticationMethod(src.getAuthenticationMethod()); - setAuthenticationInstant(src.getAuthenticationInstant()); - if (src.getSubjectLocality()) - setSubjectLocality(src.getSubjectLocality()->cloneSubjectLocality()); - VectorOf(AuthorityBinding) v=getAuthorityBindings(); - for (vector::const_iterator i=src.m_AuthorityBindings.begin(); i!=src.m_AuthorityBindings.end(); i++) { - if (*i) { - v.push_back((*i)->cloneAuthorityBinding()); - } - } } - void init() { - m_AuthenticationMethod=NULL; - m_AuthenticationInstant=NULL; - m_SubjectLocality=NULL; - m_children.push_back(NULL); - m_pos_SubjectLocality=m_pos_Subject; - ++m_pos_SubjectLocality; + void _clone(const AuthenticationStatementImpl& src) { + SubjectStatementImpl::_clone(src); + IMPL_CLONE_ATTRIB(AuthenticationMethod); + IMPL_CLONE_ATTRIB(AuthenticationInstant); + IMPL_CLONE_TYPED_CHILD(SubjectLocality); + IMPL_CLONE_TYPED_CHILDREN(AuthorityBinding); } - 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); @@ -561,8 +531,8 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); - MARSHALL_DATETIME_ATTRIB(AuthenticationInstant,AUTHENTICATIONINSTANT,NULL); + MARSHALL_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,nullptr); + MARSHALL_DATETIME_ATTRIB(AuthenticationInstant,AUTHENTICATIONINSTANT,nullptr); SubjectStatementImpl::marshallAttributes(domElement); } @@ -573,8 +543,8 @@ namespace opensaml { } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); - PROC_DATETIME_ATTRIB(AuthenticationInstant,AUTHENTICATIONINSTANT,NULL); + PROC_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,nullptr); + PROC_DATETIME_ATTRIB(AuthenticationInstant,AUTHENTICATIONINSTANT,nullptr); SubjectStatementImpl::processAttribute(attribute); } }; @@ -591,11 +561,11 @@ namespace opensaml { } ActionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Namespace(NULL) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Namespace(nullptr) {} - ActionImpl(const ActionImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { - setNamespace(src.getNamespace()); + ActionImpl(const ActionImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), m_Namespace(nullptr) { + IMPL_CLONE_ATTRIB(Namespace); } IMPL_XMLOBJECT_CLONE(Action); @@ -603,11 +573,11 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Namespace,NAMESPACE,NULL); + MARSHALL_STRING_ATTRIB(Namespace,NAMESPACE,nullptr); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Namespace,NAMESPACE,NULL); + PROC_STRING_ATTRIB(Namespace,NAMESPACE,nullptr); } }; @@ -621,26 +591,14 @@ namespace opensaml { virtual ~EvidenceImpl() {} EvidenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, 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++) { - if (*i) { - AssertionIDReference* ref=dynamic_cast(*i); - if (ref) { - getAssertionIDReferences().push_back(ref->cloneAssertionIDReference()); - continue; - } - - Assertion* assertion=dynamic_cast(*i); - if (assertion) { - getAssertions().push_back(assertion->cloneAssertion()); - continue; - } - } - } + IMPL_CLONE_CHILDBAG_BEGIN; + IMPL_CLONE_TYPED_CHILD_IN_BAG(AssertionIDReference); + IMPL_CLONE_TYPED_CHILD_IN_BAG(Assertion); + IMPL_CLONE_CHILDBAG_END; } IMPL_XMLOBJECT_CLONE(Evidence); @@ -658,6 +616,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); @@ -672,43 +639,26 @@ namespace opensaml { AuthorizationDecisionStatementImpl(const AuthorizationDecisionStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); - setResource(src.getResource()); - setDecision(src.getDecision()); - if (src.getEvidence()) - setEvidence(src.getEvidence()->cloneEvidence()); - VectorOf(Action) v=getActions(); - for (vector::const_iterator i=src.m_Actions.begin(); i!=src.m_Actions.end(); i++) { - if (*i) { - v.push_back((*i)->cloneAction()); - } - } } - void init() { - m_Resource=NULL; - m_Decision=NULL; - m_Evidence=NULL; - m_children.push_back(NULL); - m_pos_Evidence=m_pos_Subject; - ++m_pos_Evidence; + void _clone(const AuthorizationDecisionStatementImpl& src) { + SubjectStatementImpl::_clone(src); + IMPL_CLONE_ATTRIB(Resource); + IMPL_CLONE_ATTRIB(Decision); + IMPL_CLONE_TYPED_CHILDREN(Action); + IMPL_CLONE_TYPED_CHILD(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); IMPL_TYPED_CHILDREN(Action, m_pos_Evidence); + IMPL_TYPED_CHILD(Evidence); protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); - MARSHALL_STRING_ATTRIB(Decision,DECISION,NULL); + MARSHALL_STRING_ATTRIB(Resource,RESOURCE,nullptr); + MARSHALL_STRING_ATTRIB(Decision,DECISION,nullptr); SubjectStatementImpl::marshallAttributes(domElement); } @@ -719,8 +669,8 @@ namespace opensaml { } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); - PROC_STRING_ATTRIB(Decision,DECISION,NULL); + PROC_STRING_ATTRIB(Resource,RESOURCE,nullptr); + PROC_STRING_ATTRIB(Decision,DECISION,nullptr); SubjectStatementImpl::processAttribute(attribute); } }; @@ -731,6 +681,10 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_AttributeName=m_AttributeNamespace=nullptr; + } + public: virtual ~AttributeDesignatorImpl() { XMLString::release(&m_AttributeName); @@ -745,12 +699,8 @@ namespace opensaml { 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_CLONE_ATTRIB(AttributeName); + IMPL_CLONE_ATTRIB(AttributeNamespace); } IMPL_XMLOBJECT_CLONE(AttributeDesignator); @@ -759,13 +709,13 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,NULL); - MARSHALL_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,NULL); + MARSHALL_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,nullptr); + MARSHALL_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,nullptr); } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,NULL); - PROC_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,NULL); + PROC_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,nullptr); + PROC_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,nullptr); } }; @@ -775,6 +725,9 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_AttributeName=m_AttributeNamespace=nullptr; + } public: virtual ~AttributeImpl() { XMLString::release(&m_AttributeName); @@ -789,32 +742,20 @@ namespace opensaml { AttributeImpl(const AttributeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); - setAttributeName(src.getAttributeName()); - setAttributeNamespace(src.getAttributeNamespace()); - VectorOf(XMLObject) v=getAttributeValues(); - for (vector::const_iterator i=src.m_AttributeValues.begin(); i!=src.m_AttributeValues.end(); i++) { - if (*i) { - v.push_back((*i)->clone()); - } - } - } - - void init() { - m_AttributeName=m_AttributeNamespace=NULL; + IMPL_CLONE_ATTRIB(AttributeName); + IMPL_CLONE_ATTRIB(AttributeNamespace); + IMPL_CLONE_XMLOBJECT_CHILDREN(AttributeValue); } - 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()); protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,NULL); - MARSHALL_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,NULL); + MARSHALL_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,nullptr); + MARSHALL_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -822,8 +763,8 @@ namespace opensaml { } void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,NULL); - PROC_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,NULL); + PROC_STRING_ATTRIB(AttributeName,ATTRIBUTENAME,nullptr); + PROC_STRING_ATTRIB(AttributeNamespace,ATTRIBUTENAMESPACE,nullptr); } }; @@ -833,12 +774,11 @@ namespace opensaml { virtual ~AttributeValueImpl() {} AttributeValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} 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 @@ -847,26 +787,16 @@ namespace opensaml { virtual ~AttributeStatementImpl() {} AttributeStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } + : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} - AttributeStatementImpl(const AttributeStatementImpl& src) - : AbstractXMLObject(src), SubjectStatementImpl(src) { - VectorOf(Attribute) v=getAttributes(); - for (vector::const_iterator i=src.m_Attributes.begin(); i!=src.m_Attributes.end(); i++) { - if (*i) { - v.push_back((*i)->cloneAttribute()); - } - } - } + AttributeStatementImpl(const AttributeStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) {} - IMPL_XMLOBJECT_CLONE(AttributeStatement); - SubjectStatement* cloneSubjectStatement() const { - return cloneAttributeStatement(); - } - Statement* cloneStatement() const { - return cloneAttributeStatement(); + void _clone(const AttributeStatementImpl& src) { + SubjectStatementImpl::_clone(src); + IMPL_CLONE_TYPED_CHILDREN(Attribute); } + + IMPL_XMLOBJECT_CLONE_EX(AttributeStatement); IMPL_TYPED_CHILDREN(Attribute, m_children.end()); protected: @@ -886,28 +816,15 @@ namespace opensaml { virtual ~AdviceImpl() {} AdviceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, 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++) { - if (*i) { - AssertionIDReference* ref=dynamic_cast(*i); - if (ref) { - 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_CLONE_CHILDBAG_BEGIN; + IMPL_CLONE_TYPED_CHILD_IN_BAG(AssertionIDReference); + IMPL_CLONE_TYPED_CHILD_IN_BAG(Assertion); + IMPL_CLONE_XMLOBJECT_CHILD_IN_BAG(UnknownXMLObject); + IMPL_CLONE_CHILDBAG_END; } IMPL_XMLOBJECT_CLONE(Advice); @@ -938,22 +855,23 @@ namespace opensaml { public AbstractXMLObjectUnmarshaller { void init() { - m_MinorVersion=NULL; - m_AssertionID=NULL; - m_Issuer=NULL; - m_IssueInstant=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_Conditions=NULL; - m_Advice=NULL; - m_Signature=NULL; + m_MinorVersion=nullptr; + m_AssertionID=nullptr; + m_Issuer=nullptr; + m_IssueInstant=nullptr; + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_Conditions=nullptr; + m_Advice=nullptr; + m_Signature=nullptr; m_pos_Conditions=m_children.begin(); m_pos_Advice=m_pos_Conditions; ++m_pos_Advice; m_pos_Signature=m_pos_Advice; ++m_pos_Signature; } + public: virtual ~AssertionImpl() { XMLString::release(&m_MinorVersion); @@ -970,62 +888,33 @@ namespace opensaml { AssertionImpl(const AssertionImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); - setMinorVersion(src.m_MinorVersion); - setAssertionID(src.getAssertionID()); - setIssuer(src.getIssuer()); - setIssueInstant(src.getIssueInstant()); - if (src.getConditions()) - setConditions(src.getConditions()->cloneConditions()); - if (src.getAdvice()) - setAdvice(src.getAdvice()->cloneAdvice()); - if (src.getSignature()) - setSignature(src.getSignature()->cloneSignature()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - AuthenticationStatement* authst=dynamic_cast(*i); - if (authst) { - getAuthenticationStatements().push_back(authst->cloneAuthenticationStatement()); - continue; - } - - AttributeStatement* attst=dynamic_cast(*i); - if (attst) { - getAttributeStatements().push_back(attst->cloneAttributeStatement()); - continue; - } - - AuthorizationDecisionStatement* authzst=dynamic_cast(*i); - if (authzst) { - 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()); - continue; - } - } - } + IMPL_CLONE_INTEGER_ATTRIB(MinorVersion); + IMPL_CLONE_ATTRIB(AssertionID); + IMPL_CLONE_ATTRIB(Issuer); + IMPL_CLONE_ATTRIB(IssueInstant); + IMPL_CLONE_TYPED_CHILD(Conditions); + IMPL_CLONE_TYPED_CHILD(Advice); + IMPL_CLONE_TYPED_CHILD(Signature); + IMPL_CLONE_CHILDBAG_BEGIN; + IMPL_CLONE_TYPED_CHILD_IN_BAG(AuthenticationStatement); + IMPL_CLONE_TYPED_CHILD_IN_BAG(AttributeStatement); + IMPL_CLONE_TYPED_CHILD_IN_BAG(AuthorizationDecisionStatement); + IMPL_CLONE_TYPED_CHILD_IN_BAG(SubjectStatement); + IMPL_CLONE_TYPED_CHILD_IN_BAG(Statement); + IMPL_CLONE_CHILDBAG_END; } //IMPL_TYPED_CHILD(Signature); // Need customized setter. protected: - Signature* m_Signature; + xmlsignature::Signature* m_Signature; list::iterator m_pos_Signature; public: - Signature* getSignature() const { + xmlsignature::Signature* getSignature() const { return m_Signature; } - void setSignature(Signature* sig) { + void setSignature(xmlsignature::Signature* sig) { prepareForAssignment(m_Signature,sig); *m_pos_Signature=m_Signature=sig; // Sync content reference back up. @@ -1038,11 +927,16 @@ namespace opensaml { IMPL_STRING_ATTRIB(AssertionID); // have to special-case getXMLID const XMLCh* getXMLID() const { pair v = getMinorVersion(); - return (!v.first || v.second > 0) ? m_AssertionID : NULL; + return (!v.first || v.second > 0) ? m_AssertionID : nullptr; } const XMLCh* getID() const { return getAssertionID(); } + void releaseDOM() const { + if (getDOM()) + getDOM()->removeAttributeNS(nullptr, ASSERTIONID_ATTRIB_NAME); + AbstractDOMCachingXMLObject::releaseDOM(); + } IMPL_STRING_ATTRIB(Issuer); IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_TYPED_CHILD(Conditions); @@ -1054,34 +948,39 @@ namespace opensaml { IMPL_TYPED_CHILDREN(AuthorizationDecisionStatement, m_pos_Signature); protected: + void prepareForMarshalling() const { + if (m_Signature) + declareNonVisibleNamespaces(); + } + void marshallAttributes(DOMElement* domElement) const { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); - domElement->setAttributeNS(NULL,MAJORVERSION,XML_ONE); + domElement->setAttributeNS(nullptr,MAJORVERSION,XML_ONE); if (!m_MinorVersion) const_cast(this)->m_MinorVersion=XMLString::replicate(XML_ONE); - MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); + MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,nullptr); if (!m_AssertionID) const_cast(this)->m_AssertionID=SAMLConfig::getConfig().generateIdentifier(); - domElement->setAttributeNS(NULL, ASSERTIONID_ATTRIB_NAME, m_AssertionID); + domElement->setAttributeNS(nullptr, ASSERTIONID_ATTRIB_NAME, m_AssertionID); if (*m_MinorVersion!=chDigit_0) { -#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE - domElement->setIdAttributeNS(NULL, ASSERTIONID_ATTRIB_NAME, true); -#else - domElement->setIdAttributeNS(NULL, ASSERTIONID_ATTRIB_NAME); +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + domElement->setIdAttributeNS(nullptr, ASSERTIONID_ATTRIB_NAME, true); +#else + domElement->setIdAttributeNS(nullptr, ASSERTIONID_ATTRIB_NAME); #endif } - MARSHALL_STRING_ATTRIB(Issuer,ISSUER,NULL); + MARSHALL_STRING_ATTRIB(Issuer,ISSUER,nullptr); if (!m_IssueInstant) { - const_cast(this)->m_IssueInstantEpoch=time(NULL); + const_cast(this)->m_IssueInstantEpoch=time(nullptr); const_cast(this)->m_IssueInstant=new DateTime(m_IssueInstantEpoch); } - MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); + MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Conditions,SAML1_NS,false); PROC_TYPED_CHILD(Advice,SAML1_NS,false); - PROC_TYPED_CHILD(Signature,XMLSIG_NS,false); + PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLSIG_NS,false); PROC_TYPED_CHILDREN(AuthenticationStatement,SAML1_NS,false); PROC_TYPED_CHILDREN(AttributeStatement,SAML1_NS,false); PROC_TYPED_CHILDREN(AuthorizationDecisionStatement,SAML1_NS,false); @@ -1094,24 +993,24 @@ namespace opensaml { // Standard processing, but then we check IDness. AbstractXMLObjectUnmarshaller::unmarshallAttributes(domElement); if (m_AssertionID && (!m_MinorVersion || *m_MinorVersion!=chDigit_0)) { -#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE - const_cast(domElement)->setIdAttributeNS(NULL, ASSERTIONID_ATTRIB_NAME, true); -#else - const_cast(domElement)->setIdAttributeNS(NULL, ASSERTIONID_ATTRIB_NAME); +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + const_cast(domElement)->setIdAttributeNS(nullptr, ASSERTIONID_ATTRIB_NAME, true); +#else + const_cast(domElement)->setIdAttributeNS(nullptr, ASSERTIONID_ATTRIB_NAME); #endif } } void processAttribute(const DOMAttr* attribute) { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); - if (XMLHelper::isNodeNamed(attribute,NULL,MAJORVERSION)) { + if (XMLHelper::isNodeNamed(attribute,nullptr,MAJORVERSION)) { if (!XMLString::equals(attribute->getValue(),XML_ONE)) throw UnmarshallingException("Assertion has invalid major version."); } - PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); - PROC_STRING_ATTRIB(AssertionID,ASSERTIONID,NULL); - PROC_STRING_ATTRIB(Issuer,ISSUER,NULL); - PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); + PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,nullptr); + PROC_STRING_ATTRIB(AssertionID,ASSERTIONID,nullptr); + PROC_STRING_ATTRIB(Issuer,ISSUER,nullptr); + PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,nullptr); } };