📄 ebanksessionlistener.java
字号:
package com.ebusiness.ebank.security;/** * <p>Title: </p> * <p>Description: This class implements HttpSessionListenner. * It will notify eBank system to remove user from * UserContainer when the user's session is being destroyed. * A user session will be destroyed when either the user's session * is timed out or the user performs logout action * </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: eBusiness Inc., All right reserved</p> * @author unascribed * @version 1.0 */import java.util.Date;import javax.servlet.http.HttpSession;import javax.servlet.http.HttpSessionEvent;import javax.servlet.http.HttpSessionListener;import org.apache.log4j.Logger;import org.apache.log4j.MDC;import com.ebusiness.ebank.util.Constants;public class EbankSessionListener implements HttpSessionListener{ private Logger log = Logger.getLogger(this.getClass()); /** * When a user login and create a new HttpSession, this method will be automatically called. */ public void sessionCreated(HttpSessionEvent sessionEvent) { //log.info("A new session was created."); } /** * When a user logout or the user's session is expired, this method will be automatically called. * After the method is called, the user's profile will be removed from the UserContainer */ public void sessionDestroyed(HttpSessionEvent sessionEvent) { Date startTime = new Date(); HttpSession session = sessionEvent.getSession(); String userID = (String)session.getAttribute(Constants.USER_ID); UserContainer.removeUser(userID); //remove the user from the container MDC.put(Constants.USER_ID, userID); MDC.put(Constants.ACTION, "Sign Out"); MDC.put(Constants.ENTITY, "eBusiness Online Banking"); MDC.put(Constants.STATUS, "Successful"); MDC.put(Constants.FAILED_REASON, ""); Date endTime = new Date(); long duration = endTime.getTime()- startTime.getTime(); MDC.put(Constants.DURATION, Long.toString(duration)); log.audit(""); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -