CookiePolicy (HttpClient 3.1 API)
Keywords: org.apache.commons.httpclient.cookie.CookiePolicy class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.httpclient.cookie
Class CookiePolicy

    java.lang.Object
      org.apache.commons.httpclient.cookie.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:

- `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
`static String` | `BROWSER_COMPATIBILITY` The policy that provides high degree of compatibilty with common cookie management of popular HTTP agents.
`static int` | `COMPATIBILITY` Deprecated. Use `BROWSER_COMPATIBILITY`
`static String` | `DEFAULT` The default cookie policy.
`static String` | `IGNORE_COOKIES` The policy that ignores cookies.
`protected static Log` | `LOG` Log object.
`static String` | `NETSCAPE` The Netscape cookie draft compliant policy.
`static int` | `NETSCAPE_DRAFT` Deprecated. Use `NETSCAPE`
`static String` | `RFC_2109` The RFC 2109 compliant policy.
`static String` | `RFC_2965` The RFC 2965 compliant policy.
`static int` | `RFC2109` Deprecated. Use `RFC_2109`
`static int` | `RFC2965` Deprecated. Use `RFC_2965`

Constructor Summary
`CookiePolicy()`

Method Summary
`static CookieSpec` | `getCompatibilitySpec()` Deprecated. Use `getCookieSpec(String)`
`static CookieSpec` | `getCookieSpec(String id)` Gets the `cookie specification` with the given ID.
`static int` | `getDefaultPolicy()` Deprecated. Use `getDefaultSpec()`
`static CookieSpec` | `getDefaultSpec()` Returns `cookie specification` registered as `DEFAULT`.
`static String[]` | `getRegisteredCookieSpecs()` Obtains the currently registered cookie policy names.
`static CookieSpec` | `getSpecByPolicy(int policy)` Deprecated. Use `getCookieSpec(String)`
`static CookieSpec` | `getSpecByVersion(int ver)` Deprecated. Use `getCookieSpec(String)`
`static void` | `registerCookieSpec(String id, Class clazz)` Registers a new `cookie specification` with the given identifier.
`static void` | `setDefaultPolicy(int policy)` Deprecated. Use `registerCookieSpec(String, Class)`
`static void` | `unregisterCookieSpec(String id)` Unregisters the `cookie specification` with the given ID.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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
  See Also:
    Constant Field Values

### NETSCAPE

    public static final String NETSCAPE

  The Netscape cookie draft compliant policy.

  Since:
    3.0
  See Also:
    Constant Field Values

### RFC_2109

    public static final String RFC_2109

  The RFC 2109 compliant policy.

  Since:
    3.0
  See Also:
    Constant Field Values

### RFC_2965

    public static final String RFC_2965

  The RFC 2965 compliant policy.

  Since:
    3.0
  See Also:
    Constant Field Values

### IGNORE_COOKIES

    public static final String IGNORE_COOKIES

  The policy that ignores cookies.

  Since:
    3.0
  See Also:
    Constant Field Values

### DEFAULT

    public static final String DEFAULT

  The default cookie policy.

  Since:
    3.0
  See Also:
    Constant Field Values

### COMPATIBILITY

    public static final int COMPATIBILITY

  Deprecated. Use `BROWSER_COMPATIBILITY`
  The `COMPATIBILITY` policy provides high compatibilty with common cookie management of popular HTTP agents.

  See Also:
    Constant Field Values

### NETSCAPE_DRAFT

    public static final int NETSCAPE_DRAFT

  Deprecated. Use `NETSCAPE`
  The `NETSCAPE_DRAFT` Netscape draft compliant policy.

  See Also:
    Constant Field Values

### RFC2109

    public static final int RFC2109

  Deprecated. Use `RFC_2109`
  The `RFC2109` RFC 2109 compliant policy.

  See Also:
    Constant Field Values

### RFC2965

    public static final int RFC2965

  Deprecated. Use `RFC_2965`
  The `RFC2965` RFC 2965 compliant policy.

  See Also:
    Constant Field Values

### LOG

    protected static final Log LOG

  Log object.

Constructor Detail

### CookiePolicy

    public CookiePolicy()

Method Detail

### 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(String)`.

  Parameters:
    `id` - the identifier for this specification
    `clazz` - the `cookie specification` class to register
  Since:
    3.0
  See Also:
    `getCookieSpec(String)`

### 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

### getCookieSpec

    public static CookieSpec getCookieSpec(String id)
                                    throws IllegalStateException

  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()`

### setDefaultPolicy

    public static void setDefaultPolicy(int policy)

  Deprecated. Use `registerCookieSpec(String, Class)`

  Parameters:
    `policy` - new default cookie policy
  See Also:
    `DEFAULT`

### getSpecByPolicy

    public static CookieSpec getSpecByPolicy(int policy)

  Deprecated. Use `getCookieSpec(String)`

  Parameters:
    `policy` - cookie policy to get the CookieSpec for
  Returns:
    cookie specification interface for the given policy

### 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`

### getSpecByVersion

    public static CookieSpec getSpecByVersion(int ver)

  Deprecated. Use `getCookieSpec(String)`

  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

    public static CookieSpec getCompatibilitySpec()

  Deprecated. Use `getCookieSpec(String)`

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

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.