Rework POST handling to avoid remoting data if handler doesn't run.
[shibboleth/cpp-sp.git] / shibsp / handler / AbstractHandler.h
index e88ab33..20a480b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 #define __shibsp_abshandler_h__
 
 #include <shibsp/handler/Handler.h>
+#include <shibsp/remoting/ddf.h>
 #include <shibsp/util/DOMPropertySet.h>
 
 #ifndef SHIBSP_LITE
@@ -54,7 +55,8 @@ namespace shibsp {
         /**
          * Constructor
          * 
-         * @param e         DOM element to load as property set. 
+         * @param e         DOM element to load as property set.
+         * @param log       logging category to use
          * @param filter    optional filter controls what child elements to include as nested PropertySets
          * @param remapper  optional map of property rename rules for legacy property support
          */
@@ -83,9 +85,10 @@ namespace shibsp {
         /**
          * Prepares Status information in a SAML 2.0 response.
          * 
-         * @param response  SAML 2.0 response message
+         * @param response  SAML 2.0 response message
          * @param code      SAML status code
-         * @param ex        optional message to pass back
+         * @param subcode   optional SAML substatus code
+         * @param msg       optional message to pass back
          */
         void fillStatus(
             opensaml::saml2p::StatusResponseType& response, const XMLCh* code, const XMLCh* subcode=NULL, const char* msg=NULL
@@ -128,7 +131,9 @@ namespace shibsp {
          * @param response      outgoing HTTP response
          * @param relayState    RelayState token to supply with message
          */
-        virtual void preserveRelayState(const Application& application, xmltooling::HTTPResponse& response, std::string& relayState) const;
+        virtual void preserveRelayState(
+            const Application& application, xmltooling::HTTPResponse& response, std::string& relayState
+            ) const;
 
         /**
          * Implements various mechanisms to recover RelayState,
@@ -139,13 +144,68 @@ namespace shibsp {
          * 
          * @param application   the associated Application
          * @param request       incoming HTTP request
+         * @param response      outgoing HTTP response
          * @param relayState    RelayState token supplied with message
          * @param clear         true iff the token state should be cleared
          */
         virtual void recoverRelayState(
-            const Application& application, xmltooling::HTTPRequest& request, std::string& relayState, bool clear=true
+            const Application& application,
+            const xmltooling::HTTPRequest& request,
+            xmltooling::HTTPResponse& response,
+            std::string& relayState,
+            bool clear=true
             ) const;
         
+        /**
+         * Implements a mechanism to preserve form post data.
+         *
+         * @param application   the associated Application
+         * @param request       incoming HTTP request
+         * @param response      outgoing HTTP response
+         * @param relayState    relay state information attached to current sequence, if any
+         */
+        virtual void preservePostData(
+            const Application& application,
+            const xmltooling::HTTPRequest& request,
+            xmltooling::HTTPResponse& response,
+            const char* relayState
+            ) const;
+
+        /**
+         * Implements storage service and cookie mechanism to recover PostData.
+         *
+         * <p>If a supported mechanism can be identified, the return value will be
+         * the recovered state information.
+         *
+         * @param application   the associated Application
+         * @param request       incoming HTTP request
+         * @param response      outgoing HTTP response
+         * @param relayState    relay state information attached to current sequence, if any
+         * @return  recovered form post data associated with request as a DDF list of string members
+         */
+        virtual DDF recoverPostData(
+            const Application& application,
+            const xmltooling::HTTPRequest& request,
+            xmltooling::HTTPResponse& response,
+            const char* relayState
+            ) const;
+
+        /**
+         * Post a redirect response with post data.
+         * 
+         * @param application   the associated Application
+         * @param response      outgoing HTTP response
+         * @param request       incoming HTTP request
+         * @param url           action url for the form
+         * @param postData      list of parameters to load into the form, as DDF string members
+         */
+        virtual long sendPostResponse(
+            const Application& application,
+            xmltooling::HTTPResponse& httpResponse,
+            const char* url,
+            DDF& postData
+            ) const;
+
         /** Logging object. */
         xmltooling::logging::Category& m_log;
         
@@ -154,6 +214,10 @@ namespace shibsp {
 
     public:
         virtual ~AbstractHandler() {}
+
+    private:
+        std::pair<std::string,const char*> getPostCookieNameProps(const Application& app, const char* relayState) const;
+        DDF getPostData(const Application& application, const xmltooling::HTTPRequest& request) const;
     };
 
 #if defined (_MSC_VER)