Authentication auth = getSession().getAuthentication();
if(auth == null || !auth.isAuthenticated()) {
// emulate what acegi 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.ACEGI_SAVED_REQUEST_KEY, savedRequest);
// then redirect to the login page