org.apache.catalina.connector.Request.getSession()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(363)

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

Request.getSession介绍

[英]Return the session associated with this Request, creating one if necessary.
[中]返回与此请求关联的会话,必要时创建一个会话。

代码示例

代码示例来源: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: org.picketlink/picketlink-consolidated-social

private boolean dealWithFacebookPrincipal(Request request, Response response, Principal principal) throws IOException {
  String userName = principal.getName();
  request.getSessionInternal().setNote(Constants.SESS_USERNAME_NOTE, userName);
  request.getSessionInternal().setNote(Constants.SESS_PASSWORD_NOTE, "");
  request.setUserPrincipal(principal);
  if (saveRestoreRequest) {
    this.restoreRequest(request, request.getSessionInternal());
  }
  registerWithAuthenticatorBase(request, response, principal, userName);
  request.getSession().setAttribute("STATE", STATES.FINISH.name());
  return true;
}

代码示例来源: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
public void invoke(Request request, Response response) throws IOException, ServletException {
 getNext().invoke(request, response);
 if (request.getSession(false) != null) {
  String ip = IpInfo.getClientAddress(request.getRequest());
  // Explicit calls to ensure result not lost
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_BY_IP, ip);
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_LOCALE,
    request.getLocale());
 }
}

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

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
 getNext().invoke(request, response);
 if (request.getSession(false) != null) {
  String ip = IpInfo.getClientAddress(request.getRequest());
  // Explicit calls to ensure result not lost
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_BY_IP, ip);
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_LOCALE,
    request.getLocale());
 }
}

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

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
 getNext().invoke(request, response);
 if (request.getSession(false) != null) {
  String ip = IpInfo.getClientAddress(request.getRequest());
  // Explicit calls to ensure result not lost
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_BY_IP, ip);
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_LOCALE,
    request.getLocale());
 }
}

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

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
 getNext().invoke(request, response);
 if (request.getSession(false) != null) {
  String ip = IpInfo.getClientAddress(request.getRequest());
  // Explicit calls to ensure result not lost
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_BY_IP, ip);
  request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_LOCALE,
    request.getLocale());
 }
}

代码示例来源:origin: apache/geode

session = (DeltaSessionFacade) request.getSession(false);
DeltaSessionManager dsm = ((DeltaSessionManager) manager);
if (session != null) {

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
  public HttpSession run() {
    return request.getSession(create);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

@Override
  public HttpSession run() {
    return request.getSession(create);
  }
}

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

@Override
public void setCurrentAction(CurrentAction action) {
  if (action == CurrentAction.NONE && request.getSession(false) == null) return;
  request.getSession().setAttribute(CURRENT_ACTION, action);
}

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

public void addElement(StringBuilder buf, Date date, Request request,
      Response response, long time) {
    HttpSession session = null;
    if (request != null) {
      session = request.getSession(false);
      if (session != null)
        buf.append(wrap(session.getAttribute(attribute)));
    }
  }
}

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

public void addElement(StringBuilder buf, Date date, Request request,
      Response response, long time) {
    HttpSession session = null;
    if (request != null) {
      session = request.getSession(false);
      if (session != null)
        buf.append(wrap(session.getAttribute(attribute)));
    }
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

@Override
  public void addElement(CharArrayWriter buf, Date date, Request request,
      Response response, long time) {
    HttpSession session = null;
    if (request != null) {
      session = request.getSession(false);
      if (session != null) {
        buf.append(wrap(session.getAttribute(attribute)));
      }
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
  public void addElement(CharArrayWriter buf, Date date, Request request,
      Response response, long time) {
    HttpSession session = null;
    if (request != null) {
      session = request.getSession(false);
      if (session != null) {
        buf.append(wrap(session.getAttribute(attribute)));
      }
    }
  }
}

代码示例来源:origin: tomcat/catalina

public HttpSession getSession(boolean create) {
  if (request == null) {
    throw new IllegalStateException(
            sm.getString("requestFacade.nullRequest"));
  }
  if (SecurityUtil.isPackageProtectionEnabled()){
    return (HttpSession)AccessController.
      doPrivileged(new GetSessionPrivilegedAction(create));
  } else {
    return request.getSession(create);
  }
}

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

public HttpSession getSession(boolean create) {
  if (request == null) {
    throw new IllegalStateException(
            sm.getString("requestFacade.nullRequest"));
  }
  if (SecurityUtil.isPackageProtectionEnabled()){
    return (HttpSession)AccessController.
      doPrivileged(new GetSessionPrivilegedAction(create));
  } else {
    return request.getSession(create);
  }
}

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

public HttpSession getSession(boolean create) {
  if (request == null) {
    throw MESSAGES.nullRequestFacade();
  }
  if (SecurityUtil.isPackageProtectionEnabled()){
    return (HttpSession)AccessController.
      doPrivileged(new GetSessionPrivilegedAction(create));
  } else {
    return request.getSession(create);
  }
}

相关文章

Request类方法