SEC-689: Further tests, logging improvements.
This commit is contained in:
@@ -99,13 +99,16 @@ public class SessionFixationProtectionFilter extends SpringSecurityFilter {
|
||||
/**
|
||||
* Response wrapper to handle the situation where we need to migrate the session after a redirect or sendError.
|
||||
* Similar in function to Martin Algesten's OnRedirectUpdateSessionResponseWrapper used in
|
||||
* HttpSessionContextIntegrationFilter.
|
||||
* HttpSessionContextIntegrationFilter.
|
||||
* <p>
|
||||
* Only used to wrap the response if the conditions are right at the start of the request to potentially
|
||||
* require starting a new session, i.e. that the user isn't authenticated and a session existed to begin with.
|
||||
*/
|
||||
private class SessionFixationProtectionResponseWrapper extends HttpServletResponseWrapper {
|
||||
class SessionFixationProtectionResponseWrapper extends HttpServletResponseWrapper {
|
||||
private HttpServletRequest request;
|
||||
private boolean newSessionStarted;
|
||||
|
||||
public SessionFixationProtectionResponseWrapper(HttpServletResponse response, HttpServletRequest request) {
|
||||
SessionFixationProtectionResponseWrapper(HttpServletResponse response, HttpServletRequest request) {
|
||||
super(response);
|
||||
this.request = request;
|
||||
}
|
||||
@@ -148,9 +151,8 @@ public class SessionFixationProtectionFilter extends SpringSecurityFilter {
|
||||
newSessionStarted = true;
|
||||
}
|
||||
|
||||
private boolean isNewSessionStarted() {
|
||||
boolean isNewSessionStarted() {
|
||||
return newSessionStarted;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public final class SessionUtils {
|
||||
String originalSessionId = session.getId();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalidating session " + (migrateAttributes ? "and" : "without") + " migrating attributes.");
|
||||
logger.debug("Invalidating session with Id '" + originalSessionId +"' " + (migrateAttributes ? "and" : "without") + " migrating attributes.");
|
||||
}
|
||||
|
||||
HashMap attributesToMigrate = null;
|
||||
@@ -55,6 +55,10 @@ public final class SessionUtils {
|
||||
session.invalidate();
|
||||
session = request.getSession(true); // we now have a new session
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Started new session: " + session.getId());
|
||||
}
|
||||
|
||||
if (attributesToMigrate != null) {
|
||||
Iterator iter = attributesToMigrate.entrySet().iterator();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user