Class CacheSessionService
java.lang.Object
org.forgerock.openig.tools.session.CacheSessionService
- All Implemented Interfaces:
LifeCycle,SessionService
Create a CacheSessionService which is responsible to manage the cache for the
SessionInfo.
The cache is an AsyncCache, 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 parametermaximumTimeout. In that case, the cached entry will expire once the smallest duration
between the maximumTimeout and (now - SessionInfo's attribute:
'getMaxSessionExpirationTime()') has elapsed.
-
Constructor Summary
ConstructorsConstructorDescriptionCacheSessionService(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
Modifier and TypeMethodDescriptiongetSessionInfo(Context context, String ssoToken) Returns a promise that will be completed with an optionalSessionInfoor with anSessionExceptionin case of errors.Returns a promise that will be completed with aVoidor with anSessionExceptionin case of errors.start()Starts this object.stop()Stops this object.
-
Constructor Details
-
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 Details
-
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
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
Description copied from interface:LifeCycleStarts this object. -
stop
Description copied from interface:LifeCycleStops this object.
-