Class CaffeineCacheAccessTokenResolver

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.forgerock.http.oauth2.AccessTokenResolver

    public class CaffeineCacheAccessTokenResolver
    extends Object
    implements org.forgerock.http.oauth2.AccessTokenResolver, Closeable
    A CaffeineCacheAccessTokenResolver is a delegating AccessTokenResolver that uses a write-through Caffeine to enable fast AccessTokenInfo resolution.
     
     {
          "type": "CacheAccessTokenResolver",
          "config": {
              "delegate"           : AccessTokenResolver    [REQUIRED]
              "enabled"            :    expression          [OPTIONAL - default to true.]
              "defaultTimeout"     :    duration            [OPTIONAL - default to 1 minute.]
              "executor"           :    executor            [OPTIONAL - By default, {@link ForkJoinPool#commonPool()}
                                                                        is used.]
              "maximumSize"        :    expression(long)    [OPTIONAL - Sets the maximum size of the cache.]
              "maximumTimeToCache" :    duration            [OPTIONAL - "zero" and "unlimited" are
                                                                        not acceptable values.]
          }
      }
      
     
    • Constructor Detail

      • CaffeineCacheAccessTokenResolver

        public CaffeineCacheAccessTokenResolver​(com.github.benmanes.caffeine.cache.Caffeine<Object,​Object> caffeine,
                                                org.forgerock.http.oauth2.AccessTokenResolver delegate,
                                                Clock clock,
                                                Duration defaultTimeout,
                                                Duration maximumTimeout)
        Builds a CaffeineCacheAccessTokenResolver delegating to the given AccessTokenResolver using the given (pre-configured) cache.
        Parameters:
        caffeine - The caffeine cache to use. Not null.
        delegate - The resolver to use. Not null.
        clock - A clock providing access to the current instant, date and time using a time-zone, not null.
        defaultTimeout - The default duration for which to cache AM access tokens. If an AM access token provides a valid expiresAt value to specify the time until which the access token remains valid, IG uses that value or the maxTimeout. Not null.
        maximumTimeout - The maximum duration for which to cache AM access tokens. If the expiresAt value provided by the AM access token is after the current time plus the maxTimeout, IG uses the maxTimeout. Can be null.
    • Method Detail

      • resolve

        public Promise<org.forgerock.http.oauth2.AccessTokenInfo,​org.forgerock.http.oauth2.AccessTokenException> resolve​(Context context,
                                                                                                                               String token)
        Specified by:
        resolve in interface org.forgerock.http.oauth2.AccessTokenResolver