super();
Authentication auth = getSession().getAuthentication();
if(auth == null || !auth.isAuthenticated() || auth instanceof AnonymousAuthenticationToken) {
// emulate what spring security url control would do so that we get a proper redirect after login
HttpServletRequest httpRequest = ((WebRequest) getRequest()).getHttpServletRequest();
ExceptionTranslationFilter translator = (ExceptionTranslationFilter) getGeoServerApplication().getBean("consoleExceptionTranslationFilter");
SavedRequest savedRequest = new SavedRequest(httpRequest, translator.getPortResolver());
HttpSession session = httpRequest.getSession();
session.setAttribute(AbstractProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY, savedRequest);
// then redirect to the login page