handler/impl/AssertionLookup.cpp \
handler/impl/ChainingLogoutInitiator.cpp \
handler/impl/ChainingSessionInitiator.cpp \
+ handler/impl/CookieSessionInitiator.cpp \
handler/impl/FormSessionInitiator.cpp \
handler/impl/LocalLogoutInitiator.cpp \
handler/impl/LogoutHandler.cpp \
/** SessionInitiator that uses HTML form submission from the user. */
#define FORM_SESSION_INITIATOR "Form"
+
+ /** SessionInitiator that reads the CDC. */
+ #define COOKIE_SESSION_INITIATOR "Cookie"
};
#endif /* __shibsp_initiator_h__ */
--- /dev/null
+/*
+ * Copyright 2001-2007 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * CookieSessionInitiator.cpp
+ *
+ * Cookie-based IdP discovery.
+ */
+
+#include "internal.h"
+#include "Application.h"
+#include "exceptions.h"
+#include "SPRequest.h"
+#include "handler/AbstractHandler.h"
+#include "handler/SessionInitiator.h"
+
+#ifndef SHIBSP_LITE
+# include <saml/util/CommonDomainCookie.h>
+#else
+# include "lite/CommonDomainCookie.h"
+#endif
+
+#include <xmltooling/XMLToolingConfig.h>
+#include <xmltooling/util/URLEncoder.h>
+
+using namespace shibsp;
+using namespace opensaml;
+using namespace xmltooling;
+using namespace std;
+
+namespace shibsp {
+
+#if defined (_MSC_VER)
+ #pragma warning( push )
+ #pragma warning( disable : 4250 )
+#endif
+
+ class SHIBSP_DLLLOCAL CookieSessionInitiator : public SessionInitiator, public AbstractHandler
+ {
+ public:
+ CookieSessionInitiator(const DOMElement* e, const char* appId)
+ : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".SessionInitiator.Cookie")), m_followMultiple(getBool("followMultiple").second) {
+ }
+ virtual ~CookieSessionInitiator() {}
+
+ pair<bool,long> run(SPRequest& request, string& entityID, bool isHandler=true) const;
+
+ private:
+ bool m_followMultiple;
+ };
+
+#if defined (_MSC_VER)
+ #pragma warning( pop )
+#endif
+
+ SessionInitiator* SHIBSP_DLLLOCAL CookieSessionInitiatorFactory(const pair<const DOMElement*,const char*>& p)
+ {
+ return new CookieSessionInitiator(p.first, p.second);
+ }
+
+};
+
+pair<bool,long> CookieSessionInitiator::run(SPRequest& request, string& entityID, bool isHandler) const
+{
+ // The IdP CANNOT be specified for us to run.
+ if (!entityID.empty())
+ return make_pair(false,0L);
+
+ // If there's no entityID yet, we can check for cookie processing.
+ CommonDomainCookie cdc(request.getCookie(CommonDomainCookie::CDCName));
+ if ((m_followMultiple && cdc.get().size() > 0) || (!m_followMultiple && cdc.get().size() == 1)) {
+ entityID = cdc.get().back();
+ m_log.info("set entityID (%s) from IdP history cookie", entityID.c_str());
+ }
+
+ return make_pair(false,0L);
+}
{
string target;
const char* option;
- bool isPassive=false;
const Application& app=request.getApplication();
if (isHandler) {
option = request.getParameter("target");
if (option)
target = option;
- recoverRelayState(request.getApplication(), request, request, target, false);
+ recoverRelayState(app, request, request, target, false);
}
else {
// We're running as a "virtual handler" from within the filter.
if (option)
target = option;
}
- preserveRelayState(request.getApplication(), request, target);
+ preserveRelayState(app, request, target);
request.setContentType("text/html");
request.setResponseHeader("Expires","01-Jan-1997 12:00:00 GMT");
throw ConfigurationException("Unable to access HTML template ($1).", params(1, m_template));
TemplateParameters tp;
tp.m_request = &request;
- tp.setPropertySet(request.getApplication().getPropertySet("Errors"));
+ tp.setPropertySet(app.getPropertySet("Errors"));
tp.m_map["action"] = returnURL;
if (!target.empty())
tp.m_map["target"] = target;
SHIBSP_DLLLOCAL PluginManager< SessionInitiator,string,pair<const DOMElement*,const char*> >::Factory SAMLDSSessionInitiatorFactory;
SHIBSP_DLLLOCAL PluginManager< SessionInitiator,string,pair<const DOMElement*,const char*> >::Factory TransformSessionInitiatorFactory;
SHIBSP_DLLLOCAL PluginManager< SessionInitiator,string,pair<const DOMElement*,const char*> >::Factory FormSessionInitiatorFactory;
+ SHIBSP_DLLLOCAL PluginManager< SessionInitiator,string,pair<const DOMElement*,const char*> >::Factory CookieSessionInitiatorFactory;
};
void SHIBSP_API shibsp::registerSessionInitiators()
conf.SessionInitiatorManager.registerFactory(WAYF_SESSION_INITIATOR, WAYFSessionInitiatorFactory);
conf.SessionInitiatorManager.registerFactory(TRANSFORM_SESSION_INITIATOR, TransformSessionInitiatorFactory);
conf.SessionInitiatorManager.registerFactory(FORM_SESSION_INITIATOR, FormSessionInitiatorFactory);
+ conf.SessionInitiatorManager.registerFactory(COOKIE_SESSION_INITIATOR, CookieSessionInitiatorFactory);
}
pair<bool,long> SessionInitiator::run(SPRequest& request, bool isHandler) const
static SHIBSP_DLLLOCAL TransformSINodeFilter g_TSINFilter;
#ifndef SHIBSP_LITE
- static const XMLCh alwaysRun[] = UNICODE_LITERAL_9(a,l,w,a,y,s,R,u,n);
static const XMLCh force[] = UNICODE_LITERAL_5(f,o,r,c,e);
static const XMLCh match[] = UNICODE_LITERAL_5(m,a,t,c,h);
static const XMLCh Regex[] = UNICODE_LITERAL_5(R,e,g,e,x);
>\r
</File>\r
<File\r
+ RelativePath=".\handler\impl\CookieSessionInitiator.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\handler\impl\FormSessionInitiator.cpp"\r
>\r
</File>\r
>\r
</File>\r
<File\r
+ RelativePath=".\handler\impl\CookieSessionInitiator.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\handler\impl\FormSessionInitiator.cpp"\r
>\r
</File>\r