Class TokenService

java.lang.Object
org.odpi.openmetadata.userauthn.TokenService

@Service public class TokenService extends Object
Token service generates JWT bearer tokens for authenticated users.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Number of hours that a bearer token is valid for if the bearerTokenTimeout property is not set.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TokenService(org.springframework.security.oauth2.jwt.JwtEncoder encoder, Long bearerTokenTimeout)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    generateToken(org.springframework.security.core.Authentication authentication)
    Generate token

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_BEARER_TOKEN_TIMEOUT

      public static final long DEFAULT_BEARER_TOKEN_TIMEOUT
      Number of hours that a bearer token is valid for if the bearerTokenTimeout property is not set.
      See Also:
  • Constructor Details

    • TokenService

      public TokenService(org.springframework.security.oauth2.jwt.JwtEncoder encoder, @Value("${bearerTokenTimeout:1}") Long bearerTokenTimeout)
      Constructor
      Parameters:
      encoder - JWT encoder
      bearerTokenTimeout - number of hours that an issued bearer token remains valid. A null value means the property is not set and the default is used. A value that is not a positive number of hours is reported and the default is used as if the property was not set.
  • Method Details

    • generateToken

      public String generateToken(org.springframework.security.core.Authentication authentication)
      Generate token
      Parameters:
      authentication - information from the request
      Returns:
      bearer token as a string