org.apache.catalina.Manager.findSession()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中org.apache.catalina.Manager.findSession()方法的一些代码示例,展示了Manager.findSession()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Manager.findSession()方法的具体详情如下:
包路径:org.apache.catalina.Manager
类名称:Manager
方法名:findSession

Manager.findSession介绍

[英]Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return null.
[中]使用指定的会话id(如果有)返回与此管理器关联的活动会话;否则返回null

代码示例

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
protected ModelAndView handleContext(String contextName, Context context,
  HttpServletRequest request, HttpServletResponse response) throws Exception {
 String sid = ServletRequestUtils.getStringParameter(request, "sid");
 String attrName = ServletRequestUtils.getStringParameter(request, "attr");
 Session session = context.getManager().findSession(sid);
 if (session != null) {
  session.getSession().removeAttribute(attrName);
 }
 return new ModelAndView(new RedirectView(
   request.getContextPath() + getViewName() + "?" + request.getQueryString()));
}

代码示例来源:origin: psi-probe/psi-probe

@Override
protected ModelAndView handleContext(String contextName, Context context,
  HttpServletRequest request, HttpServletResponse response) throws Exception {
 String sessionId = ServletRequestUtils.getStringParameter(request, "sid");
 Session session = context.getManager().findSession(sessionId);
 if (session != null) {
  session.expire();
 }
 return new ModelAndView(new InternalResourceView(getViewName()));
}

代码示例来源:origin: psi-probe/psi-probe

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
  HttpServletResponse response) throws Exception {
 for (String sidWebApp : ServletRequestUtils.getStringParameters(request, "sid_webapp")) {
  if (sidWebApp != null) {
   String[] ss = sidWebApp.split(";");
   if (ss.length == 2) {
    String sessionId = ss[0];
    String appName = ss[1];
    Context context = getContainerWrapper().getTomcatContainer().findContext(appName);
    if (context != null) {
     Manager manager = context.getManager();
     Session session = manager.findSession(sessionId);
     if (session != null && session.isValid()) {
      session.expire();
     }
    } else {
     return new ModelAndView("errors/paramerror");
    }
   } else {
    return new ModelAndView("errors/paramerror");
   }
  }
 }
 return new ModelAndView(new InternalResourceView(getViewName()));
}

代码示例来源:origin: psi-probe/psi-probe

@Override
protected ModelAndView handleContext(String contextName, Context context,
  HttpServletRequest request, HttpServletResponse response) throws Exception {
 boolean privileged = SecurityUtils.hasAttributeValueRole(getServletContext(), request);
 boolean calcSize =
   privileged && ServletRequestUtils.getBooleanParameter(request, "size", false);
 String sid = ServletRequestUtils.getStringParameter(request, "sid");
 ApplicationSession appSession = ApplicationUtils
   .getApplicationSession(context.getManager().findSession(sid), calcSize, true);
 if (appSession != null) {
  appSession.setAllowedToViewValues(privileged);
  return new ModelAndView(getViewName(), "session", appSession);
 }
 return new ModelAndView(getViewName());
}

代码示例来源:origin: org.keycloak/spring-boot-container-bundle

protected void logoutSession(Manager manager, String httpSessionId) {
  log.debug("logoutHttpSession: " + httpSessionId);
  Session session;
  try {
    session = manager.findSession(httpSessionId);
  } catch (IOException ioe) {
    log.warn("IO exception when looking for session " + httpSessionId, ioe);
    return;
  }
  logoutSession(session);
}

代码示例来源:origin: org.keycloak/keycloak-tomcat-adapter-spi

protected void logoutSession(Manager manager, String httpSessionId) {
  log.debug("logoutHttpSession: " + httpSessionId);
  Session session;
  try {
    session = manager.findSession(httpSessionId);
  } catch (IOException ioe) {
    log.warn("IO exception when looking for session " + httpSessionId, ioe);
    return;
  }
  logoutSession(session);
}

代码示例来源:origin: org.glassfish.web/web-glue

private Session getSession(ServletRequest request) {
  javax.servlet.http.HttpServletRequest httpReq = 
    (javax.servlet.http.HttpServletRequest) request;
  javax.servlet.http.HttpSession httpSess = httpReq.getSession(false);
  if(httpSess == null) {
    return null;
  }
  String id = httpSess.getId();
  Manager mgr = _context.getManager();
  Session sess = null;
  try {
    sess = mgr.findSession(id);
  } catch (java.io.IOException ex) {}
  return sess;
}

代码示例来源:origin: org.osivia.portal.core/osivia-portal-jbossas-jbossweb-lib

/*      */   public boolean isRequestedSessionIdValid()
/*      */   {
/* 2130 */     if (this.requestedSessionId == null)
/* 2131 */       return false;
/* 2132 */     if (this.context == null)
/* 2133 */       return false;
/* 2134 */     Manager manager = this.context.getManager();
/* 2135 */     if (manager == null)
/* 2136 */       return false;
/* 2137 */     Session session = null;
/*      */     try {
/* 2139 */       session = manager.findSession(this.requestedSessionId);
/*      */     } catch (IOException e) {
/* 2141 */       session = null;
/*      */     }
/*      */ 
/* 2144 */     return (session != null) && (session.isValid());
/*      */   }
/*      */

代码示例来源:origin: org.gatein.wci/wci-tomcat7

public HttpSession getHttpSession(String sessId)
{
 Manager mgr = context.getManager();
 if (mgr != null)
 {
   try
   {
    Session sess = mgr.findSession(sessId);
    if (sess != null)
    {
      return sess.getSession();
    }
   }
   catch (IOException ignored)
   {
   }
 }
 return null;
}

代码示例来源:origin: org.jboss.web/jbossweb

/**
 * Return <code>true</code> if the session identifier included in this
 * request identifies a valid session.
 */
public boolean isRequestedSessionIdValid() {
  if (requestedSessionId == null)
    return (false);
  if (context == null)
    return (false);
  Manager manager = context.getManager();
  if (manager == null)
    return (false);
  Session session = null;
  try {
    session = manager.findSession(requestedSessionId);
  } catch (IOException e) {
    session = null;
  }
  if ((session != null) && session.isValid())
    return (true);
  else
    return (false);
}

代码示例来源:origin: apache/flex-blazeds

static Session getSession(Request request, boolean create) 
{
  HttpServletRequest hreq = (HttpServletRequest)request.getRequest();
  HttpSession hses = hreq.getSession(create);
  if (hses == null)
    return null;
  Manager manager = request.getContext().getManager();
  if (manager == null)
    return null;
  try 
  {
    return manager.findSession(hses.getId());
  }
  catch (IOException e) 
  {
    Log.getLogger(LogCategories.SECURITY).error("Error in TomcatValve getting session id " + hses.getId() + " : " + ExceptionUtil.toString(e));
    return null;
  }
}

代码示例来源:origin: apache/flex-blazeds

static Session getSession(Request request, boolean create) 
{
  HttpServletRequest hreq = (HttpServletRequest)request.getRequest();
  HttpSession hses = hreq.getSession(create);
  if (hses == null)
    return null;
  Manager manager = request.getContext().getManager();
  if (manager == null)
    return null;
  try 
  {
    return manager.findSession(hses.getId());
  }
  catch (IOException e) 
  {
    Log.getLogger(LogCategories.SECURITY).error("Error in TomcatValve getting session id " + hses.getId() + " : " + ExceptionUtil.toString(e));
    return null;
  }
}

代码示例来源:origin: jboss.web/jbossweb

/**
 * Return <code>true</code> if the session identifier specified
 * identifies a valid session.
 */
public boolean isSessionIdValid(Request request, String id) {
  if (id == null)
    return (false);
  Context context = request.getContext();
  if (context == null)
    return (false);
  Manager manager = context.getManager();
  if (manager == null)
    return (false);
  Session session = null;
  try {
    session = manager.findSession(id);
  } catch (IOException e) {
    session = null;
  }
  if ((session != null) && session.isValidInternal())
    return (true);
  else
    return (false);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

protected Session getSessionForNameAndId(ContextName cn, String id,
    StringManager smClient) throws IOException {
  if ((cn == null) || !(cn.getPath().startsWith("/") ||
      cn.getPath().equals(""))) {
    String path = null;
    if (cn != null) {
      path = cn.getPath();
    }
    throw new IllegalArgumentException(smClient.getString(
        "managerServlet.invalidPath",
        RequestUtil.filter(path)));
  }
  
  Context ctxt = (Context) host.findChild(cn.getName());
  if (null == ctxt) {
    throw new IllegalArgumentException(smClient.getString(
        "managerServlet.noContext",
        RequestUtil.filter(cn.getDisplayName())));
  }
  Session session = ctxt.getManager().findSession(id);
  return session;
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

protected Session getSessionForNameAndId(ContextName cn, String id,
    StringManager smClient) throws IOException {
  if ((cn == null) || !(cn.getPath().startsWith("/") ||
      cn.getPath().equals(""))) {
    String path = null;
    if (cn != null) {
      path = cn.getPath();
    }
    throw new IllegalArgumentException(smClient.getString(
        "managerServlet.invalidPath",
        RequestUtil.filter(path)));
  }
  
  Context ctxt = (Context) host.findChild(cn.getName());
  if (null == ctxt) {
    throw new IllegalArgumentException(smClient.getString(
        "managerServlet.noContext",
        RequestUtil.filter(cn.getDisplayName())));
  }
  Session session = ctxt.getManager().findSession(id);
  return session;
}

代码示例来源:origin: org.redisson/redisson-tomcat-8

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

相关文章