Class TokenCredential
- java.lang.Object
-
- io.helidon.security.providers.common.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TokenCredential.Builder
Fluent API builder forTokenCredential
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TokenCredential.Builder
builder()
Get a builder for this class.static TokenCredential
create(String token, String issuer, Instant issueTime, Instant expTime)
Creates a new token credential for the specified token.Optional<Instant>
getExpTime()
Expiration time of the token.Optional<String>
getIssuer()
Issuer of the token.Optional<Instant>
getIssueTime()
Issue time of the token.<U> Optional<U>
getTokenInstance(Class<U> tokenClass)
Get a token of a specific class.String
token()
The full token string as it was received from token service.String
toString()
-
-
-
Method Detail
-
create
public static TokenCredential create(String token, String issuer, Instant issueTime, Instant expTime)
Creates a new token credential for the specified token.- Parameters:
token
- Token value (as received from external client)issuer
- Issuer of the token (such as accounts.google.com) - optionalissueTime
- Time instant the token was issued - optionalexpTime
- Time instant the token will expire - optional- Returns:
- new instance of credential
-
builder
public static TokenCredential.Builder builder()
Get a builder for this class.- Returns:
- a new builder to build an instance
-
token
public String token()
The full token string as it was received from token service.- Returns:
- token data as a string
-
getIssueTime
public Optional<Instant> getIssueTime()
Issue time of the token.- Returns:
- issue time or empty if not available
-
getExpTime
public Optional<Instant> getExpTime()
Expiration time of the token.- Returns:
- expiration time or empty if not available
-
getIssuer
public Optional<String> getIssuer()
Issuer of the token.- Returns:
- 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- Parameters:
tokenClass
- class we want to get- Returns:
- instance of the token if present
-
-