Provides a high level interface for ephemeral API tokens issued by a time-limited token issuing service.
Type Params | Return Type | Name and description |
---|---|---|
|
String |
getExpiration() Returns when an issued ephemeral token will expire. |
|
Boolean |
isExpired(String hash) Checks if a token is expired. |
|
Boolean |
isExpired() Checks if a token is expired. |
|
void |
setExpiration(String expiration) Sets when an ephemeral token will expire. |
|
void |
updateTokenWith(String token, String expiration, String hash) Update all three properties with a repeatable unique hash provided in case backend caching is used. |
Methods inherited from class | Name |
---|---|
interface TokenCredential |
getToken, setToken |
Returns when an issued ephemeral token will expire. isExpired(java.lang.String) or updateTokenWith(java.lang.String, java.lang.String, java.lang.String) should be called before this method.
Checks if a token is expired. This method will be called first before any other. A hash will be provided in case there's a backend cache. This method could load from the cache before returning the Boolean.
hash
- Unique to the token provided by issuer. For an example see
GitHubAppCredential.getHash.
It is used for storing and retrieving issued tokens from the
backend cache.Checks if a token is expired. isExpired(java.lang.String) or updateTokenWith(java.lang.String, java.lang.String, java.lang.String) should be called before this method.
Sets when an ephemeral token will expire. A quick parsing check can be performed with Instant. isExpired(java.lang.String) or updateTokenWith(java.lang.String, java.lang.String, java.lang.String) should be called before this method.
void setExpiration(String expiration) {
// A quick parse check
java.time.Instant.parse(expiration)
this.expiration = expiration
}
Update all three properties with a repeatable unique hash provided in case backend caching is used.
token
- An ephemeral token issued by a a token issuer. See
GitHubAppCredential
for an example of a token issuer.expiration
- The instant a token expires. The format must be
DateTimeFormatter.ISO_INSTANT.hash
- Unique to the token provided by issuer. For an example see
GitHubAppCredential.getHash.
It is used for storing and retrieving issued tokens from a
backend cache.