@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new CookieImpl(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.exchange.getResponseCookies().putIfAbsent(name, cookie); } } }
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new CookieImpl(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.exchange.getResponseCookies().putIfAbsent(name, cookie); } } }
private void setFlash(HttpServerExchange exchange) { if (this.flash != null && !this.flash.isDiscard() && this.flash.hasContent()) { String values = Joiner.on("&").withKeyValueSeparator(":").join(this.flash.getValues()); Cookie cookie = new CookieImpl(this.config.getFlashCookieName(), values) .setHttpOnly(true) .setPath("/"); exchange.setResponseCookie(cookie); } else { Cookie cookie = exchange.getRequestCookies().get(this.config.getFlashCookieName()); if (cookie != null) { cookie.setHttpOnly(true) .setPath("/") .setMaxAge(0); exchange.setResponseCookie(cookie); } } }
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new CookieImpl(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.exchange.getResponseCookies().putIfAbsent(name, cookie); } } }
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new CookieImpl(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.exchange.getResponseCookies().putIfAbsent(name, cookie); } } }
static public Cookie convertNinjaCookieToUndertowCookie(ninja.Cookie ninjaCookie) { Cookie undertowCookie = new CookieImpl(ninjaCookie.getName(), ninjaCookie.getValue()); undertowCookie.setMaxAge(ninjaCookie.getMaxAge()); if (ninjaCookie.getComment() != null) { undertowCookie.setComment(ninjaCookie.getComment()); } if (ninjaCookie.getDomain() != null) { undertowCookie.setDomain(ninjaCookie.getDomain()); } if (ninjaCookie.getPath() != null) { undertowCookie.setPath(ninjaCookie.getPath()); } undertowCookie.setSecure(ninjaCookie.isSecure()); undertowCookie.setHttpOnly(ninjaCookie.isHttpOnly()); // TODO: discard, version, and expires??? return undertowCookie; }