Class Jwt.Builder

java.lang.Object
org.springframework.security.oauth2.jwt.Jwt.Builder
Enclosing class:
Jwt

public static final class Jwt.Builder extends Object
Helps configure a Jwt
Since:
5.2
  • Method Details

    • tokenValue

      public Jwt.Builder tokenValue(String tokenValue)
      Use this token value in the resulting Jwt
      Parameters:
      tokenValue - The token value to use
      Returns:
      the Jwt.Builder for further configurations
    • claim

      public Jwt.Builder claim(String name, Object value)
      Use this claim in the resulting Jwt
      Parameters:
      name - The claim name
      value - The claim value
      Returns:
      the Jwt.Builder for further configurations
    • claims

      public Jwt.Builder claims(Consumer<Map<String,Object>> claimsConsumer)
      Provides access to every claim(String, Object) declared so far with the possibility to add, replace, or remove.
      Parameters:
      claimsConsumer - the consumer
      Returns:
      the Jwt.Builder for further configurations
    • header

      public Jwt.Builder header(String name, Object value)
      Use this header in the resulting Jwt
      Parameters:
      name - The header name
      value - The header value
      Returns:
      the Jwt.Builder for further configurations
    • headers

      public Jwt.Builder headers(Consumer<Map<String,Object>> headersConsumer)
      Provides access to every header(String, Object) declared so far with the possibility to add, replace, or remove.
      Parameters:
      headersConsumer - the consumer
      Returns:
      the Jwt.Builder for further configurations
    • audience

      public Jwt.Builder audience(Collection<String> audience)
      Use this audience in the resulting Jwt
      Parameters:
      audience - The audience(s) to use
      Returns:
      the Jwt.Builder for further configurations
    • expiresAt

      public Jwt.Builder expiresAt(Instant expiresAt)
      Use this expiration in the resulting Jwt
      Parameters:
      expiresAt - The expiration to use
      Returns:
      the Jwt.Builder for further configurations
    • jti

      public Jwt.Builder jti(String jti)
      Use this identifier in the resulting Jwt
      Parameters:
      jti - The identifier to use
      Returns:
      the Jwt.Builder for further configurations
    • issuedAt

      public Jwt.Builder issuedAt(Instant issuedAt)
      Use this issued-at timestamp in the resulting Jwt
      Parameters:
      issuedAt - The issued-at timestamp to use
      Returns:
      the Jwt.Builder for further configurations
    • issuer

      public Jwt.Builder issuer(String issuer)
      Use this issuer in the resulting Jwt
      Parameters:
      issuer - The issuer to use
      Returns:
      the Jwt.Builder for further configurations
    • notBefore

      public Jwt.Builder notBefore(Instant notBefore)
      Use this not-before timestamp in the resulting Jwt
      Parameters:
      notBefore - The not-before timestamp to use
      Returns:
      the Jwt.Builder for further configurations
    • subject

      public Jwt.Builder subject(String subject)
      Use this subject in the resulting Jwt
      Parameters:
      subject - The subject to use
      Returns:
      the Jwt.Builder for further configurations
    • build

      public Jwt build()
      Build the Jwt
      Returns:
      The constructed Jwt