public NewCookie getImmutableNewCookie() { return new NewCookie(name, value, path, domain, version, comment, maxAge, expiry, secure, httpOnly); } }
public NewCookie getImmutableNewCookie() { return new NewCookie(name, value, path, domain, version, comment, maxAge, expiry, secure, httpOnly); } }
/** * Produce a form from a static HTML file packaged with the compiled class * @return a stream from which the HTML form can be read. */ @GET public Response getForm() { Date now = new Date(); InputStream entity = this.getClass().getClassLoader().getResourceAsStream("form.html"); return Response.ok(entity) .cookie(new NewCookie("date", now.toString())).build(); }
@Override public Response add(@FormParam("id") int id, @FormParam("name") String name) { return Response.ok().cookie(new NewCookie("ck", String.valueOf(id))).entity(new User(id, name)).build(); }
/** * Generate httponly cookie from HS2 cookie * @param cookie HS2 generated cookie * @return The httponly cookie */ private static String getHttpOnlyCookieHeader(Cookie cookie) { NewCookie newCookie = new NewCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie.getSecure()); return newCookie + "; HttpOnly"; }
@GET @Path("/login") @Produces(MediaType.TEXT_PLAIN) public Response login() { NewCookie cookie = new NewCookie("name", "123"); return Response.ok("OK").cookie(cookie).build(); }
return new NewCookie(cookieName, cookieValue, path, domain, version, comment, maxAge, expiry, secure, httpOnly);
@GET @Path(value = "/test") public Response test(@CookieParam("statusCookie") javax.ws.rs.core.Cookie cookie) { NewCookie newCookie = null; if(cookie != null) { newCookie = new NewCookie("statusCookie", "second"); } else { newCookie = new NewCookie("statusCookie", "first"); } return Response.ok("test").cookie(newCookie).build(); }
private NewCookie buildNewCookie(ModifiableCookie modifiableCookie) { NewCookie newCookie = new NewCookie(modifiableCookie.name, modifiableCookie.value, modifiableCookie.path, modifiableCookie.domain, modifiableCookie.comment, modifiableCookie.maxAge, modifiableCookie.secure); return newCookie; }
@GET public Response get() { return Response.ok("blah").cookie(new NewCookie("foo", "bar")).build(); } [..] Client client = ClientBuilder.newClient(); Response response = client.target(url).request().cookie(new Cookie("foo", "bar")).get();
@Produces(MediaType.TEXT_HTML) @GET public Response login(@QueryParam("redirect") URI redirect) throws IOException { final String page = Resources.toString(Resources.getResource("login.html"), Charset.defaultCharset()); return Response.ok(page, MediaType.TEXT_HTML).cookie(new NewCookie("redirect", redirect.toString())).build(); }
@GET @Path("/logout") public Response logout() throws Exception { return Response.temporaryRedirect(new URI("/")) .cookie(new NewCookie(KxConsts.AUTH_TOKEN_NAME, "", "/", null, null, 0 /*maxAge*/, false)) .build(); }
@POST @Path("/logout") @Produces(MediaType.TEXT_PLAIN) @ApiOperation(value = "logout: disconnects current user from REST server") public Response logout() { logger.trace("logout.enter; cookie: {}", bgAuth); repos.disconnect(getClientId()); NewCookie cookie = new NewCookie(bgAuth, null, 0, false); return Response.ok("OK").cookie(cookie).build(); // may be we should notify server about disconnection? // in order to re-check activeSchemas..? }
/** * Generate httponly cookie from HS2 cookie * @param cookie HS2 generated cookie * @return The httponly cookie */ private static String getHttpOnlyCookieHeader(Cookie cookie) { NewCookie newCookie = new NewCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie.getSecure()); return newCookie + "; HttpOnly"; }
/** * Generate httponly cookie from HS2 cookie * @param cookie HS2 generated cookie * @return The httponly cookie */ private static String getHttpOnlyCookieHeader(Cookie cookie) { NewCookie newCookie = new NewCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie.getSecure()); return newCookie + "; HttpOnly"; }
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @POST public Response performLogin(@CookieParam("redirect") String redirectTo) { return Response.temporaryRedirect(URI.create(redirectTo)) .cookie(new NewCookie("loggedin", "true")) .build(); }
private Response buildResponse(HttpResponse httpResponse) { Response.ResponseBuilder responseBuilder = Response.status(httpResponse.getStatus()); if (httpResponse.getContent() != null) { responseBuilder.entity(httpResponse.getContent()).type(httpResponse.getContentType()); } httpResponse.getHeaders().entrySet() .forEach(entry -> responseBuilder.header(entry.getKey(), entry.getValue())); httpResponse.getCookies().entrySet() .forEach(entry -> responseBuilder.cookie(new NewCookie(entry.getKey(), entry.getValue()))); return responseBuilder.build(); } }
private NewCookie newCookie(String cookieName, String value, String contextPath) { if (StringUtils.isEmpty(contextPath)) { contextPath = "/"; // //EPBDS-7613 } return new NewCookie(cookieName, StringTool.encodeURL(value), contextPath, null, 1, null, -1, null, false, false); }
public void createBuilder(Response.ResponseBuilder builder, GatewayResponse gatewayResponse) { NewCookie newCookie = new NewCookie(Constants.GATEWAY_COOKIE, gatewayResponse.getSessionKey(), "/", null, "GatewayCookie", 6000, true, true); builder.cookie(newCookie); }
private static NewCookie newCookie(final HttpCookie cookie) { return new NewCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie.getVersion(), cookie.getComment(), Math.toIntExact(cookie.getMaxAge()), cookie.getSecure()); }