com.jniwrapper.win32.ie.cookie
Class CookieManager

java.lang.Object
  extended by com.jniwrapper.win32.ie.cookie.CookieManager

public class CookieManager
extends java.lang.Object

The class allows working with persistent or session cookies.

The all persistent cookies stored in the windows\cookies directory and have an expiration date set sometime in the future.

The session cookies do not have an an expiration date and created in the same process. These cookies are not written to any files.


Method Summary
 void deleteAllPersistentCookies()
          Removes all persistent cookies.
 void deleteCookie(java.net.URL domain, Cookie cookie)
          Deletes persistent or session cookie.
 void deletePersistentCookie(Cookie cookie)
          Removes specified persistent cookie.
 java.util.Set<Cookie> getCookies(java.net.URL url)
          Returns cookies, that are associated with the specified URL.
 java.util.Set<Cookie> getCookies(java.net.URL url, WebBrowser browser)
          Returns persistent cookies and session cookies for a given browser instance, that are associated with the given url.
static CookieManager getInstance()
           
 java.util.Set<Cookie> getPersistentCookies()
          Returns the all persistent cookies stored in the windows\cookies directory and that have an expiration date set sometime in the future.
 void setCookie(java.net.URL url, Cookie cookie)
          Creates a new cookies for the specified URL using WinINet API.
 void setCookies(java.net.URL url, java.util.Set<Cookie> cookies)
          Creates a new cookies for the specified URL using WinINet API.
 void setCookies(java.net.URL url, java.util.Set<Cookie> cookies, WebBrowser browser)
          Creates a new cookies for a specified url and browser instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CookieManager getInstance()

getPersistentCookies

public java.util.Set<Cookie> getPersistentCookies()
Returns the all persistent cookies stored in the windows\cookies directory and that have an expiration date set sometime in the future. The method doesn't return session cookies and the cookies that the server marked as non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.

Returns:
the all persistent cookies stored in the windows\cookies directory.

getCookies

public java.util.Set<Cookie> getCookies(java.net.URL url)
Returns cookies, that are associated with the specified URL. This is an analogue of the InternetGetCookie native function.

It checks in the windows\cookies directory for persistent cookies that have an expiration date set sometime in the future.

It also searches memory for any session cookies, that is, cookies that do not have an expiration date that were created in the same process by CookieManager.setCookie(), because these cookies are not written to any files. Rules for creating cookie files are internal to the system and can change in the future.

Note: The method does not return cookies that the server marked as non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.

Parameters:
url - specifies an URL.
Returns:
cookies, that are associated with the specified URL.

getCookies

public java.util.Set<Cookie> getCookies(java.net.URL url,
                                        WebBrowser browser)
Returns persistent cookies and session cookies for a given browser instance, that are associated with the given url.

Parameters:
url - specifies an URL.
browser - the browser instance which session cookies this method returns.
Returns:
cookies, that are associated with the specified URL.
See Also:
WebBrowser.getCookies(java.net.URL)

setCookies

public void setCookies(java.net.URL url,
                       java.util.Set<Cookie> cookies)
Creates a new cookies for the specified URL using WinINet API. This is an analogue of the InternetSetCookie native function.

Cookies created by this method without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.

Parameters:
url - specifies an URL, a new cookie will be associated with.
cookies - the collection of Cookie objects.

setCookies

public void setCookies(java.net.URL url,
                       java.util.Set<Cookie> cookies,
                       WebBrowser browser)
Creates a new cookies for a specified url and browser instance.

Parameters:
url - specifies an URL, a new cookie will be associated with.
cookies - the collection of Cookie objects.
browser - the browser instance for which session cookies will be available.
See Also:
WebBrowser.setCookies(java.net.URL, java.util.Set)

setCookie

public void setCookie(java.net.URL url,
                      Cookie cookie)
Creates a new cookies for the specified URL using WinINet API. This is an analogue of the InternetSetCookie native function.

Cookies created by this method without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.

Parameters:
url - specifies an URL, a new cookie will be associated with.
cookie - specifies a new cookie.

deletePersistentCookie

public void deletePersistentCookie(Cookie cookie)
Removes specified persistent cookie.

Parameters:
cookie - specified persistent cookie.

deleteAllPersistentCookies

public void deleteAllPersistentCookies()
Removes all persistent cookies.


deleteCookie

public void deleteCookie(java.net.URL domain,
                         Cookie cookie)
Deletes persistent or session cookie.

Parameters:
domain - the domain of this cookie.
cookie - the cookie to delete.