Class CookieProperties

java.lang.Object
org.apereo.cas.configuration.model.support.cookie.CookieProperties
All Implemented Interfaces:
Serializable, CasFeatureModule
Direct Known Subclasses:
DeviceFingerprintProperties.Cookie, GoogleAnalyticsCookieProperties, LocaleCookieProperties, OAuthCsrfCookieProperties, Pac4jDelegatedAuthenticationCookieProperties, PinnableCookieProperties, WarningCookieProperties

@RequiresModule(name="cas-server-core-cookie", automated=true) public class CookieProperties extends Object implements CasFeatureModule, Serializable
Common properties for all cookie configs.
Since:
5.0.0
See Also:
  • Constructor Details

    • CookieProperties

      public CookieProperties()
  • Method Details

    • getName

      public String getName()
      Cookie name. Constructs a cookie with a specified name and value. The name must conform to RFC 2965. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation. By default, cookies are created according to the RFC 2965 cookie specification. Cookie names are automatically calculated assigned by CAS at runtime, and there is usually no need to customize the name or assign it a different value unless a special use case warrants the change.
    • getPath

      public String getPath()
      Cookie path. Specifies a path for the cookie to which the client should return the cookie. The cookie is visible to all the pages in the directory you specify, and all the pages in that directory's subdirectories. A cookie's path must include the servlet that set the cookie, for example, /catalog, which makes the cookie visible to all directories on the server under /catalog. Consult RFC 2965 (available on the Internet) for more information on setting path names for cookies.
    • getDomain

      public String getDomain()
      Cookie domain. Specifies the domain within which this cookie should be presented. The form of the domain name is specified by RFC 2965. A domain name begins with a dot (.foo.com) and means that the cookie is visible to servers in a specified Domain Name System (DNS) zone (for example, www.foo.com, but not a.b.foo.com). By default, cookies are only returned to the server that sent them.
    • isSecure

      public boolean isSecure()
      True if sending this cookie should be restricted to a secure protocol, or false if the it can be sent using any protocol.
    • isHttpOnly

      public boolean isHttpOnly()
      true if this cookie contains the HttpOnly attribute. This means that the cookie should not be accessible to scripting engines, like javascript.
    • getMaxAge

      public int getMaxAge()
      The maximum age of the cookie, specified in seconds. By default, -1 indicating the cookie will persist until browser shutdown. A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is the maximum age when the cookie will expire, not the cookie's current age. A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A zero value causes the cookie to be deleted.
    • getSameSitePolicy

      public String getSameSitePolicy()
      If a cookie is only intended to be accessed in a first party context, the developer has the option to apply one of settings SameSite=Lax or SameSite=Strict or SameSite=None to prevent external access.

      To safeguard more websites and their users, the new secure-by-default model assumes all cookies should be protected from external access unless otherwise specified. Developers must use a new cookie setting, SameSite=None, to designate cookies for cross-site access. When the SameSite=None attribute is present, an additional Secure attribute is used so cross-site cookies can only be accessed over HTTPS connections.

      Accepted values are:
      • Lax
      • Strict
      • None
      • Off: Disable the generation of the SameSite cookie attribute altogether.
      • Path to a Groovy script that is able to generate the SameSite cookie attribute dynamically.
      • Fully qualified name of a class that implements org.apereo.cas.web.cookie.CookieSameSitePolicy
    • setName

      public CookieProperties setName(String name)
      Cookie name. Constructs a cookie with a specified name and value. The name must conform to RFC 2965. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation. By default, cookies are created according to the RFC 2965 cookie specification. Cookie names are automatically calculated assigned by CAS at runtime, and there is usually no need to customize the name or assign it a different value unless a special use case warrants the change.
      Returns:
      this.
    • setPath

      public CookieProperties setPath(String path)
      Cookie path. Specifies a path for the cookie to which the client should return the cookie. The cookie is visible to all the pages in the directory you specify, and all the pages in that directory's subdirectories. A cookie's path must include the servlet that set the cookie, for example, /catalog, which makes the cookie visible to all directories on the server under /catalog. Consult RFC 2965 (available on the Internet) for more information on setting path names for cookies.
      Returns:
      this.
    • setDomain

      public CookieProperties setDomain(String domain)
      Cookie domain. Specifies the domain within which this cookie should be presented. The form of the domain name is specified by RFC 2965. A domain name begins with a dot (.foo.com) and means that the cookie is visible to servers in a specified Domain Name System (DNS) zone (for example, www.foo.com, but not a.b.foo.com). By default, cookies are only returned to the server that sent them.
      Returns:
      this.
    • setSecure

      public CookieProperties setSecure(boolean secure)
      True if sending this cookie should be restricted to a secure protocol, or false if the it can be sent using any protocol.
      Returns:
      this.
    • setHttpOnly

      public CookieProperties setHttpOnly(boolean httpOnly)
      true if this cookie contains the HttpOnly attribute. This means that the cookie should not be accessible to scripting engines, like javascript.
      Returns:
      this.
    • setMaxAge

      public CookieProperties setMaxAge(int maxAge)
      The maximum age of the cookie, specified in seconds. By default, -1 indicating the cookie will persist until browser shutdown. A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is the maximum age when the cookie will expire, not the cookie's current age. A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A zero value causes the cookie to be deleted.
      Returns:
      this.
    • setSameSitePolicy

      public CookieProperties setSameSitePolicy(String sameSitePolicy)
      If a cookie is only intended to be accessed in a first party context, the developer has the option to apply one of settings SameSite=Lax or SameSite=Strict or SameSite=None to prevent external access.

      To safeguard more websites and their users, the new secure-by-default model assumes all cookies should be protected from external access unless otherwise specified. Developers must use a new cookie setting, SameSite=None, to designate cookies for cross-site access. When the SameSite=None attribute is present, an additional Secure attribute is used so cross-site cookies can only be accessed over HTTPS connections.

      Accepted values are:
      • Lax
      • Strict
      • None
      • Off: Disable the generation of the SameSite cookie attribute altogether.
      • Path to a Groovy script that is able to generate the SameSite cookie attribute dynamically.
      • Fully qualified name of a class that implements org.apereo.cas.web.cookie.CookieSameSitePolicy
      Returns:
      this.