Class CookieDefaults

java.lang.Object
org.apache.wicket.util.cookies.CookieDefaults
All Implemented Interfaces:
Serializable, IClusterable

public class CookieDefaults extends Object implements IClusterable
This class provides default values that are used by CookieUtils class when it creates cookies.
Author:
Juergen Donnerstag
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the cookie comment.
    Gets the cookie domain name.
    int
    Gets the max age.
    Gets the SameSite attribute of the cookie.
    boolean
    Returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Checks whether this Cookie has been marked as HttpOnly.
    void
    setComment(String comment)
    Sets the cookie comment.
    void
    setDomain(String domain)
    Sets the cookie domain name.
    void
    setHttpOnly(boolean httpOnly)
    Marks or unmarks this Cookie as HttpOnly.
    void
    setMaxAge(int maxAge)
    Sets the maximum age of the cookie in seconds.
    void
    Sets the SameSite attribute of the cookie.
    void
    setSecure(boolean secure)
    Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
    void
    setVersion(int version)
    Deprecated, for removal: This API element is subject to removal in a future version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getMaxAge

      public int getMaxAge()
      Gets the max age. After
      Returns:
      the max age
    • setMaxAge

      public void setMaxAge(int maxAge)
      Sets the maximum age of the cookie in seconds.
      Parameters:
      maxAge - the max age in seconds.
    • getComment

      public String getComment()
      Gets the cookie comment.
      Returns:
      the cookie comment
    • setComment

      public void setComment(String comment)
      Sets the cookie comment.
      Parameters:
      comment - the cookie comment
    • getDomain

      public String getDomain()
      Gets the cookie domain name.
      Returns:
      the cookie domain name
    • setDomain

      public void setDomain(String domain)
      Sets the cookie domain name.
      Parameters:
      domain - the cookie domain name
    • getSecure

      public boolean getSecure()
      Returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.
      Returns:
      whether this cookie is secure
    • setSecure

      public void setSecure(boolean secure)
      Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
      Parameters:
      secure - if true, sends the cookie from the browser to the server using only when using a secure protocol; if false, sent on any protocol
    • getVersion

      @Deprecated(since="Servlet 6.0 / Wicket 10", forRemoval=true) public int getVersion()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the version of the protocol this cookie complies with. Version 1 complies with RFC 2109, and version 0 complies with the original cookie specification drafted by Netscape. Cookies provided by a browser use and identify the browser's cookie version.
      Returns:
      0 if the cookie complies with the original Netscape specification; 1 if the cookie complies with RFC 2109
    • setVersion

      @Deprecated(since="Servlet 6.0 / Wicket 10", forRemoval=true) public void setVersion(int version)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the version of the cookie protocol this cookie complies with. Version 0 complies with the original Netscape cookie specification. Version 1 complies with RFC 2109.
      Since RFC 2109 is still somewhat new, consider version 1 as experimental; do not use it yet on production sites.
      Parameters:
      version - 0 if the cookie should comply with the original Netscape specification; 1 if the cookie should comply with RFC 2109
    • isHttpOnly

      public boolean isHttpOnly()
      Checks whether this Cookie has been marked as HttpOnly.
      Returns:
      true if this Cookie has been marked as HttpOnly, false otherwise
    • setHttpOnly

      public void setHttpOnly(boolean httpOnly)
      Marks or unmarks this Cookie as HttpOnly.

      HttpOnly cookies are not supposed to be exposed to client-side scripting code, and may therefore help mitigate certain kinds of cross-site scripting attacks.

      Parameters:
      httpOnly - true if this cookie is to be marked as HttpOnly, false otherwise
    • setSameSite

      public void setSameSite(CookieDefaults.SameSite sameSite)
      Sets the SameSite attribute of the cookie.
      Parameters:
      sameSite - the SameSite attribute of the cookie
    • getSameSite

      Gets the SameSite attribute of the cookie.
      Returns:
      the SameSite attribute of the cookie