Class RawJwt.Builder
- java.lang.Object
-
- com.google.crypto.tink.jwt.RawJwt.Builder
-
- Enclosing class:
- RawJwt
public static final class RawJwt.Builder extends java.lang.ObjectBuilder for RawJwt
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RawJwt.BuilderaddAudience(java.lang.String value)Adds an audience that the JWT is intended for.RawJwt.BuilderaddBooleanClaim(java.lang.String name, boolean value)Adds a custom claim of typebooleanto the JWT.RawJwt.BuilderaddJsonArrayClaim(java.lang.String name, java.lang.String encodedJsonArray)Adds a custom claim encoded in a JSONStringto the JWT.RawJwt.BuilderaddJsonObjectClaim(java.lang.String name, java.lang.String encodedJsonObject)Adds a custom claim encoded in a JSONStringto the JWT.RawJwt.BuilderaddNullClaim(java.lang.String name)Adds a custom claim with value null.RawJwt.BuilderaddNumberClaim(java.lang.String name, double value)Adds a custom claim of typedoubleto the JWT.RawJwt.BuilderaddNumberClaim(java.lang.String name, long value)Adds a custom claim of typelongto the JWT.RawJwt.BuilderaddStringClaim(java.lang.String name, java.lang.String value)Adds a custom claim of typeStringto the JWT.RawJwtbuild()RawJwt.BuildersetAudience(java.lang.String value)Sets the audience that the JWT is intended for.RawJwt.BuildersetAudiences(java.util.List<java.lang.String> values)Sets the audiences that the JWT is intended for.RawJwt.BuildersetExpiration(java.time.Instant value)Sets theexpclaim that identifies the instant on or after which the token MUST NOT be accepted for processing.RawJwt.BuildersetIssuedAt(java.time.Instant value)Sets theiatclaim that identifies the instant at which the JWT was issued.RawJwt.BuildersetIssuer(java.lang.String value)Sets the issuer claim that identifies the principal that issued the JWT.RawJwt.BuildersetJwtId(java.lang.String value)Sets the JWT ID claim that provides a unique identifier for the JWT.RawJwt.BuildersetNotBefore(java.time.Instant value)Sets thenbfclaim that identifies the instant before which the token MUST NOT be accepted for processing.RawJwt.BuildersetSubject(java.lang.String value)Sets the subject claim identifying the principal that is the subject of the JWT.RawJwt.BuildersetTypeHeader(java.lang.String value)Sets the Type Header Parameter.RawJwt.BuilderwithoutExpiration()Allow generating tokens without an expiration.
-
-
-
Method Detail
-
setTypeHeader
@CanIgnoreReturnValue public RawJwt.Builder setTypeHeader(java.lang.String value)
Sets the Type Header Parameter.When set, this value should be set to a shortended IANA MediaType, see https://tools.ietf.org/html/rfc7519#section-5.1 and https://tools.ietf.org/html/rfc8725#section-3.11
-
setIssuer
@CanIgnoreReturnValue public RawJwt.Builder setIssuer(java.lang.String value)
Sets the issuer claim that identifies the principal that issued the JWT.https://tools.ietf.org/html/rfc7519#section-4.1.1
-
setSubject
@CanIgnoreReturnValue public RawJwt.Builder setSubject(java.lang.String value)
Sets the subject claim identifying the principal that is the subject of the JWT.https://tools.ietf.org/html/rfc7519#section-4.1.2
-
setAudience
@CanIgnoreReturnValue public RawJwt.Builder setAudience(java.lang.String value)
Sets the audience that the JWT is intended for.Sets the
audclaim as a string. This method can't be used together withsetAudiencesoraddAudience.https://tools.ietf.org/html/rfc7519#section-4.1.3
-
setAudiences
@CanIgnoreReturnValue public RawJwt.Builder setAudiences(java.util.List<java.lang.String> values)
Sets the audiences that the JWT is intended for.Sets the
audclaim as an array of strings. This method can't be used together withsetAudience.https://tools.ietf.org/html/rfc7519#section-4.1.3
-
addAudience
@CanIgnoreReturnValue public RawJwt.Builder addAudience(java.lang.String value)
Adds an audience that the JWT is intended for.The
audclaim will always be encoded as an array of strings. This method can't be used together withsetAudience.https://tools.ietf.org/html/rfc7519#section-4.1.3
-
setJwtId
@CanIgnoreReturnValue public RawJwt.Builder setJwtId(java.lang.String value)
Sets the JWT ID claim that provides a unique identifier for the JWT.https://tools.ietf.org/html/rfc7519#section-4.1.7
-
setExpiration
@CanIgnoreReturnValue public RawJwt.Builder setExpiration(java.time.Instant value)
Sets theexpclaim that identifies the instant on or after which the token MUST NOT be accepted for processing.This API requires
Instantwhich is unavailable on Android until API level 26. To use it on older Android devices, enable API desugaring as shown in https://developer.android.com/studio/write/java8-support#library-desugaring.https://tools.ietf.org/html/rfc7519#section-4.1.4
-
withoutExpiration
@CanIgnoreReturnValue public RawJwt.Builder withoutExpiration()
Allow generating tokens without an expiration.For most applications of JWT, an expiration date should be set. This function makes sure that this is not forgotten, by requiring to user to explicitly state that no expiration should be set.
-
setNotBefore
@CanIgnoreReturnValue public RawJwt.Builder setNotBefore(java.time.Instant value)
Sets thenbfclaim that identifies the instant before which the token MUST NOT be accepted for processing.This API requires
Instantwhich is unavailable on Android until API level 26. To use it on older Android devices, enable API desugaring as shown in https://developer.android.com/studio/write/java8-support#library-desugaring.https://tools.ietf.org/html/rfc7519#section-4.1.5
-
setIssuedAt
@CanIgnoreReturnValue public RawJwt.Builder setIssuedAt(java.time.Instant value)
Sets theiatclaim that identifies the instant at which the JWT was issued.This API requires
Instantwhich is unavailable on Android until API level 26. To use it on older Android devices, enable API desugaring as shown in https://developer.android.com/studio/write/java8-support#library-desugaring.https://tools.ietf.org/html/rfc7519#section-4.1.6
-
addBooleanClaim
@CanIgnoreReturnValue public RawJwt.Builder addBooleanClaim(java.lang.String name, boolean value)
Adds a custom claim of typebooleanto the JWT.
-
addNumberClaim
@CanIgnoreReturnValue public RawJwt.Builder addNumberClaim(java.lang.String name, long value)
Adds a custom claim of typelongto the JWT.
-
addNumberClaim
@CanIgnoreReturnValue public RawJwt.Builder addNumberClaim(java.lang.String name, double value)
Adds a custom claim of typedoubleto the JWT.
-
addStringClaim
@CanIgnoreReturnValue public RawJwt.Builder addStringClaim(java.lang.String name, java.lang.String value)
Adds a custom claim of typeStringto the JWT.
-
addNullClaim
@CanIgnoreReturnValue public RawJwt.Builder addNullClaim(java.lang.String name)
Adds a custom claim with value null.
-
addJsonObjectClaim
@CanIgnoreReturnValue public RawJwt.Builder addJsonObjectClaim(java.lang.String name, java.lang.String encodedJsonObject) throws JwtInvalidException
Adds a custom claim encoded in a JSONStringto the JWT.- Throws:
JwtInvalidException
-
addJsonArrayClaim
@CanIgnoreReturnValue public RawJwt.Builder addJsonArrayClaim(java.lang.String name, java.lang.String encodedJsonArray) throws JwtInvalidException
Adds a custom claim encoded in a JSONStringto the JWT.- Throws:
JwtInvalidException
-
build
public RawJwt build()
-
-