X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml1%2Fcore%2Fimpl%2FAssertionsImpl.cpp;h=a8127abde063c988e5387f1ff105d4b82fa1ca81;hb=1bc8e721db3a50294df852662e1eddcdbdae8f9f;hp=37f76568d35a9b4e66415db3019a90ac92ad2650;hpb=03d69512df0270f36bf031c68c7271d202c57cd6;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml1/core/impl/AssertionsImpl.cpp b/saml/saml1/core/impl/AssertionsImpl.cpp index 37f7656..a8127ab 100644 --- a/saml/saml1/core/impl/AssertionsImpl.cpp +++ b/saml/saml1/core/impl/AssertionsImpl.cpp @@ -24,7 +24,6 @@ #include "exceptions.h" #include "saml1/core/Assertions.h" -#include #include #include #include @@ -32,9 +31,9 @@ #include #include #include -#include #include +#include #include using namespace opensaml::saml1; @@ -42,6 +41,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 ) @@ -55,10 +57,9 @@ namespace opensaml { DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,Audience); DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,ConfirmationMethod); - class XMLTOOL_DLLLOCAL AudienceRestrictionConditionImpl : public virtual AudienceRestrictionCondition, + class SAML_DLLLOCAL AudienceRestrictionConditionImpl : public virtual AudienceRestrictionCondition, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -70,7 +71,7 @@ namespace opensaml { } AudienceRestrictionConditionImpl(const AudienceRestrictionConditionImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(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) { @@ -87,15 +88,14 @@ 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 XMLTOOL_DLLLOCAL DoNotCacheConditionImpl : public virtual DoNotCacheCondition, - public AbstractChildlessElement, + class SAML_DLLLOCAL DoNotCacheConditionImpl : public virtual DoNotCacheCondition, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -107,7 +107,7 @@ namespace opensaml { } DoNotCacheConditionImpl(const DoNotCacheConditionImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { } IMPL_XMLOBJECT_CLONE(DoNotCacheCondition); @@ -119,7 +119,6 @@ namespace opensaml { class SAML_DLLLOCAL ConditionsImpl : public virtual Conditions, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -135,7 +134,7 @@ namespace opensaml { } ConditionsImpl(const ConditionsImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setNotBefore(src.getNotBefore()); setNotOnOrAfter(src.getNotOnOrAfter()); @@ -168,8 +167,8 @@ namespace opensaml { } IMPL_XMLOBJECT_CLONE(Conditions); - IMPL_DATETIME_ATTRIB(NotBefore); - IMPL_DATETIME_ATTRIB(NotOnOrAfter); + IMPL_DATETIME_ATTRIB(NotBefore,0); + IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); IMPL_TYPED_CHILDREN(AudienceRestrictionCondition, m_children.end()); IMPL_TYPED_CHILDREN(DoNotCacheCondition,m_children.end()); IMPL_TYPED_CHILDREN(Condition,m_children.end()); @@ -181,9 +180,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); } @@ -195,9 +194,7 @@ namespace opensaml { class SAML_DLLLOCAL NameIdentifierImpl : public virtual NameIdentifier, public AbstractSimpleElement, - public AbstractChildlessElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -213,8 +210,7 @@ namespace opensaml { } NameIdentifierImpl(const NameIdentifierImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), - AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setFormat(src.getFormat()); setNameQualifier(src.getNameQualifier()); @@ -227,7 +223,6 @@ namespace opensaml { IMPL_XMLOBJECT_CLONE(NameIdentifier); IMPL_STRING_ATTRIB(Format); IMPL_STRING_ATTRIB(NameQualifier); - IMPL_XMLOBJECT_CONTENT; protected: void marshallAttributes(DOMElement* domElement) const { @@ -241,8 +236,7 @@ namespace opensaml { } }; - class SAML_DLLLOCAL SubjectConfirmationDataImpl - : public virtual SubjectConfirmationData, public AnyElementImpl, public AbstractValidatingXMLObject + class SAML_DLLLOCAL SubjectConfirmationDataImpl : public virtual SubjectConfirmationData, public AnyElementImpl { public: virtual ~SubjectConfirmationDataImpl() {} @@ -251,8 +245,7 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) - : AnyElementImpl(src), AbstractValidatingXMLObject(src) { + SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : AnyElementImpl(src) { } IMPL_XMLOBJECT_CLONE(SubjectConfirmationData); @@ -261,7 +254,6 @@ namespace opensaml { class SAML_DLLLOCAL SubjectConfirmationImpl : public virtual SubjectConfirmation, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -274,9 +266,7 @@ namespace opensaml { } SubjectConfirmationImpl(const SubjectConfirmationImpl& src) - : AbstractXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubjectConfirmationData()) setSubjectConfirmationData(src.getSubjectConfirmationData()->clone()); @@ -307,8 +297,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()) @@ -320,7 +310,6 @@ namespace opensaml { class SAML_DLLLOCAL SubjectImpl : public virtual Subject, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -333,9 +322,7 @@ namespace opensaml { } SubjectImpl(const SubjectImpl& src) - : AbstractXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getNameIdentifier()) setNameIdentifier(src.getNameIdentifier()->cloneNameIdentifier()); @@ -359,8 +346,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); } }; @@ -368,12 +355,18 @@ namespace opensaml { class SAML_DLLLOCAL SubjectStatementImpl : public virtual SubjectStatement, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { + void init() { + m_Subject=NULL; + m_children.push_back(NULL); + m_pos_Subject=m_children.begin(); + } protected: - SubjectStatementImpl() {} + SubjectStatementImpl() { + init(); + } public: virtual ~SubjectStatementImpl() {} @@ -383,33 +376,24 @@ namespace opensaml { } SubjectStatementImpl(const SubjectStatementImpl& src) - : AbstractXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); } - void init() { - m_Subject=NULL; - m_children.push_back(NULL); - m_pos_Subject=m_children.begin(); - } - IMPL_TYPED_CHILD(Subject); 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 AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -425,7 +409,7 @@ namespace opensaml { } SubjectLocalityImpl(const SubjectLocalityImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setIPAddress(src.getIPAddress()); setDNSAddress(src.getDNSAddress()); @@ -452,9 +436,8 @@ namespace opensaml { }; class SAML_DLLLOCAL AuthorityBindingImpl : public virtual AuthorityBinding, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -471,7 +454,7 @@ namespace opensaml { } AuthorityBindingImpl(const AuthorityBindingImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setAuthorityKind(src.getAuthorityKind()); setLocation(src.getLocation()); @@ -515,7 +498,7 @@ namespace opensaml { init(); } - AuthenticationStatementImpl(const AuthenticationStatementImpl& src) : SubjectStatementImpl(src) { + AuthenticationStatementImpl(const AuthenticationStatementImpl& src) : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); setAuthenticationMethod(src.getAuthenticationMethod()); setAuthenticationInstant(src.getAuthenticationInstant()); @@ -530,13 +513,12 @@ namespace opensaml { } void init() { - SubjectStatementImpl::init(); m_AuthenticationMethod=NULL; m_AuthenticationInstant=NULL; m_SubjectLocality=NULL; m_children.push_back(NULL); m_pos_SubjectLocality=m_pos_Subject; - m_pos_SubjectLocality++; + ++m_pos_SubjectLocality; } IMPL_XMLOBJECT_CLONE(AuthenticationStatement); @@ -547,7 +529,7 @@ namespace opensaml { return cloneAuthenticationStatement(); } IMPL_STRING_ATTRIB(AuthenticationMethod); - IMPL_DATETIME_ATTRIB(AuthenticationInstant); + IMPL_DATETIME_ATTRIB(AuthenticationInstant,0); IMPL_TYPED_CHILD(SubjectLocality); IMPL_TYPED_CHILDREN(AuthorityBinding, m_children.end()); @@ -559,8 +541,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); } @@ -573,9 +555,7 @@ namespace opensaml { class SAML_DLLLOCAL ActionImpl : public virtual Action, public AbstractSimpleElement, - public AbstractChildlessElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -588,15 +568,12 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Namespace(NULL) { } - ActionImpl(const ActionImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), - AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + ActionImpl(const ActionImpl& src) : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { setNamespace(src.getNamespace()); } IMPL_XMLOBJECT_CLONE(Action); IMPL_STRING_ATTRIB(Namespace); - IMPL_XMLOBJECT_CONTENT; protected: void marshallAttributes(DOMElement* domElement) const { @@ -611,7 +588,6 @@ namespace opensaml { class SAML_DLLLOCAL EvidenceImpl : public virtual Evidence, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -623,10 +599,7 @@ namespace opensaml { } EvidenceImpl(const EvidenceImpl& src) - : AbstractXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(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); @@ -650,8 +623,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); } }; @@ -670,7 +643,8 @@ namespace opensaml { init(); } - AuthorizationDecisionStatementImpl(const AuthorizationDecisionStatementImpl& src) : SubjectStatementImpl(src) { + AuthorizationDecisionStatementImpl(const AuthorizationDecisionStatementImpl& src) + : AbstractXMLObject(src), SubjectStatementImpl(src) { init(); setResource(src.getResource()); setDecision(src.getDecision()); @@ -685,13 +659,12 @@ namespace opensaml { } void init() { - SubjectStatementImpl::init(); m_Resource=NULL; m_Decision=NULL; m_Evidence=NULL; m_children.push_back(NULL); m_pos_Evidence=m_pos_Subject; - m_pos_Evidence++; + ++m_pos_Evidence; } IMPL_XMLOBJECT_CLONE(AuthorizationDecisionStatement); @@ -714,8 +687,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); } @@ -727,9 +700,8 @@ namespace opensaml { }; class SAML_DLLLOCAL AttributeDesignatorImpl : public virtual AttributeDesignator, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -745,7 +717,7 @@ namespace opensaml { } AttributeDesignatorImpl(const AttributeDesignatorImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { init(); setAttributeName(src.getAttributeName()); setAttributeNamespace(src.getAttributeNamespace()); @@ -774,7 +746,6 @@ namespace opensaml { class SAML_DLLLOCAL AttributeImpl : public virtual Attribute, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -790,7 +761,7 @@ namespace opensaml { } AttributeImpl(const AttributeImpl& src) - : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setAttributeName(src.getAttributeName()); setAttributeNamespace(src.getAttributeNamespace()); @@ -830,8 +801,7 @@ namespace opensaml { } }; - class SAML_DLLLOCAL AttributeValueImpl - : public virtual AttributeValue, public AnyElementImpl, public AbstractValidatingXMLObject + class SAML_DLLLOCAL AttributeValueImpl : public virtual AttributeValue, public AnyElementImpl { public: virtual ~AttributeValueImpl() {} @@ -840,7 +810,7 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - AttributeValueImpl(const AttributeValueImpl& src) : AnyElementImpl(src), AbstractValidatingXMLObject(src) {} + AttributeValueImpl(const AttributeValueImpl& src) : AnyElementImpl(src) {} IMPL_XMLOBJECT_CLONE(AttributeValue); }; @@ -852,10 +822,10 @@ namespace opensaml { AttributeStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - init(); } - AttributeStatementImpl(const AttributeStatementImpl& src) : SubjectStatementImpl(src) { + 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) { @@ -875,7 +845,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); } }; @@ -883,7 +853,6 @@ namespace opensaml { class SAML_DLLLOCAL AdviceImpl : public virtual Advice, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { @@ -895,10 +864,7 @@ namespace opensaml { } AdviceImpl(const AdviceImpl& src) - : AbstractXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(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); @@ -925,13 +891,15 @@ 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); // Unknown child. const XMLCh* nsURI=root->getNamespaceURI(); - if (!XMLString::equals(nsURI,SAMLConstants::SAML1_NS) && nsURI && *nsURI) + if (!XMLString::equals(nsURI,SAML1_NS) && nsURI && *nsURI) { getOthers().push_back(childXMLObject); + return; + } AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } @@ -940,12 +908,29 @@ namespace opensaml { class SAML_DLLLOCAL AssertionImpl : public virtual Assertion, public AbstractComplexElement, public AbstractDOMCachingXMLObject, - public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, 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_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); XMLString::release(&m_AssertionID); XMLString::release(&m_Issuer); delete m_IssueInstant; @@ -956,12 +941,10 @@ namespace opensaml { init(); } - AssertionImpl(const AssertionImpl& src) - : AbstractXMLObject(src), - AbstractDOMCachingXMLObject(src), - AbstractValidatingXMLObject(src) { + AssertionImpl(const AssertionImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); - setMinorVersion(src.getMinorVersion()); + setMinorVersion(src.m_MinorVersion); setAssertionID(src.getAssertionID()); setIssuer(src.getIssuer()); setIssueInstant(src.getIssueInstant()); @@ -1006,32 +989,38 @@ namespace opensaml { } } - void init() { - m_MinorVersion=1; - 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_pos_Conditions=m_children.begin(); - m_pos_Advice=m_pos_Conditions; - m_pos_Advice++; - m_pos_Signature=m_pos_Advice; - m_pos_Signature++; + //IMPL_TYPED_CHILD(Signature); + // Need customized setter. + protected: + Signature* m_Signature; + list::iterator m_pos_Signature; + public: + Signature* getSignature() const { + return m_Signature; + } + + void setSignature(Signature* sig) { + prepareForAssignment(m_Signature,sig); + *m_pos_Signature=m_Signature=sig; + // Sync content reference back up. + if (m_Signature) + m_Signature->setContentReference(new opensaml::ContentReference(*this)); } IMPL_XMLOBJECT_CLONE(Assertion); IMPL_INTEGER_ATTRIB(MinorVersion); - IMPL_STRING_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); + IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_TYPED_CHILD(Conditions); IMPL_TYPED_CHILD(Advice); - IMPL_TYPED_CHILD(Signature); IMPL_TYPED_CHILDREN(Statement, m_pos_Signature); IMPL_TYPED_CHILDREN(SubjectStatement, m_pos_Signature); IMPL_TYPED_CHILDREN(AuthenticationStatement, m_pos_Signature); @@ -1041,34 +1030,37 @@ 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); - static const XMLCh ONE[] = { chDigit_1, chNull }; - domElement->setAttributeNS(NULL,MAJORVERSION,ONE); + domElement->setAttributeNS(NULL,MAJORVERSION,XML_ONE); + if (!m_MinorVersion) + 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(); MARSHALL_ID_ATTRIB(AssertionID,ASSERTIONID,NULL); MARSHALL_STRING_ATTRIB(Issuer,ISSUER,NULL); - if (!m_IssueInstant) - const_cast(this)->m_IssueInstant=new DateTime(time(NULL)); + if (!m_IssueInstant) { + const_cast(this)->m_IssueInstantEpoch=time(NULL); + const_cast(this)->m_IssueInstant=new DateTime(m_IssueInstantEpoch); + } MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); } 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::parseInt(attribute->getValue()) != 1) + if (!XMLString::equals(attribute->getValue(),XML_ONE)) throw UnmarshallingException("Assertion has invalid major version."); } PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); @@ -1175,6 +1167,115 @@ const XMLCh SubjectLocality::LOCAL_NAME[] = UNICODE_LITERAL_15(S,u,b,j,e const XMLCh SubjectLocality::TYPE_NAME[] = UNICODE_LITERAL_19(S,u,b,j,e,c,t,L,o,c,a,l,i,t,y,T,y,p,e); const XMLCh SubjectLocality::IPADDRESS_ATTRIB_NAME[] = UNICODE_LITERAL_9(I,P,A,d,d,r,e,s,s); const XMLCh SubjectLocality::DNSADDRESS_ATTRIB_NAME[] = UNICODE_LITERAL_10(D,N,S,A,d,d,r,e,s,s); +const XMLCh SubjectStatement::LOCAL_NAME[] = UNICODE_LITERAL_16(S,u,b,j,e,c,t,S,t,a,t,e,m,e,n,t); + +const XMLCh NameIdentifier::UNSPECIFIED[] = // urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_1, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_i, chLatin_d, chDash, + chLatin_f, chLatin_o, chLatin_r, chLatin_m, chLatin_a, chLatin_t, chColon, + chLatin_u, chLatin_n, chLatin_s, chLatin_p, chLatin_e, chLatin_c, chLatin_i, chLatin_f, chLatin_i, chLatin_e, chLatin_d, chLatin_d, chNull +}; + +const XMLCh NameIdentifier::EMAIL[] = // urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_1, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_i, chLatin_d, chDash, + chLatin_f, chLatin_o, chLatin_r, chLatin_m, chLatin_a, chLatin_t, chColon, + chLatin_e, chLatin_m, chLatin_a, chLatin_i, chLatin_l, chLatin_A, chLatin_d, chLatin_d, chLatin_r, chLatin_e, chLatin_s, chLatin_s, chNull +}; + +const XMLCh NameIdentifier::X509_SUBJECT[] = // urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_1, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_i, chLatin_d, chDash, + chLatin_f, chLatin_o, chLatin_r, chLatin_m, chLatin_a, chLatin_t, chColon, + chLatin_X, chDigit_5, chDigit_0, chDigit_9, chLatin_S, chLatin_u, chLatin_b, chLatin_j, chLatin_e, chLatin_c, chLatin_t, + chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull +}; + +const XMLCh NameIdentifier::WIN_DOMAIN_QUALIFIED[] = // urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_1, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_i, chLatin_d, chDash, + chLatin_f, chLatin_o, chLatin_r, chLatin_m, chLatin_a, chLatin_t, chColon, + chLatin_W, chLatin_i, chLatin_n, chLatin_d, chLatin_o, chLatin_w, chLatin_s, + chLatin_D, chLatin_o, chLatin_m, chLatin_a, chLatin_i, chLatin_n, + chLatin_Q, chLatin_u, chLatin_a, chLatin_l, chLatin_i, chLatin_f, chLatin_i, chLatin_e, chLatin_d, + chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull +}; + +const XMLCh SubjectConfirmation::ARTIFACT01[] = // urn:oasis:names:tc:SAML:1.0:cm:artifact-01 +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_c, chLatin_m, chColon, chLatin_a, chLatin_r, chLatin_t, chLatin_i, chLatin_f, chLatin_a, chLatin_c, chLatin_t, + chDash, chDigit_0, chDigit_1, chNull +}; + +const XMLCh SubjectConfirmation::ARTIFACT[] = // urn:oasis:names:tc:SAML:1.0:cm:artifact +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_c, chLatin_m, chColon, chLatin_a, chLatin_r, chLatin_t, chLatin_i, chLatin_f, chLatin_a, chLatin_c, chLatin_t, chNull +}; + +const XMLCh SubjectConfirmation::BEARER[] = // urn:oasis:names:tc:SAML:1.0:cm:bearer +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_c, chLatin_m, chColon, chLatin_b, chLatin_e, chLatin_a, chLatin_r, chLatin_e, chLatin_r, chNull +}; + +const XMLCh SubjectConfirmation::HOLDER_KEY[] = // urn:oasis:names:tc:SAML:1.0:cm:holder-of-key +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_c, chLatin_m, chColon, chLatin_h, chLatin_o, chLatin_l, chLatin_d, chLatin_e, chLatin_r, chDash, + chLatin_o, chLatin_f, chDash, chLatin_k, chLatin_e, chLatin_y, chNull +}; + +const XMLCh SubjectConfirmation::SENDER_VOUCHES[] = // urn:oasis:names:tc:SAML:1.0:cm:sender-vouches +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_c, chLatin_m, chColon, chLatin_s, chLatin_e, chLatin_n, chLatin_d, chLatin_e, chLatin_r, chDash, + chLatin_v, chLatin_o, chLatin_u, chLatin_c, chLatin_h, chLatin_e, chLatin_s, chNull +}; + +const XMLCh Action::RWEDC_ACTION_NAMESPACE[] = // urn:oasis:names:tc:SAML:1.0:action:rwedc +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_a, chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chColon, + chLatin_r, chLatin_w, chLatin_e, chLatin_d, chLatin_c, chNull +}; -#define XCH(ch) chLatin_##ch -#define XNUM(d) chDigit_##d +const XMLCh Action::RWEDC_NEG_ACTION_NAMESPACE[] = // urn:oasis:names:tc:SAML:1.0:action:rwedc-negation +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_a, chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chColon, + chLatin_r, chLatin_w, chLatin_e, chLatin_d, chLatin_c, chDash, + chLatin_n, chLatin_e, chLatin_g, chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull +}; + +const XMLCh Action::GHPP_ACTION_NAMESPACE[] = // urn:oasis:names:tc:SAML:1.0:action:ghpp +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_a, chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chColon, + chLatin_g, chLatin_h, chLatin_p, chLatin_p, chNull +}; + +const XMLCh Action::UNIX_ACTION_NAMESPACE[] = // urn:oasis:names:tc:SAML:1.0:action:unix +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_a, chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chColon, + chLatin_u, chLatin_n, chLatin_i, chLatin_x, chNull +};