X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml1%2Fcore%2Fimpl%2FAssertionsImpl.cpp;h=25da19534f1bed7efacaca76e92a1c9768f9ea18;hb=932cfaae2176c2eba1a9938dc420591a9551a7f3;hp=0efb14b913e96e1a74605c95c26102fafd14e5f2;hpb=335291aa66a9f8eae1a4604aa3502ccc948841e9;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml1/core/impl/AssertionsImpl.cpp b/saml/saml1/core/impl/AssertionsImpl.cpp index 0efb14b..25da195 100644 --- a/saml/saml1/core/impl/AssertionsImpl.cpp +++ b/saml/saml1/core/impl/AssertionsImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2007 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,7 @@ #include "exceptions.h" #include "saml1/core/Assertions.h" -#include #include -#include #include #include #include @@ -42,6 +40,9 @@ using namespace opensaml; using namespace xmlsignature; using namespace xmltooling; using namespace std; +using xmlconstants::XMLSIG_NS; +using xmlconstants::XML_ONE; +using samlconstants::SAML1_NS; #if defined (_MSC_VER) #pragma warning( push ) @@ -69,7 +70,7 @@ namespace opensaml { } AudienceRestrictionConditionImpl(const AudienceRestrictionConditionImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(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) { @@ -86,13 +87,13 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(Audience,SAMLConstants::SAML1_NS,false); + PROC_TYPED_CHILDREN(Audience,SAML1_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; class SAML_DLLLOCAL DoNotCacheConditionImpl : public virtual DoNotCacheCondition, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -104,7 +105,8 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - DoNotCacheConditionImpl(const DoNotCacheConditionImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + DoNotCacheConditionImpl(const DoNotCacheConditionImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { } IMPL_XMLOBJECT_CLONE(DoNotCacheCondition); @@ -130,7 +132,8 @@ namespace opensaml { init(); } - ConditionsImpl(const ConditionsImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + ConditionsImpl(const ConditionsImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setNotBefore(src.getNotBefore()); setNotOnOrAfter(src.getNotOnOrAfter()); @@ -176,9 +179,9 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(AudienceRestrictionCondition,SAMLConstants::SAML1_NS,true); - PROC_TYPED_CHILDREN(DoNotCacheCondition,SAMLConstants::SAML1_NS,true); - PROC_TYPED_CHILDREN(Condition,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILDREN(AudienceRestrictionCondition,SAML1_NS,true); + PROC_TYPED_CHILDREN(DoNotCacheCondition,SAML1_NS,true); + PROC_TYPED_CHILDREN(Condition,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } @@ -190,7 +193,6 @@ namespace opensaml { class SAML_DLLLOCAL NameIdentifierImpl : public virtual NameIdentifier, public AbstractSimpleElement, - public AbstractChildlessElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -220,7 +222,6 @@ namespace opensaml { IMPL_XMLOBJECT_CLONE(NameIdentifier); IMPL_STRING_ATTRIB(Format); IMPL_STRING_ATTRIB(NameQualifier); - IMPL_XMLOBJECT_CONTENT; protected: void marshallAttributes(DOMElement* domElement) const { @@ -243,8 +244,7 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) - : AnyElementImpl(src) { + SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : AnyElementImpl(src) { } IMPL_XMLOBJECT_CLONE(SubjectConfirmationData); @@ -264,7 +264,8 @@ namespace opensaml { init(); } - SubjectConfirmationImpl(const SubjectConfirmationImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + SubjectConfirmationImpl(const SubjectConfirmationImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubjectConfirmationData()) setSubjectConfirmationData(src.getSubjectConfirmationData()->clone()); @@ -295,8 +296,8 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(ConfirmationMethod,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILD(KeyInfo,XMLConstants::XMLSIG_NS,false); + PROC_TYPED_CHILDREN(ConfirmationMethod,SAML1_NS,false); + PROC_TYPED_CHILD(KeyInfo,XMLSIG_NS,false); // Anything else we'll assume is the data. if (getSubjectConfirmationData()) @@ -319,7 +320,8 @@ namespace opensaml { init(); } - SubjectImpl(const SubjectImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + SubjectImpl(const SubjectImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getNameIdentifier()) setNameIdentifier(src.getNameIdentifier()->cloneNameIdentifier()); @@ -343,8 +345,8 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(NameIdentifier,SAMLConstants::SAML1_NS,true); - PROC_TYPED_CHILD(SubjectConfirmation,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILD(NameIdentifier,SAML1_NS,true); + PROC_TYPED_CHILD(SubjectConfirmation,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; @@ -372,7 +374,8 @@ namespace opensaml { init(); } - SubjectStatementImpl(const SubjectStatementImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + SubjectStatementImpl(const SubjectStatementImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); @@ -382,13 +385,13 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Subject,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILD(Subject,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; class SAML_DLLLOCAL SubjectLocalityImpl : public virtual SubjectLocality, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -404,7 +407,8 @@ namespace opensaml { init(); } - SubjectLocalityImpl(const SubjectLocalityImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + SubjectLocalityImpl(const SubjectLocalityImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setIPAddress(src.getIPAddress()); setDNSAddress(src.getDNSAddress()); @@ -431,7 +435,7 @@ namespace opensaml { }; class SAML_DLLLOCAL AuthorityBindingImpl : public virtual AuthorityBinding, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -448,7 +452,8 @@ namespace opensaml { init(); } - AuthorityBindingImpl(const AuthorityBindingImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + AuthorityBindingImpl(const AuthorityBindingImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setAuthorityKind(src.getAuthorityKind()); setLocation(src.getLocation()); @@ -535,8 +540,8 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(SubjectLocality,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(AuthorityBinding,SAMLConstants::SAML1_NS,false); + PROC_TYPED_CHILD(SubjectLocality,SAML1_NS,false); + PROC_TYPED_CHILDREN(AuthorityBinding,SAML1_NS,false); SubjectStatementImpl::processChildElement(childXMLObject,root); } @@ -549,7 +554,6 @@ namespace opensaml { class SAML_DLLLOCAL ActionImpl : public virtual Action, public AbstractSimpleElement, - public AbstractChildlessElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -569,7 +573,6 @@ namespace opensaml { IMPL_XMLOBJECT_CLONE(Action); IMPL_STRING_ATTRIB(Namespace); - IMPL_XMLOBJECT_CONTENT; protected: void marshallAttributes(DOMElement* domElement) const { @@ -594,8 +597,8 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - EvidenceImpl(const EvidenceImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { - + 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); @@ -619,8 +622,8 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(AssertionIDReference,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(Assertion,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILDREN(AssertionIDReference,SAML1_NS,false); + PROC_TYPED_CHILDREN(Assertion,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; @@ -683,8 +686,8 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Evidence,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(Action,SAMLConstants::SAML1_NS,false); + PROC_TYPED_CHILD(Evidence,SAML1_NS,false); + PROC_TYPED_CHILDREN(Action,SAML1_NS,false); SubjectStatementImpl::processChildElement(childXMLObject,root); } @@ -696,7 +699,7 @@ namespace opensaml { }; class SAML_DLLLOCAL AttributeDesignatorImpl : public virtual AttributeDesignator, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -712,7 +715,8 @@ namespace opensaml { init(); } - AttributeDesignatorImpl(const AttributeDesignatorImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + AttributeDesignatorImpl(const AttributeDesignatorImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setAttributeName(src.getAttributeName()); setAttributeNamespace(src.getAttributeNamespace()); @@ -755,7 +759,8 @@ namespace opensaml { init(); } - AttributeImpl(const AttributeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + AttributeImpl(const AttributeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setAttributeName(src.getAttributeName()); setAttributeNamespace(src.getAttributeNamespace()); @@ -839,7 +844,7 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(Attribute,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILDREN(Attribute,SAML1_NS,true); SubjectStatementImpl::processChildElement(childXMLObject,root); } }; @@ -857,8 +862,8 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - AdviceImpl(const AdviceImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { - + 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); @@ -873,7 +878,7 @@ namespace opensaml { continue; } - getOthers().push_back((*i)->clone()); + getUnknownXMLObjects().push_back((*i)->clone()); } } } @@ -881,17 +886,17 @@ namespace opensaml { IMPL_XMLOBJECT_CLONE(Advice); IMPL_TYPED_CHILDREN(AssertionIDReference,m_children.end()); IMPL_TYPED_CHILDREN(Assertion,m_children.end()); - IMPL_XMLOBJECT_CHILDREN(Other,m_children.end()); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(AssertionIDReference,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(Assertion,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILDREN(AssertionIDReference,SAML1_NS,false); + PROC_TYPED_CHILDREN(Assertion,SAML1_NS,true); // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); - if (!XMLString::equals(nsURI,SAMLConstants::SAML1_NS) && nsURI && *nsURI) { - getOthers().push_back(childXMLObject); + if (!XMLString::equals(nsURI,SAML1_NS) && nsURI && *nsURI) { + getUnknownXMLObjects().push_back(childXMLObject); return; } @@ -935,7 +940,8 @@ namespace opensaml { init(); } - AssertionImpl(const AssertionImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + AssertionImpl(const AssertionImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setMinorVersion(src.m_MinorVersion); setAssertionID(src.getAssertionID()); @@ -1002,7 +1008,14 @@ namespace opensaml { IMPL_XMLOBJECT_CLONE(Assertion); IMPL_INTEGER_ATTRIB(MinorVersion); - IMPL_ID_ATTRIB(AssertionID); + 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; + } + const XMLCh* getID() const { + return getAssertionID(); + } IMPL_STRING_ATTRIB(Issuer); IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_TYPED_CHILD(Conditions); @@ -1016,9 +1029,9 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); - domElement->setAttributeNS(NULL,MAJORVERSION,XMLConstants::XML_ONE); + domElement->setAttributeNS(NULL,MAJORVERSION,XML_ONE); if (!m_MinorVersion) - const_cast(this)->m_MinorVersion=XMLString::replicate(XMLConstants::XML_ONE); + const_cast(this)->m_MinorVersion=XMLString::replicate(XML_ONE); MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); if (!m_AssertionID) const_cast(this)->m_AssertionID=SAMLConfig::getConfig().generateIdentifier(); @@ -1032,21 +1045,21 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Conditions,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILD(Advice,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILD(Signature,XMLConstants::XMLSIG_NS,false); - PROC_TYPED_CHILDREN(AuthenticationStatement,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(AttributeStatement,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(AuthorizationDecisionStatement,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(SubjectStatement,SAMLConstants::SAML1_NS,true); - PROC_TYPED_CHILDREN(Statement,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILD(Conditions,SAML1_NS,false); + PROC_TYPED_CHILD(Advice,SAML1_NS,false); + PROC_TYPED_CHILD(Signature,XMLSIG_NS,false); + PROC_TYPED_CHILDREN(AuthenticationStatement,SAML1_NS,false); + PROC_TYPED_CHILDREN(AttributeStatement,SAML1_NS,false); + PROC_TYPED_CHILDREN(AuthorizationDecisionStatement,SAML1_NS,false); + PROC_TYPED_CHILDREN(SubjectStatement,SAML1_NS,true); + PROC_TYPED_CHILDREN(Statement,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } 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 (!XMLString::equals(attribute->getValue(),XMLConstants::XML_ONE)) + if (!XMLString::equals(attribute->getValue(),XML_ONE)) throw UnmarshallingException("Assertion has invalid major version."); } PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);