org.apache.commons.httpclient.cookie

Class CookiePolicy

public abstract class CookiePolicy extends Object

Cookie management policy class. The cookie policy provides corresponding cookie management interfrace for a given type or version of cookie.

RFC 2109 specification is used per default. Other supported specification can be chosen when appropriate or set default when desired

The following specifications are provided:

Since: 2.0

Author: Oleg Kalnichevski Mike Bowler

Field Summary
static StringBROWSER_COMPATIBILITY
The policy that provides high degree of compatibilty with common cookie management of popular HTTP agents.
static intCOMPATIBILITY
The COMPATIBILITY policy provides high compatibilty with common cookie management of popular HTTP agents.
static StringDEFAULT
The default cookie policy.
static StringIGNORE_COOKIES
The policy that ignores cookies.
protected static LogLOG
Log object.
static StringNETSCAPE
The Netscape cookie draft compliant policy.
static intNETSCAPE_DRAFT
The NETSCAPE_DRAFT Netscape draft compliant policy.
static intRFC2109
The RFC2109 RFC 2109 compliant policy.
static intRFC2965
The RFC2965 RFC 2965 compliant policy.
static StringRFC_2109
The RFC 2109 compliant policy.
static StringRFC_2965
The RFC 2965 compliant policy.
Method Summary
static CookieSpecgetCompatibilitySpec()
static CookieSpecgetCookieSpec(String id)
Gets the cookie specification with the given ID.
static intgetDefaultPolicy()
static CookieSpecgetDefaultSpec()
Returns cookie specification registered as DEFAULT.
static String[]getRegisteredCookieSpecs()
Obtains the currently registered cookie policy names.
static CookieSpecgetSpecByPolicy(int policy)
static CookieSpecgetSpecByVersion(int ver)
Gets the CookieSpec for a particular cookie version.
static voidregisterCookieSpec(String id, Class clazz)
Registers a new cookie specification with the given identifier.
static voidsetDefaultPolicy(int policy)
static voidunregisterCookieSpec(String id)
Unregisters the cookie specification with the given ID.

Field Detail

BROWSER_COMPATIBILITY

public static final String BROWSER_COMPATIBILITY
The policy that provides high degree of compatibilty with common cookie management of popular HTTP agents.

Since: 3.0

COMPATIBILITY

public static final int COMPATIBILITY

Deprecated: Use BROWSER_COMPATIBILITY

The COMPATIBILITY policy provides high compatibilty with common cookie management of popular HTTP agents.

DEFAULT

public static final String DEFAULT
The default cookie policy.

Since: 3.0

IGNORE_COOKIES

public static final String IGNORE_COOKIES
The policy that ignores cookies.

Since: 3.0

LOG

protected static final Log LOG
Log object.

NETSCAPE

public static final String NETSCAPE
The Netscape cookie draft compliant policy.

Since: 3.0

NETSCAPE_DRAFT

public static final int NETSCAPE_DRAFT

Deprecated: Use NETSCAPE

The NETSCAPE_DRAFT Netscape draft compliant policy.

RFC2109

public static final int RFC2109

Deprecated: Use RFC_2109

The RFC2109 RFC 2109 compliant policy.

RFC2965

public static final int RFC2965

Deprecated: Use RFC_2965

The RFC2965 RFC 2965 compliant policy.

RFC_2109

public static final String RFC_2109
The RFC 2109 compliant policy.

Since: 3.0

RFC_2965

public static final String RFC_2965
The RFC 2965 compliant policy.

Since: 3.0

Method Detail

getCompatibilitySpec

public static CookieSpec getCompatibilitySpec()

Deprecated: Use getCookieSpec

Returns: cookie specification interface that provides high compatibilty with common cookie management of popular HTTP agents

getCookieSpec

public static CookieSpec getCookieSpec(String id)
Gets the cookie specification with the given ID.

Parameters: id the cookie specification ID

Returns: cookie specification

Throws: IllegalStateException if a policy with the ID cannot be found

Since: 3.0

getDefaultPolicy

public static int getDefaultPolicy()

Deprecated: Use getDefaultSpec

Returns: default cookie policy

See Also: getDefaultSpec

getDefaultSpec

public static CookieSpec getDefaultSpec()
Returns cookie specification registered as DEFAULT. If no default cookie specification has been registered, RFC2109 specification is returned.

Returns: default cookie specification

See Also: DEFAULT

getRegisteredCookieSpecs

public static String[] getRegisteredCookieSpecs()
Obtains the currently registered cookie policy names. Note that the DEFAULT policy (if present) is likely to be the same as one of the other policies, but does not have to be.

Returns: array of registered cookie policy names

Since: 3.1

getSpecByPolicy

public static CookieSpec getSpecByPolicy(int policy)

Deprecated: Use getCookieSpec

Parameters: policy cookie policy to get the CookieSpec for

Returns: cookie specification interface for the given policy

getSpecByVersion

public static CookieSpec getSpecByVersion(int ver)

Deprecated: Use getCookieSpec

Gets the CookieSpec for a particular cookie version.

Supported versions:

registerCookieSpec

public static void registerCookieSpec(String id, Class clazz)
Registers a new cookie specification with the given identifier. If a specification with the given ID already exists it will be overridden. This ID is the same one used to retrieve the cookie specification from getCookieSpec.

Parameters: id the identifier for this specification clazz the cookie specification class to register

Since: 3.0

See Also:

setDefaultPolicy

public static void setDefaultPolicy(int policy)

Deprecated: Use CookiePolicy

Parameters: policy new default cookie policy

See Also: DEFAULT

unregisterCookieSpec

public static void unregisterCookieSpec(String id)
Unregisters the cookie specification with the given ID.

Parameters: id the ID of the cookie specification to unregister

Since: 3.0

Copyright (c) 1999-2005 - Apache Software Foundation