@Test public void testLogout() throws Exception { LoginCommand loginCom = new LoginCommand(); loginCom.setUsername("test1"); loginCom.setPassword("yes"); loginController = (LoginController) context.getBean("loginController"); loginController.logIn(request, response, loginCom, new BindException(loginCom, "test")); ModelAndView mav = loginController.logOut(request, response, loginCom, new BindException(loginCom, "test")); Assert.assertEquals(mav.getViewName(), Constants.LOGIN_VIEW); }
public ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); if (state != null) { if (state.getCurrentUser() != null){ String userName = state.getCurrentUser().getName(); LOG.debug("Logout: user=" + userName); } state.setCurrentUser(null); state.setPreviousAction(null); clearAutoLogin(response); clearSingleLogin(response); clearSecureRandom(response); clearRootCookie(response); clearOtherCookie(response,JSESSION,UI_FW); clearOtherCookie(response,JSESSION,MONITORING); clearOtherCookie(response,JSESSION,BPMS_CONSOLE); } Map model = new HashMap(); model.put("login", new LoginCommand()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); return new ModelAndView(Constants.LOGIN_VIEW, model); }
LoginController extends UIController { public ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); if (state != null) { if (state.getCurrentUser() != null){ String userName = state.getCurrentUser().getName(); LOG.debug("Logout: user=" + userName); } state.setCurrentUser(null); state.setPreviousAction(null); clearAutoLogin(response); clearSingleLogin(response); clearSecureRandom(response); clearRootCookie(response); clearOtherCookie(response,JSESSION,UI_FW); clearOtherCookie(response,JSESSION,MONITORING); clearOtherCookie(response,JSESSION,BPMS_CONSOLE); } Map model = new HashMap(); model.put("login", new LoginCommand()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); return new ModelAndView(Constants.LOGIN_VIEW, model); } }
LoginController extends UIController { public ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); if (state != null) { if (state.getCurrentUser() != null){ String userName = state.getCurrentUser().getName(); LOG.debug("Logout: user=" + userName); } state.setCurrentUser(null); state.setPreviousAction(null); clearAutoLogin(response); clearSingleLogin(response); clearSecureRandom(response); clearRootCookie(response); clearOtherCookie(response,JSESSION,UI_FW); clearOtherCookie(response,JSESSION,MONITORING); clearOtherCookie(response,JSESSION,BPMS_CONSOLE); } Map model = new HashMap(); model.put("login", new LoginCommand()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); return new ModelAndView(Constants.LOGIN_VIEW, model); } LoginController(TokenService tokenService, String redirectSuccessfulLogin); }
LoginController extends UIController { public ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); if (state != null) { if (state.getCurrentUser() != null){ String userName = state.getCurrentUser().getName(); LOG.debug("Logout: user=" + userName); } state.setCurrentUser(null); state.setPreviousAction(null); clearAutoLogin(response); clearSingleLogin(response); clearSecureRandom(response); clearRootCookie(response); clearOtherCookie(response,JSESSION,UI_FW); clearOtherCookie(response,JSESSION,MONITORING); clearOtherCookie(response,JSESSION,BPMS_CONSOLE); } Map model = new HashMap(); model.put("login", new LoginCommand()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); return new ModelAndView(Constants.LOGIN_VIEW, model); } LoginController(TokenService tokenService, String redirectSuccessfulLogin); String getLoginPageURL(); void setLoginPageURL(String url); static ModelAndView redirect(String url); ModelAndView redirectAfterLogin(HttpServletRequest request, HttpServletResponse response); static void clearAutoLogin(HttpServletResponse response); static void clearSingleLogin(HttpServletResponse response); static void clearSecureRandom(HttpServletResponse response); static void clearRootCookie(HttpServletResponse response); static String getSecureRandomCookie(HttpServletRequest request); static String getSecureRandomSession(HttpServletRequest request); static void setSecureRandomSession(HttpServletRequest request, String secureRandom); static void generateSecureRandom(HttpServletRequest request, HttpServletResponse response); static String generateSecureRandom(); static String bytesToHex(byte[] bytes); static void clearCookie(String cookieName, HttpServletResponse response); static void clearOtherCookie(HttpServletResponse response,String cookieName,String path); static String extractUser(Property[] props); static String[] extractRoles(Property[] props); User getCurrentUser(HttpServletRequest request); void setRedirectAfterLoginCookie(HttpServletResponse response); static void setRedirectAfterLoginCookie(HttpServletResponse response, String url); static void setAutoLoginCookie(HttpServletResponse response, String token); static void setSingleLoginCookie(HttpServletResponse response, String token); List<String> getGrantedRoles(); void setGrantedRoles(List<String> roles); String arrayToString(String[] stringArray, String delimiter); void executePost(PostMethod post); @SuppressWarnings("unchecked") ModelAndView logIn(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
            BindException errors); ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
            BindException errors); }
LoginController extends UIController { public ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); if (state != null) { if (state.getCurrentUser() != null){ String userName = state.getCurrentUser().getName(); LOG.debug("Logout: user=" + userName); } state.setCurrentUser(null); state.setPreviousAction(null); clearAutoLogin(response); clearSingleLogin(response); clearSecureRandom(response); clearRootCookie(response); clearOtherCookie(response,JSESSION,UI_FW); clearOtherCookie(response,JSESSION,MONITORING); clearOtherCookie(response,JSESSION,BPMS_CONSOLE); } Map model = new HashMap(); model.put("login", new LoginCommand()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); return new ModelAndView(Constants.LOGIN_VIEW, model); } LoginController(TokenService tokenService, String redirectSuccessfulLogin); String getLoginPageURL(); void setLoginPageURL(String url); static ModelAndView redirect(String url); ModelAndView redirectAfterLogin(HttpServletRequest request, HttpServletResponse response); static void clearAutoLogin(HttpServletResponse response); static void clearSingleLogin(HttpServletResponse response); static void clearSecureRandom(HttpServletResponse response); static void clearRootCookie(HttpServletResponse response); static String getSecureRandomCookie(HttpServletRequest request); static String getSecureRandomSession(HttpServletRequest request); static void setSecureRandomSession(HttpServletRequest request, String secureRandom); static void generateSecureRandom(HttpServletRequest request, HttpServletResponse response); static String generateSecureRandom(); static String bytesToHex(byte[] bytes); static void clearCookie(String cookieName, HttpServletResponse response); static void clearOtherCookie(HttpServletResponse response,String cookieName,String path); static String extractUser(Property[] props); static String[] extractRoles(Property[] props); User getCurrentUser(HttpServletRequest request); void setRedirectAfterLoginCookie(HttpServletResponse response); static void setRedirectAfterLoginCookie(HttpServletResponse response, String url); static void setAutoLoginCookie(HttpServletResponse response, String token); static void setSingleLoginCookie(HttpServletResponse response, String token); List<String> getGrantedRoles(); void setGrantedRoles(List<String> roles); String arrayToString(String[] stringArray, String delimiter); void executePost(PostMethod post); @SuppressWarnings("unchecked") ModelAndView logIn(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
            BindException errors); ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
            BindException errors); static final String AUTO_LOGIN_ID; static final String SINGLE_LOGIN_ID; static final String REDIRECT_AFTER_LOGIN; static final String SECURE_RANDOM; static final String JSESSION; static final String UI_FW; static final String MONITORING; static final String BPMS_CONSOLE; }