Removed unnecessary class from string literals.
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / impl / AssertionsImpl.cpp
index 0efb14b..6d6bb1c 100644 (file)
@@ -24,7 +24,6 @@
 #include "exceptions.h"
 #include "saml1/core/Assertions.h"
 
-#include <xmltooling/AbstractChildlessElement.h>
 #include <xmltooling/AbstractComplexElement.h>
 #include <xmltooling/AbstractElementProxy.h>
 #include <xmltooling/AbstractSimpleElement.h>
@@ -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 )
@@ -69,7 +71,7 @@ namespace opensaml {
             }
                 
             AudienceRestrictionConditionImpl(const AudienceRestrictionConditionImpl& src)
-                    : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 VectorOf(Audience) v=getAudiences();
                 for (vector<Audience*>::const_iterator i=src.m_Audiences.begin(); i!=src.m_Audiences.end(); i++) {
                     if (*i) {
@@ -86,13 +88,13 @@ namespace opensaml {
     
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(Audience,SAMLConstants::SAML1_NS,false);
+                PROC_TYPED_CHILDREN(Audience,SAML1_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
         };
 
         class SAML_DLLLOCAL DoNotCacheConditionImpl : public virtual DoNotCacheCondition,
-            public AbstractChildlessElement,
+            public AbstractSimpleElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -104,7 +106,8 @@ namespace opensaml {
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
                 
-            DoNotCacheConditionImpl(const DoNotCacheConditionImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            DoNotCacheConditionImpl(const DoNotCacheConditionImpl& src)
+                : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
             }
             
             IMPL_XMLOBJECT_CLONE(DoNotCacheCondition);
@@ -130,7 +133,8 @@ namespace opensaml {
                 init();
             }
                 
-            ConditionsImpl(const ConditionsImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            ConditionsImpl(const ConditionsImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setNotBefore(src.getNotBefore());
                 setNotOnOrAfter(src.getNotOnOrAfter());
@@ -176,9 +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);
             }
     
@@ -190,7 +194,6 @@ namespace opensaml {
 
         class SAML_DLLLOCAL NameIdentifierImpl : public virtual NameIdentifier,
             public AbstractSimpleElement,
-            public AbstractChildlessElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -220,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 {
@@ -243,8 +245,7 @@ namespace opensaml {
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
                 
-            SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src)
-                : AnyElementImpl(src) {
+            SubjectConfirmationDataImpl(const SubjectConfirmationDataImpl& src) : AnyElementImpl(src) {
             }
             
             IMPL_XMLOBJECT_CLONE(SubjectConfirmationData);
@@ -264,7 +265,8 @@ namespace opensaml {
                 init();
             }
                 
-            SubjectConfirmationImpl(const SubjectConfirmationImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            SubjectConfirmationImpl(const SubjectConfirmationImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getSubjectConfirmationData())
                     setSubjectConfirmationData(src.getSubjectConfirmationData()->clone());
@@ -295,8 +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())
@@ -319,7 +321,8 @@ namespace opensaml {
                 init();
             }
                 
-            SubjectImpl(const SubjectImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            SubjectImpl(const SubjectImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getNameIdentifier())
                     setNameIdentifier(src.getNameIdentifier()->cloneNameIdentifier());
@@ -343,8 +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);
             }
         };
@@ -372,7 +375,8 @@ namespace opensaml {
                 init();
             }
                 
-            SubjectStatementImpl(const SubjectStatementImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            SubjectStatementImpl(const SubjectStatementImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getSubject())
                     setSubject(src.getSubject()->cloneSubject());
@@ -382,13 +386,13 @@ namespace opensaml {
     
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(Subject,SAMLConstants::SAML1_NS,true);
+                PROC_TYPED_CHILD(Subject,SAML1_NS,true);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
         };
 
         class SAML_DLLLOCAL SubjectLocalityImpl : public virtual SubjectLocality,
-            public AbstractChildlessElement,
+            public AbstractSimpleElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -404,7 +408,8 @@ namespace opensaml {
                 init();
             }
                 
-            SubjectLocalityImpl(const SubjectLocalityImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            SubjectLocalityImpl(const SubjectLocalityImpl& src)
+                    : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setIPAddress(src.getIPAddress());
                 setDNSAddress(src.getDNSAddress());
@@ -431,7 +436,7 @@ namespace opensaml {
         };
 
         class SAML_DLLLOCAL AuthorityBindingImpl : public virtual AuthorityBinding,
-            public AbstractChildlessElement,
+            public AbstractSimpleElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -448,7 +453,8 @@ namespace opensaml {
                 init();
             }
                 
-            AuthorityBindingImpl(const AuthorityBindingImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            AuthorityBindingImpl(const AuthorityBindingImpl& src)
+                    : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setAuthorityKind(src.getAuthorityKind());
                 setLocation(src.getLocation());
@@ -535,8 +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);
             }
     
@@ -549,7 +555,6 @@ namespace opensaml {
 
         class SAML_DLLLOCAL ActionImpl : public virtual Action,
             public AbstractSimpleElement,
-            public AbstractChildlessElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -569,7 +574,6 @@ namespace opensaml {
             
             IMPL_XMLOBJECT_CLONE(Action);
             IMPL_STRING_ATTRIB(Namespace);
-            IMPL_XMLOBJECT_CONTENT;
     
         protected:
             void marshallAttributes(DOMElement* domElement) const {
@@ -594,8 +598,8 @@ namespace opensaml {
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
                 
-            EvidenceImpl(const EvidenceImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
-    
+            EvidenceImpl(const EvidenceImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
                     if (*i) {
                         AssertionIDReference* ref=dynamic_cast<AssertionIDReference*>(*i);
@@ -619,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);
             }
         };
@@ -683,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);
             }
     
@@ -696,7 +700,7 @@ namespace opensaml {
         };
 
         class SAML_DLLLOCAL AttributeDesignatorImpl : public virtual AttributeDesignator,
-            public AbstractChildlessElement,
+            public AbstractSimpleElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -712,7 +716,8 @@ namespace opensaml {
                 init();
             }
                 
-            AttributeDesignatorImpl(const AttributeDesignatorImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            AttributeDesignatorImpl(const AttributeDesignatorImpl& src)
+                    : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setAttributeName(src.getAttributeName());
                 setAttributeNamespace(src.getAttributeNamespace());
@@ -755,7 +760,8 @@ namespace opensaml {
                 init();
             }
                 
-            AttributeImpl(const AttributeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            AttributeImpl(const AttributeImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setAttributeName(src.getAttributeName());
                 setAttributeNamespace(src.getAttributeNamespace());
@@ -839,7 +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);
             }
         };
@@ -857,8 +863,8 @@ namespace opensaml {
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
                 
-            AdviceImpl(const AdviceImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
-    
+            AdviceImpl(const AdviceImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
                     if (*i) {
                         AssertionIDReference* ref=dynamic_cast<AssertionIDReference*>(*i);
@@ -885,12 +891,12 @@ 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;
                 }
@@ -935,7 +941,8 @@ namespace opensaml {
                 init();
             }
                 
-            AssertionImpl(const AssertionImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+            AssertionImpl(const AssertionImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setMinorVersion(src.m_MinorVersion);
                 setAssertionID(src.getAssertionID());
@@ -1002,7 +1009,11 @@ namespace opensaml {
             
             IMPL_XMLOBJECT_CLONE(Assertion);
             IMPL_INTEGER_ATTRIB(MinorVersion);
-            IMPL_ID_ATTRIB(AssertionID);
+            IMPL_STRING_ATTRIB(AssertionID);    // have to special-case getXMLID
+            const XMLCh* getXMLID() const {
+                pair<bool,int> v = getMinorVersion();
+                return (!v.first || v.second > 0) ? m_AssertionID : NULL;
+            }
             IMPL_STRING_ATTRIB(Issuer);
             IMPL_DATETIME_ATTRIB(IssueInstant,0);
             IMPL_TYPED_CHILD(Conditions);
@@ -1016,9 +1027,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<AssertionImpl*>(this)->m_MinorVersion=XMLString::replicate(XMLConstants::XML_ONE);
+                    const_cast<AssertionImpl*>(this)->m_MinorVersion=XMLString::replicate(XML_ONE);
                 MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);
                 if (!m_AssertionID)
                     const_cast<AssertionImpl*>(this)->m_AssertionID=SAMLConfig::getConfig().generateIdentifier();
@@ -1032,21 +1043,21 @@ namespace opensaml {
             }
     
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(Conditions,SAMLConstants::SAML1_NS,false);
-                PROC_TYPED_CHILD(Advice,SAMLConstants::SAML1_NS,false);
-                PROC_TYPED_CHILD(Signature,XMLConstants::XMLSIG_NS,false);
-                PROC_TYPED_CHILDREN(AuthenticationStatement,SAMLConstants::SAML1_NS,false);
-                PROC_TYPED_CHILDREN(AttributeStatement,SAMLConstants::SAML1_NS,false);
-                PROC_TYPED_CHILDREN(AuthorizationDecisionStatement,SAMLConstants::SAML1_NS,false);
-                PROC_TYPED_CHILDREN(SubjectStatement,SAMLConstants::SAML1_NS,true);
-                PROC_TYPED_CHILDREN(Statement,SAMLConstants::SAML1_NS,true);
+                PROC_TYPED_CHILD(Conditions,SAML1_NS,false);
+                PROC_TYPED_CHILD(Advice,SAML1_NS,false);
+                PROC_TYPED_CHILD(Signature,XMLSIG_NS,false);
+                PROC_TYPED_CHILDREN(AuthenticationStatement,SAML1_NS,false);
+                PROC_TYPED_CHILDREN(AttributeStatement,SAML1_NS,false);
+                PROC_TYPED_CHILDREN(AuthorizationDecisionStatement,SAML1_NS,false);
+                PROC_TYPED_CHILDREN(SubjectStatement,SAML1_NS,true);
+                PROC_TYPED_CHILDREN(Statement,SAML1_NS,true);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
     
             void processAttribute(const DOMAttr* attribute) {
                 static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n);
                 if (XMLHelper::isNodeNamed(attribute,NULL,MAJORVERSION)) {
-                    if (!XMLString::equals(attribute->getValue(),XMLConstants::XML_ONE))
+                    if (!XMLString::equals(attribute->getValue(),XML_ONE))
                         throw UnmarshallingException("Assertion has invalid major version.");
                 }
                 PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL);