private static Cookie cookie(final io.undertow.server.handlers.Cookie c) { Cookie.Definition cookie = new Cookie.Definition(c.getName(), c.getValue()); Optional.ofNullable(c.getComment()).ifPresent(cookie::comment); Optional.ofNullable(c.getDomain()).ifPresent(cookie::domain); Optional.ofNullable(c.getPath()).ifPresent(cookie::path); return cookie.toCookie(); }
/** * Sets a response cookie * * @param cookie The cookie */ public HttpServerExchange setResponseCookie(final Cookie cookie) { if(getConnection().getUndertowOptions().get(UndertowOptions.ENABLE_RFC6265_COOKIE_VALIDATION, UndertowOptions.DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION)) { if (cookie.getValue() != null && !cookie.getValue().isEmpty()) { Rfc6265CookieSupport.validateCookieValue(cookie.getValue()); } if (cookie.getPath() != null && !cookie.getPath().isEmpty()) { Rfc6265CookieSupport.validatePath(cookie.getPath()); } if (cookie.getDomain() != null && !cookie.getDomain().isEmpty()) { Rfc6265CookieSupport.validateDomain(cookie.getDomain()); } } if (responseCookies == null) { responseCookies = new TreeMap<>(); //hashmap is slow to allocate in JDK7 } responseCookies.put(cookie.getName(), cookie); return this; }
if (cookies != null) { for (Cookie cookie : cookies.values()) { sb.append(" cookie=" + cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + "; path=" + cookie.getPath() + "\n");
String domain = cookie.getDomain(); String comment = cookie.getComment();
private static Cookie cookie(final io.undertow.server.handlers.Cookie c) { Cookie.Definition cookie = new Cookie.Definition(c.getName(), c.getValue()); Optional.ofNullable(c.getComment()).ifPresent(cookie::comment); Optional.ofNullable(c.getDomain()).ifPresent(cookie::domain); Optional.ofNullable(c.getPath()).ifPresent(cookie::path); return cookie.toCookie(); }
/** * Sets a response cookie * * @param cookie The cookie */ public HttpServerExchange setResponseCookie(final Cookie cookie) { if(getConnection().getUndertowOptions().get(UndertowOptions.ENABLE_RFC6265_COOKIE_VALIDATION, UndertowOptions.DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION)) { if (cookie.getValue() != null && !cookie.getValue().isEmpty()) { Rfc6265CookieSupport.validateCookieValue(cookie.getValue()); } if (cookie.getPath() != null && !cookie.getPath().isEmpty()) { Rfc6265CookieSupport.validatePath(cookie.getPath()); } if (cookie.getDomain() != null && !cookie.getDomain().isEmpty()) { Rfc6265CookieSupport.validateDomain(cookie.getDomain()); } } if (responseCookies == null) { responseCookies = new TreeMap<>(); //hashmap is slow to allocate in JDK7 } responseCookies.put(cookie.getName(), cookie); return this; }
/** * Sets a response cookie * * @param cookie The cookie */ public HttpServerExchange setResponseCookie(final Cookie cookie) { if(getConnection().getUndertowOptions().get(UndertowOptions.ENABLE_RFC6265_COOKIE_VALIDATION, UndertowOptions.DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION)) { if (cookie.getValue() != null && !cookie.getValue().isEmpty()) { Rfc6265CookieSupport.validateCookieValue(cookie.getValue()); } if (cookie.getPath() != null && !cookie.getPath().isEmpty()) { Rfc6265CookieSupport.validatePath(cookie.getPath()); } if (cookie.getDomain() != null && !cookie.getDomain().isEmpty()) { Rfc6265CookieSupport.validateDomain(cookie.getDomain()); } } if (responseCookies == null) { responseCookies = new TreeMap<>(); //hashmap is slow to allocate in JDK7 } responseCookies.put(cookie.getName(), cookie); return this; }
@Override public Cookie getCookie(String cookieName) { Map<String, io.undertow.server.handlers.Cookie> requestCookies = exchange.getRequestCookies(); if (requestCookies == null) return null; io.undertow.server.handlers.Cookie cookie = requestCookies.get(cookieName); if (cookie == null) return null; return new Cookie(cookie.getName(), cookie.getValue(), cookie.getVersion(), cookie.getDomain(), cookie.getPath()); }
@Override public Cookie getCookie(String cookieName) { Map<String, io.undertow.server.handlers.Cookie> requestCookies = exchange.getRequestCookies(); if (requestCookies == null) return null; io.undertow.server.handlers.Cookie cookie = requestCookies.get(cookieName); if (cookie == null) return null; return new Cookie(cookie.getName(), cookie.getValue(), cookie.getVersion(), cookie.getDomain(), cookie.getPath()); }
if (cookies != null) { for (Cookie cookie : cookies.values()) { sb.append(" cookie=" + cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + "; path=" + cookie.getPath() + "\n");
key, cookie.getDomain(), cookie.getName(), cookie.getPath(), cookie.getValue(), cookie.getExpires(), cookie.getMaxAge(), cookie.getComment(), cookie.getVersion() );
@Override public Collection<Cookie> getRequestCookies() { final Collection<io.undertow.server.handlers.Cookie> uCookies = exchange.getRequestCookies().values(); final List<Cookie> cookies = new ArrayList<>(uCookies.size()); for (final io.undertow.server.handlers.Cookie uCookie : uCookies) { final Cookie cookie = new Cookie(uCookie.getName(), uCookie.getValue()); cookie.setComment(uCookie.getComment()); cookie.setDomain(uCookie.getDomain()); cookie.setPath(uCookie.getPath()); cookie.setMaxAge(uCookie.getMaxAge() == null ? -1 : uCookie.getMaxAge()); cookie.setSecure(uCookie.isSecure()); cookie.setHttpOnly(uCookie.isHttpOnly()); cookies.add(cookie); } return cookies; }
static public ninja.Cookie convertUndertowCookieToNinjaCookie(@NotNull Cookie undertowCookie) { ninja.Cookie.Builder ninjaCookieBuilder = ninja.Cookie.builder(undertowCookie.getName(), undertowCookie.getValue()); if (undertowCookie.getMaxAge() != null) { ninjaCookieBuilder.setMaxAge(undertowCookie.getMaxAge()); } if (undertowCookie.getComment() != null) { ninjaCookieBuilder.setComment(undertowCookie.getComment()); } if (undertowCookie.getDomain() != null) { ninjaCookieBuilder.setDomain(undertowCookie.getDomain()); } if (undertowCookie.getPath() != null) { ninjaCookieBuilder.setPath(undertowCookie.getPath()); } ninjaCookieBuilder.setHttpOnly(undertowCookie.isHttpOnly()); ninjaCookieBuilder.setSecure(undertowCookie.isSecure()); // TODO: discard, version, and expires??? return ninjaCookieBuilder.build(); }
String domain = cookie.getDomain(); String comment = cookie.getComment();
public static H.Cookie undertow2osgl(Cookie uc) { H.Cookie c = new H.Cookie(uc.getName(), uc.getValue()); c.domain(uc.getDomain()).httpOnly(uc.isHttpOnly()) .path(uc.getPath()).secure(uc.isSecure()) .version(uc.getVersion()).comment(uc.getComment()); Integer maxAge = uc.getMaxAge(); if (null != maxAge) { c.maxAge(maxAge); } Date exp = uc.getExpires(); if (null != exp) { c.expires(exp); } return c; }
public static H.Cookie undertow2osgl(Cookie uc) { H.Cookie c = new H.Cookie(uc.getName(), uc.getValue()); c.domain(uc.getDomain()).httpOnly(uc.isHttpOnly()) .path(uc.getPath()).secure(uc.isSecure()) .version(uc.getVersion()).comment(uc.getComment()); Integer maxAge = uc.getMaxAge(); if (null != maxAge) { c.maxAge(maxAge); } Date exp = uc.getExpires(); if (null != exp) { c.expires(exp); } return c; }