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 { ...@@ -160,20 +160,9 @@ public class AuthenticatedDispatcher implements Dispatcher {
// authenticated! // authenticated!
try { try {
//kill session if not secured via SSL //kill session if not secured via SSL
if (forceSecureAccessOnly && !request.isSecure()) { if (forceSecureAccessOnly && !request.isSecure()) {
SessionInfo sessionInfo = usess.getSessionInfo(); invalidateSession(usess);
if (sessionInfo!=null) {
HttpSession session = sessionInfo.getSession();
if (session!=null) {
try{
session.invalidate();
} catch(IllegalStateException ise) {
// thrown when session already invalidated. fine. ignore.
}
}
}
redirectToDefaultDispatcher(request, response); redirectToDefaultDispatcher(request, response);
return; return;
} }
...@@ -267,7 +256,14 @@ public class AuthenticatedDispatcher implements Dispatcher { ...@@ -267,7 +256,14 @@ public class AuthenticatedDispatcher implements Dispatcher {
} }
private void processValidDispatchURI(UserRequest ureq, UserSession usess, HttpServletRequest request, HttpServletResponse response) { 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); ws.disposeClosedWindows(ureq);
Window window = ws.getWindow(ureq); Window window = ws.getWindow(ureq);
if (window == null) { if (window == null) {
...@@ -283,6 +279,20 @@ public class AuthenticatedDispatcher implements Dispatcher { ...@@ -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) { private void redirectToDefaultDispatcher(HttpServletRequest request, HttpServletResponse response) {
if(ServletUtil.acceptJson(request)) { if(ServletUtil.acceptJson(request)) {
try { 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