/** * Discard a cookie in this result * * @param name The name of the cookie to discard, must not be null * @param path The path of the cookie te discard, may be null * @param domain The domain of the cookie to discard, may be null * @param secure Whether the cookie to discard is secure */ public Result discardingCookie(String name, String path, String domain, boolean secure) { return withCookies(new DiscardingCookie(name, path, Option.apply(domain), secure).toCookie().asJava()); }
/** * Discard a cookie in this result * * @param name The name of the cookie to discard, must not be null * @param path The path of the cookie te discard, may be null * @param domain The domain of the cookie to discard, may be null * @param secure Whether the cookie to discard is secure */ public Result discardingCookie(String name, String path, String domain, boolean secure) { return withCookies(new DiscardingCookie(name, path, Option.apply(domain), secure).toCookie().asJava()); }
/** * Discard a cookie in this result * * @param name The name of the cookie to discard, must not be null * @param path The path of the cookie te discard, may be null * @param domain The domain of the cookie to discard, may be null * @param secure Whether the cookie to discard is secure */ public Result discardingCookie(String name, String path, String domain, boolean secure) { return withCookies(new DiscardingCookie(name, path, Option.apply(domain), secure).toCookie().asJava()); }
/** * 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()); } }