Class CachedTokenRefresher.Builder<TokenT extends SdkToken>

java.lang.Object
software.amazon.awssdk.awscore.internal.token.CachedTokenRefresher.Builder<TokenT>
Enclosing class:
CachedTokenRefresher<TokenT extends SdkToken>

public static class CachedTokenRefresher.Builder<TokenT extends SdkToken> extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • tokenRetriever

      public CachedTokenRefresher.Builder tokenRetriever(Supplier<TokenT> tokenRetriever)
      Parameters:
      tokenRetriever - Supplier to retrieve the token from its respective sources.
      Returns:
    • staleDuration

      public CachedTokenRefresher.Builder staleDuration(Duration staleDuration)
      Parameters:
      staleDuration - The time before which the token is marked as stale to indicate it is time to fetch a fresh token.
      Returns:
    • prefetchTime

      public CachedTokenRefresher.Builder prefetchTime(Duration prefetchTime)
      Configure the amount of time, relative to SSO session token expiration, that the cached credentials are considered close to stale and should be updated. See asyncRefreshEnabled.

      By default, this is 5 minutes.

    • asyncRefreshEnabled

      public CachedTokenRefresher.Builder asyncRefreshEnabled(Boolean asyncRefreshEnabled)
      Configure whether this refresher should fetch tokens asynchronously in the background. If this is true, threads are less likely to block when CachedTokenRefresher.refreshIfStaleAndFetch() ()} is called, but additional resources are used to maintain the provider.

      By default, this is disabled.

    • exceptionHandler

      public CachedTokenRefresher.Builder exceptionHandler(Function<SdkException,TokenT> exceptionHandler)
      Parameters:
      exceptionHandler - Handler which takes action when a Runtime exception occurs while fetching a token. Handler can return a previously stored token or throw back the exception.
      Returns:
    • build

      public CachedTokenRefresher build()