com.holonplatform.auth.jwt

## Class JwtTokenBuilder

- java.lang.Object
- - com.holonplatform.auth.jwt.JwtTokenBuilder

- All Implemented Interfaces:
    Serializable

      public final class JwtTokenBuilder
      extends Object
      implements Serializable

  JWT builder using `Authentication` objects
  Since:
    5.0.0
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JwtTokenBuilder.AuthPart` Enumeration of `Authentication` parts

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `buildJWT(Authentication authentication, String id, String issuer, Long timeToLiveMs, JwtTokenBuilder.AuthPart... includeParts)` Build a not signed JSON Web Token form given `Authentication`
    `static String` | `buildJWT(Authentication authentication, String id, String issuer, Long timeToLiveMs, io.jsonwebtoken.SignatureAlgorithm algorithm, byte[] signingKey, JwtTokenBuilder.AuthPart... includeParts)` Build a JSON Web Token form given `Authentication`
    `static String` | `buildJWT(Authentication authentication, String id, String issuer, Long timeToLiveMs, io.jsonwebtoken.SignatureAlgorithm algorithm, Key privateKey, JwtTokenBuilder.AuthPart... includeParts)` Build a JSON Web Token form given `Authentication`
    `static String` | `buildJWT(Authentication authentication, String id, String issuer, Long timeToLiveMs, io.jsonwebtoken.SignatureAlgorithm algorithm, String base64EncodedKey, JwtTokenBuilder.AuthPart... includeParts)` Build a JSON Web Token form given `Authentication`
    `static String` | `buildJwtToken(JwtConfiguration configuration, Authentication authentication, String jwtTokenId)` Build a JWT token using given `JwtConfiguration` for given `Authentication`.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### buildJwtToken

          public static String buildJwtToken(JwtConfiguration configuration,
                                             Authentication authentication,
                                             String jwtTokenId)
                                      throws JwtConfiguration.InvalidJwtConfigurationException

      Build a JWT token using given `JwtConfiguration` for given `Authentication`.
      Parameters:
        `configuration` - JWT configuration (not null)
        `authentication` - Authentication for which to create the token (not null)
        `jwtTokenId` - Optional JWT token id (jit claim)
      Returns:
        JWT token
      Throws:
        `JwtConfiguration.InvalidJwtConfigurationException` - Invalid JWT configuration

    - #### buildJWT

          public static String buildJWT(Authentication authentication,
                                        String id,
                                        String issuer,
                                        Long timeToLiveMs,
                                        JwtTokenBuilder.AuthPart... includeParts)

      Build a not signed JSON Web Token form given `Authentication`
      Parameters:
        `authentication` - Authentication source
        `id` - Optional JWT id (jit)
        `issuer` - Optional Issuer name
        `timeToLiveMs` - Optional time to live for token expiration (`null` or less than 0 means token not expires)
        `includeParts` - Optional Authentication parts to include as claims in JWT
      Returns:
        JWT String
      See Also:
        `JwtTokenBuilder.AuthPart`

    - #### buildJWT

          public static String buildJWT(Authentication authentication,
                                        String id,
                                        String issuer,
                                        Long timeToLiveMs,
                                        io.jsonwebtoken.SignatureAlgorithm algorithm,
                                        Key privateKey,
                                        JwtTokenBuilder.AuthPart... includeParts)

      Build a JSON Web Token form given `Authentication`
      Parameters:
        `authentication` - Authentication source
        `id` - Optional JWT id (jit)
        `issuer` - Optional Issuer name
        `timeToLiveMs` - Optional time to live for token expiration (`null` or less than 0 means token not expires)
        `algorithm` - Signature algorithm to use with given key to sign JWT. Only meaningful if `signingKey` is not `null`
        `privateKey` - Optional `Key` to sign JWT using given `algorithm`
        `includeParts` - Optional Authentication parts to include as claims in JWT
      Returns:
        JWT String
      See Also:
        `JwtTokenBuilder.AuthPart`

    - #### buildJWT

          public static String buildJWT(Authentication authentication,
                                        String id,
                                        String issuer,
                                        Long timeToLiveMs,
                                        io.jsonwebtoken.SignatureAlgorithm algorithm,
                                        String base64EncodedKey,
                                        JwtTokenBuilder.AuthPart... includeParts)

      Build a JSON Web Token form given `Authentication`
      Parameters:
        `authentication` - Authentication source
        `id` - Optional JWT id (jit)
        `issuer` - Optional Issuer name
        `timeToLiveMs` - Optional time to live for token expiration (`null` or less than 0 means token not expires)
        `algorithm` - Signature algorithm to use with given key to sign JWT. Only meaningful if `signingKey` is not `null`
        `base64EncodedKey` - Optional Base64 encoded key to sign JWT using given `algorithm`
        `includeParts` - Optional Authentication parts to include as claims in JWT
      Returns:
        JWT String
      See Also:
        `JwtTokenBuilder.AuthPart`

    - #### buildJWT

          public static String buildJWT(Authentication authentication,
                                        String id,
                                        String issuer,
                                        Long timeToLiveMs,
                                        io.jsonwebtoken.SignatureAlgorithm algorithm,
                                        byte[] signingKey,
                                        JwtTokenBuilder.AuthPart... includeParts)

      Build a JSON Web Token form given `Authentication`
      Parameters:
        `authentication` - Authentication source
        `id` - Optional JWT id (jit)
        `issuer` - Optional Issuer name
        `timeToLiveMs` - Optional time to live for token expiration (`null` or less than 0 means token not expires)
        `algorithm` - Signature algorithm to use with given key to sign JWT. Only meaningful if `signingKey` is not `null`
        `signingKey` - Optional Base64 encoded key to sign JWT using given `algorithm`
        `includeParts` - Optional Authentication parts to include as claims in JWT
      Returns:
        JWT String
      See Also:
        `JwtTokenBuilder.AuthPart`

Copyright © 2017 The Holon Platform. All rights reserved.