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
ConstructorDescriptionCacheSessionService
(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 optionalSessionInfo
or with anSessionException
in case of errors.Returns a promise that will be completed with aVoid
or with anSessionException
in 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
- TheSessionService
to execute when aSessionInfo
is not found in the cachenotificationService
- The notification service used for entry eviction, can benull
if 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 aSessionInfo
is 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:SessionService
Returns a promise that will be completed with an optionalSessionInfo
or with anSessionException
in case of errors. The optionalSessionInfo
will be empty only when the givenssoToken
is invalid or expired.- Specified by:
getSessionInfo
in interfaceSessionService
- Parameters:
context
- The request context.ssoToken
- The ssoToken used to retrieve the session information about.- Returns:
- a promise that will be completed with
SessionInfo
or with anSessionException
in case of errors.
-
logout
Description copied from interface:SessionService
Returns a promise that will be completed with aVoid
or with anSessionException
in case of errors.- Specified by:
logout
in interfaceSessionService
- Parameters:
context
- The request context.ssoToken
- The ssoToken to logout.- Returns:
- a promise that will be completed with a
Void
or with anSessionException
in case of errors.
-
start
Description copied from interface:LifeCycle
Starts this object. -
stop
Description copied from interface:LifeCycle
Stops this object.
-