Class JwtClaims (1.20.0)

public abstract class JwtClaims implements Serializable

Value class representing the set of fields used as the payload of a JWT token.

To create and customize claims, use the builder:


 Claims claims = Claims.newBuilder()
     .setAudience("https://example.com/some-audience")
     .setIssuer("some-issuer@example.com")
     .setSubject("some-subject@example.com")
     .build();
 

Inheritance

java.lang.Object > JwtClaims

Implements

Serializable

Static Methods

newBuilder()

public static JwtClaims.Builder newBuilder()
Returns
Type Description
JwtClaims.Builder

Constructors

JwtClaims()

public JwtClaims()

Methods

isComplete()

public boolean isComplete()

Returns whether or not this set of claims is complete.

Audience, issuer, and subject are required to be set in order to use the claim set for a JWT token. An incomplete Claims instance is useful for overriding claims when using ServiceAccountJwtAccessCredentials#jwtWithClaims(JwtClaims) or JwtCredentials#jwtWithClaims(JwtClaims).

Returns
Type Description
boolean

true if all required fields have been set; false otherwise

merge(JwtClaims other)

public JwtClaims merge(JwtClaims other)

Returns a new Claims instance with overridden fields.

Any non-null field will overwrite the value from the original claims instance.

Parameter
Name Description
other JwtClaims

claims to override

Returns
Type Description
JwtClaims

new claims