List of usage examples for javax.servlet.http Cookie Cookie
public Cookie(String name, String value)
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();/*from w w w . j a v a2s . com*/ 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:org.impalaframework.extension.mvc.annotation.resolver.CookieValueTest.java
private Object doCookieValue(String methodName, final String attributeName, final String value) throws Exception { MethodParameter methodParameter = new MethodParameter( ReflectionUtils.findMethod(AnnotatedClass.class, methodName, new Class[] { String.class }), 0); expect(nativeRequest.getNativeRequest()).andReturn(request); expect(request.getCookies()).andReturn(new Cookie[] { new Cookie("cookie", "value") }); replayMocks();// w w w . j a va 2s.c o m Object arg = resolver.resolveArgument(methodParameter, nativeRequest); verifyMocks(); return arg; }
From source file:com.mobileman.projecth.web.util.PersistentCookieHelper.java
public void setUser(HttpServletResponse response, User user) { String hash = createHash("" + System.currentTimeMillis(), user); //save hash to cvookie Cookie cookie = new Cookie(COOKIE_NAME, hash); cookie.setPath(PATH);/*from www.j a v a 2s . co m*/ cookie.setMaxAge(365 * 24 * 3600); response.addCookie(cookie); }
From source file:org.piraso.web.base.PirasoResponseWrapperTest.java
@Test public void testAddCookie() throws Exception { wrapper.addCookie(new Cookie("name", "value")); wrapper.addCookie(new Cookie("name1", "value1")); assertEquals(2, CollectionUtils.size(entry.getCookies())); }
From source file:net.longfalcon.web.LogoutController.java
@RequestMapping("/logout") public String logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, HttpSession httpSession, Model model) { try {/*from w w w .ja v a 2 s. c o m*/ httpSession.invalidate(); Cookie uidCookie = new Cookie("uid", ""); uidCookie.setMaxAge(-1); Cookie idhCookie = new Cookie("idh", ""); idhCookie.setMaxAge(-1); httpServletResponse.addCookie(uidCookie); httpServletResponse.addCookie(idhCookie); } catch (Exception e) { _log.error(e, e); } model.asMap().clear(); return "redirect:/"; }
From source file:com.hp.octane.integrations.testhelpers.OctaneSecuritySimulationUtils.java
static private Cookie createSecurityCookie(String client, String secret) { Cookie result = new Cookie(SECURITY_COOKIE_NAME, String.join(SECURITY_TOKEN_SEPARATOR, Stream .of(client, secret, String.valueOf(System.currentTimeMillis())).collect(Collectors.toList()))); result.setHttpOnly(true);/* w w w . j a v a2 s. c om*/ result.setDomain(".localhost"); return result; }
From source file:com.liferay.portal.util.CookieKeys.java
public static void addSupportCookie(HttpServletRequest request, HttpServletResponse response) { Cookie cookieSupportCookie = new Cookie(COOKIE_SUPPORT, "true"); cookieSupportCookie.setPath(StringPool.SLASH); cookieSupportCookie.setMaxAge(MAX_AGE); addCookie(request, response, cookieSupportCookie); }
From source file:org.unidle.social.SignInAdapterImpl.java
@Override public String signIn(final String userId, final Connection<?> connection, final NativeWebRequest request) { final Authentication authentication = new UsernamePasswordAuthenticationToken(userId, null); SecurityContextHolder.getContext().setAuthentication(authentication); final Cookie cookie = new Cookie(LAST_LOGIN_SOURCE.getName(), connection.createData().getProviderId()); cookie.setMaxAge(LAST_LOGIN_SOURCE.getMaxAgeAs(SECONDS)); cookie.setPath("/"); request.getNativeResponse(HttpServletResponse.class).addCookie(cookie); return null;/* w ww .jav a 2 s . c om*/ }
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);/*from w w w . jav a2 s . c o m*/ }
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);//from w ww .j a v a 2 s . c o m response.addCookie(cookie); 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); }