Java Code Examples for io.vertx.ext.web.Session#id()

The following examples show how to use io.vertx.ext.web.Session#id() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSRFHandlerImpl.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
private String getTokenFromSession(RoutingContext ctx) {
  Session session = ctx.session();
  if (session == null) {
    return null;
  }
  // get the token from the session
  String sessionToken = session.get(headerName);
  if (sessionToken != null) {
    // attempt to parse the value
    int idx = sessionToken.indexOf('/');
    if (idx != -1 && session.id() != null && session.id().equals(sessionToken.substring(0, idx))) {
      return sessionToken.substring(idx + 1);
    }
  }
  // fail
  return null;
}
 
Example 2
Source File: TestSessionRest.java    From rest.vertx with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/echo")
@Produces(MediaType.TEXT_HTML)
public String echo(@Context RoutingContext routingContext) {
	Session session = routingContext.session();
	return session.id();
}