public void execute(HttpServletRequest request, HttpServletResponse response, String uriPrefix) {
if (rejectRequest(request, response)) {
return;
}
UserRequest ureq = null;
String referer = request.getHeader("referer");
if(referer != null && referer.indexOf(DispatcherAction.PATH_MAPPED) > -1) {
//TODO:gs may no longer needed as bad rel links are catched in dispatcherAction
//OLAT-3334
//ignore /dmz/ requests issued from "content" delivered by
// /m/98129834/folder0/folder1/folder3/bla.hmtl
// this can happen if for example a CP contains a relative link pointing back like
// ../../../../../../presentation/cool.js where the "up navigation" exceeds the
// the /folder0/folder1/folder3 path and even jumps over /m/98129834.
//The DMZ is reached, the session invalidated and next click shows login screen.
//
//Because /g/ mapped content is considered to be save against such errors, there
// is no check for PATH_GLOBAL_MAPPED. Typically /g/ mapped paths are
// application wide defined and not brought in by users. Hence it should
// be discovered during developing or testing.
//
String msg = "BAD LINK IN [["+referer+"]]";
Tracing.logWarn(msg, DMZDispatcher.class);
DispatcherAction.sendNotFound(msg, response);
return;
}
try {
// upon creation URL is checked for
ureq = new UserRequest(uriPrefix, request, response);
} catch (NumberFormatException nfe) {
// MODE could not be decoded
// typically if robots with wrong urls hit the system
// or user have bookmarks
// or authors copy-pasted links to the content.
// showing redscreens for non valid URL is wrong instead
// a 404 message must be shown -> e.g. robots correct their links.
if (Tracing.isDebugEnabled(DMZDispatcher.class)) {
Tracing.logDebug("Bad Request " + request.getPathInfo(), this.getClass());
}
DispatcherAction.sendBadRequest(request.getPathInfo(), response);
return;
}
//set load performance mode depending on logged in user or global parameter
//here in the DMZ only the global parameter plays a role.
GUIInterna.setLoadPerformanceMode(ureq);
try {
// find out about which subdispatcher is meant
// e.g. got here because of /dmz/...
// maybe something like /dmz/registration/
//
// add the context path to align with uriPrefix e.g. /olat/dmz/
String pathInfo = request.getContextPath() + request.getPathInfo();
ChiefControllerCreator subPathccc = null;
boolean dmzOnly = pathInfo.equals(uriPrefix);// if /olat/dmz/
if (!dmzOnly) {
int sl = pathInfo.indexOf('/', uriPrefix.length());
String sub;
if (sl > 1) {
// e.g. something like /registration/ or /pwchange/
sub = pathInfo.substring(uriPrefix.length() - 1, sl + 1);
} else {
// e.g. something like /info.html from (/dmz/info.html)
sub = pathInfo;
}
// chief controller creator for sub path, e.g.
subPathccc = dmzServicesByPath.get(sub);
UserSession usess = ureq.getUserSession();
Windows ws = Windows.getWindows(usess);
synchronized (ws) { //o_clusterOK by:fj per user session
ChiefController occ;
if(subPathccc != null){
occ = subPathccc.createChiefController(ureq);
Window window = occ.getWindow();
window.setUriPrefix(uriPrefix);
ws.registerWindow(window);
window.dispatchRequest(ureq, true);
return;
}
}
}//else a /olat/dmz/ request
/*
* create content as it is defined in config.xml in he dmzbean
*/
/*
* solve this with a predispatcher action
*/
// // convenience method to jump immediatly to AAI (Shibboleth) home
// // organisation for login without selecting home organisation manually
// if (ShibbolethModule.isEnableShibbolethLogins()) {
// String preSelIdp = request.getParameter("preselection");
// String redirect = request.getParameter("redirect");
// if (preSelIdp != null && redirect != null && redirect.equalsIgnoreCase("true")) {
// preSelIdp = preSelIdp.toLowerCase();
// Collection sites = IdPSite.getIdPSites(ShibbolethModule.getMetadata());
// for (Iterator iter = sites.iterator(); iter.hasNext();) {
// IdPSite site = (IdPSite) iter.next();
// if (site.getName().toLowerCase().indexOf(preSelIdp) > -1) {
// response.sendRedirect(AssertionConsumerService.buildRequest(request.getLocale(), site));
// break;
// }
// }
// }
// }
UserSession usess = ureq.getUserSession();
Windows ws = Windows.getWindows(usess);
synchronized (ws) { //o_clusterOK by:fj per user session
Window window;
boolean windowHere = ws.isExisting(ureq.getWindowID());
boolean validDispatchUri = ureq.isValidDispatchURI();
if (validDispatchUri && !windowHere) {
// probably valid framework link from previous user && new Session(no window):
// when a previous user logged off, and 30min later (when the httpsession is invalidated), the next user clicks e.g. on
// the log-in link in the -same- browser window ->
// -> there is no window -> create a new one