@Test public void testGetCurrentUser() throws Exception { FakeUIFWApplicationState state = new FakeUIFWApplicationState(); User currentUser = new User("test1", new String[] { "test/test1" }, "token1"); state.setCurrentUser(currentUser); request.getSession().setAttribute("APPLICATION_STATE", state); securedController = (SecuredController) context.getBean("tasksController"); String userName = securedController.getCurrentUserName(request); Assert.assertEquals("test1", userName); }
public static String getCurrentUserName(HttpServletRequest request) { ApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request)); if (state == null || state.getCurrentUser() == null) { return "UnknownUser"; } return state.getCurrentUser().getName(); }
SecuredController extends UIController { public static String getCurrentUserName(HttpServletRequest request) { ApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request)); if (state == null || state.getCurrentUser() == null) { return "UnknownUser"; } return state.getCurrentUser().getName(); } }
SecuredController extends UIController { public static String getCurrentUserName(HttpServletRequest request) { ApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request)); if (state == null || state.getCurrentUser() == null) { return "UnknownUser"; } return state.getCurrentUser().getName(); }  }
SecuredController extends UIController { public static String getCurrentUserName(HttpServletRequest request) { ApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request)); if (state == null || state.getCurrentUser() == null) { return "UnknownUser"; } return state.getCurrentUser().getName(); }  static String getCurrentUserName(HttpServletRequest request); }
SecuredController extends UIController { public static String getCurrentUserName(HttpServletRequest request) { ApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request)); if (state == null || state.getCurrentUser() == null) { return "UnknownUser"; } return state.getCurrentUser().getName(); }  static String getCurrentUserName(HttpServletRequest request);  }