Package com.nimbusds.jose
Class PlainHeader.Builder
- java.lang.Object
-
- com.nimbusds.jose.PlainHeader.Builder
-
- Enclosing class:
- PlainHeader
public static class PlainHeader.Builder extends Object
Builder for constructing unsecured (plain) headers.Example usage:
PlainHeader header = new PlainHeader.Builder(). contentType("text/plain"). customParam("exp", new Date().getTime()). build();
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates a new unsecured (plain) header builder.Builder(PlainHeader plainHeader)
Creates a new unsecured (plain) header builder with the parameters from the specified header.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlainHeader
build()
Builds a new unsecured (plain) header.PlainHeader.Builder
contentType(String cty)
Sets the content type (cty
) parameter.PlainHeader.Builder
criticalParams(Set<String> crit)
Sets the critical header parameters (crit
) parameter.PlainHeader.Builder
customParam(String name, Object value)
Sets a custom (non-registered) parameter.PlainHeader.Builder
customParams(Map<String,Object> customParameters)
Sets the custom (non-registered) parameters.PlainHeader.Builder
parsedBase64URL(Base64URL base64URL)
Sets the parsed Base64URL.PlainHeader.Builder
type(JOSEObjectType typ)
Sets the type (typ
) parameter.
-
-
-
Constructor Detail
-
Builder
public Builder()
Creates a new unsecured (plain) header builder.
-
Builder
public Builder(PlainHeader plainHeader)
Creates a new unsecured (plain) header builder with the parameters from the specified header.- Parameters:
plainHeader
- The unsecured header to use. Must not benull
.
-
-
Method Detail
-
type
public PlainHeader.Builder type(JOSEObjectType typ)
Sets the type (typ
) parameter.- Parameters:
typ
- The type parameter,null
if not specified.- Returns:
- This builder.
-
contentType
public PlainHeader.Builder contentType(String cty)
Sets the content type (cty
) parameter.- Parameters:
cty
- The content type parameter,null
if not specified.- Returns:
- This builder.
-
criticalParams
public PlainHeader.Builder criticalParams(Set<String> crit)
Sets the critical header parameters (crit
) parameter.- Parameters:
crit
- The names of the critical header parameters, empty set ornull
if none.- Returns:
- This builder.
-
customParam
public PlainHeader.Builder customParam(String name, Object value)
Sets a custom (non-registered) parameter.- Parameters:
name
- The name of the custom parameter. Must not match a registered parameter name and must not benull
.value
- The value of the custom parameter, should map to a valid JSON entity,null
if not specified.- Returns:
- This builder.
- Throws:
IllegalArgumentException
- If the specified parameter name matches a registered parameter name.
-
customParams
public PlainHeader.Builder customParams(Map<String,Object> customParameters)
Sets the custom (non-registered) parameters. The values must be serialisable to a JSON entity, otherwise will be ignored.- Parameters:
customParameters
- The custom parameters, empty map ornull
if none.- Returns:
- This builder.
-
parsedBase64URL
public PlainHeader.Builder parsedBase64URL(Base64URL base64URL)
Sets the parsed Base64URL.- Parameters:
base64URL
- The parsed Base64URL,null
if the header is created from scratch.- Returns:
- This builder.
-
build
public PlainHeader build()
Builds a new unsecured (plain) header.- Returns:
- The unsecured header.
-
-