< prev index next >

src/java.base/share/classes/java/net/CookieHandler.java

Print this page




  34  * A CookieHandler object provides a callback mechanism to hook up a
  35  * HTTP state management policy implementation into the HTTP protocol
  36  * handler. The HTTP state management mechanism specifies a way to
  37  * create a stateful session with HTTP requests and responses.
  38  *
  39  * <p> A system-wide CookieHandler to be used by the {@linkplain
  40  * HttpURLConnection HTTP URL stream protocol handler} can be registered by
  41  * doing a CookieHandler.setDefault(CookieHandler). The currently registered
  42  * CookieHandler can be retrieved by calling
  43  * CookieHandler.getDefault().
  44  *
  45  * For more information on HTTP state management, see <a
  46  * href="http://www.ietf.org/rfc/rfc2965.txt"><i>RFC&nbsp;2965: HTTP
  47  * State Management Mechanism</i></a>
  48  *
  49  * @author Yingxian Wang
  50  * @since 1.5
  51  */
  52 public abstract class CookieHandler {
  53     /**





  54      * The system-wide cookie handler that will apply cookies to the
  55      * request headers and manage cookies from the response headers.
  56      *
  57      * @see setDefault(CookieHandler)
  58      * @see getDefault()
  59      */
  60     private static CookieHandler cookieHandler;
  61 
  62     /**
  63      * Gets the system-wide cookie handler.
  64      *
  65      * @return the system-wide cookie handler; A null return means
  66      *        there is no system-wide cookie handler currently set.
  67      * @throws SecurityException
  68      *       If a security manager has been installed and it denies
  69      * {@link NetPermission}{@code ("getCookieHandler")}
  70      * @see #setDefault(CookieHandler)
  71      */
  72     public static synchronized CookieHandler getDefault() {
  73         SecurityManager sm = System.getSecurityManager();




  34  * A CookieHandler object provides a callback mechanism to hook up a
  35  * HTTP state management policy implementation into the HTTP protocol
  36  * handler. The HTTP state management mechanism specifies a way to
  37  * create a stateful session with HTTP requests and responses.
  38  *
  39  * <p> A system-wide CookieHandler to be used by the {@linkplain
  40  * HttpURLConnection HTTP URL stream protocol handler} can be registered by
  41  * doing a CookieHandler.setDefault(CookieHandler). The currently registered
  42  * CookieHandler can be retrieved by calling
  43  * CookieHandler.getDefault().
  44  *
  45  * For more information on HTTP state management, see <a
  46  * href="http://www.ietf.org/rfc/rfc2965.txt"><i>RFC&nbsp;2965: HTTP
  47  * State Management Mechanism</i></a>
  48  *
  49  * @author Yingxian Wang
  50  * @since 1.5
  51  */
  52 public abstract class CookieHandler {
  53     /**
  54      * Constructor for subclasses to call.
  55      */
  56     public CookieHandler() {}
  57 
  58     /**
  59      * The system-wide cookie handler that will apply cookies to the
  60      * request headers and manage cookies from the response headers.
  61      *
  62      * @see setDefault(CookieHandler)
  63      * @see getDefault()
  64      */
  65     private static CookieHandler cookieHandler;
  66 
  67     /**
  68      * Gets the system-wide cookie handler.
  69      *
  70      * @return the system-wide cookie handler; A null return means
  71      *        there is no system-wide cookie handler currently set.
  72      * @throws SecurityException
  73      *       If a security manager has been installed and it denies
  74      * {@link NetPermission}{@code ("getCookieHandler")}
  75      * @see #setDefault(CookieHandler)
  76      */
  77     public static synchronized CookieHandler getDefault() {
  78         SecurityManager sm = System.getSecurityManager();


< prev index next >