Class Jwt.Builder

  • Enclosing class:
    Jwt

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Jwt.Builder audience​(java.util.Collection<java.lang.String> audience)
      Use this audience in the resulting Jwt
      Jwt build()
      Build the Jwt
      Jwt.Builder claim​(java.lang.String name, java.lang.Object value)
      Use this claim in the resulting Jwt
      Jwt.Builder claims​(java.util.function.Consumer<java.util.Map<java.lang.String,​java.lang.Object>> claimsConsumer)
      Provides access to every claim(String, Object) declared so far with the possibility to add, replace, or remove.
      Jwt.Builder expiresAt​(java.time.Instant expiresAt)
      Use this expiration in the resulting Jwt
      Jwt.Builder header​(java.lang.String name, java.lang.Object value)
      Use this header in the resulting Jwt
      Jwt.Builder headers​(java.util.function.Consumer<java.util.Map<java.lang.String,​java.lang.Object>> headersConsumer)
      Provides access to every header(String, Object) declared so far with the possibility to add, replace, or remove.
      Jwt.Builder issuedAt​(java.time.Instant issuedAt)
      Use this issued-at timestamp in the resulting Jwt
      Jwt.Builder issuer​(java.lang.String issuer)
      Use this issuer in the resulting Jwt
      Jwt.Builder jti​(java.lang.String jti)
      Use this identifier in the resulting Jwt
      Jwt.Builder notBefore​(java.time.Instant notBefore)
      Use this not-before timestamp in the resulting Jwt
      Jwt.Builder subject​(java.lang.String subject)
      Use this subject in the resulting Jwt
      Jwt.Builder tokenValue​(java.lang.String tokenValue)
      Use this token value in the resulting Jwt
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • tokenValue

        public Jwt.Builder tokenValue​(java.lang.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​(java.lang.String name,
                                 java.lang.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​(java.util.function.Consumer<java.util.Map<java.lang.String,​java.lang.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​(java.lang.String name,
                                  java.lang.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​(java.util.function.Consumer<java.util.Map<java.lang.String,​java.lang.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​(java.util.Collection<java.lang.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​(java.time.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​(java.lang.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​(java.time.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​(java.lang.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​(java.time.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​(java.lang.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