@Override public void addResponseCookie(final Cookie cookie) { Definition c = new Definition(cookie.getName(), cookie.getValue()); Optional.ofNullable(cookie.getDomain()).ifPresent(c::domain); Optional.ofNullable(cookie.getPath()).ifPresent(c::path); c.httpOnly(cookie.isHttpOnly()); c.maxAge(cookie.getMaxAge()); c.secure(cookie.isSecure()); rsp.cookie(c); }
@Override public void addResponseCookie(Cookie cookie) { org.jooby.Cookie.Definition c = new org.jooby.Cookie.Definition(cookie.getName(), cookie.getValue()); Optional.ofNullable(cookie.getDomain()).ifPresent(c::domain); Optional.ofNullable(cookie.getPath()).ifPresent(c::path); c.httpOnly(cookie.isHttpOnly()); c.maxAge(cookie.getMaxAge()); c.secure(cookie.isSecure()); rsp.cookie(c); }
@Override public void addResponseCookie(Cookie cookie) { getResponse().cookie(cookie.getPath(), cookie.getDomain(), cookie.getName(), cookie.getValue(), cookie.getMaxAge(), cookie.isSecure() ); javax.servlet.http.Cookie addedCookie = getResponse().getCookie(cookie.getName()); addedCookie.setHttpOnly(cookie.isHttpOnly()); addedCookie.setComment(cookie.getComment()); }
@Override public Object get(WebContext context, String key) { final Cookie cookie = ContextHelper.getCookie(context, PAC4J_SESSION_PREFIX + key); Object value = null; if (cookie != null) { value = uncompressDecryptBase64(cookie.getValue()); } logger.debug("Get from session: {} = {}", key, value); return value; }
public Object get(WebContext context, String key) { final Cookie cookie = ContextHelper.getCookie(context, PAC4J_SESSION_PREFIX + key); Object value = null; if (cookie != null) { value = uncompressDecryptBase64(cookie.getValue()); } logger.debug("Get from session: {} = {}", key, value); return value; }
@Override public TokenCredentials extract(final WebContext context) { final Collection<Cookie> col = context.getRequestCookies(); for (final Cookie c : col) { if (c.getName().equals(this.cookieName)) { return new TokenCredentials(c.getValue()); } } return null; }
@Override public void addResponseCookie(Cookie cookie) { routingContext.addCookie(io.vertx.ext.web.Cookie.cookie(cookie.getName(), cookie.getValue())); }
@Override public void addResponseCookie(Cookie cookie) { routingContext.addCookie(io.vertx.ext.web.Cookie.cookie(cookie.getName(), cookie.getValue())); }
@Override public void addResponseCookie(final Cookie cookie) { Definition c = new Definition(cookie.getName(), cookie.getValue()); Optional.ofNullable(cookie.getDomain()).ifPresent(c::domain); Optional.ofNullable(cookie.getPath()).ifPresent(c::path); c.httpOnly(cookie.isHttpOnly()); c.maxAge(cookie.getMaxAge()); c.secure(cookie.isSecure()); rsp.cookie(c); }
@Test public void testAuthentication() { final CookieClient client = new CookieClient(USERNAME, new SimpleTestTokenAuthenticator()); final MockWebContext context = MockWebContext.create(); final Cookie c = new Cookie(USERNAME, Base64.getEncoder().encodeToString(getClass().getName().getBytes(StandardCharsets.UTF_8))); context.getRequestCookies().add(c); final TokenCredentials credentials = client.getCredentials(context); final CommonProfile profile = client.getUserProfile(credentials, context); assertEquals(c.getValue(), profile.getId()); } }
@Override public void addResponseCookie(Cookie cookie) { final DefaultCookie newCookie = new DefaultCookie(cookie.getName(), cookie.getValue()); newCookie.setDomain(cookie.getDomain()); newCookie.setPath(cookie.getPath()); if (cookie.getMaxAge() >= 0) { newCookie.setMaxAge(cookie.getMaxAge()); } newCookie.setSecure(cookie.isSecure()); newCookie.setHttpOnly(cookie.isHttpOnly()); response.getCookies().add(newCookie); }
@Override public void addResponseCookie(Cookie cookie) { CommonHelper.assertNotNull("cookie", cookie); // Note: expiry is not in servlet and is meant to be superseeded by // max-age, so we simply make it null NewCookie c = new NewCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), null, cookie.isSecure(), cookie.isHttpOnly()); getAbortBuilder().cookie(c); getResponseHolder().addResponseCookie(c); }
@Override public void addResponseCookie(final Cookie cookie) { final CookieImpl newCookie = new CookieImpl(cookie.getName(), cookie.getValue()); newCookie.setComment(cookie.getComment()); newCookie.setDomain(cookie.getDomain()); newCookie.setPath(cookie.getPath()); newCookie.setMaxAge(cookie.getMaxAge() < 0 ? null : cookie.getMaxAge()); newCookie.setSecure(cookie.isSecure()); newCookie.setHttpOnly(cookie.isHttpOnly()); exchange.setResponseCookie(newCookie); }
@Override public void addResponseCookie(final Cookie cookie) { final Http.CookieBuilder cookieBuilder = Http.Cookie.builder(cookie.getName(), cookie.getValue()) .withPath(cookie.getPath()) .withDomain(cookie.getDomain()) .withSecure(cookie.isSecure()) .withHttpOnly(cookie.isHttpOnly()); // in Play, maxAge: Cookie duration in seconds (null for a transient cookie [value by default], 0 or less for one that expires now) // in pac4j, maxAge == -1 -> session cookie, 0 -> expires now, > 0, expires in x seconds final int maxAge = cookie.getMaxAge(); if (maxAge != -1) { cookieBuilder.withMaxAge(Duration.of(maxAge, ChronoUnit.SECONDS)); } final Http.Cookie responseCookie = cookieBuilder.build(); response.setCookie(responseCookie); }
@Override public void addResponseCookie(final Cookie cookie) { final Http.CookieBuilder cookieBuilder = Http.Cookie.builder(cookie.getName(), cookie.getValue()) .withPath(cookie.getPath()) .withDomain(cookie.getDomain()) .withSecure(cookie.isSecure()) .withHttpOnly(cookie.isHttpOnly()); // in Play, maxAge: Cookie duration in seconds (null for a transient cookie [value by default], 0 or less for one that expires now) // in pac4j, maxAge == -1 -> session cookie, 0 -> expires now, > 0, expires in x seconds final int maxAge = cookie.getMaxAge(); if (maxAge != -1) { cookieBuilder.withMaxAge(Duration.of(maxAge, ChronoUnit.SECONDS)); } final Http.Cookie responseCookie = cookieBuilder.build(); response.setCookie(responseCookie); }