public class FixedDurationExpirationSessionRepository<S extends org.springframework.session.Session>
extends java.lang.Object
implements org.springframework.session.SessionRepository<S>
FixedDurationExpirationSessionRepository
class is a SessionRepository
implementation wrapping
an existing SessionRepository
, data store specific, implementation in order to implement
a fixed Duration
expiration policy on the Session
.
That is, the Session
will always expire (or be considered "expired") after a fixed amount of time. Even if
the user Session
is still actively being accessed up to the last moment right before the Session
is about to expire, the Session
will expire regardless.
This may be useful in certain UCs where, for security reasons, the Session
must expire no matter what.Duration
,
Instant
,
Session
,
SessionRepository
,
Absolute Session TimeoutsConstructor and Description |
---|
FixedDurationExpirationSessionRepository(org.springframework.session.SessionRepository<S> sessionRepository,
java.time.Duration expirationTimeout)
Constructs a new instance of
FixedDurationExpirationSessionRepository initialized with the given
data store specific SessionRepository . |
Modifier and Type | Method and Description |
---|---|
S |
createSession()
Creates a new instance of
Session . |
void |
deleteById(java.lang.String id)
Deletes the
Session identified by the given ID . |
S |
findById(java.lang.String id)
Finds a
Session with the given ID . |
protected org.springframework.session.SessionRepository<S> |
getDelegate()
Returns a reference to the data store specific
SessionRepository . |
java.util.Optional<java.time.Duration> |
getExpirationTimeout()
Return an
Optional expiraiton timeout . |
void |
save(S session)
Saves the given
Session to the underlying data (persistent) store. |
public FixedDurationExpirationSessionRepository(@NonNull org.springframework.session.SessionRepository<S> sessionRepository, @Nullable java.time.Duration expirationTimeout)
FixedDurationExpirationSessionRepository
initialized with the given
data store specific SessionRepository
.sessionRepository
- SessionRepository
delegate.expirationTimeout
- Duration
specifying the length of time until the Session
expires.java.lang.IllegalArgumentException
- if SessionRepository
is null.SessionRepository
,
Duration
@NonNull protected org.springframework.session.SessionRepository<S> getDelegate()
SessionRepository
.SessionRepository
.SessionRepository
public java.util.Optional<java.time.Duration> getExpirationTimeout()
Optional
expiraiton timeout
.Optional
expiraiton timeout
.Duration
,
Optional
public S createSession()
Session
.
The Session
instance will be managed by Apache Geode or Pivotal GemFire.createSession
in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
Session
.Session
public S findById(java.lang.String id)
Session
with the given ID
.
This method will also perform a lazy expiration check to determine if the Session
has already expired
upon access, and if so, delete the Session
with the given ID
.findById
in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
id
- String
containing the ID identifying the Session
to lookup.Session
with the given ID
or null if no Session
with ID
exists or the Session
is expired.Session
,
handleExpired(Session, Duration)
,
getExpirationTimeout()
public void save(S session)
Session
to the underlying data (persistent) store.save
in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
session
- Session
to save.Session
public void deleteById(java.lang.String id)
Session
identified by the given ID
.deleteById
in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
id
- String
containing the ID of the Session
to delete.Session