From 7ea27969e97416995f4c8759df8849397bc98ed4 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Sun, 24 Oct 2010 00:09:33 +0000 Subject: [PATCH] Remote additional headers based on plugin requirements. --- shibsp/handler/RemotedHandler.h | 13 ++++++++++++- shibsp/handler/impl/RemotedHandler.cpp | 22 ++++++++++++++++++---- shibsp/impl/StorageServiceSessionCache.cpp | 3 +++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/shibsp/handler/RemotedHandler.h b/shibsp/handler/RemotedHandler.h index 3511af6..ef1a25c 100644 --- a/shibsp/handler/RemotedHandler.h +++ b/shibsp/handler/RemotedHandler.h @@ -26,6 +26,8 @@ #include #include +#include + namespace xmltooling { class XMLTOOL_API HTTPRequest; class XMLTOOL_API HTTPResponse; @@ -38,9 +40,18 @@ namespace shibsp { */ class SHIBSP_API RemotedHandler : public virtual Handler, public Remoted { + static std::set m_remotedHeaders; + public: virtual ~RemotedHandler(); + /** + * Ensures that a request header will be remoted. + * + * @param header name of request header to remote + */ + static void addRemotedHeader(const char* header); + protected: RemotedHandler(); @@ -56,7 +67,7 @@ namespace shibsp { * to remote the request information. * * @param request an SPRequest to remote - * @param headers array of request headers to copy to remote request + * @param headers array of additional request headers to copy to remote request * @param certs true iff client certificates should be available for the remote request * @return the input dataflow object */ diff --git a/shibsp/handler/impl/RemotedHandler.cpp b/shibsp/handler/impl/RemotedHandler.cpp index 765d09a..272f667 100644 --- a/shibsp/handler/impl/RemotedHandler.cpp +++ b/shibsp/handler/impl/RemotedHandler.cpp @@ -285,6 +285,8 @@ void RemotedHandler::setAddress(const char* address) } } +set RemotedHandler::m_remotedHeaders; + RemotedHandler::RemotedHandler() { } @@ -297,6 +299,11 @@ RemotedHandler::~RemotedHandler() listener->unregListener(m_address.c_str(),this); } +void RemotedHandler::addRemotedHeader(const char* header) +{ + m_remotedHeaders.insert(header); +} + DDF RemotedHandler::wrap(const SPRequest& request, const vector* headers, bool certs) const { DDF in = DDF(m_address.c_str()).structure(); @@ -314,13 +321,20 @@ DDF RemotedHandler::wrap(const SPRequest& request, const vector* headers in.addmember("url").unsafe_string(request.getRequestURL()); in.addmember("query").string(request.getQueryString()); - if (headers) { + if (headers || !m_remotedHeaders.empty()) { string hdr; DDF hin = in.addmember("headers").structure(); - for (vector::const_iterator h = headers->begin(); h!=headers->end(); ++h) { - hdr = request.getHeader(h->c_str()); + if (headers) { + for (vector::const_iterator h = headers->begin(); h!=headers->end(); ++h) { + hdr = request.getHeader(h->c_str()); + if (!hdr.empty()) + hin.addmember(h->c_str()).unsafe_string(hdr.c_str()); + } + } + for (set::const_iterator hh = m_remotedHeaders.begin(); hh != m_remotedHeaders.end(); ++hh) { + hdr = request.getHeader(hh->c_str()); if (!hdr.empty()) - hin.addmember(h->c_str()).unsafe_string(hdr.c_str()); + hin.addmember(hh->c_str()).unsafe_string(hdr.c_str()); } } diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp index 8f13d1b..764f057 100644 --- a/shibsp/impl/StorageServiceSessionCache.cpp +++ b/shibsp/impl/StorageServiceSessionCache.cpp @@ -35,6 +35,7 @@ #include "SessionCacheEx.h" #include "TransactionLog.h" #include "attribute/Attribute.h" +#include "handler/RemotedHandler.h" #include "remoting/ListenerService.h" #include "util/SPConstants.h" @@ -756,6 +757,8 @@ SSCache::SSCache(const DOMElement* e) if (inproc) m_inprocTimeout = XMLHelper::getAttrInt(e, 900, inprocTimeout); m_inboundHeader = XMLHelper::getAttrString(e, nullptr, inboundHeader); + if (!m_inboundHeader.empty()) + RemotedHandler::addRemotedHeader(m_inboundHeader.c_str()); m_outboundHeader = XMLHelper::getAttrString(e, nullptr, outboundHeader); #ifndef SHIBSP_LITE -- 2.1.4