X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=blobdiff_plain;f=saml%2Fsaml1%2Fcore%2Fimpl%2FProtocolsImpl.cpp;h=28a5fe107a9ce141670e8e14d3e4194e5e064ca9;hp=a1300d6c45145aacf59adf33d1ac0d8f5c484dcd;hb=ede749b3b44c70d6b8f5fc59d4f17a81d6e07a1a;hpb=38ec6425a33c32f3532a20aa85fd03f95f5ff472 diff --git a/saml/saml1/core/impl/ProtocolsImpl.cpp b/saml/saml1/core/impl/ProtocolsImpl.cpp index a1300d6..28a5fe1 100644 --- a/saml/saml1/core/impl/ProtocolsImpl.cpp +++ b/saml/saml1/core/impl/ProtocolsImpl.cpp @@ -1,6 +1,6 @@ /* - * Copyright 2001-2007 Internet2 - * + * Copyright 2001-2010 Internet2 + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,20 +16,23 @@ /** * ProtocolsImpl.cpp - * - * Implementation classes for SAML 1.x Protocols schema + * + * Implementation classes for SAML 1.x Protocols schema. */ #include "internal.h" #include "exceptions.h" #include "saml1/core/Assertions.h" #include "saml1/core/Protocols.h" +#include "signature/ContentReference.h" #include #include #include #include #include +#include +#include #include #include @@ -53,7 +56,7 @@ using samlconstants::SAML1P_PREFIX; namespace opensaml { namespace saml1p { - + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AssertionArtifact); DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,StatusMessage); @@ -63,38 +66,56 @@ namespace opensaml { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { - QName* m_qname; + mutable xmltooling::QName* m_qname; public: virtual ~RespondWithImpl() { delete m_qname; } - - RespondWithImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_qname(NULL) { + + RespondWithImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_qname(nullptr) { } - + RespondWithImpl(const RespondWithImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), m_qname(NULL) { + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), m_qname(nullptr) { setQName(src.getQName()); } - - QName* getQName() const { + + xmltooling::QName* getQName() const { + if (!m_qname && getDOM() && getDOM()->getTextContent()) { + m_qname = XMLHelper::getNodeValueAsQName(getDOM()); + } return m_qname; } - - void setQName(const QName* qname) { + + void setQName(const xmltooling::QName* qname) { m_qname=prepareForAssignment(m_qname,qname); if (m_qname) { auto_ptr_XMLCh temp(m_qname->toString().c_str()); setTextContent(temp.get()); } - else - setTextContent(NULL); + else { + setTextContent(nullptr); + } } - + IMPL_XMLOBJECT_CLONE(RespondWith); }; + class SAML_DLLLOCAL QueryImpl : public virtual Query, public AnyElementImpl + { + public: + virtual ~QueryImpl() {} + + QueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + QueryImpl(const QueryImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {} + + IMPL_XMLOBJECT_CLONE(Query); + }; + class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, public AbstractComplexElement, public AbstractDOMCachingXMLObject, @@ -102,8 +123,8 @@ 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: @@ -112,21 +133,21 @@ namespace opensaml { } public: virtual ~SubjectQueryImpl() {} - - SubjectQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + SubjectQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); } - + IMPL_TYPED_CHILD(Subject); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Subject,SAML1_NS,true); @@ -137,23 +158,23 @@ namespace opensaml { class SAML_DLLLOCAL AuthenticationQueryImpl : public virtual AuthenticationQuery, public SubjectQueryImpl { void init() { - m_AuthenticationMethod=NULL; + m_AuthenticationMethod=nullptr; } public: virtual ~AuthenticationQueryImpl() { XMLString::release(&m_AuthenticationMethod); } - - AuthenticationQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + AuthenticationQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthenticationQueryImpl(const AuthenticationQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); setAuthenticationMethod(src.getAuthenticationMethod()); } - + IMPL_XMLOBJECT_CLONE(AuthenticationQuery); SubjectQuery* cloneSubjectQuery() const { return cloneAuthenticationQuery(); @@ -162,15 +183,15 @@ namespace opensaml { return cloneAuthenticationQuery(); } IMPL_STRING_ATTRIB(AuthenticationMethod); - + protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); + MARSHALL_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,nullptr); SubjectQueryImpl::marshallAttributes(domElement); } - + void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,NULL); + PROC_STRING_ATTRIB(AuthenticationMethod,AUTHENTICATIONMETHOD,nullptr); SubjectQueryImpl::processAttribute(attribute); } }; @@ -178,18 +199,18 @@ namespace opensaml { class SAML_DLLLOCAL AttributeQueryImpl : public virtual AttributeQuery, public SubjectQueryImpl { void init() { - m_Resource=NULL; + m_Resource=nullptr; } public: virtual ~AttributeQueryImpl() { XMLString::release(&m_Resource); } - - AttributeQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + AttributeQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AttributeQueryImpl(const AttributeQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); setResource(src.getResource()); @@ -200,7 +221,7 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AttributeQuery); SubjectQuery* cloneSubjectQuery() const { return cloneAttributeQuery(); @@ -210,20 +231,20 @@ namespace opensaml { } IMPL_STRING_ATTRIB(Resource); IMPL_TYPED_CHILDREN(AttributeDesignator,m_children.end()); - + protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); + MARSHALL_STRING_ATTRIB(Resource,RESOURCE,nullptr); SubjectQueryImpl::marshallAttributes(domElement); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILDREN(AttributeDesignator,SAML1_NS,true); SubjectQueryImpl::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); + PROC_STRING_ATTRIB(Resource,RESOURCE,nullptr); SubjectQueryImpl::processAttribute(attribute); } }; @@ -231,9 +252,9 @@ namespace opensaml { class SAML_DLLLOCAL AuthorizationDecisionQueryImpl : public virtual AuthorizationDecisionQuery, public SubjectQueryImpl { void init() { - m_Resource=NULL; - m_Evidence=NULL; - m_children.push_back(NULL); + m_Resource=nullptr; + m_Evidence=nullptr; + m_children.push_back(nullptr); m_pos_Evidence=m_pos_Subject; ++m_pos_Evidence; } @@ -241,12 +262,12 @@ namespace opensaml { virtual ~AuthorizationDecisionQueryImpl() { XMLString::release(&m_Resource); } - - AuthorizationDecisionQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + AuthorizationDecisionQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + AuthorizationDecisionQueryImpl(const AuthorizationDecisionQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { init(); setResource(src.getResource()); @@ -259,7 +280,7 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(AuthorizationDecisionQuery); SubjectQuery* cloneSubjectQuery() const { return cloneAuthorizationDecisionQuery(); @@ -270,21 +291,21 @@ namespace opensaml { IMPL_STRING_ATTRIB(Resource); IMPL_TYPED_CHILD(Evidence); IMPL_TYPED_CHILDREN(Action, m_pos_Evidence); - + protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); + MARSHALL_STRING_ATTRIB(Resource,RESOURCE,nullptr); SubjectQueryImpl::marshallAttributes(domElement); } - + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Evidence,SAML1_NS,false); PROC_TYPED_CHILDREN(Action,SAML1_NS,false); SubjectQueryImpl::processChildElement(childXMLObject,root); } - + void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); + PROC_STRING_ATTRIB(Resource,RESOURCE,nullptr); SubjectQueryImpl::processAttribute(attribute); } }; @@ -296,11 +317,11 @@ namespace opensaml { public AbstractXMLObjectUnmarshaller { void init() { - m_MinorVersion=NULL; - m_RequestID=NULL; - m_IssueInstant=NULL; - m_children.push_back(NULL); - m_Signature=NULL; + m_MinorVersion=nullptr; + m_RequestID=nullptr; + m_IssueInstant=nullptr; + m_children.push_back(nullptr); + m_Signature=nullptr; m_pos_Signature=m_children.begin(); } protected: @@ -313,12 +334,12 @@ namespace opensaml { XMLString::release(&m_RequestID); delete m_IssueInstant; } - - RequestAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + RequestAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -334,7 +355,7 @@ namespace opensaml { } } } - + //IMPL_TYPED_CHILD(Signature); // Need customized setter. protected: @@ -344,7 +365,7 @@ namespace opensaml { Signature* getSignature() const { return m_Signature; } - + void setSignature(Signature* sig) { prepareForAssignment(m_Signature,sig); *m_pos_Signature=m_Signature=sig; @@ -357,31 +378,46 @@ namespace opensaml { IMPL_STRING_ATTRIB(RequestID); // have to special-case getXMLID const XMLCh* getXMLID() const { pair v = getMinorVersion(); - return (!v.first || v.second > 0) ? m_RequestID : NULL; + return (!v.first || v.second > 0) ? m_RequestID : nullptr; } const XMLCh* getID() const { return getRequestID(); } + void releaseDOM() const { + if (getDOM()) + getDOM()->removeAttributeNS(nullptr, REQUESTID_ATTRIB_NAME); + AbstractDOMCachingXMLObject::releaseDOM(); + } IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_TYPED_CHILDREN(RespondWith,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_RequestID) const_cast(this)->m_RequestID=SAMLConfig::getConfig().generateIdentifier(); - domElement->setAttributeNS(NULL, REQUESTID_ATTRIB_NAME, m_RequestID); - if (*m_MinorVersion!=chDigit_0) - domElement->setIdAttributeNS(NULL, REQUESTID_ATTRIB_NAME); + domElement->setAttributeNS(nullptr, REQUESTID_ATTRIB_NAME, m_RequestID); + if (*m_MinorVersion!=chDigit_0) { +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + domElement->setIdAttributeNS(nullptr, REQUESTID_ATTRIB_NAME, true); +#else + domElement->setIdAttributeNS(nullptr, REQUESTID_ATTRIB_NAME); +#endif + } 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) { @@ -393,38 +429,43 @@ namespace opensaml { void unmarshallAttributes(const DOMElement* domElement) { // Standard processing, but then we check IDness. AbstractXMLObjectUnmarshaller::unmarshallAttributes(domElement); - if (m_RequestID && (!m_MinorVersion || *m_MinorVersion!=chDigit_0)) - const_cast(domElement)->setIdAttributeNS(NULL, REQUESTID_ATTRIB_NAME); + if (m_RequestID && (!m_MinorVersion || *m_MinorVersion!=chDigit_0)) { +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + const_cast(domElement)->setIdAttributeNS(nullptr, REQUESTID_ATTRIB_NAME, true); +#else + const_cast(domElement)->setIdAttributeNS(nullptr, REQUESTID_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("Request has invalid major version."); } - PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); - PROC_STRING_ATTRIB(RequestID,REQUESTID,NULL); - PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); + PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,nullptr); + PROC_STRING_ATTRIB(RequestID,REQUESTID,nullptr); + PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,nullptr); } }; class SAML_DLLLOCAL RequestImpl : public virtual Request, public RequestAbstractTypeImpl { void init() { - m_children.push_back(NULL); - m_Query=NULL; + m_children.push_back(nullptr); + m_Query=nullptr; m_pos_Query=m_pos_Signature; ++m_pos_Query; } public: virtual ~RequestImpl() {} - - RequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + RequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + RequestImpl(const RequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { init(); if (src.getQuery()) @@ -442,13 +483,13 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Request); RequestAbstractType* cloneRequestAbstractType() const { return cloneRequest(); } IMPL_TYPED_CHILD(Query); - + SubjectQuery* getSubjectQuery() const { return dynamic_cast(getQuery()); } @@ -474,10 +515,10 @@ namespace opensaml { void setAuthorizationDecisionQuery(AuthorizationDecisionQuery* q) { setQuery(q); } - + IMPL_TYPED_CHILDREN(AssertionIDReference, m_children.end()); IMPL_TYPED_CHILDREN(AssertionArtifact, m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Query,SAML1P_NS,true); @@ -494,21 +535,21 @@ namespace opensaml { public AbstractXMLObjectUnmarshaller { void init() { - m_Value=NULL; - m_children.push_back(NULL); - m_StatusCode=NULL; + m_Value=nullptr; + m_children.push_back(nullptr); + m_StatusCode=nullptr; m_pos_StatusCode=m_children.begin(); } public: virtual ~StatusCodeImpl() { delete m_Value; } - - StatusCodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + StatusCodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + StatusCodeImpl(const StatusCodeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -516,14 +557,14 @@ namespace opensaml { if (src.getStatusCode()) setStatusCode(src.getStatusCode()->cloneStatusCode()); } - + IMPL_XMLOBJECT_CLONE(StatusCode); - IMPL_XMLOBJECT_ATTRIB(Value,QName); + IMPL_XMLOBJECT_ATTRIB(Value,xmltooling::QName); IMPL_TYPED_CHILD(StatusCode); - + protected: void marshallAttributes(DOMElement* domElement) const { - MARSHALL_QNAME_ATTRIB(Value,VALUE,NULL); + MARSHALL_QNAME_ATTRIB(Value,VALUE,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -532,7 +573,7 @@ namespace opensaml { } void processAttribute(const DOMAttr* attribute) { - PROC_QNAME_ATTRIB(Value,VALUE,NULL); + PROC_QNAME_ATTRIB(Value,VALUE,nullptr); } }; @@ -544,21 +585,21 @@ namespace opensaml { { public: virtual ~StatusDetailImpl() {} - - StatusDetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + StatusDetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - + StatusDetailImpl(const StatusDetailImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOf(XMLObject) v=getUnknownXMLObjects(); for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) v.push_back((*i)->clone()); } - + IMPL_XMLOBJECT_CLONE(StatusDetail); IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { getUnknownXMLObjects().push_back(childXMLObject); @@ -572,26 +613,26 @@ namespace opensaml { public AbstractXMLObjectUnmarshaller { void init() { - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_StatusCode=NULL; + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_children.push_back(nullptr); + m_StatusCode=nullptr; m_pos_StatusCode=m_children.begin(); - m_StatusMessage=NULL; + m_StatusMessage=nullptr; m_pos_StatusMessage=m_pos_StatusCode; ++m_pos_StatusMessage; - m_StatusDetail=NULL; + m_StatusDetail=nullptr; m_pos_StatusDetail=m_pos_StatusMessage; ++m_pos_StatusDetail; } public: virtual ~StatusImpl() {} - - StatusImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + StatusImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + StatusImpl(const StatusImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -602,12 +643,12 @@ namespace opensaml { if (src.getStatusDetail()) setStatusDetail(src.getStatusDetail()->cloneStatusDetail()); } - + IMPL_XMLOBJECT_CLONE(Status); IMPL_TYPED_CHILD(StatusCode); IMPL_TYPED_CHILD(StatusMessage); IMPL_TYPED_CHILD(StatusDetail); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(StatusCode,SAML1P_NS,false); @@ -624,13 +665,13 @@ namespace opensaml { public AbstractXMLObjectUnmarshaller { void init() { - m_MinorVersion=NULL; - m_ResponseID=NULL; - m_InResponseTo=NULL; - m_IssueInstant=NULL; - m_Recipient=NULL; - m_children.push_back(NULL); - m_Signature=NULL; + m_MinorVersion=nullptr; + m_ResponseID=nullptr; + m_InResponseTo=nullptr; + m_IssueInstant=nullptr; + m_Recipient=nullptr; + m_children.push_back(nullptr); + m_Signature=nullptr; m_pos_Signature=m_children.begin(); } protected: @@ -645,12 +686,12 @@ namespace opensaml { XMLString::release(&m_Recipient); delete m_IssueInstant; } - - ResponseAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + ResponseAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + ResponseAbstractTypeImpl(const ResponseAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); @@ -672,7 +713,7 @@ namespace opensaml { Signature* getSignature() const { return m_Signature; } - + void setSignature(Signature* sig) { prepareForAssignment(m_Signature,sig); *m_pos_Signature=m_Signature=sig; @@ -685,34 +726,49 @@ namespace opensaml { IMPL_STRING_ATTRIB(ResponseID); // have to special-case getXMLID const XMLCh* getXMLID() const { pair v = getMinorVersion(); - return (!v.first || v.second > 0) ? m_ResponseID : NULL; + return (!v.first || v.second > 0) ? m_ResponseID : nullptr; } const XMLCh* getID() const { return getResponseID(); } + void releaseDOM() const { + if (getDOM()) + getDOM()->removeAttributeNS(nullptr, RESPONSEID_ATTRIB_NAME); + AbstractDOMCachingXMLObject::releaseDOM(); + } IMPL_STRING_ATTRIB(InResponseTo); IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_STRING_ATTRIB(Recipient); - + 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_ResponseID) const_cast(this)->m_ResponseID=SAMLConfig::getConfig().generateIdentifier(); - domElement->setAttributeNS(NULL, RESPONSEID_ATTRIB_NAME, m_ResponseID); - if (*m_MinorVersion!=chDigit_0) - domElement->setIdAttributeNS(NULL, RESPONSEID_ATTRIB_NAME); - MARSHALL_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); + domElement->setAttributeNS(nullptr, RESPONSEID_ATTRIB_NAME, m_ResponseID); + if (*m_MinorVersion!=chDigit_0) { +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + domElement->setIdAttributeNS(nullptr, RESPONSEID_ATTRIB_NAME, true); +#else + domElement->setIdAttributeNS(nullptr, RESPONSEID_ATTRIB_NAME); +#endif + } + MARSHALL_STRING_ATTRIB(InResponseTo,INRESPONSETO,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_STRING_ATTRIB(Recipient,RECIPIENT,NULL); + MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,nullptr); + MARSHALL_STRING_ATTRIB(Recipient,RECIPIENT,nullptr); } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -723,40 +779,45 @@ namespace opensaml { void unmarshallAttributes(const DOMElement* domElement) { // Standard processing, but then we check IDness. AbstractXMLObjectUnmarshaller::unmarshallAttributes(domElement); - if (m_ResponseID && (!m_MinorVersion || *m_MinorVersion!=chDigit_0)) - const_cast(domElement)->setIdAttributeNS(NULL, RESPONSEID_ATTRIB_NAME); + if (m_ResponseID && (!m_MinorVersion || *m_MinorVersion!=chDigit_0)) { +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + const_cast(domElement)->setIdAttributeNS(nullptr, RESPONSEID_ATTRIB_NAME, true); +#else + const_cast(domElement)->setIdAttributeNS(nullptr, RESPONSEID_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("Response has invalid major version."); } - PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); - PROC_STRING_ATTRIB(ResponseID,RESPONSEID,NULL); - PROC_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); - PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); - PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL); + PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,nullptr); + PROC_STRING_ATTRIB(ResponseID,RESPONSEID,nullptr); + PROC_STRING_ATTRIB(InResponseTo,INRESPONSETO,nullptr); + PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,nullptr); + PROC_STRING_ATTRIB(Recipient,RECIPIENT,nullptr); } }; class SAML_DLLLOCAL ResponseImpl : public virtual Response, public ResponseAbstractTypeImpl { void init() { - m_children.push_back(NULL); - m_Status=NULL; + m_children.push_back(nullptr); + m_Status=nullptr; m_pos_Status=m_pos_Signature; ++m_pos_Status; } public: virtual ~ResponseImpl() {} - - ResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + + ResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } - + ResponseImpl(const ResponseImpl& src) : AbstractXMLObject(src), ResponseAbstractTypeImpl(src) { init(); if (src.getStatus()) @@ -768,14 +829,14 @@ namespace opensaml { } } } - + IMPL_XMLOBJECT_CLONE(Response); ResponseAbstractType* cloneResponseAbstractType() const { return cloneResponse(); } IMPL_TYPED_CHILD(Status); IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml1,m_children.end()); - + protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { PROC_TYPED_CHILD(Status,SAML1P_NS,false); @@ -797,6 +858,7 @@ IMPL_XMLOBJECTBUILDER(AssertionArtifact); IMPL_XMLOBJECTBUILDER(AttributeQuery); IMPL_XMLOBJECTBUILDER(AuthenticationQuery); IMPL_XMLOBJECTBUILDER(AuthorizationDecisionQuery); +IMPL_XMLOBJECTBUILDER(Query); IMPL_XMLOBJECTBUILDER(Request); IMPL_XMLOBJECTBUILDER(RespondWith); IMPL_XMLOBJECTBUILDER(Response); @@ -851,8 +913,8 @@ const XMLCh _SUCCESS[] = UNICODE_LITERAL_7(S, const XMLCh _REQUESTER[] = UNICODE_LITERAL_9(R,e,q,u,e,s,t,e,r); const XMLCh _RESPONDER[] = UNICODE_LITERAL_9(R,e,s,p,o,n,d,e,r); const XMLCh _VERSIONMISMATCH[] = UNICODE_LITERAL_15(V,e,r,s,i,o,n,M,i,s,m,a,t,c,h); - -QName StatusCode::SUCCESS(SAML1P_NS,_SUCCESS,SAML1P_PREFIX); -QName StatusCode::REQUESTER(SAML1P_NS,_REQUESTER,SAML1P_PREFIX); -QName StatusCode::RESPONDER(SAML1P_NS,_RESPONDER,SAML1P_PREFIX); -QName StatusCode::VERSIONMISMATCH(SAML1P_NS,_VERSIONMISMATCH,SAML1P_PREFIX); + +xmltooling::QName StatusCode::SUCCESS(SAML1P_NS,_SUCCESS,SAML1P_PREFIX); +xmltooling::QName StatusCode::REQUESTER(SAML1P_NS,_REQUESTER,SAML1P_PREFIX); +xmltooling::QName StatusCode::RESPONDER(SAML1P_NS,_RESPONDER,SAML1P_PREFIX); +xmltooling::QName StatusCode::VERSIONMISMATCH(SAML1P_NS,_VERSIONMISMATCH,SAML1P_PREFIX);