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 themaximumTimeout
and (now - SessionInfo's attribute: 'getMaxSessionExpirationTime()') has elapsed.
-
-
Constructor Summary
Constructors Constructor Description CacheSessionService(SessionService sessionService, NotificationService notificationService, 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 optionalSessionInfo
or with anSessionException
in case of errors.Promise<Void,SessionException>
logout(Context context, String ssoToken)
Returns a promise that will be completed with aVoid
or with anSessionException
in 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, 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.caffeine
- 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 Detail
-
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
public Promise<Void,SessionException> logout(Context context, String ssoToken)
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
public Promise<Void,Exception> start()
Description copied from interface:LifeCycle
Starts this object.
-
-