use of org.eclipse.jetty.server.session.Session in project blade by biezhi.
the class LoginAuthenticator method renewSession.
/* ------------------------------------------------------------ */
/** Change the session id.
* The session is changed to a new instance with a new ID if and only if:<ul>
* <li>A session exists.
* <li>The {@link AuthConfiguration#isSessionRenewedOnAuthentication()} returns true.
* <li>The session ID has been given to unauthenticated responses
* </ul>
* @param request the request
* @param response the response
* @return The new session.
*/
protected HttpSession renewSession(HttpServletRequest request, HttpServletResponse response) {
HttpSession httpSession = request.getSession(false);
if (_renewSession && httpSession != null) {
synchronized (httpSession) {
//(indicated by SESSION_SECURED not being set on the session) then we should change id
if (httpSession.getAttribute(Session.SESSION_CREATED_SECURE) != Boolean.TRUE) {
if (httpSession instanceof Session) {
Session s = (Session) httpSession;
String oldId = s.getId();
s.renewId(request);
s.setAttribute(Session.SESSION_CREATED_SECURE, Boolean.TRUE);
if (s.isIdChanged() && response != null && (response instanceof Response))
((Response) response).addCookie(s.getSessionHandler().getSessionCookie(s, request.getContextPath(), request.isSecure()));
LOG.debug("renew {}->{}", oldId, s.getId());
} else
LOG.warn("Unable to renew session " + httpSession);
return httpSession;
}
}
}
return httpSession;
}
use of org.eclipse.jetty.server.session.Session in project jetty.project by eclipse.
the class LoginAuthenticator method renewSession.
/* ------------------------------------------------------------ */
/** Change the session id.
* The session is changed to a new instance with a new ID if and only if:<ul>
* <li>A session exists.
* <li>The {@link org.eclipse.jetty.security.Authenticator.AuthConfiguration#isSessionRenewedOnAuthentication()} returns true.
* <li>The session ID has been given to unauthenticated responses
* </ul>
* @param request the request
* @param response the response
* @return The new session.
*/
protected HttpSession renewSession(HttpServletRequest request, HttpServletResponse response) {
HttpSession httpSession = request.getSession(false);
if (_renewSession && httpSession != null) {
synchronized (httpSession) {
//(indicated by SESSION_SECURED not being set on the session) then we should change id
if (httpSession.getAttribute(Session.SESSION_CREATED_SECURE) != Boolean.TRUE) {
if (httpSession instanceof Session) {
Session s = (Session) httpSession;
String oldId = s.getId();
s.renewId(request);
s.setAttribute(Session.SESSION_CREATED_SECURE, Boolean.TRUE);
if (s.isIdChanged() && response != null && (response instanceof Response))
((Response) response).addCookie(s.getSessionHandler().getSessionCookie(s, request.getContextPath(), request.isSecure()));
LOG.debug("renew {}->{}", oldId, s.getId());
} else
LOG.warn("Unable to renew session " + httpSession);
return httpSession;
}
}
}
return httpSession;
}
use of org.eclipse.jetty.server.session.Session in project jetty.project by eclipse.
the class Request method changeSessionId.
/* ------------------------------------------------------------ */
@Override
public String changeSessionId() {
HttpSession session = getSession(false);
if (session == null)
throw new IllegalStateException("No session");
if (session instanceof Session) {
Session s = ((Session) session);
s.renewId(this);
if (getRemoteUser() != null)
s.setAttribute(Session.SESSION_CREATED_SECURE, Boolean.TRUE);
if (s.isIdChanged())
_channel.getResponse().addCookie(_sessionHandler.getSessionCookie(s, getContextPath(), isSecure()));
}
return session.getId();
}
Aggregations