com.sun.xml.ws.transport.http.client
Class CookieManager

java.lang.Object
  extended by java.net.CookieHandler
      extended by com.sun.xml.ws.transport.http.client.CookieManager

public class CookieManager
extends java.net.CookieHandler

CookieManager provides a concrete implementation of CookieHandler, which separates the storage of cookies from the policy surrounding accepting and rejecting cookies. A CookieManager is initialized with a CookieStore which manages storage, and a CookiePolicy object, which makes policy decisions on cookie acceptance/rejection.

The HTTP cookie management in java.net package looks like:

                  use
 CookieHandler <------- HttpURLConnection
       ^
       | impl
       |         use
 CookieManager -------> CookiePolicy
             |   use
             |--------> HttpCookie
             |              ^
             |              | use
             |   use        |
             |--------> CookieStore
                            ^
                            | impl
                            |
                  Internal in-memory implementation
 

There're various ways user can hook up his own HTTP cookie management behavior, e.g.

The implementation conforms to RFC 2965, section 3.3.

Since:
1.6
See Also:
CookiePolicy

Constructor Summary
CookieManager()
          Create a new cookie manager.
CookieManager(com.sun.xml.ws.transport.http.client.CookieStore store, CookiePolicy cookiePolicy)
          Create a new cookie manager with specified cookie store and cookie policy.
 
Method Summary
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> get(java.net.URI uri, java.util.Map<java.lang.String,java.util.List<java.lang.String>> requestHeaders)
           
 com.sun.xml.ws.transport.http.client.CookieStore getCookieStore()
          To retrieve current cookie store.
 void put(java.net.URI uri, java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaders)
           
 void setCookiePolicy(CookiePolicy cookiePolicy)
          To set the cookie policy of this cookie manager.
 
Methods inherited from class java.net.CookieHandler
getDefault, setDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieManager

public CookieManager()
Create a new cookie manager.

This constructor will create new cookie manager with default cookie store and accept policy. The effect is same as CookieManager(null, null).


CookieManager

public CookieManager(com.sun.xml.ws.transport.http.client.CookieStore store,
                     CookiePolicy cookiePolicy)
Create a new cookie manager with specified cookie store and cookie policy.

Parameters:
store - a CookieStore to be used by cookie manager. if null, cookie manager will use a default one, which is an in-memory CookieStore implmentation.
cookiePolicy - a CookiePolicy instance to be used by cookie manager as policy callback. if null, ACCEPT_ORIGINAL_SERVER will be used.
Method Detail

setCookiePolicy

public void setCookiePolicy(CookiePolicy cookiePolicy)
To set the cookie policy of this cookie manager.

A instance of CookieManager will have cookie policy ACCEPT_ORIGINAL_SERVER by default. Users always can call this method to set another cookie policy.

Parameters:
cookiePolicy - the cookie policy. Can be null, which has no effects on current cookie policy.

getCookieStore

public com.sun.xml.ws.transport.http.client.CookieStore getCookieStore()
To retrieve current cookie store.

Returns:
the cookie store currently used by cookie manager.

get

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> get(java.net.URI uri,
                                                                            java.util.Map<java.lang.String,java.util.List<java.lang.String>> requestHeaders)
                                                                     throws java.io.IOException
Specified by:
get in class java.net.CookieHandler
Throws:
java.io.IOException

put

public void put(java.net.URI uri,
                java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaders)
         throws java.io.IOException
Specified by:
put in class java.net.CookieHandler
Throws:
java.io.IOException


Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.