Class CodeFlowAuthTokenAPIHandler
- 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.AbstractRemoteAuthTokenAPIHandler
-
- co.arago.hiro.client.connection.token.CodeFlowAuthTokenAPIHandler
-
- All Implemented Interfaces:
TokenAPIHandler,java.lang.AutoCloseable
public class CodeFlowAuthTokenAPIHandler extends AbstractRemoteAuthTokenAPIHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCodeFlowAuthTokenAPIHandler.Builderstatic classCodeFlowAuthTokenAPIHandler.Conf<T extends CodeFlowAuthTokenAPIHandler.Conf<T>>-
Nested classes/interfaces inherited from class co.arago.hiro.client.connection.token.AbstractRemoteAuthTokenAPIHandler
AbstractRemoteAuthTokenAPIHandler.TokenInfo
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringcodeprotected java.lang.StringredirectURIprotected java.lang.Stringscopeprotected java.lang.Stringstate-
Fields inherited from class co.arago.hiro.client.connection.token.AbstractRemoteAuthTokenAPIHandler
apiName, apiPath, apiURI, clientId, clientSecret, organization, organizationId, tokenInfo
-
Fields inherited from class co.arago.hiro.client.connection.AbstractAPIHandler
httpClientHandler, httpRequestTimeout, maxRetries, rootApiURI, title, userAgent, version, webSocketURI
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCodeFlowAuthTokenAPIHandler(CodeFlowAuthTokenAPIHandler.Conf<?> builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URIgetAuthorizeURI()Generate a URI for a browser to use for the authorization call.voidhandleAuthorizeCallback(java.lang.String state, java.lang.String code)Handle authorization callback data.static CodeFlowAuthTokenAPIHandler.Conf<?>newBuilder()voidrefreshToken()Refresh an invalid token.protected voidrequestToken(java.lang.String organization, java.lang.String organizationId)Obtain a new token from the auth API.-
Methods inherited from class co.arago.hiro.client.connection.token.AbstractRemoteAuthTokenAPIHandler
checkResponse, expiryInstant, getRefreshOffset, getRefreshToken, getToken, getURI, hasRefreshToken, hasToken, refreshToken, revokeToken, revokeToken, setRefreshOffset, tokenExpired
-
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, 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, getApiURIOf, getConf, getOrBuildClient, getRootApiURI, getUserAgent, getVersionMap
-
-
-
-
Constructor Detail
-
CodeFlowAuthTokenAPIHandler
protected CodeFlowAuthTokenAPIHandler(CodeFlowAuthTokenAPIHandler.Conf<?> builder)
-
-
Method Detail
-
newBuilder
public static CodeFlowAuthTokenAPIHandler.Conf<?> newBuilder()
-
getAuthorizeURI
public java.net.URI getAuthorizeURI() throws HiroException, java.io.IOException, java.lang.InterruptedExceptionGenerate a URI for a browser to use for the authorization call. This call will be answered with a redirection to a login page.- Returns:
- The URI for a login page.
- Throws:
java.io.IOException- On a failed call to /api/versionjava.lang.InterruptedException- Call got interruptedHiroException- When calling /api/version responds with an error
-
handleAuthorizeCallback
public void handleAuthorizeCallback(java.lang.String state, java.lang.String code) throws AuthenticationTokenExceptionHandle authorization callback data.- Parameters:
state- The state returned by the callback. Must not have changed.code- The one-time-code returned (used to obtain a full authorization token).- Throws:
AuthenticationTokenException- When the state of the callback does not match the internal state.
-
requestToken
protected void requestToken(java.lang.String organization, java.lang.String organizationId) throws java.io.IOException, java.lang.InterruptedException, HiroExceptionObtain a new token from the auth API.- Specified by:
requestTokenin classAbstractRemoteAuthTokenAPIHandler- Parameters:
organization- : Optional organization name. May be null.organizationId- : Optional organization id. May be null.- Throws:
java.lang.InterruptedException- When call gets interrupted.java.io.IOException- When call has IO errors.HiroException- On Hiro protocol / handling errors.TokenUnauthorizedException- Whencodeis blank, i.e. the code has never been submitted viahandleAuthorizeCallback(String state, String code)or has already been used.
-
refreshToken
public void refreshToken() throws HiroException, java.io.IOException, java.lang.InterruptedExceptionRefresh an invalid token.Uses the internal values of organization and organizationId if present.
- Specified by:
refreshTokenin interfaceTokenAPIHandler- Overrides:
refreshTokenin classAbstractRemoteAuthTokenAPIHandler- Throws:
java.lang.InterruptedException- When call gets interrupted.java.io.IOException- When call has IO errors.HiroException- On Hiro protocol / handling errors.TokenUnauthorizedException- When no refresh_token exists.
-
-