*/
protected void addIdPSessionCookieToResponse(HttpServletRequest request, HttpServletResponse response,
Session userSession) {
- Cookie sessionCookie = new Cookie(IDP_SESSION_COOKIE_NAME, userSession.getSessionID());
- sessionCookie.setDomain(request.getLocalName());
- sessionCookie.setPath(request.getContextPath());
- sessionCookie.setSecure(false);
+ if (userSession == null) {
+ userSession = (Session) request.getAttribute(Session.HTTP_SESSION_BINDING_ATTRIBUTE);
+ }
+
+ if (userSession != null) {
+ Cookie sessionCookie = new Cookie(IDP_SESSION_COOKIE_NAME, userSession.getSessionID());
+ sessionCookie.setDomain(request.getLocalName());
+ sessionCookie.setPath(request.getContextPath());
+ sessionCookie.setSecure(false);
- int maxAge = (int) (userSession.getInactivityTimeout() / 1000);
- sessionCookie.setMaxAge(maxAge);
+ int maxAge = (int) (userSession.getInactivityTimeout() / 1000);
+ sessionCookie.setMaxAge(maxAge);
- response.addCookie(sessionCookie);
+ response.addCookie(sessionCookie);
+ }
}
}
\ No newline at end of file
*/
public interface Session extends edu.internet2.middleware.shibboleth.common.session.Session {
- /** Name of the HttpSession attribute to which a users IdP session is bound. */
+ /** Name of the HTTP request attribute to which a users IdP session is bound. */
public static final String HTTP_SESSION_BINDING_ATTRIBUTE = "ShibbolethIdPSession";
/**