Class TokenCacheConfiguration
- java.lang.Object
-
- com.sap.cloud.security.xsuaa.tokenflows.TokenCacheConfiguration
-
- All Implemented Interfaces:
CacheConfiguration
public class TokenCacheConfiguration extends Object implements CacheConfiguration
Data class to capture configuration options of token caches.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TokenCacheConfigurationcacheDisabled()The default cache configuration.static TokenCacheConfigurationdefaultConfiguration()A special cache configuration used to disable caching.booleanequals(Object o)DurationgetCacheDuration()intgetCacheSize()static TokenCacheConfigurationgetInstance(Duration cacheDuration, int cacheSize, Duration tokenExpirationDelta)Creates a newTokenCacheConfigurationinstance with the given properties.static TokenCacheConfigurationgetInstance(Duration cacheDuration, int cacheSize, Duration tokenExpirationDelta, boolean cacheStatisticsEnabled)Creates a newTokenCacheConfigurationinstance with the given properties.DurationgetTokenExpirationDelta()If a cached token expires because its expiration time (exp) has been reached, it should not be retrieved from the cache.inthashCode()booleanisCacheStatisticsEnabled()StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.sap.cloud.security.config.CacheConfiguration
isCacheDisabled
-
-
-
-
Method Detail
-
getInstance
public static TokenCacheConfiguration getInstance(@Nonnull Duration cacheDuration, int cacheSize, @Nonnull Duration tokenExpirationDelta)
Creates a newTokenCacheConfigurationinstance with the given properties. SeeCacheConfiguration.getCacheDuration(),CacheConfiguration.getCacheSize()andgetTokenExpirationDelta()for an explanation of the respective properties.- Parameters:
cacheDuration- the cache duration property.cacheSize- the cache size property.tokenExpirationDelta- the token expiration delta.- Returns:
- a new
TokenCacheConfigurationinstance.
-
getInstance
public static TokenCacheConfiguration getInstance(Duration cacheDuration, int cacheSize, Duration tokenExpirationDelta, boolean cacheStatisticsEnabled)
Creates a newTokenCacheConfigurationinstance with the given properties. SeeCacheConfiguration.getCacheDuration(),CacheConfiguration.getCacheSize(),getTokenExpirationDelta()andCacheConfiguration.isCacheStatisticsEnabled()for an explanation of the respective properties.- Parameters:
cacheDuration- the cache duration property.cacheSize- the cache size property.tokenExpirationDelta- the token expiration delta.cacheStatisticsEnabled-trueif cache statistic recording has been enabled- Returns:
- a new
TokenCacheConfigurationinstance.
-
cacheDisabled
public static TokenCacheConfiguration cacheDisabled()
The default cache configuration.
-
defaultConfiguration
public static TokenCacheConfiguration defaultConfiguration()
A special cache configuration used to disable caching.
-
getCacheDuration
@Nonnull public Duration getCacheDuration()
- Specified by:
getCacheDurationin interfaceCacheConfiguration
-
getCacheSize
public int getCacheSize()
- Specified by:
getCacheSizein interfaceCacheConfiguration
-
getTokenExpirationDelta
public Duration getTokenExpirationDelta()
If a cached token expires because its expiration time (exp) has been reached, it should not be retrieved from the cache. A new token should be requested in this case. For this to work cached tokens are being checked if their expiration time (exp) has already been reached or if it is soon going to be reached. The expiration delta controls what soon means. For example if the expiration delta is set to 10 seconds and a cached token will expire in 5 seconds, it will not be retrieved from cache anymore because the duration until the token is expired is smaller than delta.- Returns:
- the token expiration delta.
-
isCacheStatisticsEnabled
public boolean isCacheStatisticsEnabled()
- Specified by:
isCacheStatisticsEnabledin interfaceCacheConfiguration
-
-