com.sun.slamd.http
Class HTTPCookie

java.lang.Object
  extended bycom.sun.slamd.http.HTTPCookie

public class HTTPCookie
extends java.lang.Object

This class defines a cookie that may be used to help retain state information between requests.


Field Summary
static java.text.SimpleDateFormat EXPIRATION_DATE_FORMAT
          The date formatter that will be used to parse dates from cookies.
 
Constructor Summary
HTTPCookie(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, long expirationDate, boolean secure)
          Creates a new cookie with the provided information.
HTTPCookie(java.net.URL requestURL, java.lang.String cookieString)
          Creates a new cookie by parsing it from the provided string.
 
Method Summary
 boolean appliesToRequest(java.net.URL requestURL, long currentTime)
          Indicates whether this cookie applies to the provided request.
 java.lang.String getDomain()
          Retrieves the domain associated with this cookie.
 long getExpirationDate()
          Retrieves the expiration date for this cookie.
 java.lang.String getName()
          Retrieves the name for this cookie.
 java.lang.String getPath()
          Retrieves the path associated with this cookie.
 boolean getSecure()
          Indicates whether this cookie should be only provided over secure connections.
 java.lang.String getValue()
          Retrieves the value for this cookie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPIRATION_DATE_FORMAT

public static final java.text.SimpleDateFormat EXPIRATION_DATE_FORMAT
The date formatter that will be used to parse dates from cookies.

Constructor Detail

HTTPCookie

public HTTPCookie(java.net.URL requestURL,
                  java.lang.String cookieString)
           throws HTTPException
Creates a new cookie by parsing it from the provided string.

Parameters:
requestURL - The URL of the request with which the cookie is associated.
cookieString - The string to be parsed to create the cookie.
Throws:
HTTPException - If a problem occurs while attempting to parse the provided string as a cookie.

HTTPCookie

public HTTPCookie(java.lang.String name,
                  java.lang.String value,
                  java.lang.String domain,
                  java.lang.String path,
                  long expirationDate,
                  boolean secure)
Creates a new cookie with the provided information.

Parameters:
name - The name of the data associated with this cookie.
value - The value of the data associated with this cookie.
domain - The domain with which this cookie should be used.
path - The path for which this cookie should be used.
expirationDate - The time that this cookie should expire, or -1 if there should be no expiration date.
secure - Indicates whether this cookie should only be provided over a secure connection.
Method Detail

getName

public java.lang.String getName()
Retrieves the name for this cookie.

Returns:
The name for this cookie.

getValue

public java.lang.String getValue()
Retrieves the value for this cookie.

Returns:
The value for this cookie.

getDomain

public java.lang.String getDomain()
Retrieves the domain associated with this cookie.

Returns:
The domain associated with this cookie.

getPath

public java.lang.String getPath()
Retrieves the path associated with this cookie.

Returns:
The path associated with this cookie.

getExpirationDate

public long getExpirationDate()
Retrieves the expiration date for this cookie.

Returns:
The expiration date for this cookie.

getSecure

public boolean getSecure()
Indicates whether this cookie should be only provided over secure connections.

Returns:
true if this cookie should only be provided over secure connections, or false if not.

appliesToRequest

public boolean appliesToRequest(java.net.URL requestURL,
                                long currentTime)
Indicates whether this cookie applies to the provided request.

Parameters:
requestURL - The request for which to make the determination.
currentTime - The time to use when determining whether the cookie is expired.
Returns:
true if this cookie should be included in the given request, or false if not.