public class DefaultTokenManager extends Object implements TokenManager
Modifier and Type | Field and Description |
---|---|
protected static InternalLogApi |
log |
Constructor and Description |
---|
DefaultTokenManager(String apiKey)
Default constructor using the apiKey.
|
DefaultTokenManager(TokenProvider provider)
Constructor which will allow a custom TokenHandler to retrieve the token
from the IAM Service
|
Modifier and Type | Method and Description |
---|---|
static void |
addProxyConfig(org.apache.http.impl.client.HttpClientBuilder builder,
HttpClientSettings settings)
Add a proxy to the http request if it has been set within settings
|
protected void |
cacheToken(Token token)
Add the Token object to in-memory cache
|
protected boolean |
checkCache()
Check if cache has a Token object stored
|
protected void |
finalize() |
protected Token |
getCachedToken() |
ClientConfiguration |
getClientConfiguration()
Client config to customise the IAM Client
|
TokenProvider |
getProvider()
Return the TokenProvider used by the TokenManager
|
String |
getToken()
Retrieve the access token String from the OAuth2 token object
|
protected boolean |
hasTokenExpired(Token token)
Check if the current cached token has expired.
|
protected boolean |
isAsyncInProgress()
boolean value to signal if the async refresh method is already in use
|
protected boolean |
isTokenExpiring(Token token)
Check if the current cached token is expiring in less than the given
offset.
|
protected void |
retrieveToken()
retrieve token from provider.
|
protected Token |
retrieveTokenFromCache()
Retrieve the IAM token from cache storage
|
void |
setClientConfiguration(ClientConfiguration clientConfiguration)
Set the client config that is been used on the s3client
|
void |
setIamEndpoint(String iamEndpoint)
Overwrite the default IAM endpoint.
|
void |
setIamMaxRetry(int count)
Over write the default IAM max retry count.
|
void |
setIamRefreshOffset(double offset)
Over write the default IAM refresh offset.
|
protected void |
setTokenCache(Token token) |
protected void |
submitRefreshTask()
Submits a token refresh task
|
protected static final InternalLogApi log
public DefaultTokenManager(String apiKey)
apiKey
- The IBM API Keypublic DefaultTokenManager(TokenProvider provider)
provider
- The Token Provider which will retrieve the Token Object from
the IAM servicepublic void setIamEndpoint(String iamEndpoint)
iamEndpoint
- The http endpoint to retrieve the tokenpublic void setIamRefreshOffset(double offset)
offset
- The percentage of token life that token should be refreshed
before expiration.public void setIamMaxRetry(int count)
offset
- The max number of times to attempt IAM token retrieval.public TokenProvider getProvider()
public String getToken()
getToken
in interface TokenManager
protected boolean checkCache()
protected void cacheToken(Token token)
token
- The IAM Token objectprotected Token retrieveTokenFromCache()
protected boolean hasTokenExpired(Token token)
token
- The IAM Token objectprotected boolean isTokenExpiring(Token token)
token
- The IAM Token objectprotected Token getCachedToken()
protected void setTokenCache(Token token)
token
- Sets the Token object in cacheprotected void retrieveToken()
protected void submitRefreshTask()
protected boolean isAsyncInProgress()
public ClientConfiguration getClientConfiguration()
public void setClientConfiguration(ClientConfiguration clientConfiguration)
clientConfiguration
- protected void finalize() throws Throwable
public static void addProxyConfig(org.apache.http.impl.client.HttpClientBuilder builder, HttpClientSettings settings)
builder
- Builder used to create the http clientsettings
- Settings which contain any proxy configuration detailsCopyright © 2024. All rights reserved.