Class DPoPProofReplayValidator.InMemoryCache

java.lang.Object
org.springframework.security.oauth2.jwt.DPoPProofReplayValidator.InMemoryCache
All Implemented Interfaces:
org.springframework.cache.Cache
Enclosing class:
DPoPProofReplayValidator

public static final class DPoPProofReplayValidator.InMemoryCache extends Object implements org.springframework.cache.Cache
An in-memory Cache implementation backed by a ConcurrentHashMap.

NOTE: This implementation has limitations as it only works in a single-node setup. For production (and clustered) environments, it is recommended to use a distributed Cache implementation (e.g. Redis, Hazelcast, etc.).

This implementation can be fine-tuned based on the following configuration settings:

Since:
6.5.12
  • Constructor Details

    • InMemoryCache

      public InMemoryCache()
  • Method Details

    • getMaxSize

      public int getMaxSize()
      Returns the maximum number of entries the cache can hold.
      Returns:
      the maximum number of entries the cache can hold
    • setMaxSize

      public void setMaxSize(int maxSize)
      Sets the maximum number of entries the cache can hold. The default is 100,000.
      Parameters:
      maxSize - the maximum number of entries the cache can hold
    • getMaxRequestsPerKey

      public int getMaxRequestsPerKey()
      Returns the maximum number of requests allowed per JWK thumbprint.
      Returns:
      the maximum number of requests allowed per JWK thumbprint
    • setMaxRequestsPerKey

      public void setMaxRequestsPerKey(int maxRequestsPerKey)
      Sets the maximum number of requests allowed per JWK thumbprint. The default is 1000.
      Parameters:
      maxRequestsPerKey - the maximum number of requests allowed per JWK thumbprint
    • getName

      public String getName()
      Specified by:
      getName in interface org.springframework.cache.Cache
    • getNativeCache

      public Object getNativeCache()
      Specified by:
      getNativeCache in interface org.springframework.cache.Cache
    • get

      public @Nullable org.springframework.cache.Cache.ValueWrapper get(Object key)
      Specified by:
      get in interface org.springframework.cache.Cache
    • get

      public <T> @Nullable T get(Object key, @Nullable Class<T> type)
      Specified by:
      get in interface org.springframework.cache.Cache
    • get

      public <T> @Nullable T get(Object key, Callable<T> valueLoader)
      Specified by:
      get in interface org.springframework.cache.Cache
    • put

      public void put(Object key, @Nullable Object value)
      Specified by:
      put in interface org.springframework.cache.Cache
    • putIfAbsent

      public @Nullable org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, @Nullable Object value)
      Specified by:
      putIfAbsent in interface org.springframework.cache.Cache
    • evict

      public void evict(Object key)
      Specified by:
      evict in interface org.springframework.cache.Cache
    • clear

      public void clear()
      Specified by:
      clear in interface org.springframework.cache.Cache