List of usage examples for javax.servlet.http Cookie setMaxAge
public void setMaxAge(int expiry)
From source file:org.jasig.cas.web.support.CookieRetrievingCookieGenerator.java
public void addCookie(final HttpServletRequest request, final HttpServletResponse response, final String cookieValue) { if (!StringUtils.hasText(request.getParameter(RememberMeCredentials.REQUEST_PARAMETER_REMEMBER_ME))) { super.addCookie(response, cookieValue); } else {//from w w w . ja v a2 s .c o m final Cookie cookie = createCookie(cookieValue); cookie.setMaxAge(this.rememberMeMaxAge); if (isCookieSecure()) { cookie.setSecure(true); } response.addCookie(cookie); } }
From source file:net.anthonychaves.bookmarks.web.TokenController.java
@RequestMapping(method = RequestMethod.POST) public String rememberMe(HttpSession session, HttpServletResponse response, ModelMap model) { int duration = 168; //hours to remember me for = 1 week User user = (User) session.getAttribute("user"); String tokenId = tokenService.setupNewLoginToken(user); Cookie cookie = new Cookie("loginToken", tokenId); cookie.setMaxAge(duration * 60 * 60); cookie.setPath("/bookmarks"); response.addCookie(cookie);//from w w w . j a v a2 s. c o m model.addAttribute("status", "success"); return "redirect:/b/user"; }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.facebook.FacebookLogoutHandler.java
private void cancelCookie(final String name, final String path, final HttpServletResponse response) { Cookie cookie = new Cookie(name, null); cookie.setMaxAge(0); cookie.setPath(path);//from w w w . j av a2 s. c o m response.addCookie(cookie); }
From source file:org.apache.hadoop.hive.hwi.servlet.RBase.java
/** * set current user/*from w w w .j av a2 s. c o m*/ * @param user */ protected void setUser(String user) { Cookie cookie = new Cookie(USER_COOKIE_NAME, user); cookie.setMaxAge(365 * 24 * 60 * 60); cookie.setPath("/hwi"); response.addCookie(cookie); }
From source file:com.bennavetta.appsite.serve.HttpServletResp.java
@Override public void setCookie(String name, String value, int maxAge) { Cookie cookie = new Cookie(name, value); cookie.setMaxAge(maxAge); response.addCookie(cookie);/*w w w. ja v a 2s . c om*/ }
From source file:com.reever.humilheme.web.CookieController.java
public Cookie createCookie(HttpServletRequest request, HttpServletResponse response, String conteudo) { String path = StringUtils.isEmpty(request.getContextPath()) ? "/" : request.getContextPath(); try {//from w ww .j a v a2 s. c om conteudo = URLEncoder.encode(conteudo, "UTF-8"); } catch (UnsupportedEncodingException e) { _logger.error("Erro no encode do cookie", e); } Cookie cookie = new Cookie(nomeCookie, conteudo); cookie.setMaxAge(expiry); cookie.setPath(path); cookie.setVersion(1); response.addCookie(cookie); return cookie; }
From source file:org.egov.infstr.security.spring.filter.CustomLogoutHandler.java
private void clearAllCookies(final HttpServletRequest request, final HttpServletResponse response) { final Cookie cookies[] = request.getCookies(); if (cookies == null || cookies.length < 1) return;// ww w . j a v a 2 s.c o m for (final Cookie cookie : cookies) { cookie.setMaxAge(0); cookie.setPath("/"); cookie.setValue(null); response.addCookie(cookie); } }
From source file:nl.surfnet.coin.teams.control.LandingPageController.java
@RequestMapping(value = "/landingpage.shtml", method = RequestMethod.POST) public void storeCookie(HttpServletResponse response) { Cookie cookie = new Cookie(LoginInterceptor.TEAMS_COOKIE, "skipLanding=true"); cookie.setMaxAge(Integer.MAX_VALUE); response.addCookie(cookie);//w w w . j av a 2 s .c om }
From source file:com.demandware.vulnapp.challenge.impl.CookieChallenge.java
@SuppressWarnings("unchecked") private Cookie generateCookie() { JSONObject o = new JSONObject(); o.put(ACCESS_KEY, "false"); String value = new String(Base64.encodeBase64(o.toJSONString().getBytes())); Cookie c = new Cookie(COOKIE_NAME, value); c.setMaxAge(MAX_AGE); c.setPath("/"); return c;//from ww w . ja v a2 s .c o m }
From source file:net.prasenjit.auth.config.CsrfCookieGeneratorFilter.java
/** * {@inheritDoc}/*ww w.jav a2s . c om*/ */ @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { // Spring put the CSRF token in session attribute "_csrf" CsrfToken csrfToken = (CsrfToken) request.getAttribute("_csrf"); // Send the cookie only if the token has changed String actualToken = request.getHeader("X-XSRF-TOKEN"); if (actualToken == null || !actualToken.equals(csrfToken.getToken())) { // Session cookie that will be used by AngularJS String pCookieName = "XSRF-TOKEN"; Cookie cookie = new Cookie(pCookieName, csrfToken.getToken()); cookie.setMaxAge(-1); cookie.setHttpOnly(false); cookie.setPath("/"); response.addCookie(cookie); } filterChain.doFilter(request, response); }