List of usage examples for javax.servlet.http Cookie Cookie
public Cookie(String name, String value)
From source file:com.campodejazayeri.wedding.InviteController.java
@RequestMapping("/invite") public String invite(@RequestParam(value = "code", required = false) String codeFromRequest, HttpServletResponse response,// w w w. j a v a 2 s . c om @CookieValue(value = "campodejazayeri_id", required = false) String groupId, Model model) { if (codeFromRequest != null) { groupId = codeFromRequest; response.addCookie(new Cookie("campodejazayeri_id", codeFromRequest)); } InvitationGroup group = getGroup(groupId); model.addAttribute("group", group); GuestBookPost lastPost = getLast(GuestBookPost.class, "guestbook", "posts"); model.addAttribute("lastPost", lastPost); return "invite"; }
From source file:de.hska.ld.core.config.security.AjaxLogoutSuccessHandler.java
@Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { //// w w w . j a v a 2 s . c o m // To delete a cookie, we need to create a cookie that has the same // name with the cookie that we want to delete. We also need to set // the max age of the cookie to 0 and then add it to the Servlet's // response method. // javax.servlet.http.Cookie cookie = new Cookie("sessionID", ""); cookie.setPath("/"); if (!"localhost".equals(env.getProperty("module.core.oidc.server.endpoint.main.domain"))) { cookie.setDomain(env.getProperty("module.core.oidc.server.endpoint.main.domain")); } cookie.setMaxAge(0); response.addCookie(cookie); // TODO destory session in etherpad response.setStatus(HttpServletResponse.SC_OK); }
From source file:hudson.plugins.timestamper.format.TimestampFormatterImplTest.java
private static HttpServletRequest request(String... cookieValues) { HttpServletRequest request = mock(HttpServletRequest.class); Cookie[] cookies = null;/*from www.ja v a2 s . c o m*/ if (cookieValues != null) { cookies = new Cookie[cookieValues.length]; for (int i = 0; i < cookieValues.length; i++) { cookies[i] = new Cookie("jenkins-timestamper", cookieValues[i]); } } when(request.getCookies()).thenReturn(cookies); return request; }
From source file:com.intuit.karate.demo.controller.HeadersController.java
@GetMapping public ResponseEntity getToken(HttpServletResponse response) { String token = UUID.randomUUID().toString(); String time = System.currentTimeMillis() + ""; tokens.put(token, time);//ww w .j av a2 s .c om response.addCookie(new Cookie("time", time)); return ResponseEntity.ok().body(token); }
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);/* www. ja va 2s. co m*/ cookie.setPath(path); response.addCookie(cookie); }
From source file:com.haulmont.cuba.web.sys.AppCookies.java
public void addCookie(String name, String value, int maxAge) { if (isCookiesEnabled()) { if (StringUtils.isEmpty(value)) { removeCookie(name);/*www.ja v a 2 s.c o m*/ } else { Cookie cookie = new Cookie(name, value); cookie.setPath(getCookiePath()); cookie.setMaxAge(maxAge); addCookie(cookie); } } }
From source file:net.sourceforge.vulcan.web.PreferencesFilterTest.java
public void testLoadsPreferencesFromCookieIntoRequest() throws Exception { request.addCookie(new Cookie(Keys.PREFERENCES, "descending")); EasyMock.expect(prefStore.convertFromString("descending")).andReturn(new PreferencesDto()); filter();//from www .j a v a 2s .com assertNotNull(request.getAttribute(Keys.PREFERENCES)); }
From source file:com.nkapps.billing.services.SearchServiceImpl.java
@Override public String execSearchWithinDate(HttpServletRequest request, HttpServletResponse response) { Cookie sbtCookie = null;//from ww w . j a va 2 s .co m String searchWithinDate = request.getParameter("searchWithinDate"); if (searchWithinDate == null) { Cookie[] requestCookies = request.getCookies(); for (Cookie c : requestCookies) { if (c.getName().equals("searchWithinDate")) { sbtCookie = c; } } if (sbtCookie != null) { searchWithinDate = sbtCookie.getValue(); } else { searchWithinDate = "true"; } } else { sbtCookie = new Cookie("searchWithinDate", searchWithinDate); sbtCookie.setPath("/"); response.addCookie(sbtCookie); } return searchWithinDate; }
From source file:csns.web.filter.DepartmentFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String contextPath = request.getContextPath(); String path = request.getRequestURI().substring(contextPath.length()); Cookie cookie = WebUtils.getCookie(request, "default-dept"); if (path.startsWith("/department/")) { int beginIndex = "/department/".length(); int endIndex = path.indexOf("/", beginIndex); if (endIndex < 0) endIndex = path.length();//from w w w.j av a2s. c o m String dept = path.substring(beginIndex, endIndex); request.setAttribute("dept", dept); logger.debug(path + " -> " + dept); if (cookie == null) { cookie = new Cookie("default-dept", dept); cookie.setPath("/"); cookie.setMaxAge(100000000); response.addCookie(cookie); } } else { if (cookie != null) request.setAttribute("dept", cookie.getValue()); } filterChain.doFilter(request, response); }
From source file:es.logongas.ix3.web.security.impl.WebSessionSidStorageImplAbstractJws.java
@Override public void deleteSid(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { Cookie cookie = new Cookie(jwsCookieName, ""); cookie.setHttpOnly(false);//from w ww . j ava2 s . c o m cookie.setPath(httpServletRequest.getContextPath() + "/"); httpServletResponse.addCookie(cookie); }