单点登陆多地踢掉第一个登陆的人

在类SendTicketGrantingTicketAction.java中修改的java

 protected Event doExecute(final RequestContext context) {
        final String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context); 
        final String ticketGrantingTicketValueFromCookie = (String) context.getFlowScope().get("ticketGrantingTicketId");
        
        if (ticketGrantingTicketId == null) {
            return success();
        }
        
        try {
        	/*
        	 * 根据用户和密码存放ticket 后者登陆踢掉前者
        	 */
 	    String ticketIdkey = context.getRequestParameters().get("username")+"$"+context.getRequestParameters().get("password");
// 	    String contextKey = ticketIdkey + "#";
        if(LoginRememberMap.LoginCookieRemberTicket.get(ticketIdkey) != null){

            
//            HttpSession httpSession = WebUtils.getHttpServletRequest(LoginRememberMap.LoginCookieRemberContent.get(contextKey)).getSession();
//            httpSession.setAttribute("loginRepeat", "您的帐号已在别处登陆!");
            
        	this.centralAuthenticationService
            .destroyTicketGrantingTicket(LoginRememberMap.LoginCookieRemberTicket.get(ticketIdkey));
        }
//        LoginRememberMap.LoginCookieRemberContent.put(contextKey, context);
        LoginRememberMap.LoginCookieRemberTicket.put(ticketIdkey, ticketGrantingTicketId);
        
        
		} catch (Exception e) {
			e.printStackTrace();
		}
        
        this.ticketGrantingTicketCookieGenerator.addCookie(WebUtils.getHttpServletRequest(context), WebUtils
            .getHttpServletResponse(context), ticketGrantingTicketId);

        if (ticketGrantingTicketValueFromCookie != null && !ticketGrantingTicketId.equals(ticketGrantingTicketValueFromCookie)) {
            this.centralAuthenticationService
                .destroyTicketGrantingTicket(ticketGrantingTicketValueFromCookie);
        }

        return success();
    }

记得注销的时候还要移除相应的this

源码看的不明不白的,提示信息一直传不到页面,code

相关文章
相关标签/搜索