Package edu.indiana.lib.twinpeaks.util
Class CookieUtils
- java.lang.Object
-
- edu.indiana.lib.twinpeaks.util.CookieUtils
-
public class CookieUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ListfindCookiesForServer(List cookieList, URL url)Find all stored cookies which associated with this serverstatic ListgetCookies(List cookieList, URL url, String name, boolean exact)Find cookies associated with this server (by name)static ListgetCookiesByName(List cookieList, URL url, String name)Find cookies associated with this server (exact name match)static ListgetCookiesByPrefix(List cookieList, URL url, String name)Find cookies associated with this server (match on name "prefix")static booleaninDomain(String urlString, CookieData cookie)Does the cookie domain match the URL?static booleaninDomain(URL url, CookieData cookie)Does the cookie domain match the URL?static booleaninPath(String urlString, CookieData cookie)Does the cookie path match the URL "file"?static booleaninPath(URL url, CookieData cookie)Does the cookie path match the URL "file"?static ListnewCookieList()Get a new (empty) CookieData list return An empty ArrayListstatic CookieDataparseCookie(URL url, String value)Parse an HTTP cookiestatic voidstoreCookie(List cookieList, CookieData cookie)Maintain a list of CookieData objects (add, replace, or delete a cookie)
-
-
-
Method Detail
-
newCookieList
public static List newCookieList()
Get a new (empty) CookieData list return An empty ArrayList
-
parseCookie
public static CookieData parseCookie(URL url, String value)
Parse an HTTP cookie- Parameters:
value- Cookie value- Returns:
- A CookieData object representing this cookie
-
storeCookie
public static void storeCookie(List cookieList, CookieData cookie)
Maintain a list of CookieData objects (add, replace, or delete a cookie)- Parameters:
cookieList- CookieData listcookie- A CookieData object
-
inDomain
public static boolean inDomain(String urlString, CookieData cookie)
Does the cookie domain match the URL?- Parameters:
urlString- URL String to matchcookie- CookieData object (the cookie)- Returns:
- true if the cookie domain matches the URL
-
inDomain
public static boolean inDomain(URL url, CookieData cookie)
Does the cookie domain match the URL?- Parameters:
url- URL to matchcookie- CookieData object (the cookie)- Returns:
- true if the cookie domain matches the URL
-
inPath
public static boolean inPath(String urlString, CookieData cookie)
Does the cookie path match the URL "file"?- Parameters:
urlString- String URL to matchcookie- CookieData object (the cookie)- Returns:
- true if the cookie domain matches the URL
-
inPath
public static boolean inPath(URL url, CookieData cookie)
Does the cookie path match the URL "file"?- Parameters:
url- URL to matchcookie- CookieData object (the cookie)- Returns:
- true if the cookie domain matches the URL
-
findCookiesForServer
public static List findCookiesForServer(List cookieList, URL url)
Find all stored cookies which associated with this server- Parameters:
cookieList- List of stored cookies (CookieData objects)url- URL representing the request to lookup (server)- Returns:
- A List of associated cookies
-
getCookies
public static List getCookies(List cookieList, URL url, String name, boolean exact)
Find cookies associated with this server (by name)- Parameters:
cookieList- List of stored cookies (CookieData objects)url- URL representing the request to lookup (server)name- Cookie nameexact- true for exact name match, false to match on name prefix- Returns:
- A List of associated cookies
-
getCookiesByName
public static List getCookiesByName(List cookieList, URL url, String name)
Find cookies associated with this server (exact name match)- Parameters:
cookieList- List of stored cookies (CookieData objects)url- URL representing the request to lookup (server)name- Cookie name- Returns:
- A List of associated cookies
-
getCookiesByPrefix
public static List getCookiesByPrefix(List cookieList, URL url, String name)
Find cookies associated with this server (match on name "prefix")- Parameters:
cookieList- List of stored cookies (CookieData objects)url- URL representing the request to lookup (server)name- Cookie name- Returns:
- A List of associated cookies
-
-