Class JwtClaimsSet.Builder

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

public static final class JwtClaimsSet.Builder extends Object
A builder for JwtClaimsSet.
  • Method Details

    • issuer

      public JwtClaimsSet.Builder issuer(String issuer)
      Sets the issuer (iss) claim, which identifies the principal that issued the JWT.
      Parameters:
      issuer - the issuer identifier
      Returns:
      the JwtClaimsSet.Builder
    • subject

      public JwtClaimsSet.Builder subject(String subject)
      Sets the subject (sub) claim, which identifies the principal that is the subject of the JWT.
      Parameters:
      subject - the subject identifier
      Returns:
      the JwtClaimsSet.Builder
    • audience

      public JwtClaimsSet.Builder audience(List<String> audience)
      Sets the audience (aud) claim, which identifies the recipient(s) that the JWT is intended for.
      Parameters:
      audience - the audience that this JWT is intended for
      Returns:
      the JwtClaimsSet.Builder
    • expiresAt

      public JwtClaimsSet.Builder expiresAt(Instant expiresAt)
      Sets the expiration time (exp) claim, which identifies the time on or after which the JWT MUST NOT be accepted for processing.
      Parameters:
      expiresAt - the time on or after which the JWT MUST NOT be accepted for processing
      Returns:
      the JwtClaimsSet.Builder
    • notBefore

      public JwtClaimsSet.Builder notBefore(Instant notBefore)
      Sets the not before (nbf) claim, which identifies the time before which the JWT MUST NOT be accepted for processing.
      Parameters:
      notBefore - the time before which the JWT MUST NOT be accepted for processing
      Returns:
      the JwtClaimsSet.Builder
    • issuedAt

      public JwtClaimsSet.Builder issuedAt(Instant issuedAt)
      Sets the issued at (iat) claim, which identifies the time at which the JWT was issued.
      Parameters:
      issuedAt - the time at which the JWT was issued
      Returns:
      the JwtClaimsSet.Builder
    • id

      public JwtClaimsSet.Builder id(String jti)
      Sets the JWT ID (jti) claim, which provides a unique identifier for the JWT.
      Parameters:
      jti - the unique identifier for the JWT
      Returns:
      the JwtClaimsSet.Builder
    • claim

      public JwtClaimsSet.Builder claim(String name, Object value)
      Sets the claim.
      Parameters:
      name - the claim name
      value - the claim value
      Returns:
      the JwtClaimsSet.Builder
    • claims

      public JwtClaimsSet.Builder claims(Consumer<Map<String,Object>> claimsConsumer)
      A Consumer to be provided access to the claims allowing the ability to add, replace, or remove.
      Parameters:
      claimsConsumer - a Consumer of the claims
    • build

      public JwtClaimsSet build()
      Builds a new JwtClaimsSet.
      Returns:
      a JwtClaimsSet