public void dissolve() { if (!shouldWriteLocaleCookie()) { return; } String cookieName = config.localeCookieName(); Locale locale = context.locale(); if (null == locale) { locale = this.locale; } String localeStr = locale.toString(); H.Session session = context.session(); if (null != session) { if (reset) { session.remove(KEY); } else { session.put(KEY, localeStr); } } H.Cookie cookie = new H.Cookie(cookieName, localeStr); cookie.domain(config.cookieDomain()); cookie.path("/"); // in case we have resolved locale from cookie and we shouldn't write cookie anymore, we need to clear it cookie.maxAge(reset ? -1 : COOKIE_TTL); if (reset) { cookie.expires(DateTime.now().minusDays(1).toDate()); } context.resp().addCookie(cookie); }
public void dissolve() { if (!shouldWriteLocaleCookie()) { return; } String cookieName = config.localeCookieName(); Locale locale = context.locale(); if (null == locale) { locale = this.locale; } String localeStr = locale.toString(); H.Session session = context.session(); if (null != session) { if (reset) { session.remove(KEY); } else { session.put(KEY, localeStr); } } H.Cookie cookie = new H.Cookie(cookieName, localeStr); cookie.domain(config.cookieDomain()); cookie.path("/"); // in case we have resolved locale from cookie and we shouldn't write cookie anymore, we need to clear it cookie.maxAge(reset ? -1 : COOKIE_TTL); if (reset) { cookie.expires(DateTime.now().minusDays(1).toDate()); } context.resp().addCookie(cookie); }
public void setCookieAndRenderArgs(ActionContext context) { if (!enabled) { return; } String token = retrieveCsrfToken(context); if (S.blank(token)) { // this branch is for safe methods H.Session session = context.session(); token = csrfProtector.retrieveToken(session, cookieName, app); } if (S.blank(token) || justLoggedIn(context)) { H.Session session = context.session(); csrfProtector.clearExistingToken(session, cookieName); token = app.encrypt(csrfProtector.generateToken(session, app)); H.Cookie cookie = new H.Cookie(cookieName, token); cookie.secure(context.config().sessionSecure()); cookie.domain(cookieDomain); cookie.path("/"); cookie.httpOnly(false); context.resp().addCookie(cookie); csrfProtector.outputToken(token, cookieName, cookieDomain, context); } context.renderArg(paramName, token); }
public void setCookieAndRenderArgs(ActionContext context) { if (!enabled) { return; } String token = retrieveCsrfToken(context); if (S.blank(token)) { // this branch is for safe methods H.Session session = context.session(); token = csrfProtector.retrieveToken(session, cookieName, app); } if (S.blank(token) || justLoggedIn(context)) { H.Session session = context.session(); csrfProtector.clearExistingToken(session, cookieName); token = app.encrypt(csrfProtector.generateToken(session, app)); H.Cookie cookie = new H.Cookie(cookieName, token); cookie.secure(context.config().sessionSecure()); cookie.domain(cookieDomain); cookie.path("/"); cookie.httpOnly(false); context.resp().addCookie(cookie); csrfProtector.outputToken(token, cookieName, cookieDomain, context); } context.renderArg(paramName, token); }
@Override public String getDomain() { return hc.domain(); }
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; }
@Override public String getDomain() { return hc.domain(); }
@Override public Cookie setDomain(String domain) { hc.domain(domain); return this; }
private H.Cookie createCookie(String name, String value) { H.Cookie cookie = new H.Cookie(name, value); cookie.path("/"); cookie.domain(cookieDomain); cookie.httpOnly(true); cookie.secure(sessionSecure); if (sessionWillExpire && persistentSession) { cookie.maxAge(ttl); } return cookie; }
@Override public Cookie setDomain(String domain) { hc.domain(domain); return this; }
private H.Cookie createCookie(String name, String value) { H.Cookie cookie = new H.Cookie(name, value); cookie.path("/"); cookie.domain(cookieDomain); cookie.httpOnly(true); cookie.secure(sessionSecure); if (sessionWillExpire && persistentSession) { cookie.maxAge(ttl); } return cookie; }