1 package com.atlassian.seraph.cookie;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5 import javax.servlet.http.Cookie;
6
7 /**
8 * Handles basic cookie tasks
9 */
10 public interface CookieHandler
11 {
12 /**
13 * Invalidate the specified cookie and delete it from the response object.
14 *
15 * @param response The HttpServletResponse object, known as "response" in a JSP page.
16 * @param cookieName The name of the cookie you want to delete.
17 * @param path of the path the cookie you want to delete.
18 */
19 public void invalidateCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String path);
20
21
22 /**
23 * Returns the specified Cookie object, or null if the cookie does not exist.
24 *
25 * @param request The HttpServletRequest object, known as "request" in a
26 * JSP page.
27 * @param name the name of the cookie.
28 * @return the Cookie object if it exists, otherwise null.
29 */
30 public Cookie getCookie(HttpServletRequest request, String name);
31
32
33 /**
34 * Sets a cookie
35 *
36 * This will also put the cookie in a list of cookies to send with this request's response
37 * (so that in case of a redirect occurring down the chain, the first filter
38 * will always try to set this cookie again)
39 *
40 * The cookie secure flag is set if the request is secure.
41 */
42 public Cookie setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int maxAge, String path);
43
44
45 /**
46 * Returns the value of the specified cookie as a String. If the cookie
47 * does not exist, the method returns null.
48 *
49 * @param request the HttpServletRequest object, known as "request" in a
50 * JSP page.
51 * @param name the name of the cookie
52 * @return the value of the cookie, or null if the cookie does not exist.
53 */
54 public String getCookieValue(HttpServletRequest request, String name);
55
56 }