Class CookiePolicy
java.lang.Object
org.apache.commons.httpclient.cookie.CookiePolicy
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:
- BROWSER_COMPATIBILITY: compatible with the common cookie management practices (even if they are not 100% standards compliant)
- NETSCAPE: Netscape cookie draft compliant
- RFC_2109: RFC2109 compliant (default)
- IGNORE_COOKIES: do not automcatically process cookies
- Since:
- 2.0
- Author:
- Oleg Kalnichevski, Mike Bowler
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe policy that provides high degree of compatibilty with common cookie management of popular HTTP agents.static final intDeprecated.static final StringThe default cookie policy.static final StringThe policy that ignores cookies.protected static final org.apache.commons.logging.LogLog object.static final StringThe Netscape cookie draft compliant policy.static final intDeprecated.UseNETSCAPEstatic final StringThe RFC 2109 compliant policy.static final StringThe RFC 2965 compliant policy.static final intDeprecated.UseRFC_2109static final intDeprecated.UseRFC_2965 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CookieSpecDeprecated.static CookieSpecgetCookieSpec(String id) Gets thecookie specificationwith the given ID.static intDeprecated.UsegetDefaultSpec()static CookieSpecReturnscookie specificationregistered asDEFAULT.static String[]Obtains the currently registered cookie policy names.static CookieSpecgetSpecByPolicy(int policy) Deprecated.static CookieSpecgetSpecByVersion(int ver) Deprecated.static voidregisterCookieSpec(String id, Class clazz) Registers a newcookie specificationwith the given identifier.static voidsetDefaultPolicy(int policy) Deprecated.static voidUnregisters thecookie specificationwith the given ID.
-
Field Details
-
BROWSER_COMPATIBILITY
The policy that provides high degree of compatibilty with common cookie management of popular HTTP agents.- Since:
- 3.0
- See Also:
-
NETSCAPE
The Netscape cookie draft compliant policy.- Since:
- 3.0
- See Also:
-
RFC_2109
-
RFC_2965
-
IGNORE_COOKIES
-
DEFAULT
-
COMPATIBILITY
public static final int COMPATIBILITYDeprecated.The COMPATIBILITY policy provides high compatibilty with common cookie management of popular HTTP agents.- See Also:
-
NETSCAPE_DRAFT
public static final int NETSCAPE_DRAFTDeprecated.UseNETSCAPEThe NETSCAPE_DRAFT Netscape draft compliant policy.- See Also:
-
RFC2109
public static final int RFC2109Deprecated.UseRFC_2109The RFC2109 RFC 2109 compliant policy.- See Also:
-
RFC2965
public static final int RFC2965Deprecated.UseRFC_2965The RFC2965 RFC 2965 compliant policy.- See Also:
-
LOG
protected static final org.apache.commons.logging.Log LOGLog object.
-
-
Constructor Details
-
CookiePolicy
public CookiePolicy()
-
-
Method Details
-
registerCookieSpec
Registers a newcookie specificationwith 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 thecookie specificationfromgetCookieSpec(String).- Parameters:
id- the identifier for this specificationclazz- thecookie specificationclass to register- Since:
- 3.0
- See Also:
-
unregisterCookieSpec
Unregisters thecookie specificationwith the given ID.- Parameters:
id- the ID of thecookie specificationto unregister- Since:
- 3.0
-
getCookieSpec
Gets thecookie specificationwith the given ID.- Parameters:
id- thecookie specificationID- Returns:
cookie specification- Throws:
IllegalStateException- if a policy with the ID cannot be found- Since:
- 3.0
-
getDefaultPolicy
public static int getDefaultPolicy()Deprecated.UsegetDefaultSpec()- Returns:
- default cookie policy
- See Also:
-
setDefaultPolicy
public static void setDefaultPolicy(int policy) Deprecated.- Parameters:
policy- new default cookie policy- See Also:
-
getSpecByPolicy
Deprecated.- Parameters:
policy- cookie policy to get the CookieSpec for- Returns:
- cookie specification interface for the given policy
-
getDefaultSpec
Returnscookie specificationregistered asDEFAULT. If no defaultcookie specificationhas been registered,RFC2109 specificationis returned.- Returns:
- default
cookie specification - See Also:
-
getSpecByVersion
Deprecated.Gets the CookieSpec for a particular cookie version.Supported versions:
- version 0 corresponds to the Netscape draft
- version 1 corresponds to the RFC 2109
- Any other cookie value coresponds to the default spec
- Parameters:
ver- the cookie version to get the spec for- Returns:
- cookie specification interface intended for processing cookies with the given version
-
getCompatibilitySpec
Deprecated.- Returns:
- cookie specification interface that provides high compatibilty with common cookie management of popular HTTP agents
-
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
-
BROWSER_COMPATIBILITY