org.jooby.Request.session()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(384)

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

Request.session介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

@Override
public Session session() {
 return req.session();
}

代码示例来源:origin: jooby-project/jooby

@Override
public Object getSessionIdentifier() {
 return req.session().id();
}

代码示例来源:origin: jooby-project/jooby

@Override public String getOrCreateSessionId(WebContext context) {
 return req.session().id();
}

代码示例来源:origin: jooby-project/jooby

private String profileID(final boolean useSession, final Request req) {
 return req.<String>ifGet(Auth.ID)
   .orElseGet(() -> useSession ? req.session().get(Auth.ID).value(null) : null);
}

代码示例来源:origin: jooby-project/jooby

@Override
public Object getSessionAttribute(final String name) {
 Session session = req.session();
 return AuthSerializer.strToObject(session.get(name).value(null));
}

代码示例来源:origin: jooby-project/jooby

@Override
public void setSessionAttribute(final String name, final Object value) {
 Session session = req.session();
 if (value == null) {
  session.unset(name);
 } else {
  session.set(name, AuthSerializer.objToStr(value));
 }
}

代码示例来源:origin: jooby-project/jooby

@Override public void set(WebContext context, String key, Object value) {
 if (value == null) {
  req.ifSession().ifPresent(session -> session.unset(key));
 } else {
  req.session().set(key, objToStr(value));
 }
}

代码示例来源:origin: jooby-project/jooby

@Override
 public void handle(final Request req, final Response rsp, final Route.Chain chain)
   throws Throwable {

  /**
   * Get or generate a token
   */
  Session session = req.session();
  String token = session.get(name).toOptional().orElseGet(() -> {
   String newToken = generator.apply(req);
   session.set(name, newToken);
   return newToken;
  });

  req.set(name, token);

  if (requireToken.test(req)) {
   String candidate = req.header(name).toOptional()
     .orElseGet(() -> req.param(name).toOptional().orElse(null));
   if (!token.equals(candidate)) {
    throw new Err(Status.FORBIDDEN, "Invalid Csrf token: " + candidate);
   }
  }

  chain.next(req, rsp);
 }
}

代码示例来源:origin: jooby-project/jooby

log.debug("profile : {}", profile);
Session session = req.session();
if (profile != null) {
 String id = profile.getId();

代码示例来源:origin: org.jooby/jooby

@Override
public Session session() {
 return req.session();
}

代码示例来源:origin: org.jooby/jooby-pac4j

@Override
public Object getSessionIdentifier() {
 return req.session().id();
}

代码示例来源:origin: org.jooby/jooby-pac4j

private String profileID(final boolean useSession, final Request req) {
 return req.<String>ifGet(Auth.ID)
   .orElseGet(() -> useSession ? req.session().get(Auth.ID).value(null) : null);
}

代码示例来源:origin: org.jooby/jooby-pac4j

@Override
public void setSessionAttribute(final String name, final Object value) {
 Session session = req.session();
 if (value == null) {
  session.unset(name);
 } else {
  session.set(name, AuthSerializer.objToStr(value));
 }
}

代码示例来源:origin: org.jooby/jooby-pac4j

@Override
public Object getSessionAttribute(final String name) {
 Session session = req.session();
 return AuthSerializer.strToObject(session.get(name).value(null));
}

代码示例来源:origin: org.jooby/jooby

@Override
 public void handle(final Request req, final Response rsp, final Route.Chain chain)
   throws Throwable {

  /**
   * Get or generate a token
   */
  Session session = req.session();
  String token = session.get(name).toOptional().orElseGet(() -> {
   String newToken = generator.apply(req);
   session.set(name, newToken);
   return newToken;
  });

  req.set(name, token);

  if (requireToken.test(req)) {
   String candidate = req.header(name).toOptional()
     .orElseGet(() -> req.param(name).toOptional().orElse(null));
   if (!token.equals(candidate)) {
    throw new Err(Status.FORBIDDEN, "Invalid Csrf token: " + candidate);
   }
  }

  chain.next(req, rsp);
 }
}

代码示例来源:origin: org.jooby/jooby-pac4j

log.debug("profile : {}", profile);
Session session = req.session();
if (profile != null) {
 String id = profile.getId();

相关文章