Class Cookie

  • All Implemented Interfaces:
    java.io.Serializable

    public class Cookie
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Cookie.Builder  
    • Constructor Summary

      Constructors 
      Constructor Description
      Cookie​(java.lang.String name, java.lang.String value)
      Create a cookie for the default path with the given name and value with no expiry set.
      Cookie​(java.lang.String name, java.lang.String value, java.lang.String path)
      Create a cookie.
      Cookie​(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, java.util.Date expiry)
      Creates an insecure non-httpOnly cookie.
      Cookie​(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, java.util.Date expiry, boolean isSecure)
      Creates a non-httpOnly cookie.
      Cookie​(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, java.util.Date expiry, boolean isSecure, boolean isHttpOnly)
      Creates a cookie.
      Cookie​(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, java.util.Date expiry, boolean isSecure, boolean isHttpOnly, java.lang.String sameSite)
      Creates a cookie.
      Cookie​(java.lang.String name, java.lang.String value, java.lang.String path, java.util.Date expiry)
      Creates an insecure non-httpOnly cookie with no domain specified.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Two cookies are equal if the name and value match
      java.lang.String getDomain()  
      java.util.Date getExpiry()  
      java.lang.String getName()  
      java.lang.String getPath()  
      java.lang.String getSameSite()  
      java.lang.String getValue()  
      int hashCode()  
      boolean isHttpOnly()  
      boolean isSecure()  
      java.util.Map<java.lang.String,​java.lang.Object> toJson()
      JSON object keys are defined in https://w3c.github.io/webdriver/#dfn-table-for-cookie-conversion.
      java.lang.String toString()  
      void validate()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Cookie

        public Cookie​(java.lang.String name,
                      java.lang.String value,
                      java.lang.String path,
                      java.util.Date expiry)
        Creates an insecure non-httpOnly cookie with no domain specified.
        Parameters:
        name - The name of the cookie; may not be null or an empty string.
        value - The cookie value; may not be null.
        path - The path the cookie is visible to. If left blank or set to null, will be set to "/".
        expiry - The cookie's expiration date; may be null.
        See Also:
        Cookie(String, String, String, String, Date)
      • Cookie

        public Cookie​(java.lang.String name,
                      java.lang.String value,
                      java.lang.String domain,
                      java.lang.String path,
                      java.util.Date expiry)
        Creates an insecure non-httpOnly cookie.
        Parameters:
        name - The name of the cookie; may not be null or an empty string.
        value - The cookie value; may not be null.
        domain - The domain the cookie is visible to.
        path - The path the cookie is visible to. If left blank or set to null, will be set to "/".
        expiry - The cookie's expiration date; may be null.
        See Also:
        Cookie(String, String, String, String, Date, boolean)
      • Cookie

        public Cookie​(java.lang.String name,
                      java.lang.String value,
                      java.lang.String domain,
                      java.lang.String path,
                      java.util.Date expiry,
                      boolean isSecure)
        Creates a non-httpOnly cookie.
        Parameters:
        name - The name of the cookie; may not be null or an empty string.
        value - The cookie value; may not be null.
        domain - The domain the cookie is visible to.
        path - The path the cookie is visible to. If left blank or set to null, will be set to "/".
        expiry - The cookie's expiration date; may be null.
        isSecure - Whether this cookie requires a secure connection.
      • Cookie

        public Cookie​(java.lang.String name,
                      java.lang.String value,
                      java.lang.String domain,
                      java.lang.String path,
                      java.util.Date expiry,
                      boolean isSecure,
                      boolean isHttpOnly)
        Creates a cookie.
        Parameters:
        name - The name of the cookie; may not be null or an empty string.
        value - The cookie value; may not be null.
        domain - The domain the cookie is visible to.
        path - The path the cookie is visible to. If left blank or set to null, will be set to "/".
        expiry - The cookie's expiration date; may be null.
        isSecure - Whether this cookie requires a secure connection.
        isHttpOnly - Whether this cookie is a httpOnly cooke.
      • Cookie

        public Cookie​(java.lang.String name,
                      java.lang.String value,
                      java.lang.String domain,
                      java.lang.String path,
                      java.util.Date expiry,
                      boolean isSecure,
                      boolean isHttpOnly,
                      java.lang.String sameSite)
        Creates a cookie.
        Parameters:
        name - The name of the cookie; may not be null or an empty string.
        value - The cookie value; may not be null.
        domain - The domain the cookie is visible to.
        path - The path the cookie is visible to. If left blank or set to null, will be set to "/".
        expiry - The cookie's expiration date; may be null.
        isSecure - Whether this cookie requires a secure connection.
        isHttpOnly - Whether this cookie is a httpOnly cookie.
        sameSite - The samesite attribute of this cookie; e.g. None, Lax, Strict.
      • Cookie

        public Cookie​(java.lang.String name,
                      java.lang.String value)
        Create a cookie for the default path with the given name and value with no expiry set.
        Parameters:
        name - The cookie's name
        value - The cookie's value
      • Cookie

        public Cookie​(java.lang.String name,
                      java.lang.String value,
                      java.lang.String path)
        Create a cookie.
        Parameters:
        name - The cookie's name
        value - The cookie's value
        path - The path the cookie is for
    • Method Detail

      • getName

        public java.lang.String getName()
      • getValue

        public java.lang.String getValue()
      • getDomain

        public java.lang.String getDomain()
      • getPath

        public java.lang.String getPath()
      • isSecure

        public boolean isSecure()
      • isHttpOnly

        public boolean isHttpOnly()
      • getExpiry

        public java.util.Date getExpiry()
      • getSameSite

        public java.lang.String getSameSite()
      • validate

        public void validate()
      • toJson

        public java.util.Map<java.lang.String,​java.lang.Object> toJson()
        JSON object keys are defined in https://w3c.github.io/webdriver/#dfn-table-for-cookie-conversion.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Two cookies are equal if the name and value match
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object