Class EnvironmentTokenAPIHandler
- java.lang.Object
-
- co.arago.hiro.client.connection.AbstractAPIHandler
-
- co.arago.hiro.client.connection.AbstractVersionAPIHandler
-
- co.arago.hiro.client.connection.token.AbstractTokenAPIHandler
-
- co.arago.hiro.client.connection.token.EnvironmentTokenAPIHandler
-
- All Implemented Interfaces:
TokenAPIHandler,java.lang.AutoCloseable
public class EnvironmentTokenAPIHandler extends AbstractTokenAPIHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEnvironmentTokenAPIHandler.Builderstatic classEnvironmentTokenAPIHandler.Conf<T extends EnvironmentTokenAPIHandler.Conf<T>>
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_ENVprotected java.lang.StringtokenEnv-
Fields inherited from class co.arago.hiro.client.connection.AbstractAPIHandler
httpClientHandler, httpRequestTimeout, maxRetries, rootApiURI, title, userAgent, version, webSocketURI
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEnvironmentTokenAPIHandler(EnvironmentTokenAPIHandler.Conf<?> builder)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.time.InstantexpiryInstant()Calculate the Instant after which the token should be refreshed.java.lang.StringgetToken()Return the current token from the System environment.booleanhasRefreshToken()Check for existence of a refresh token in the TokenAPIHandler.booleanhasToken()Check for existence of a token in the TokenAPIHandler.static EnvironmentTokenAPIHandler.Conf<?>newBuilder()voidrefreshToken()Refresh an invalid token.voidrevokeToken()Revoke a token-
Methods inherited from class co.arago.hiro.client.connection.token.AbstractTokenAPIHandler
addToHeaders, close, decodeToken
-
Methods inherited from class co.arago.hiro.client.connection.AbstractVersionAPIHandler
getApiURIOf, getVersionMap, requestVersionMap
-
Methods inherited from class co.arago.hiro.client.connection.AbstractAPIHandler
addQueryFragmentAndNormalize, buildApiURI, buildEndpointURI, buildURI, buildWebSocketURI, checkResponse, delete, executeAsyncWithStreamBody, executeAsyncWithStringBody, executeBinary, executeWithStreamBody, executeWithStringBody, get, getBinary, getConf, getHttpLogger, getHttpRequestTimeout, getMaxRetries, getOrBuildClient, getRequestBuilder, getRootApiURI, getUserAgent, getWebSocketURI, patch, patchBinary, post, postBinary, put, putBinary, send, sendAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface co.arago.hiro.client.connection.token.TokenAPIHandler
buildWebSocketURI, checkResponse, getApiURIOf, getConf, getOrBuildClient, getRootApiURI, getUserAgent, getVersionMap
-
-
-
-
Field Detail
-
DEFAULT_ENV
public static final java.lang.String DEFAULT_ENV
- See Also:
- Constant Field Values
-
tokenEnv
protected final java.lang.String tokenEnv
-
-
Constructor Detail
-
EnvironmentTokenAPIHandler
protected EnvironmentTokenAPIHandler(EnvironmentTokenAPIHandler.Conf<?> builder)
Constructor.- Parameters:
builder- The builder to use.
-
-
Method Detail
-
newBuilder
public static EnvironmentTokenAPIHandler.Conf<?> newBuilder()
-
getToken
public java.lang.String getToken()
Return the current token from the System environment.- Returns:
- The current token.
-
refreshToken
public void refreshToken() throws HiroExceptionRefresh an invalid token.- Throws:
HiroException- On Hiro protocol / handling errors.
-
revokeToken
public void revokeToken() throws HiroExceptionRevoke a token- Throws:
HiroException- On Hiro protocol / handling errors.
-
hasToken
public 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 boolean hasRefreshToken()
Check for existence of a refresh token in the TokenAPIHandler.- Returns:
- false
-
expiryInstant
public 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.
-
-