Class CacheSessionService
- java.lang.Object
-
- org.forgerock.openig.tools.session.CacheSessionService
-
- All Implemented Interfaces:
LifeCycle,SessionService
public class CacheSessionService extends Object implements SessionService, LifeCycle
Create a CacheSessionService which is responsible to manage the cache for theSessionInfo. The cache is anAsyncCache, which loads entries asynchronously.By default a cached entry will expire once the duration (now - SessionInfo's attribute: 'getMaxSessionExpirationTime()') has elapsed. But it is possible to cap that duration to a maximum through the parameter
maximumTimeout. In that case, the cached entry will expire once the smallest duration between themaximumTimeoutand (now - SessionInfo's attribute: 'getMaxSessionExpirationTime()') has elapsed.
-
-
Constructor Summary
Constructors Constructor Description CacheSessionService(SessionService sessionService, NotificationService notificationService, String sessionNotificationTopic, com.github.benmanes.caffeine.cache.Caffeine<Object,Object> caffeine, Supplier<String> generator, Clock clock, Duration maximumTimeout, DisconnectionStrategy disconnectionStrategy, boolean sessionIdleRefreshEnabled)Creates a new CacheSessionService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<Optional<SessionInfo>,SessionException>getSessionInfo(Context context, String ssoToken)Returns a promise that will be completed with an optionalSessionInfoor with anSessionExceptionin case of errors.Promise<Void,SessionException>logout(Context context, String ssoToken)Returns a promise that will be completed with aVoidor with anSessionExceptionin case of errors.Promise<Void,Exception>start()Starts this object.Promise<Void,NeverThrowsException>stop()Stops this object.
-
-
-
Constructor Detail
-
CacheSessionService
public CacheSessionService(SessionService sessionService, NotificationService notificationService, String sessionNotificationTopic, com.github.benmanes.caffeine.cache.Caffeine<Object,Object> caffeine, Supplier<String> generator, Clock clock, Duration maximumTimeout, DisconnectionStrategy disconnectionStrategy, boolean sessionIdleRefreshEnabled)
Creates a new CacheSessionService.- Parameters:
sessionService- TheSessionServiceto execute when aSessionInfois not found in the cachenotificationService- The notification service used for entry eviction, can benullif none.sessionNotificationTopic- The topic to subscribe to receive session notificationscaffeine- The parameters of the underlying cachegenerator- The generator to provide the cache idsclock- A clock providing access to the current instant, date and time using a time-zone, notnull.maximumTimeout- The maximum time to cache a session. Can benull, and in that case the time to cache for aSessionInfois not capped.disconnectionStrategy- The strategy to apply in case of notifications' disconnection.sessionIdleRefreshEnabled- If true, the session idle refresh service has been enabled.- Throws:
NullPointerException- if sessionService or caffeine or clock arenull.
-
-
Method Detail
-
getSessionInfo
public Promise<Optional<SessionInfo>,SessionException> getSessionInfo(Context context, String ssoToken)
Description copied from interface:SessionServiceReturns a promise that will be completed with an optionalSessionInfoor with anSessionExceptionin case of errors. The optionalSessionInfowill be empty only when the givenssoTokenis invalid or expired.- Specified by:
getSessionInfoin interfaceSessionService- Parameters:
context- The request context.ssoToken- The ssoToken used to retrieve the session information about.- Returns:
- a promise that will be completed with
SessionInfoor with anSessionExceptionin case of errors.
-
logout
public Promise<Void,SessionException> logout(Context context, String ssoToken)
Description copied from interface:SessionServiceReturns a promise that will be completed with aVoidor with anSessionExceptionin case of errors.- Specified by:
logoutin interfaceSessionService- Parameters:
context- The request context.ssoToken- The ssoToken to logout.- Returns:
- a promise that will be completed with a
Voidor with anSessionExceptionin case of errors.
-
start
public Promise<Void,Exception> start()
Description copied from interface:LifeCycleStarts this object.
-
-