Skip to content
Snippets Groups Projects
Commit e57a5142 authored by srosse's avatar srosse
Browse files

OO-5232: catch a common place for invalidate session exceptions

parent 4e04e7bc
No related branches found
No related tags found
No related merge requests found
......@@ -160,20 +160,9 @@ public class AuthenticatedDispatcher implements Dispatcher {
// authenticated!
try {
//kill session if not secured via SSL
if (forceSecureAccessOnly && !request.isSecure()) {
SessionInfo sessionInfo = usess.getSessionInfo();
if (sessionInfo!=null) {
HttpSession session = sessionInfo.getSession();
if (session!=null) {
try{
session.invalidate();
} catch(IllegalStateException ise) {
// thrown when session already invalidated. fine. ignore.
}
}
}
invalidateSession(usess);
redirectToDefaultDispatcher(request, response);
return;
}
......@@ -267,7 +256,14 @@ public class AuthenticatedDispatcher implements Dispatcher {
}
private void processValidDispatchURI(UserRequest ureq, UserSession usess, HttpServletRequest request, HttpServletResponse response) {
Windows ws = Windows.getWindows(ureq);
Windows ws;
try {
ws = Windows.getWindows(ureq);
} catch (IllegalStateException e) {
log.error("", e);// session was invalidate, return to login screen
redirectToDefaultDispatcher(request, response);
return;
}
ws.disposeClosedWindows(ureq);
Window window = ws.getWindow(ureq);
if (window == null) {
......@@ -283,6 +279,20 @@ public class AuthenticatedDispatcher implements Dispatcher {
}
}
private void invalidateSession(UserSession usess) {
SessionInfo sessionInfo = usess.getSessionInfo();
if (sessionInfo!=null) {
HttpSession session = sessionInfo.getSession();
if (session!=null) {
try{
session.invalidate();
} catch(IllegalStateException ise) {
// thrown when session already invalidated. fine. ignore.
}
}
}
}
private void redirectToDefaultDispatcher(HttpServletRequest request, HttpServletResponse response) {
if(ServletUtil.acceptJson(request)) {
try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment