https://issues.shibboleth.net/jira/browse/CPPOST-64
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / impl / ProtocolsImpl.cpp
index 118ff98..28a5fe1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  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.
 /**
  * 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 <xmltooling/AbstractComplexElement.h>
 #include <xmltooling/AbstractSimpleElement.h>
 #include <xmltooling/impl/AnyElement.h>
 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
+#include <xmltooling/signature/Signature.h>
+#include <xmltooling/util/DateTime.h>
 #include <xmltooling/util/XMLHelper.h>
 
 #include <ctime>
@@ -63,33 +66,37 @@ 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);
@@ -100,11 +107,11 @@ namespace opensaml {
         public:
             virtual ~QueryImpl() {}
 
-            QueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+            QueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
 
-            QueryImpl(const QueryImpl& src) : AnyElementImpl(src) {}
+            QueryImpl(const QueryImpl& src) : AbstractXMLObject(src), AnyElementImpl(src) {}
 
             IMPL_XMLOBJECT_CLONE(Query);
         };
@@ -116,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:
@@ -127,7 +134,7 @@ 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();
             }
@@ -151,14 +158,14 @@ 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();
             }
@@ -179,12 +186,12 @@ namespace opensaml {
 
         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);
             }
         };
@@ -192,14 +199,14 @@ 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();
             }
@@ -227,7 +234,7 @@ namespace opensaml {
 
         protected:
             void marshallAttributes(DOMElement* domElement) const {
-                MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL);
+                MARSHALL_STRING_ATTRIB(Resource,RESOURCE,nullptr);
                 SubjectQueryImpl::marshallAttributes(domElement);
             }
 
@@ -237,7 +244,7 @@ namespace opensaml {
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                PROC_STRING_ATTRIB(Resource,RESOURCE,NULL);
+                PROC_STRING_ATTRIB(Resource,RESOURCE,nullptr);
                 SubjectQueryImpl::processAttribute(attribute);
             }
         };
@@ -245,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;
             }
@@ -256,7 +263,7 @@ namespace opensaml {
                 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();
             }
@@ -287,7 +294,7 @@ namespace opensaml {
 
         protected:
             void marshallAttributes(DOMElement* domElement) const {
-                MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL);
+                MARSHALL_STRING_ATTRIB(Resource,RESOURCE,nullptr);
                 SubjectQueryImpl::marshallAttributes(domElement);
             }
 
@@ -298,7 +305,7 @@ namespace opensaml {
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                PROC_STRING_ATTRIB(Resource,RESOURCE,NULL);
+                PROC_STRING_ATTRIB(Resource,RESOURCE,nullptr);
                 SubjectQueryImpl::processAttribute(attribute);
             }
         };
@@ -310,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:
@@ -328,7 +335,7 @@ namespace opensaml {
                 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();
             }
@@ -371,31 +378,46 @@ namespace opensaml {
             IMPL_STRING_ATTRIB(RequestID);    // have to special-case getXMLID
             const XMLCh* getXMLID() const {
                 pair<bool,int> 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<RequestAbstractTypeImpl*>(this)->m_MinorVersion=XMLString::replicate(XML_ONE);
-                MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);
+                MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,nullptr);
                 if (!m_RequestID)
                     const_cast<RequestAbstractTypeImpl*>(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<RequestAbstractTypeImpl*>(this)->m_IssueInstantEpoch=time(NULL);
+                    const_cast<RequestAbstractTypeImpl*>(this)->m_IssueInstantEpoch=time(nullptr);
                     const_cast<RequestAbstractTypeImpl*>(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) {
@@ -407,34 +429,39 @@ 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*>(domElement)->setIdAttributeNS(NULL, REQUESTID_ATTRIB_NAME);
+                if (m_RequestID && (!m_MinorVersion || *m_MinorVersion!=chDigit_0)) {
+#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE
+                    const_cast<DOMElement*>(domElement)->setIdAttributeNS(nullptr, REQUESTID_ATTRIB_NAME, true);
+#else
+                    const_cast<DOMElement*>(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();
             }
@@ -508,9 +535,9 @@ 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:
@@ -518,7 +545,7 @@ namespace opensaml {
                 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();
             }
@@ -532,12 +559,12 @@ namespace opensaml {
             }
 
             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) {
@@ -546,7 +573,7 @@ namespace opensaml {
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                PROC_QNAME_ATTRIB(Value,VALUE,NULL);
+                PROC_QNAME_ATTRIB(Value,VALUE,nullptr);
             }
         };
 
@@ -559,7 +586,7 @@ 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) {
             }
 
@@ -586,22 +613,22 @@ 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();
             }
@@ -638,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:
@@ -660,7 +687,7 @@ namespace opensaml {
                 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();
             }
@@ -699,34 +726,49 @@ namespace opensaml {
             IMPL_STRING_ATTRIB(ResponseID);    // have to special-case getXMLID
             const XMLCh* getXMLID() const {
                 pair<bool,int> 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<ResponseAbstractTypeImpl*>(this)->m_MinorVersion=XMLString::replicate(XML_ONE);
-                MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);
+                MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,nullptr);
                 if (!m_ResponseID)
                     const_cast<ResponseAbstractTypeImpl*>(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<ResponseAbstractTypeImpl*>(this)->m_IssueInstantEpoch=time(NULL);
+                    const_cast<ResponseAbstractTypeImpl*>(this)->m_IssueInstantEpoch=time(nullptr);
                     const_cast<ResponseAbstractTypeImpl*>(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) {
@@ -737,36 +779,41 @@ 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*>(domElement)->setIdAttributeNS(NULL, RESPONSEID_ATTRIB_NAME);
+                if (m_ResponseID && (!m_MinorVersion || *m_MinorVersion!=chDigit_0)) {
+#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE
+                    const_cast<DOMElement*>(domElement)->setIdAttributeNS(nullptr, RESPONSEID_ATTRIB_NAME, true);
+#else
+                    const_cast<DOMElement*>(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();
             }
@@ -867,7 +914,7 @@ const XMLCh _REQUESTER[] =                                  UNICODE_LITERAL_9(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);