Package com.adobe.acs.commons.util
Class CookieUtil
java.lang.Object
com.adobe.acs.commons.util.CookieUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddCookie(javax.servlet.http.Cookie cookie, javax.servlet.http.HttpServletResponse response) Add the provided HTTP Cookie to the Responsestatic intdropAllCookies(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath) Removes all cookies for the domainstatic intdropCookies(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath, String... cookieNames) Remove the named Cookies from Responsestatic intdropCookiesByRegex(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath, String... regexes) Remove the Cookies whose names match the provided Regex from Responsestatic intdropCookiesByRegexArray(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath, String[] regexes) Remove the Cookies whose names match the provided Regex from Responsestatic booleanextendCookieLife(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookieName, String cookiePath, int expiry) Extend the cookie life.static javax.servlet.http.CookieGet the named cookie from the HTTP Requeststatic List<javax.servlet.http.Cookie>getCookies(javax.servlet.http.HttpServletRequest request, String regex) Gets Cookies from the Request whose names match the provides Regex
-
Method Details
-
addCookie
public static boolean addCookie(javax.servlet.http.Cookie cookie, javax.servlet.http.HttpServletResponse response) Add the provided HTTP Cookie to the Response- Parameters:
cookie- Cookie to addresponse- Response to add Cookie to- Returns:
- true unless cookie or response is null
-
getCookie
public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest request, String cookieName) Get the named cookie from the HTTP Request- Parameters:
request- Request to get the Cookie fromcookieName- name of Cookie to get- Returns:
- the named Cookie, null if the named Cookie cannot be found
-
getCookies
public static List<javax.servlet.http.Cookie> getCookies(javax.servlet.http.HttpServletRequest request, String regex) Gets Cookies from the Request whose names match the provides Regex- Parameters:
request- Request to get the Cookie fromregex- Regex to match against Cookie names- Returns:
- Cookies which match the Regex
-
extendCookieLife
public static boolean extendCookieLife(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookieName, String cookiePath, int expiry) Extend the cookie life.
This can be used when a cookie should be valid for X minutes from the last point of activity. This method will leave expired or deleted cookies alone.- Parameters:
request- Request to get the Cookie fromresponse- Response to write the extended Cookie tocookieName- Name of Cookie to extend the life ofexpiry- New Cookie expiry
-
dropCookies
public static int dropCookies(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath, String... cookieNames) Remove the named Cookies from Response- Parameters:
request- Request to get the Cookies to dropresponse- Response to expire the Cookies oncookieNames- Names of cookies to drop- Returns:
- Number of Cookies dropped
-
dropCookiesByRegex
public static int dropCookiesByRegex(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath, String... regexes) Remove the Cookies whose names match the provided Regex from Response- Parameters:
request- Request to get the Cookies to dropresponse- Response to expire the Cookies onregexes- Regex to find Cookies to drop- Returns:
- Number of Cookies dropped
-
dropCookiesByRegexArray
public static int dropCookiesByRegexArray(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath, String[] regexes) Remove the Cookies whose names match the provided Regex from Response- Parameters:
request- Request to get the Cookies to dropresponse- Response to expire the Cookies onregexes- Regex to find Cookies to drop- Returns:
- Number of Cookies dropped
-
dropAllCookies
public static int dropAllCookies(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String cookiePath) Removes all cookies for the domain- Parameters:
request- Request to get the Cookies to dropresponse- Response to expire the Cookies on
-