Class AbstractTokenAPIHandler
- java.lang.Object
-
- co.arago.util.validation.RequiredFieldChecks
-
- co.arago.hiro.client.connection.AbstractAPIHandler
-
- co.arago.hiro.client.connection.AbstractClientAPIHandler
-
- co.arago.hiro.client.connection.AbstractVersionAPIHandler
-
- co.arago.hiro.client.connection.token.AbstractTokenAPIHandler
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Direct Known Subclasses:
EnvironmentTokenAPIHandler,FixedTokenAPIHandler,PasswordAuthTokenAPIHandler
public abstract class AbstractTokenAPIHandler extends AbstractVersionAPIHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractTokenAPIHandler.Conf<T extends AbstractTokenAPIHandler.Conf<T>>-
Nested classes/interfaces inherited from class co.arago.hiro.client.connection.AbstractClientAPIHandler
AbstractClientAPIHandler.ProxySpec
-
Nested classes/interfaces inherited from class co.arago.hiro.client.connection.AbstractAPIHandler
AbstractAPIHandler.GetterConf
-
-
Field Summary
-
Fields inherited from class co.arago.hiro.client.connection.AbstractClientAPIHandler
connectTimeout, externalHttpClient, followRedirects, httpClient, httpLogger, maxConnectionPool, proxy, sslContext, sslParameters
-
Fields inherited from class co.arago.hiro.client.connection.AbstractAPIHandler
apiUrl, httpRequestTimeout, maxRetries, title, userAgent, version, webSocketUri
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTokenAPIHandler(AbstractTokenAPIHandler.Conf builder)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddToHeaders(java.util.Map<java.lang.String,java.lang.String> headers)Override this to add authentication tokens.abstract java.time.InstantexpiryInstant()Calculate the Instant after which the token should be refreshed.abstract java.lang.StringgetToken()Return the current token.abstract booleanhasRefreshToken()Check for existence of a refresh token in the TokenAPIHandler.abstract booleanhasToken()Check for existence of a token in the TokenAPIHandler.abstract voidrefreshToken()Refresh an invalid token.abstract voidrevokeToken()Revoke a token-
Methods inherited from class co.arago.hiro.client.connection.AbstractVersionAPIHandler
getApiUriOf, getVersionMap, requestVersionMap
-
Methods inherited from class co.arago.hiro.client.connection.AbstractClientAPIHandler
close, getHttpLogger, getOrBuildClient
-
Methods inherited from class co.arago.hiro.client.connection.AbstractAPIHandler
addQueryAndFragment, buildApiURI, buildEndpointURI, buildURI, buildWebSocketURI, checkResponse, delete, executeAsyncWithStreamBody, executeAsyncWithStringBody, executeBinary, executeWithStreamBody, executeWithStringBody, get, getApiUrl, getBinary, getHttpRequestTimeout, getMaxRetries, getRequestBuilder, getUserAgent, getWebSocketUri, patch, patchBinary, post, postBinary, put, putBinary, send, sendAsync
-
-
-
-
Constructor Detail
-
AbstractTokenAPIHandler
protected AbstractTokenAPIHandler(AbstractTokenAPIHandler.Conf builder)
Constructor- Parameters:
builder- The builder to use.
-
-
Method Detail
-
addToHeaders
public void addToHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Override this to add authentication tokens. TokenHandlers do not have tokens, so this only returns default headers.- Specified by:
addToHeadersin classAbstractAPIHandler- Parameters:
headers- Map of headers with initial values.
-
getToken
public abstract java.lang.String getToken() throws java.io.IOException, java.lang.InterruptedException, HiroExceptionReturn the current token.- Returns:
- The current token.
- Throws:
java.lang.InterruptedException- When call gets interrupted.java.io.IOException- When call has IO errors.HiroException- On Hiro protocol / handling errors.
-
refreshToken
public abstract void refreshToken() throws java.io.IOException, java.lang.InterruptedException, HiroExceptionRefresh an invalid token.- Throws:
java.lang.InterruptedException- When call gets interrupted.java.io.IOException- When call has IO errors.HiroException- On Hiro protocol / handling errors.
-
revokeToken
public abstract void revokeToken() throws java.io.IOException, java.lang.InterruptedException, HiroExceptionRevoke a token- Throws:
java.lang.InterruptedException- When call gets interrupted.java.io.IOException- When call has IO errors.HiroException- On Hiro protocol / handling errors.
-
hasToken
public abstract boolean hasToken()
Check for existence of a token in the TokenAPIHandler.- Returns:
- true if a token has been set or retrieved, false if the token is empty.
-
hasRefreshToken
public abstract boolean hasRefreshToken()
Check for existence of a refresh token in the TokenAPIHandler.- Returns:
- true if a refresh token retrieved, false if no such token exists or these tokens are not applicable for this TokenAPIHandler.
-
expiryInstant
public abstract java.time.Instant expiryInstant()
Calculate the Instant after which the token should be refreshed.- Returns:
- The Instant after which the token shall be refreshed. null if token cannot be refreshed.
-
-