Merged marshalling/unmarshalling methods into core interface.
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / impl / XMLSecSignature.h
index c196be5..d97fd81 100644 (file)
@@ -15,7 +15,7 @@
  */\r
 \r
 /**\r
- * @file XMLSecSignature.h\r
+ * XMLSecSignature.h\r
  * \r
  * Signature classes for XMLSec-based signature-handling\r
  */\r
 \r
 namespace xmltooling {\r
 \r
-    /**\r
-     * XMLObject representing XML Digital Signature, version 20020212, Signature element.\r
-     * Manages an Apache XML Signature object and the associated DOM.  \r
-     */\r
     class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
     {\r
     public:\r
@@ -51,6 +47,10 @@ namespace xmltooling {
         void releaseDOM();\r
         XMLObject* clone() const;\r
 \r
+        DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
+        DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
+        XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
+        \r
         // Getters\r
         const XMLCh* getCanonicalizationMethod() const { return m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC; }\r
         const XMLCh* getSignatureAlgorithm() const { return m_sm ? m_sm : DSIGConstants::s_unicodeStrURIRSA_SHA1; }\r
@@ -60,69 +60,23 @@ namespace xmltooling {
         void setCanonicalizationMethod(const XMLCh* c14n) { m_c14n = prepareForAssignment(m_c14n,c14n); }\r
         void setSignatureAlgorithm(const XMLCh* sm) { m_sm = prepareForAssignment(m_sm,sm); }\r
 \r
-        void sign(const SigningContext* ctx);\r
+        void sign(const SigningContext& ctx);\r
+        void verify(const VerifyingContext& ctx) const;\r
 \r
     private:\r
-        DSIGSignature* m_signature;\r
+        mutable DSIGSignature* m_signature;\r
         XMLCh* m_c14n;\r
         XMLCh* m_sm;\r
-\r
-        friend class XMLTOOL_DLLLOCAL XMLSecSignatureMarshaller;\r
-        friend class XMLTOOL_DLLLOCAL XMLSecSignatureUnmarshaller;\r
     };\r
 \r
-    /**\r
-     * Factory for XMLSecSignatureImpl objects\r
-     */\r
     class XMLTOOL_DLLLOCAL XMLSecSignatureBuilder : public virtual XMLObjectBuilder\r
     {\r
     public:\r
-        /**\r
-         * @see XMLObjectBuilder::buildObject()\r
-         */\r
-        XMLObject* buildObject() const {\r
+        XMLObject* buildObject(const DOMElement* e=NULL) const {\r
             return new XMLSecSignatureImpl();\r
         }\r
     };\r
 \r
-    /**\r
-     * Marshaller for XMLSecSignatureImpl objects\r
-     */\r
-    class XMLTOOL_DLLLOCAL XMLSecSignatureMarshaller : public virtual Marshaller\r
-    {\r
-    public:\r
-        /**\r
-         * @see Marshaller::marshall(XMLObject*,DOMDocument*, const MarshallingContext*)\r
-         */\r
-        DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
-\r
-        /**\r
-         * @see Marshaller::marshall(XMLObject*,DOMElement*, const MarshallingContext* ctx)\r
-         */\r
-        DOMElement* marshall(XMLObject* xmlObject, DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
-        \r
-    protected:\r
-        void setDocumentElement(DOMDocument* document, DOMElement* element) const {\r
-            DOMElement* documentRoot = document->getDocumentElement();\r
-            if (documentRoot)\r
-                document->replaceChild(documentRoot, element);\r
-            else\r
-                document->appendChild(element);\r
-        }\r
-    };\r
-\r
-    /**\r
-     * Unmarshaller for XMLSecSignatureImpl objects\r
-     */\r
-    class XMLTOOL_DLLLOCAL XMLSecSignatureUnmarshaller : public virtual Unmarshaller\r
-    {\r
-    public:\r
-        /**\r
-         * @see Unmarshaller::unmarshall()\r
-         */\r
-        XMLObject* unmarshall(DOMElement* element, bool bindDocument=false) const;\r
-    };\r
-\r
 };\r
 \r
 #if defined (_MSC_VER)\r