Class TokenCredential

  • public class TokenCredential
    extends Object
    A public credential representing an access token. Example is a Google access token you get when authenticating against Google's Open ID Connect.
    • Method Detail

      • create

        public static TokenCredential create​(String token,
                                             String issuer,
                                             Instant issueTime,
                                             Instant expTime)
        Creates a new token credential for the specified token.
        token - Token value (as received from external client)
        issuer - Issuer of the token (such as - optional
        issueTime - Time instant the token was issued - optional
        expTime - Time instant the token will expire - optional
        new instance of credential
      • builder

        public static TokenCredential.Builder builder()
        Get a builder for this class.
        a new builder to build an instance
      • token

        public String token()
        The full token string as it was received from token service.
        token data as a string
      • getIssueTime

        public Optional<Instant> getIssueTime()
        Issue time of the token.
        issue time or empty if not available
      • getExpTime

        public Optional<Instant> getExpTime()
        Expiration time of the token.
        expiration time or empty if not available
      • getIssuer

        public Optional<String> getIssuer()
        Issuer of the token.
        issuer or empty if not available
      • getTokenInstance

        public <U> Optional<U> getTokenInstance​(Class<U> tokenClass)
        Get a token of a specific class. By default the String.class is supported - and returns the token content. Other instances may be available from authentication provider (e.g. Jwt).
        Type Parameters:
        U - type of the class
        tokenClass - class we want to get
        instance of the token if present