* @param request
* @param response
* @param uriPrefix
*/
public void execute(HttpServletRequest request, HttpServletResponse response, String uriPrefix) {
UserSession usess = UserSession.getUserSession(request);
UserRequest ureq = null;
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(UzhAuthenticatedDispatcher.class)){
Tracing.logDebug("Bad Request "+request.getPathInfo(), this.getClass());
}
DispatcherAction.sendBadRequest(request.getPathInfo(), response);
return;
}
GUIInterna.setLoadPerformanceMode(ureq);
boolean auth = usess.isAuthenticated();
if (!auth) {
//check for legacy unizh url's and redirect
if (checkForRedirect(request, response) ) return;
if (!ureq.isValidDispatchURI()) {
// might be a direct jump request -> remember it if not logged in yet
String reqUri = request.getRequestURI();
String query = request.getQueryString();
String allGet = reqUri + QUESTIONMARK + query;
usess.putEntryInNonClearedStore(AUTHDISPATCHER_ENTRYURL, allGet);
}
String guestAccess = ureq.getParameter(GUEST);
if (guestAccess == null) {
DispatcherAction.redirectToDefaultDispatcher(response);
return;
} else if (guestAccess.equals(TRUE)) {
// try to log in as anonymous
int loginStatus = AuthHelper.doAnonymousLogin(ureq,I18nManager.getInstance().getLocaleOrDefault(ureq.getParameter(LANG)) );
if ( loginStatus != AuthHelper.LOGIN_OK ) {
if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
DispatcherAction.redirectToServiceNotAvailable(response);
}
return;
}
// else now logged in as anonymous user, continue
}
}
// 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.
}
}
}
DispatcherAction.redirectToDefaultDispatcher(response);
return;
}
//check for legacy unizh url's and redirect
if (checkForRedirect(request, response)) return ;
usess.getSessionInfo().setLastClickTime();
String origUrl = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_ENTRYURL);
if (origUrl != null) {
// we had a direct jump request
// to avoid a endless redirect, remove the guest parameter if any
// this can happen if a guest has cookies disabled
String url = new URIHelper(origUrl).removeParameter(GUEST).toString();