Example usage for javax.servlet.http HttpSession equals

List of usage examples for javax.servlet.http HttpSession equals

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.sun.socialsite.web.filters.SessionFilter.java

/**
 *
 *///w w  w.jav a2s .  c  o  m
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest httpReq = (HttpServletRequest) req;
    String remoteUser = httpReq.getRemoteUser();

    if (remoteUser != null) {

        HttpSession httpSession = httpReq.getSession();
        if (httpSession.getAttribute(REMOTE_USER) == null) {
            log.debug(
                    String.format("Setting REMOTE_USER=%s on Session[id=%s]", remoteUser, httpSession.getId()));
            httpSession.setAttribute(REMOTE_USER, remoteUser);
        }

        assert (httpSession.equals(SessionListener.getSession(httpSession.getId())));

    }

    chain.doFilter(req, resp);

}

From source file:com.skilrock.lms.web.loginMgmt.RolesInterceptor.java

public boolean isSessionValid(HttpSession session) {
    HttpSession sessionNew = null;
    ServletContext sc = ServletActionContext.getServletContext();
    Map currentUserSessionMap = (Map) sc.getAttribute("LOGGED_IN_USERS");
    UserInfoBean userBean = (UserInfoBean) session.getAttribute("USER_INFO");
    if (userBean == null) {

        return false;
    }//from  www  .j a  v a2 s.  c o m
    if (currentUserSessionMap != null && userBean != null) {
        sessionNew = (HttpSession) currentUserSessionMap.get(userBean.getUserName());
    }
    // logger.debug("In Else If New is --"+sessionNew+" Session Current
    // --"+session);
    // logger.debug("The User in Map are"+currentUserSessionMap );
    if (sessionNew != null) {
        if (!sessionNew.equals(session)) {
            session.removeAttribute("USER_INFO");
            session.invalidate();
            session = null;
            return false;
        }
    }
    return true;

}