Class CookieProperties
- All Implemented Interfaces:
Serializable
,CasFeatureModule
- Direct Known Subclasses:
DeviceFingerprintProperties.Cookie
,GoogleAnalyticsCookieProperties
,LocaleCookieProperties
,OAuthCsrfCookieProperties
,Pac4jDelegatedAuthenticationCookieProperties
,PinnableCookieProperties
,WarningCookieProperties
- Since:
- 5.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apereo.cas.configuration.features.CasFeatureModule
CasFeatureModule.FeatureCatalog
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCookie domain.int
The maximum age of the cookie, specified in seconds.getName()
Cookie name.getPath()
Cookie path.If a cookie is only intended to be accessed in a first party context, the developer has the option to apply one of settingsSameSite=Lax
orSameSite=Strict
orSameSite=None
to prevent external access.boolean
true if this cookie contains the HttpOnly attribute.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.Cookie domain.setHttpOnly
(boolean httpOnly) true if this cookie contains the HttpOnly attribute.setMaxAge
(int maxAge) The maximum age of the cookie, specified in seconds.Cookie name.Cookie path.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 settingsSameSite=Lax
orSameSite=Strict
orSameSite=None
to prevent external access.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.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apereo.cas.configuration.features.CasFeatureModule
isDefined, isUndefined
-
Constructor Details
-
CookieProperties
public CookieProperties()
-
-
Method Details
-
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
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
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
If a cookie is only intended to be accessed in a first party context, the developer has the option to apply one of settingsSameSite=Lax
orSameSite=Strict
orSameSite=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,
Accepted values are:SameSite=None
, to designate cookies for cross-site access. When theSameSite=None
attribute is present, an additionalSecure
attribute is used so cross-site cookies can only be accessed over HTTPS connections.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
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
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
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
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
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
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
If a cookie is only intended to be accessed in a first party context, the developer has the option to apply one of settingsSameSite=Lax
orSameSite=Strict
orSameSite=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,
Accepted values are:SameSite=None
, to designate cookies for cross-site access. When theSameSite=None
attribute is present, an additionalSecure
attribute is used so cross-site cookies can only be accessed over HTTPS connections.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
.
-