@Test public void testShowFormWithoutUser() throws Exception { securedController = (SecuredController) context.getBean("tasksController"); ModelAndView mav = securedController.showForm(request, response, null); Assert.assertTrue(mav.getView().toString().contains(Constants.LOGIN_URL)); }
@Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; }
SecuredController extends UIController { @Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; } }
SecuredController extends UIController { @Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; }  }
SecuredController extends UIController { @Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; }  static String getCurrentUserName(HttpServletRequest request); }
SecuredController extends UIController { @Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; }  static String getCurrentUserName(HttpServletRequest request);  }