List of usage examples for javax.servlet.http Cookie setMaxAge
public void setMaxAge(int expiry)
From source file:com.music.web.SocialSignInAdapter.java
public void addPermanentCookies(User user, HttpServletResponse response) { Cookie authTokenCookie = new Cookie(AUTH_TOKEN_COOKIE_NAME, user.getLoginToken()); authTokenCookie.setMaxAge(COOKIE_AGE); authTokenCookie.setPath("/"); authTokenCookie.setDomain(".computoser.com"); response.addCookie(authTokenCookie); Cookie seriesCookie = new Cookie(AUTH_TOKEN_SERIES_COOKIE_NAME, user.getLoginSeries()); seriesCookie.setMaxAge(COOKIE_AGE);//from ww w .j ava2 s .c om seriesCookie.setPath("/"); seriesCookie.setDomain(".computoser.com"); response.addCookie(seriesCookie); }
From source file:com.trailmagic.image.ui.LogoutController.java
@RequestMapping("/logout") public void handleRequestInternal(HttpServletRequest req, HttpServletResponse res) throws Exception { SavedRequest savedRequest = requestCache.getRequest(req, res); HttpSession session = req.getSession(false); session.invalidate();/*w ww . jav a2 s .c o m*/ Cookie terminate = new Cookie(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, null); terminate.setMaxAge(0); res.addCookie(terminate); if (savedRequest != null) { res.sendRedirect(savedRequest.getRedirectUrl()); } else { res.sendRedirect("/photo/albums/"); } }
From source file:eu.semlibproject.annotationserver.managers.CookiesManager.java
/** * Remove an annotation server cookie *///from ww w . j a va 2 s. c o m public void removeASCookie(HttpServletResponse response, Cookie cookie) { cookie.setMaxAge(0); response.addCookie(cookie); }
From source file:org.jasig.cas.web.support.CookieRetrievingCookieGeneratorTests.java
public void testCookieRetrieve() { final MockHttpServletRequest request = new MockHttpServletRequest(); final Cookie cookie = new Cookie("test", "test"); cookie.setDomain("cas.org"); cookie.setMaxAge(5); request.setCookies(new Cookie[] { cookie }); assertEquals("test", this.g.retrieveCookieValue(request)); }
From source file:org.uaa.security.core.LogoutHandler.java
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException { String uri = request.getRequestURI(); // clear Cookies Cookie[] cookies = request.getCookies(); for (Cookie cookie : cookies) { log.debug(cookie.getName());/*from ww w .j a v a2 s . c o m*/ cookie.setMaxAge(0); response.addCookie(cookie); } // set response message ResponseWithStatus res = new ResponseWithStatus(uri, "0", ConfigUtil.getValue("00000")); response.setContentType("application/json;charset=UTF-8"); response.getOutputStream().write(res.toJson().getBytes()); return; }
From source file:com.google.acre.script.AcreCookie.java
public Cookie toServletCookie() { Cookie c = new Cookie(name, value); c.setPath(path);//from w w w . j ava2 s . c o m c.setMaxAge(max_age); if (domain != null) c.setDomain(domain); c.setSecure(secure); return c; }
From source file:Controladores.ControladorLogin.java
@RequestMapping("efetua-login") public ModelAndView efetuaLogin(String usuario, String senha, boolean ckSalvaLogin, HttpSession sessao, HttpServletResponse response) {//from w w w .ja v a2 s. c o m ModelAndView mv; Funcionario f = DAO.Model.FuncionarioDAO.autenticacaoLogin(usuario, senha); if (f != null) { if (ckSalvaLogin) { Cookie c = new Cookie("loginCookie", usuario); c.setMaxAge(60); // em segundos response.addCookie(c); c = new Cookie("senhaCookie", senha); c.setMaxAge(60); // em segundos response.addCookie(c); } sessao.setAttribute("logado", true); sessao.setAttribute("funcionario", f); if (sessao.getAttribute("endereco") == null) { mv = new ModelAndView("redirect:index"); } else { String endereco = sessao.getAttribute("endereco").toString(); endereco = endereco.substring(endereco.lastIndexOf("/") + 1); mv = new ModelAndView("redirect:" + endereco); } sessao.removeAttribute("endereco"); } else { sessao.setAttribute("logado", false); mv = new ModelAndView("redirect:exibe-login"); } return mv; }
From source file:eu.trentorise.smartcampus.permissionprovider.controller.CookieCleaner.java
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { for (String s : cookieNames) { Cookie cookie = new Cookie(s, null); cookie.setPath("/"); cookie.setMaxAge(0); response.addCookie(cookie);/* www . j a va 2 s. c om*/ cookie = new Cookie(s, null); cookie.setPath(request.getContextPath() + "/eauth/"); cookie.setMaxAge(0); response.addCookie(cookie); } if (request.getCookies() != null) { for (int i = 0; i < request.getCookies().length; i++) { Cookie cookie = request.getCookies()[i]; for (String s : cookieNames) { if (cookie.getName().startsWith(s)) { cookie = new Cookie(cookie.getName(), null); cookie.setPath("/"); cookie.setMaxAge(0); response.addCookie(cookie); cookie = new Cookie(cookie.getName(), null); cookie.setPath(request.getContextPath() + "/eauth/"); cookie.setMaxAge(0); response.addCookie(cookie); } } } } request.getSession().invalidate(); if (authentication != null) authentication.setAuthenticated(false); response.sendRedirect(request.getContextPath() + redirect); }
From source file:de.voolk.marbles.web.app.IdentSession.java
@Override public boolean authenticate(String loginName, String password) { boolean auth = getAuthentificationService().authenticate(loginName, password); if (auth) {/*from ww w .ja v a 2 s. c o m*/ this.login = loginName; String identKey = getUser().getIdentKey(); Cookie cookie = new Cookie(IDENT_COOKIE, identKey); cookie.setMaxAge(COOKIE_MAX_AGE); ((WebResponse) RequestCycle.get().getResponse()).addCookie(cookie); } signIn(auth); return auth; }
From source file:com.edgenius.wiki.integration.client.Authentication.java
private void setCookie(String[] tokens, int maxAge, String targetWebContext, HttpServletRequest request, HttpServletResponse response) {/*from w ww .java 2s .c o m*/ String cookieValue = encodeCookie(tokens); Cookie cookie = new Cookie(WsContants.REMEMBER_ME_COOKIE_NAME, cookieValue); cookie.setMaxAge(maxAge); cookie.setPath(targetWebContext); response.addCookie(cookie); }