Package org.forgerock.openig.http
Class CookieBuilder
- java.lang.Object
-
- org.forgerock.openig.http.CookieBuilder
-
public final class CookieBuilder extends Object
Class to collate all static cookie configuration data for building response cookies.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Cookie
build()
Create aCookie
based on the details held in thisCookieBuilder
.static CookieBuilder
builder(String name)
Create aCookieBuilder
with just the cookie name set.static CookieBuilder
builder(JsonValue cookieConfig, String defaultName, String defaultPath)
Create aCookieBuilder
based on the JSON structure of:CookieBuilder
domain(String domain)
Set the domain and return a new instance of this builder.String
getName()
The name of the cookie that will be built from thisCookieBuilder
.CookieBuilder
httpOnly(boolean httpOnly)
Set the httpOnly flag and return a new instance of this builder.CookieBuilder
path(String path)
Set the path and return a new instance of this builder.CookieBuilder
sameSite(Cookie.SameSite sameSite)
Set theSameSite
enum and return a new instance of this builder.CookieBuilder
secure(boolean secure)
Set the secure flag and return a new instance of this builder.
-
-
-
Method Detail
-
builder
public static CookieBuilder builder(JsonValue cookieConfig, String defaultName, String defaultPath)
Create aCookieBuilder
based on the JSON structure of:{ "name" : Name of cookie. Defaults to {@literal defaultName}. "domain" : Domain that cookie is applicable to. "path" : Path to apply to the cookie. Defaults to {@literal defaultPath}. "secure" : Set to {@code true} if the cookie should be secure. Default is {@code false}. "httpOnly" : Set to {@code true} if cookie should be httpOnly. Default is {@code true}. "sameSite" : SameSite cookie configuration. Default is {@code null}. }
- Parameters:
cookieConfig
- The JSON containing the cookie details.defaultName
- The cookie name to use if not defined in the cookieConfig.defaultPath
- The cookie path to use if not defined in the cookieConfig.- Returns:
- a
CookieBuilder
based on the values defined in the cookieConfig.
-
builder
public static CookieBuilder builder(String name)
Create aCookieBuilder
with just the cookie name set.- Parameters:
name
- The name to use for the cookie name.- Returns:
- a
CookieBuilder
with just the cookie name set.
-
getName
public String getName()
The name of the cookie that will be built from thisCookieBuilder
.- Returns:
- the name of the cookie that will be built from this
CookieBuilder
.
-
domain
public CookieBuilder domain(String domain)
Set the domain and return a new instance of this builder.- Parameters:
domain
- the value of domain to use.- Returns:
- a new instance of the builder
-
path
public CookieBuilder path(String path)
Set the path and return a new instance of this builder.- Parameters:
path
- the value of path to use.- Returns:
- a new instance of the builder
-
secure
public CookieBuilder secure(boolean secure)
Set the secure flag and return a new instance of this builder.- Parameters:
secure
-true
if secure cookies should be enabled orfalse
otherwise.- Returns:
- a new instance of the builder
-
httpOnly
public CookieBuilder httpOnly(boolean httpOnly)
Set the httpOnly flag and return a new instance of this builder.- Parameters:
httpOnly
-true
if httpOnly cookies should be enabled orfalse
otherwise.- Returns:
- a new instance of the builder
-
sameSite
public CookieBuilder sameSite(Cookie.SameSite sameSite)
Set theSameSite
enum and return a new instance of this builder.- Parameters:
sameSite
-LAX
orSTRICT
.- Returns:
- a new instance of the builder
-
build
public Cookie build()
Create aCookie
based on the details held in thisCookieBuilder
.- Returns:
- a
Cookie
based on the details held in thisCookieBuilder
.
-
-