Convert logging to log4shib via compile time switch.
[shibboleth/cpp-sp.git] / shibsp / handler / AbstractHandler.h
index 3fda7f8..7893b13 100644 (file)
 #include <shibsp/handler/Handler.h>
 #include <shibsp/util/DOMPropertySet.h>
 
-#include <log4cpp/Category.hh>
-
+#ifndef SHIBSP_LITE
+# include <saml/binding/MessageEncoder.h>
+# include <saml/saml2/core/Protocols.h>
+#endif
+#include <xmltooling/logging.h>
 #include <xmltooling/XMLObject.h>
 #include <xmltooling/io/HTTPRequest.h>
 #include <xmltooling/io/HTTPResponse.h>
@@ -57,7 +60,7 @@ namespace shibsp {
          */
         AbstractHandler(
             const xercesc::DOMElement* e,
-            log4cpp::Category& log,
+            xmltooling::logging::Category& log,
             xercesc::DOMNodeFilter* filter=NULL,
             const std::map<std::string,std::string>* remapper=NULL
             );
@@ -69,9 +72,51 @@ namespace shibsp {
          * 
          * <p>The base class version understands SAML 1.x and SAML 2.0 responses.
          * 
-         * @param response      a response message of some known protocol
+         * @param response  a response message of some known protocol
+         * @param role      issuer of message
+         */
+        virtual void checkError(
+            const xmltooling::XMLObject* response,
+            const opensaml::saml2md::RoleDescriptor* role=NULL
+            ) const;
+
+        /**
+         * Prepares Status information in a SAML 2.0 response.
+         * 
+         * @param response  a SAML 2.0 response message
+         * @param code      SAML status code
+         * @param ex        optional message to pass back
          */
-        virtual void checkError(const xmltooling::XMLObject* response) const;
+        void fillStatus(
+            opensaml::saml2p::StatusResponseType& response, const XMLCh* code, const XMLCh* subcode=NULL, const char* msg=NULL
+            ) const;
+
+        /**
+         * Encodes and sends SAML 2.0 message, optionally signing it in the process.
+         * If the method returns, the message MUST NOT be freed by the caller.
+         *
+         * @param encoder           the MessageEncoder to use
+         * @param msg               the message to send
+         * @param relayState        any RelayState to include with the message
+         * @param destination       location to send message, if not a backchannel response
+         * @param role              recipient of message, if known
+         * @param application       the Application sending the message
+         * @param httpResponse      channel for sending message
+         * @param signingOption     name of property to lookup controlling signing
+         * @param signIfPossible    true iff signing should be attempted regardless of property
+         * @return  the result of sending the message using the encoder
+         */
+        long sendMessage(
+            const opensaml::MessageEncoder& encoder,
+            xmltooling::XMLObject* msg,
+            const char* relayState,
+            const char* destination,
+            const opensaml::saml2md::RoleDescriptor* role,
+            const Application& application,
+            xmltooling::HTTPResponse& httpResponse,
+            const char* signingOption,
+            bool signIfPossible=false
+            ) const;
 #endif
 
         /**
@@ -104,8 +149,11 @@ namespace shibsp {
             ) const;
         
         /** Logging object. */
-        log4cpp::Category& m_log;
+        xmltooling::logging::Category& m_log;
         
+        /** Configuration namespace for custom properties. */
+        xmltooling::auto_ptr_char m_configNS;
+
     public:
         virtual ~AbstractHandler() {}
     };