ice.net
Class CookieManager

java.lang.Object
  extended byjava.beans.VetoableChangeSupport
      extended byice.net.CookieManager
All Implemented Interfaces:
Serializable

public class CookieManager
extends VetoableChangeSupport

This class provides support for cookies.

See Also:
Serialized Form

Constructor Summary
CookieManager()
           
CookieManager(CookieManagerSettings cookieManagerSettings)
           
CookieManager(ice.net.HttpSession httpSession)
          Deprecated. As of 1.5, replaced by CookieManager(HttpSession).
 
Method Summary
 void addCookie(Cookie c)
          Add one cookie to the list of cookies maintained by the CookieManager.
 void addVetoableChangeListener(VetoableChangeListener vc)
          Register a listener for Cookie events.
protected  void applyAllCookies(URL url, URLConnection uc)
          Apply any cookies found for this URL.
 Enumeration elements()
          Returns an Enumeration of Cookie objects.
protected  boolean extractAllCookies(URL url, URLConnection urlConnection)
          Extracts any and all cookies found for this URL, and stores them.
 Cookie[] getAllCookies()
          Returns an array of Cookie objects.
 int getMaxCookieSize()
          Get the maximum allowed size for a single cookie.
 int getMaxNumberOfCookies()
          Get the maximum allowed number of cookies.
 int getMaxTotalCookieSize()
          Return the total maximum size allowed for cookies.
 boolean isCookieExpirationBufferEnabled()
           
 boolean isEnabled()
          Returns true if cookies are enabled.
 void readCookies(ObjectInput in)
          Reads cookies from an object stream
 void removeAllCookies()
          Removes all cookies.
 void removeAllExpiredCookies()
          Remove all cookies which has expired.
 void removeAllSessionCookies()
          Remove all session cookies, that is all cookies that are only valid for the current session.
 void setEnabled(boolean enable)
          Enable/Disable cookies.
 void setMaxCookieSize(int newSize)
          Set the maximum size of cookies in bytes.
 void setMaxNumberOfCookies(int maxCount)
          Set the maximum allowed number of cookies.
 void setMaxTotalCookieSize(int newSize)
          Set the maximum total size of all cookies in bytes.
 boolean shouldPersistPrivateCookies()
           
 void writeCookies(ObjectOutput out)
          Writes all stored cookies to an object stream
 
Methods inherited from class java.beans.VetoableChangeSupport
addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, hasListeners, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieManager

public CookieManager()

CookieManager

public CookieManager(CookieManagerSettings cookieManagerSettings)

CookieManager

public CookieManager(ice.net.HttpSession httpSession)
Deprecated. As of 1.5, replaced by CookieManager(HttpSession).

Method Detail

isCookieExpirationBufferEnabled

public boolean isCookieExpirationBufferEnabled()

shouldPersistPrivateCookies

public boolean shouldPersistPrivateCookies()

getMaxTotalCookieSize

public int getMaxTotalCookieSize()
Return the total maximum size allowed for cookies.


setMaxTotalCookieSize

public void setMaxTotalCookieSize(int newSize)
Set the maximum total size of all cookies in bytes.


setMaxCookieSize

public void setMaxCookieSize(int newSize)
Set the maximum size of cookies in bytes.


getMaxCookieSize

public int getMaxCookieSize()
Get the maximum allowed size for a single cookie.


setMaxNumberOfCookies

public void setMaxNumberOfCookies(int maxCount)
Set the maximum allowed number of cookies.


getMaxNumberOfCookies

public int getMaxNumberOfCookies()
Get the maximum allowed number of cookies.


setEnabled

public void setEnabled(boolean enable)
Enable/Disable cookies.


isEnabled

public boolean isEnabled()
Returns true if cookies are enabled.


elements

public Enumeration elements()
Returns an Enumeration of Cookie objects.

Returns:
An Enumeration of Cookies.

getAllCookies

public Cookie[] getAllCookies()
Returns an array of Cookie objects.

Returns:
An array of Cookies.
See Also:
elements()

extractAllCookies

protected boolean extractAllCookies(URL url,
                                    URLConnection urlConnection)
Extracts any and all cookies found for this URL, and stores them.

Parameters:
url - The actual url.
urlConnection - The URLconenction we extract cookies from.
Returns:
True if any cookies were found.
See Also:
applyAllCookies(java.net.URL, java.net.URLConnection)

removeAllCookies

public void removeAllCookies()
Removes all cookies.


removeAllSessionCookies

public void removeAllSessionCookies()
Remove all session cookies, that is all cookies that are only valid for the current session.


removeAllExpiredCookies

public void removeAllExpiredCookies()
Remove all cookies which has expired.


addCookie

public void addCookie(Cookie c)
Add one cookie to the list of cookies maintained by the CookieManager.


applyAllCookies

protected void applyAllCookies(URL url,
                               URLConnection uc)
Apply any cookies found for this URL.

Parameters:
url - The (not connected)url that may have cookies.
uc - The urlconnection to recieve the cookies.
See Also:
extractAllCookies(java.net.URL, java.net.URLConnection)

writeCookies

public void writeCookies(ObjectOutput out)
Writes all stored cookies to an object stream

Parameters:
out - The object stream to write to.

readCookies

public void readCookies(ObjectInput in)
Reads cookies from an object stream

Parameters:
in - The object stream to read from

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener vc)
Register a listener for Cookie events. Listeners can thow PropertyVetoException if they do not want a cookie to be added.