Removed unnecessary class from string literals.
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / impl / ProtocolsImpl.cpp
index f5e65a9..a823253 100644 (file)
@@ -22,9 +22,9 @@
 
 #include "internal.h"
 #include "exceptions.h"
+#include "saml1/core/Assertions.h"
 #include "saml1/core/Protocols.h"
 
-#include <xmltooling/AbstractChildlessElement.h>
 #include <xmltooling/AbstractComplexElement.h>
 #include <xmltooling/AbstractElementProxy.h>
 #include <xmltooling/AbstractSimpleElement.h>
@@ -42,6 +42,11 @@ using namespace opensaml;
 using namespace xmlsignature;
 using namespace xmltooling;
 using namespace std;
+using xmlconstants::XMLSIG_NS;
+using xmlconstants::XML_ONE;
+using samlconstants::SAML1P_NS;
+using samlconstants::SAML1_NS;
+using samlconstants::SAML1P_PREFIX;
 
 #if defined (_MSC_VER)
     #pragma warning( push )
@@ -55,8 +60,7 @@ namespace opensaml {
         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,StatusMessage);
 
         class SAML_DLLLOCAL RespondWithImpl : public virtual RespondWith,
-            protected AbstractSimpleElement,
-            public AbstractChildlessElement,
+            public AbstractSimpleElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -91,7 +95,6 @@ namespace opensaml {
             }
             
             IMPL_XMLOBJECT_CLONE(RespondWith);
-            IMPL_XMLOBJECT_CONTENT;
         };
 
         class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery,
@@ -117,7 +120,8 @@ namespace opensaml {
                 init();
             }
                 
-            SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            SubjectQueryImpl(const SubjectQueryImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getSubject())
                     setSubject(src.getSubject()->cloneSubject());
@@ -127,7 +131,7 @@ 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);
             }
         };
@@ -216,7 +220,7 @@ namespace opensaml {
             }
     
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(AttributeDesignator,SAMLConstants::SAML1_NS,true);
+                PROC_TYPED_CHILDREN(AttributeDesignator,SAML1_NS,true);
                 SubjectQueryImpl::processChildElement(childXMLObject,root);
             }
     
@@ -276,8 +280,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);
                 SubjectQueryImpl::processChildElement(childXMLObject,root);
             }
     
@@ -317,7 +321,8 @@ namespace opensaml {
                 init();
             }
                 
-            RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setMinorVersion(src.m_MinorVersion);
                 setRequestID(src.getRequestID());
@@ -332,10 +337,6 @@ namespace opensaml {
                 }
             }
             
-            const XMLCh* getId() const {
-                return getRequestID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -355,16 +356,20 @@ namespace opensaml {
             }
 
             IMPL_INTEGER_ATTRIB(MinorVersion);
-            IMPL_STRING_ATTRIB(RequestID);
+            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;
+            }
             IMPL_DATETIME_ATTRIB(IssueInstant,0);
             IMPL_TYPED_CHILDREN(RespondWith,m_pos_Signature);
     
         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<RequestAbstractTypeImpl*>(this)->m_MinorVersion=XMLString::replicate(XMLConstants::XML_ONE);
+                    const_cast<RequestAbstractTypeImpl*>(this)->m_MinorVersion=XMLString::replicate(XML_ONE);
                 MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);
                 if (!m_RequestID)
                     const_cast<RequestAbstractTypeImpl*>(this)->m_RequestID=SAMLConfig::getConfig().generateIdentifier();
@@ -377,15 +382,15 @@ namespace opensaml {
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(RespondWith,SAMLConstants::SAML1P_NS,false);
-                PROC_TYPED_CHILD(Signature,XMLConstants::XMLSIG_NS,false);
+                PROC_TYPED_CHILDREN(RespondWith,SAML1P_NS,false);
+                PROC_TYPED_CHILD(Signature,XMLSIG_NS,false);
                 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("Request has invalid major version.");
                 }
                 PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);
@@ -465,9 +470,9 @@ namespace opensaml {
     
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(Query,SAMLConstants::SAML1P_NS,true);
-                PROC_TYPED_CHILDREN(AssertionIDReference,SAMLConstants::SAML1_NS,false);
-                PROC_TYPED_CHILDREN(AssertionArtifact,SAMLConstants::SAML1P_NS,false);
+                PROC_TYPED_CHILD(Query,SAML1P_NS,true);
+                PROC_TYPED_CHILDREN(AssertionIDReference,SAML1_NS,false);
+                PROC_TYPED_CHILDREN(AssertionArtifact,SAML1P_NS,false);
                 RequestAbstractTypeImpl::processChildElement(childXMLObject,root);
             }
         };
@@ -494,7 +499,8 @@ namespace opensaml {
                 init();
             }
                 
-            StatusCodeImpl(const StatusCodeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            StatusCodeImpl(const StatusCodeImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setValue(src.getValue());
                 if (src.getStatusCode())
@@ -511,7 +517,7 @@ namespace opensaml {
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML1P_NS,true);
+                PROC_TYPED_CHILD(StatusCode,SAML1P_NS,true);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
@@ -533,7 +539,8 @@ namespace opensaml {
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
                 
-            StatusDetailImpl(const StatusDetailImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            StatusDetailImpl(const StatusDetailImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 VectorOf(XMLObject) v=getDetails();
                 for (vector<XMLObject*>::const_iterator i=src.m_Details.begin(); i!=src.m_Details.end(); i++) {
                     if (*i) {
@@ -578,7 +585,8 @@ namespace opensaml {
                 init();
             }
                 
-            StatusImpl(const StatusImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            StatusImpl(const StatusImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getStatusCode())
                     setStatusCode(src.getStatusCode()->cloneStatusCode());
@@ -595,9 +603,9 @@ namespace opensaml {
     
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML1P_NS,false);
-                PROC_TYPED_CHILD(StatusMessage,SAMLConstants::SAML1P_NS,false);
-                PROC_TYPED_CHILD(StatusDetail,SAMLConstants::SAML1P_NS,false);
+                PROC_TYPED_CHILD(StatusCode,SAML1P_NS,false);
+                PROC_TYPED_CHILD(StatusMessage,SAML1P_NS,false);
+                PROC_TYPED_CHILD(StatusDetail,SAML1P_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
         };
@@ -636,7 +644,8 @@ namespace opensaml {
                 init();
             }
                 
-            ResponseAbstractTypeImpl(const ResponseAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            ResponseAbstractTypeImpl(const ResponseAbstractTypeImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setMinorVersion(src.m_MinorVersion);
                 setResponseID(src.getResponseID());
@@ -647,10 +656,6 @@ namespace opensaml {
                     setSignature(src.getSignature()->cloneSignature());
             }
 
-            const XMLCh* getId() const {
-                return getResponseID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -670,7 +675,11 @@ namespace opensaml {
             }
 
             IMPL_INTEGER_ATTRIB(MinorVersion);
-            IMPL_STRING_ATTRIB(ResponseID);
+            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;
+            }
             IMPL_STRING_ATTRIB(InResponseTo);
             IMPL_DATETIME_ATTRIB(IssueInstant,0);
             IMPL_STRING_ATTRIB(Recipient);
@@ -678,9 +687,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<ResponseAbstractTypeImpl*>(this)->m_MinorVersion=XMLString::replicate(XMLConstants::XML_ONE);
+                    const_cast<ResponseAbstractTypeImpl*>(this)->m_MinorVersion=XMLString::replicate(XML_ONE);
                 MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);
                 if (!m_ResponseID)
                     const_cast<ResponseAbstractTypeImpl*>(this)->m_ResponseID=SAMLConfig::getConfig().generateIdentifier();
@@ -695,14 +704,14 @@ namespace opensaml {
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(Signature,XMLConstants::XMLSIG_NS,false);
+                PROC_TYPED_CHILD(Signature,XMLSIG_NS,false);
                 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("Response has invalid major version.");
                 }
                 PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);
@@ -750,8 +759,8 @@ namespace opensaml {
     
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(Status,SAMLConstants::SAML1P_NS,false);
-                PROC_TYPED_CHILDREN(Assertion,SAMLConstants::SAML1_NS,true);
+                PROC_TYPED_CHILD(Status,SAML1P_NS,false);
+                PROC_TYPED_CHILDREN(Assertion,SAML1_NS,true);
                 ResponseAbstractTypeImpl::processChildElement(childXMLObject,root);
             }
         };
@@ -824,7 +833,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(SAMLConstants::SAML1P_NS,_SUCCESS,SAMLConstants::SAML1P_PREFIX);
-QName StatusCode::REQUESTER(SAMLConstants::SAML1P_NS,_REQUESTER,SAMLConstants::SAML1P_PREFIX);
-QName StatusCode::RESPONDER(SAMLConstants::SAML1P_NS,_RESPONDER,SAMLConstants::SAML1P_PREFIX);
-QName StatusCode::VERSIONMISMATCH(SAMLConstants::SAML1P_NS,_VERSIONMISMATCH,SAMLConstants::SAML1P_PREFIX);
+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);