*/
#include "internal.h"
+#include "Application.h"
#include "exceptions.h"
#include "ServiceProvider.h"
#include "handler/RemotedHandler.h"
#include <algorithm>
-#include <log4cpp/Category.hh>
#include <xmltooling/unicode.h>
#ifndef SHIBSP_LITE
-# include <saml/util/CGIParser.h>
+# include "util/CGIParser.h"
# include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
# include <xsec/enc/XSECCryptoException.hpp>
# include <xsec/framework/XSECException.hpp>
using namespace shibsp;
using namespace opensaml;
using namespace xmltooling;
-using namespace log4cpp;
using namespace xercesc;
using namespace std;
const std::vector<XSECCryptoX509*>& RemotedRequest::getClientCertificates() const
{
if (m_certs.empty()) {
- DDF cert = m_input["certificates"].first();
- while (cert.isstring()) {
+ DDF certs = m_input["certificates"];
+ DDF cert = certs.first();
+ while (cert.string()) {
try {
auto_ptr<XSECCryptoX509> x509(XSECPlatformUtils::g_cryptoProvider->X509());
- x509->loadX509Base64Bin(cert.string(), cert.strlen());
+ if (strstr(cert.string(), "BEGIN"))
+ x509->loadX509PEM(cert.string(), cert.strlen());
+ else
+ x509->loadX509Base64Bin(cert.string(), cert.strlen());
m_certs.push_back(x509.release());
}
catch(XSECException& e) {
catch(XSECCryptoException& e) {
Category::getInstance(SHIBSP_LOGCAT".SPRequest").error("XML-Security exception loading client certificate: %s", e.getMsg());
}
- cert = cert.next();
+ cert = certs.next();
}
}
return m_certs;
throw ConfigurationException("Cannot register a remoting address twice for the same Handler.");
m_address = address;
SPConfig& conf = SPConfig::getConfig();
- if (conf.isEnabled(SPConfig::OutOfProcess)) {
+ if (!conf.isEnabled(SPConfig::InProcess)) {
ListenerService* listener = conf.getServiceProvider()->getListenerService(false);
if (listener)
listener->regListener(m_address.c_str(),this);
{
SPConfig& conf = SPConfig::getConfig();
ListenerService* listener=conf.getServiceProvider()->getListenerService(false);
- if (listener && conf.isEnabled(SPConfig::OutOfProcess))
+ if (listener && conf.isEnabled(SPConfig::OutOfProcess) && !conf.isEnabled(SPConfig::InProcess))
listener->unregListener(m_address.c_str(),this);
}
DDF RemotedHandler::wrap(const SPRequest& request, const vector<string>* headers, bool certs) const
{
DDF in = DDF(m_address.c_str()).structure();
+ in.addmember("application_id").string(request.getApplication().getId());
in.addmember("scheme").string(request.getScheme());
in.addmember("hostname").string(request.getHostname());
in.addmember("port").integer(request.getPort());
pair<bool,long> RemotedHandler::unwrap(SPRequest& request, DDF& out) const
{
DDF h = out["headers"];
- h = h.first();
- while (h.isstring()) {
- request.setResponseHeader(h.name(), h.string());
- h = h.next();
+ DDF hdr = h.first();
+ while (hdr.isstring()) {
+#ifdef HAVE_STRCASECMP
+ if (!strcasecmp(hdr.name(), "Content-Type"))
+#else
+ if (!stricmp(hdr.name(), "Content-Type"))
+#endif
+ request.setContentType(hdr.string());
+ else
+ request.setResponseHeader(hdr.name(), hdr.string());
+ hdr = h.next();
}
h = out["redirect"];
if (h.isstring())
istringstream s(h["data"].string());
return make_pair(true, request.sendResponse(s, h["status"].integer()));
}
- return make_pair(false,0);
+ return make_pair(false,0L);
}
HTTPRequest* RemotedHandler::getRequest(DDF& in) const