First cut at signing support.
[shibboleth/cpp-xmltooling.git] / xmltooling / io / Marshaller.h
index 0beb061..ba334c4 100644 (file)
 #define __xmltooling_marshaller_h__\r
 \r
 #include <map>\r
+#include <vector>\r
 #include <xercesc/dom/DOM.hpp>\r
 #include <xmltooling/XMLObject.h>\r
+#ifndef XMLTOOLING_NO_XMLSEC\r
+    #include <xmltooling/signature/Signature.h>\r
+#endif\r
 \r
 using namespace xercesc;\r
 \r
@@ -37,6 +41,27 @@ using namespace xercesc;
 namespace xmltooling {\r
 \r
     /**\r
+     * Supplies additional information to the marshalling process.\r
+     * Currently this only consists of signature related information.\r
+     */\r
+    class XMLTOOL_API MarshallingContext\r
+    {\r
+        MAKE_NONCOPYABLE(MarshallingContext);\r
+    public:\r
+        MarshallingContext() {}\r
+        ~MarshallingContext() {}\r
+\r
+#ifndef XMLTOOLING_NO_XMLSEC\r
+        MarshallingContext(Signature* sig, const SigningContext* ctx) {\r
+            m_signingContexts.push_back(std::make_pair(sig,ctx));\r
+        }\r
+        \r
+        /** Array of signing contexts, keyed off of the associated Signature */\r
+        std::vector< std::pair<Signature*,const SigningContext*> > m_signingContexts;\r
+#endif\r
+    };\r
+\r
+    /**\r
      * Marshallers are used to marshall an XMLObject into a W3C DOM element.\r
      */\r
     class XMLTOOL_API Marshaller\r
@@ -55,11 +80,14 @@ namespace xmltooling {
          * marshalled, unless an existing DOM can be reused without creating a new document. \r
          * \r
          * @param xmlObject the object to marshall\r
-         * @param document the DOM document the marshalled element will be placed in, or NULL\r
+         * @param document  the DOM document the marshalled element will be placed in, or NULL\r
+         * @param ctx       optional marshalling context\r
          * @return the DOM element representing this XMLObject\r
+         * \r
          * @throws MarshallingException thrown if there is a problem marshalling the given object\r
+         * @throws SignatureException thrown if a problem occurs during signature creation \r
          */\r
-        virtual DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document=NULL) const=0;\r
+        virtual DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const=0;\r
         \r
         /**\r
          * Marshall the given XMLObject and append it as a child of the given parent element.\r
@@ -69,10 +97,13 @@ namespace xmltooling {
          * \r
          * @param xmlObject the XMLObject to be marshalled\r
          * @param parentElement the parent element to append the resulting DOM tree\r
+         * @param ctx       optional marshalling context\r
          * @return the marshalled element tree\r
+\r
          * @throws MarshallingException thrown if the given XMLObject can not be marshalled.\r
+         * @throws SignatureException thrown if a problem occurs during signature creation \r
          */\r
-        virtual DOMElement* marshall(XMLObject* xmlObject, DOMElement* parentElement) const=0;\r
+        virtual DOMElement* marshall(XMLObject* xmlObject, DOMElement* parentElement, MarshallingContext* ctx=NULL) const=0;\r
 \r
         /**\r
          * Retrieves a Marshaller using the key it was registered with.\r