/** * Adds the given key and value to the session. * * @param key The key to add to this result's session * @param value The value to add to this result's session * @return A copy of this result with the key and value added to its session scope. */ public Result addingToSession(Http.Request request, String key, String value) { Map<String, String> newValues = new HashMap<>(1); newValues.put(key, value); return addingToSession(request, newValues); }
/** * Adds the given key and value to the session. * * @param key The key to add to this result's session * @param value The value to add to this result's session * @return A copy of this result with the key and value added to its session scope. */ public Result addingToSession(Http.Request request, String key, String value) { Map<String, String> newValues = new HashMap<>(1); newValues.put(key, value); return addingToSession(request, newValues); }
/** * Adds the given key and value to the session. * * @param key The key to add to this result's session * @param value The value to add to this result's session * @return A copy of this result with the key and value added to its session scope. */ public Result addingToSession(Http.Request request, String key, String value) { Map<String, String> newValues = new HashMap<>(1); newValues.put(key, value); return addingToSession(request, newValues); }
/** * Places the CSRF token in the session or in a cookie (if a cookie name is configured) */ private Result placeToken(Http.Request req, final Result result, CSRF.Token token) { if (config.cookieName().isDefined()) { scala.Option<String> domain = sessionConfiguration.domain(); Http.Cookie cookie = new Http.Cookie( config.cookieName().get(), token.value(), null, sessionConfiguration.path(), domain.isDefined() ? domain.get() : null, config.secureCookie(), config.httpOnlyCookie(), OptionConverters.toJava(config.sameSiteCookie()).map(c -> c.asJava()).orElse(null)); return result.withCookies(cookie); } return result.addingToSession(req, token.name(), token.value()); } }
/** * Places the CSRF token in the session or in a cookie (if a cookie name is configured) */ private Result placeToken(Http.Request req, final Result result, CSRF.Token token) { if (config.cookieName().isDefined()) { scala.Option<String> domain = sessionConfiguration.domain(); Http.Cookie cookie = new Http.Cookie( config.cookieName().get(), token.value(), null, sessionConfiguration.path(), domain.isDefined() ? domain.get() : null, config.secureCookie(), config.httpOnlyCookie(), OptionConverters.toJava(config.sameSiteCookie()).map(c -> c.asJava()).orElse(null)); return result.withCookies(cookie); } return result.addingToSession(req, token.name(), token.value()); } }