src/share/classes/java/net/CookieManager.java

Print this page




  24  */
  25 
  26 package java.net;
  27 
  28 import java.util.Map;
  29 import java.util.List;
  30 import java.util.Collections;
  31 import java.util.Comparator;
  32 import java.io.IOException;
  33 import sun.util.logging.PlatformLogger;
  34 
  35 /**
  36  * CookieManager provides a concrete implementation of {@link CookieHandler},
  37  * which separates the storage of cookies from the policy surrounding accepting
  38  * and rejecting cookies. A CookieManager is initialized with a {@link CookieStore}
  39  * which manages storage, and a {@link CookiePolicy} object, which makes
  40  * policy decisions on cookie acceptance/rejection.
  41  *
  42  * <p> The HTTP cookie management in java.net package looks like:
  43  * <blockquote>
  44  * <pre>
  45  *                  use
  46  * CookieHandler <------- HttpURLConnection
  47  *       ^
  48  *       | impl
  49  *       |         use
  50  * CookieManager -------> CookiePolicy
  51  *             |   use
  52  *             |--------> HttpCookie
  53  *             |              ^
  54  *             |              | use
  55  *             |   use        |
  56  *             |--------> CookieStore
  57  *                            ^
  58  *                            | impl
  59  *                            |
  60  *                  Internal in-memory implementation
  61  * </pre>
  62  * <ul>
  63  *   <li>
  64  *     CookieHandler is at the core of cookie management. User can call
  65  *     CookieHandler.setDefault to set a concrete CookieHanlder implementation
  66  *     to be used.
  67  *   </li>
  68  *   <li>
  69  *     CookiePolicy.shouldAccept will be called by CookieManager.put to see whether
  70  *     or not one cookie should be accepted and put into cookie store. User can use
  71  *     any of three pre-defined CookiePolicy, namely ACCEPT_ALL, ACCEPT_NONE and
  72  *     ACCEPT_ORIGINAL_SERVER, or user can define his own CookiePolicy implementation
  73  *     and tell CookieManager to use it.
  74  *   </li>
  75  *   <li>
  76  *     CookieStore is the place where any accepted HTTP cookie is stored in.
  77  *     If not specified when created, a CookieManager instance will use an internal
  78  *     in-memory implementation. Or user can implements one and tell CookieManager
  79  *     to use it.
  80  *   </li>
  81  *   <li>




  24  */
  25 
  26 package java.net;
  27 
  28 import java.util.Map;
  29 import java.util.List;
  30 import java.util.Collections;
  31 import java.util.Comparator;
  32 import java.io.IOException;
  33 import sun.util.logging.PlatformLogger;
  34 
  35 /**
  36  * CookieManager provides a concrete implementation of {@link CookieHandler},
  37  * which separates the storage of cookies from the policy surrounding accepting
  38  * and rejecting cookies. A CookieManager is initialized with a {@link CookieStore}
  39  * which manages storage, and a {@link CookiePolicy} object, which makes
  40  * policy decisions on cookie acceptance/rejection.
  41  *
  42  * <p> The HTTP cookie management in java.net package looks like:
  43  * <blockquote>
  44  * <pre>{@code
  45  *                  use
  46  * CookieHandler <------- HttpURLConnection
  47  *       ^
  48  *       | impl
  49  *       |         use
  50  * CookieManager -------> CookiePolicy
  51  *             |   use
  52  *             |--------> HttpCookie
  53  *             |              ^
  54  *             |              | use
  55  *             |   use        |
  56  *             |--------> CookieStore
  57  *                            ^
  58  *                            | impl
  59  *                            |
  60  *                  Internal in-memory implementation
  61  * }</pre>
  62  * <ul>
  63  *   <li>
  64  *     CookieHandler is at the core of cookie management. User can call
  65  *     CookieHandler.setDefault to set a concrete CookieHanlder implementation
  66  *     to be used.
  67  *   </li>
  68  *   <li>
  69  *     CookiePolicy.shouldAccept will be called by CookieManager.put to see whether
  70  *     or not one cookie should be accepted and put into cookie store. User can use
  71  *     any of three pre-defined CookiePolicy, namely ACCEPT_ALL, ACCEPT_NONE and
  72  *     ACCEPT_ORIGINAL_SERVER, or user can define his own CookiePolicy implementation
  73  *     and tell CookieManager to use it.
  74  *   </li>
  75  *   <li>
  76  *     CookieStore is the place where any accepted HTTP cookie is stored in.
  77  *     If not specified when created, a CookieManager instance will use an internal
  78  *     in-memory implementation. Or user can implements one and tell CookieManager
  79  *     to use it.
  80  *   </li>
  81  *   <li>