Class TimeoutSessionPolicy<U>
- Type Parameters:
U- subject type
- All Implemented Interfaces:
SessionPolicy<U>
SessionPolicy with idle timeout, absolute lifetime, and
optional session-id rotation after login.
The policy is Vaadin-free and stateless — it makes decisions purely
from the SessionContext's timestamps. Tracking last-activity
inside the session is the adapter's job.
Decisions
onLogin(SessionContext)— emitsSessionCreated. IfTimeoutSessionPolicy.Config.rotateSessionAfterLogin()istrue, returnsSessionDecision.Invalidateso the adapter rotates the session id; otherwiseSessionDecision.Continue.INSTANCE.beforeNavigation(SessionContext)— checks absolute lifetime first, then idle timeout. Either trip emitsSessionExpiredand returnsSessionDecision.Invalidate.onLogout(SessionContext)— emitsSessionInvalidated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordTunable thresholds. -
Constructor Summary
ConstructorsConstructorDescriptionTimeoutSessionPolicy(TimeoutSessionPolicy.Config config, Clock clock, JSentinelAuditService auditService) -
Method Summary
Modifier and TypeMethodDescriptionbeforeNavigation(SessionContext<U> context) Called before each protected navigation.evaluate(SessionMetadata metadata) Pure-query lifetime check called by the VaadinSessionLifetimeListenerand by the REST filters.onLogin(SessionContext<U> context) Called after a successful login.voidonLogout(SessionContext<U> context) Called when the subject explicitly logs out.
-
Constructor Details
-
TimeoutSessionPolicy
public TimeoutSessionPolicy() -
TimeoutSessionPolicy
public TimeoutSessionPolicy(TimeoutSessionPolicy.Config config, Clock clock, JSentinelAuditService auditService) - Parameters:
config- thresholds and post-login behaviourclock- time source — fixed clocks make testing deterministicauditService- audit sink, ornullto resolve fromJSentinelServiceResolveron each event
-
-
Method Details
-
onLogin
Description copied from interface:SessionPolicyCalled after a successful login.The default returns
SessionDecision.Continue.INSTANCE. Implementations that want to rotate the session id after login should returnSessionDecision.Invalidatewith a target route — the adapter then closes the old session and the next request creates a fresh one.- Specified by:
onLoginin interfaceSessionPolicy<U>- Parameters:
context- session view at the moment of login- Returns:
- decision for the post-login navigation
-
evaluate
Pure-query lifetime check called by the VaadinSessionLifetimeListenerand by the REST filters.Returns
SessionPolicyDecision.AbsoluteLifetimeExceededfirst when both bounds are tripped — the absolute lifetime trumps the idle timeout, mirroring the precedence inbeforeNavigation(SessionContext).Audit emit-sites are deliberately not duplicated here:
beforeNavigation(SessionContext)is the audit boundary, since the lifecycle hooks carry the richersubjectandsessionId. The Vaadin / REST adapter that callsevaluate(...)is expected to emit the audit event itself when it acts on the decision.- Specified by:
evaluatein interfaceSessionPolicy<U>- Parameters:
metadata- current session view- Returns:
- decision; never
null
-
onLogout
Description copied from interface:SessionPolicyCalled when the subject explicitly logs out.The default is a no-op; implementations that emit audit events for logout should override or delegate.
- Specified by:
onLogoutin interfaceSessionPolicy<U>- Parameters:
context- session view at the moment of logout
-