/*
- * 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.
#include "Application.h"
#include "ServiceProvider.h"
#include "SessionCache.h"
+#include "SPRequest.h"
#include "handler/AbstractHandler.h"
-#include "handler/LogoutHandler.h"
+#include "handler/LogoutInitiator.h"
using namespace shibsp;
using namespace xmltooling;
-using namespace log4cpp;
using namespace std;
namespace shibsp {
#pragma warning( disable : 4250 )
#endif
- class SHIBSP_DLLLOCAL LocalLogoutInitiator : public AbstractHandler, public LogoutHandler
+ class SHIBSP_DLLLOCAL LocalLogoutInitiator : public AbstractHandler, public LogoutInitiator
{
public:
LocalLogoutInitiator(const DOMElement* e, const char* appId);
virtual ~LocalLogoutInitiator() {}
+ void setParent(const PropertySet* parent);
pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
private:
- vector<Handler*> m_handlers;
+ string m_appId;
};
#if defined (_MSC_VER)
};
LocalLogoutInitiator::LocalLogoutInitiator(const DOMElement* e, const char* appId)
- : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".LogoutInitiator"))
+ : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".LogoutInitiator.Local")), m_appId(appId)
{
pair<bool,const char*> loc = getString("Location");
if (loc.first) {
}
}
+void LocalLogoutInitiator::setParent(const PropertySet* parent)
+{
+ DOMPropertySet::setParent(parent);
+ pair<bool,const char*> loc = getString("Location");
+ if (loc.first) {
+ string address = m_appId + loc.second + "::run::LocalLI";
+ setAddress(address.c_str());
+ }
+ else {
+ m_log.warn("no Location property in Local LogoutInitiator (or parent), can't register as remoted handler");
+ }
+}
+
pair<bool,long> LocalLogoutInitiator::run(SPRequest& request, bool isHandler) const
{
// Defer to base class first.
if (ret.first)
return ret;
- // Get session ID from cookie.
- pair<string,const char*> shib_cookie = request.getApplication().getCookieNameProps("_shibsession_");
- const char* session_id = request.getCookie(shib_cookie.first.c_str());
- if (session_id)
- request.getServiceProvider().getSessionCache()->remove(session_id, request.getApplication());
+ const Application& app = request.getApplication();
+ string session_id = app.getServiceProvider().getSessionCache()->active(app, request);
+ if (!session_id.empty()) {
+ // Do back channel notification.
+ vector<string> sessions(1, session_id);
+ bool result = notifyBackChannel(app, request.getRequestURL(), sessions, true);
+ app.getServiceProvider().getSessionCache()->remove(app, request, &request);
+ if (!result)
+ return sendLogoutPage(app, request, request, "partial");
+ }
- return sendLogoutPage(request.getApplication(), request, true, "Logout was successful.");
+ // Route back to return location specified, or use the local template.
+ const char* dest = request.getParameter("return");
+ if (dest)
+ return make_pair(true, request.sendRedirect(dest));
+ return sendLogoutPage(app, request, request, "local");
}