Class TokenInfo

java.lang.Object
io.strimzi.kafka.oauth.common.TokenInfo

public class TokenInfo extends Object
TokenInfo encapsulates the information about the access token.

It can also be used for storing extra application information associated with the access token by directly accessing the payload JSON object.

  • Field Details

  • Constructor Details

    • TokenInfo

      public TokenInfo(com.fasterxml.jackson.databind.JsonNode payload, String token, String principal)
      Create a new instance
      Parameters:
      payload - The body of the JWT token or composed of authorization server's introspection endpoint response
      token - The raw access token
      principal - The extracted user ID
    • TokenInfo

      public TokenInfo(com.fasterxml.jackson.databind.JsonNode payload, String token, String principal, Set<String> groups)
      Create a new instance
      Parameters:
      payload - The body of the JWT token or composed of authorization server's introspection endpoint response
      token - The raw access token
      principal - The extracted user ID
      groups - A set of groups extracted from JWT token or authorization server's inspect endpoint response
    • TokenInfo

      public TokenInfo(String token, String scope, String principal, Set<String> groups, long issuedAtMs, long expiresAtMs)
      Parameters:
      token - The raw access token
      scope - The scope returned by authorization server's inspect endpoint response
      principal - The extracted user ID
      groups - A set of groups extracted from JWT token or authorization server's inspect endpoint response
      issuedAtMs - The token's `issued at` time in millis
      expiresAtMs - The token's `expires at` time in millis
    • TokenInfo

      public TokenInfo(String token, Set<String> scopes, String principal, Set<String> groups, long issuedAtMs, long expiresAtMs, com.fasterxml.jackson.databind.JsonNode payload)
      Parameters:
      token - The raw access token
      scopes - The list of scopes
      principal - The extracted user ID
      groups - A set of groups extracted from JWT token or authorization server's inspect endpoint response
      issuedAtMs - The token's `issued at` time in millis
      expiresAtMs - The token's `expires at` time in millis
      payload - The body of the JWT token or composed of authorization server's introspection endpoint response
  • Method Details

    • token

      public String token()
      Get raw access token
      Returns:
      Access token as String
    • scope

      public Set<String> scope()
      Get scopes for this token
      Returns:
      A Set of scopes as strings
    • expiresAtMs

      public long expiresAtMs()
      Get token expiry time in ISO millis time
      Returns:
      Long value representing time
    • principal

      public String principal()
      Get a principal (user id) for this token
      Returns:
      User id as String
    • groups

      public Set<String> groups()
      Get groups for this token
      Returns:
      Set of groups as strings
    • issuedAtMs

      public long issuedAtMs()
      Get token creation time ISO millis
      Returns:
      Long value representing time
    • payload

      public com.fasterxml.jackson.databind.node.ObjectNode payload()
      Get the payload object passed during construction.

      The same instance, passed to the TokenInfo constructor is returned which makes it possible to add custom attributes or make modifications during request processing.

      Returns:
      The payload object.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object