List of usage examples for javax.servlet.http HttpServletResponse addCookie
public void addCookie(Cookie cookie);
From source file:io.cfp.auth.MainCtrl.java
@RequestMapping("/logout") public String logout(HttpServletResponse response, @CookieValue(required = false) String token, @CookieValue(required = false) String returnTo) { Cookie tokenCookie = cookieService.getTokenCookie(""); tokenCookie.setMaxAge(0);// www . j a va2 s . c om response.addCookie(tokenCookie); tokenSrv.remove(token); return "redirect:/"; }
From source file:com.acme.demo.web.LogoutController.java
private void handleLogOutResponse(HttpServletRequest request, HttpServletResponse response) { Cookie[] cookies = request.getCookies(); for (Cookie cookie : cookies) { cookie.setMaxAge(0);/*from w ww . j a v a2 s.c om*/ cookie.setValue(null); cookie.setPath("/"); response.addCookie(cookie); } }
From source file:com.ms.commons.summer.security.web.DefaultSecurityFormResolver.java
/** * csrf tokencookie//www. j a v a 2 s . co m * * @param request * @param response * @param tokenCode */ public void renderCSRFTokenInput(HttpServletRequest request, HttpServletResponse response, StringBuilder tokenCode) { String token = createToken(); Cookie cookie = new Cookie(SESSION_TOKEN, token); response.addCookie(cookie); tokenCode.append("<input type=\"hidden\" name=\"").append(SESSION_TOKEN).append("\" value=\"").append(token) .append("\"/>"); if (logger.isDebugEnabled()) { logger.debug("render csrf token value = " + token); } }
From source file:com.mawujun.util.web.CookieGenerator.java
/** * Remove the cookie that this generator describes from the response. * Will generate a cookie with empty value and max age 0. * <p>Delegates to <code>createCookie</code> for cookie creation. * @param response the HTTP response to remove the cookie from * @see #setCookieName/*from ww w . j a v a 2 s . co m*/ * @see #setCookieDomain * @see #setCookiePath * @see #createCookie */ public void removeCookie(HttpServletResponse response) { Cookie cookie = createCookie(""); cookie.setMaxAge(0); response.addCookie(cookie); if (logger.isDebugEnabled()) { logger.debug("Removed cookie with name [" + getCookieName() + "]"); } }
From source file:org.chos.transaction.passport.HttpContextSessionManager.java
public void close(HttpServletResponse response) { Cookie newCookie = new Cookie(USER_TOKEN, null); newCookie.setMaxAge(0); //? newCookie.setPath("/"); response.addCookie(newCookie); }
From source file:com.bosch.cr.examples.jwt.auth.ImAuthenticationServlet.java
@Override protected void doDelete(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final Cookie cookie = CookieUtil.getJwtAuthenticationCookie("invalid", false, 0); resp.addCookie(cookie); resp.setStatus(HttpStatus.SC_NO_CONTENT); }
From source file:com.junly.service.helper.TicketHelper.java
/** <p class="detail"> * ?cookie//from w w w . j a va 2 s .c o m * </p> * @author junly * @date 2016420 * @param response * @param cookie */ public void deleteCookie(HttpServletResponse response, Cookie cookie) { if (cookie != null) { cookie.setMaxAge(0); response.addCookie(cookie); } }
From source file:com.braintree.cscockpit.widgets.renderers.impl.customer.CustomerPaymentMethodAddWidgetRenderer.java
private void preparedClientCookie() { final String clientToken = getCsBrainTreeFacade().generateClientToken(); final HttpServletResponse response = (HttpServletResponse) Executions.getCurrent().getNativeResponse(); response.addCookie(new Cookie(COOKIE_CLIENT_TOKEN, clientToken)); }
From source file:org.codice.ddf.security.servlet.logout.LocalLogoutServlet.java
private void deleteJSessionId(HttpServletResponse response) { Cookie cookie = new Cookie("JSESSIONID", ""); cookie.setMaxAge(0);//w w w . j a va 2 s .c o m cookie.setPath("/"); cookie.setComment("EXPIRING COOKIE at " + System.currentTimeMillis()); response.addCookie(cookie); }
From source file:org.apache.lucene.gdata.servlet.handler.AuthenticationHandler.java
private void sendToken(HttpServletResponse response, String token) throws IOException { Writer responseWriter = response.getWriter(); Cookie cookie = new Cookie(AuthenticationController.TOKEN_KEY, token); response.addCookie(cookie); responseWriter.write(AuthenticationController.TOKEN_KEY); responseWriter.write(seperatory);// w ww.ja v a2s.com responseWriter.write(token); responseWriter.close(); }