Class OAuth2Options.TokenCacheParameters

java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.OAuth2Options.TokenCacheParameters
All Implemented Interfaces:
ServiceBindingDestinationOptions.OptionsEnhancer<OAuth2Options.TokenCacheParameters>
Enclosing class:
OAuth2Options

@Beta public static class OAuth2Options.TokenCacheParameters extends Object implements ServiceBindingDestinationOptions.OptionsEnhancer<OAuth2Options.TokenCacheParameters>
Configuration for the token response cache used by OAuth2Service.

Important: These values are passed to TokenCacheConfiguration used by XSUAAs DefaultOAuth2TokenService. This cache stores the HTTP token response (including the token) and it governs the cache entry, not the token's lifetime.

Expired (or almost expired) tokens are never served, regardless of cacheDuration as xsuaa checks exp - tokenExpirationDelta before returning a cached entry.

Since:
5.21.0
  • Method Details

    • getValue

      @Nonnull public OAuth2Options.TokenCacheParameters getValue()
      Description copied from interface: ServiceBindingDestinationOptions.OptionsEnhancer
      Get the value of the option.
      Specified by:
      getValue in interface ServiceBindingDestinationOptions.OptionsEnhancer<OAuth2Options.TokenCacheParameters>
      Returns:
      The value of the option.
    • getCacheDuration

      @Nonnull public Duration getCacheDuration()
      Upper bound for how long a successful token response may remain cached. A cached entry is ignored earlier if the token would be (almost) expired.
    • getCacheSize

      @Nonnull public Integer getCacheSize()
      The maximum number of tokens to cache.
    • getTokenExpirationDelta

      @Nonnull public Duration getTokenExpirationDelta()
      The delta to be subtracted from the token expiration time to determine how early should a token be refreshed before it expires.
    • of

      @Nonnull public static OAuth2Options.TokenCacheParameters of(@Nonnull Duration cacheDuration, @Nonnull Integer cacheSize, @Nonnull Duration tokenExpirationDelta)
      Creates a new TokenCacheParameters instance.
      Parameters:
      cacheDuration - Upper bound for how long a successful token response may remain cached. A cached entry is ignored earlier if the token would be (almost) expired.
      cacheSize - The maximum number of tokens to cache.
      tokenExpirationDelta - The delta to be subtracted from the token expiration time to determine how early should a token be refreshed before it expires.