Stop blowing away native signature from setters, need xmlsec fix to complete.
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / impl / XMLSecSignatureImpl.cpp
index 292d771..dfda1a4 100644 (file)
 #include "util/NDC.h"\r
 #include "util/XMLConstants.h"\r
 #include "util/XMLHelper.h"\r
-#include "validation/ValidatingXMLObject.h"\r
 \r
 #include <log4cpp/Category.hh>\r
 #include <xercesc/framework/MemBufInputSource.hpp>\r
 #include <xercesc/framework/Wrapper4InputSource.hpp>\r
 #include <xercesc/util/XMLUniDefs.hpp>\r
 #include <xsec/dsig/DSIGKeyInfoX509.hpp>\r
+#include <xsec/dsig/DSIGReference.hpp>\r
 #include <xsec/enc/XSECCryptoException.hpp>\r
 #include <xsec/framework/XSECException.hpp>\r
 \r
@@ -49,8 +49,7 @@ using namespace std;
 \r
 namespace xmlsignature {\r
     \r
-    class XMLTOOL_DLLLOCAL XMLSecSignatureImpl\r
-        : public UnknownElementImpl, public virtual Signature, public virtual ValidatingXMLObject\r
+    class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
     {\r
     public:\r
         XMLSecSignatureImpl() : UnknownElementImpl(XMLConstants::XMLSIG_NS, Signature::LOCAL_NAME, XMLConstants::XMLSIG_PREFIX),\r
@@ -85,8 +84,6 @@ namespace xmlsignature {
         void setSigningKey(XSECCryptoKey* signingKey) {\r
             delete m_key;\r
             m_key=signingKey;\r
-            if (m_key)\r
-                releaseThisandParentDOM();\r
         }\r
         void setKeyInfo(KeyInfo* keyInfo) {\r
             prepareForAssignment(m_keyInfo, keyInfo);\r
@@ -95,16 +92,10 @@ namespace xmlsignature {
         void setContentReference(ContentReference* reference) {\r
             delete m_reference;\r
             m_reference=reference;\r
-            releaseThisandParentDOM();\r
         }\r
         \r
         void sign();\r
 \r
-        void registerValidator(Validator* validator);\r
-        void deregisterValidator(Validator* validator);\r
-        void deregisterAll();\r
-        void validate(bool validateDescendants) const;\r
-\r
     private:\r
         mutable DSIGSignature* m_signature;\r
         XMLCh* m_c14n;\r
@@ -112,7 +103,6 @@ namespace xmlsignature {
         XSECCryptoKey* m_key;\r
         KeyInfo* m_keyInfo;\r
         ContentReference* m_reference;\r
-        vector<Validator*> m_validators;\r
     };\r
     \r
 };\r
@@ -132,7 +122,6 @@ XMLSecSignatureImpl::~XMLSecSignatureImpl()
     delete m_key;\r
     delete m_keyInfo;\r
     delete m_reference;\r
-    for_each(m_validators.begin(),m_validators.end(),cleanup<Validator>());\r
 }\r
 \r
 void XMLSecSignatureImpl::releaseDOM() const\r
@@ -165,8 +154,6 @@ Signature* XMLSecSignatureImpl::cloneSignature() const
     if (m_keyInfo)\r
         ret->m_keyInfo=m_keyInfo->cloneKeyInfo();\r
 \r
-    xmltooling::clone(m_validators,ret->m_validators);\r
-\r
     // If there's no XML locally, serialize this object into the new one, otherwise just copy it over.\r
     if (m_xml.empty())\r
         serialize(ret->m_xml);\r
@@ -190,6 +177,10 @@ void XMLSecSignatureImpl::sign()
 \r
     try {\r
         log.debug("creating signature reference(s)");\r
+        // TODO: Need XML-Sec fixed to clear references.\r
+        //DSIGReferenceList* refs = m_signature->getReferenceList();\r
+        //while (refs && refs->getSize())\r
+        //    delete refs->removeReference(0);\r
         m_reference->createReferences(m_signature);\r
         \r
         log.debug("computing signature");\r
@@ -401,49 +392,6 @@ XMLObject* XMLSecSignatureImpl::unmarshall(DOMElement* element, bool bindDocumen
     return this;\r
 }\r
 \r
-void XMLSecSignatureImpl::registerValidator(Validator* validator)\r
-{\r
-    m_validators.push_back(validator);\r
-}\r
-\r
-void XMLSecSignatureImpl::deregisterValidator(Validator* validator)\r
-{\r
-    for (vector<Validator*>::iterator i=m_validators.begin(); i!=m_validators.end(); i++) {\r
-        if ((*i)==validator) {\r
-            m_validators.erase(i);\r
-            return;\r
-        }\r
-    }\r
-}\r
-\r
-void XMLSecSignatureImpl::deregisterAll()\r
-{\r
-    for_each(m_validators.begin(),m_validators.end(),cleanup<Validator>());\r
-    m_validators.clear();\r
-}\r
-\r
-class _validate : public binary_function<const XMLObject*,bool,void> {\r
-public:\r
-    void operator()(const XMLObject* obj, bool propagate) const {\r
-        const ValidatingXMLObject* val = dynamic_cast<const ValidatingXMLObject*>(obj);\r
-        if (val) {\r
-            val->validate(propagate);\r
-        }\r
-    }\r
-};\r
-\r
-void XMLSecSignatureImpl::validate(bool validateDescendants) const\r
-{\r
-    for_each(\r
-        m_validators.begin(),m_validators.end(),\r
-        bind2nd(mem_fun<void,Validator,const XMLObject*>(&Validator::validate),this)\r
-        );\r
-    \r
-    if (validateDescendants && m_keyInfo) {\r
-        m_keyInfo->validate(validateDescendants);\r
-    }\r
-}\r
-\r
 Signature* SignatureBuilder::buildObject(\r
     const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType\r
     ) const\r