Class AuthSession
java.lang.Object
com.serinity.accesscontrol.model.base.IdentifiableEntity
com.serinity.accesscontrol.model.AuthSession
Represents an authentication session for a user. Used to manage user login
sessions, refresh tokens, and session validity.
This entity extends IdentifiableEntity, which provides a unique
id for
each session entry.
The table auth_sessions has the following indexes for performance
optimization:
idx_session_token- Indexed onrefresh_tokento quickly validate or revoke sessions.idx_session_user- Indexed onuser_idfor efficient lookup of all sessions by user.
Fields include:
refreshToken- The refresh token associated with this session. Must be unique.createdAt- Timestamp when the session was created.expiresAt- Timestamp when the session expires and is no longer valid.revoked- Boolean flag indicating if the session has been revoked.user- TheUserwho owns this session.
Note: This class is declared final to prevent inheritance and ensure
session integrity.
- Since:
- 2026-02-03
- Version:
- 1.0
- Author:
- @ZouariOmar (zouariomar20@gmail.com)
- See Also:
-
Field Summary
Fields inherited from class IdentifiableEntity
id -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the creation timestamp of this session.Returns the expiration timestamp for this session.Returns the refresh token for this session.getUser()Returns the user that owns this session.booleanIndicates whether this session has been revoked.voidsetCreatedAt(Instant createdAt) Sets the creation timestamp of this session.voidsetExpiresAt(Instant expiresAt) Sets the expiration timestamp for this session.voidsetRevoked(boolean revoked) Marks this session as revoked or active.voidSets the user that owns this session.Methods inherited from class IdentifiableEntity
getId
-
Constructor Details
-
AuthSession
public AuthSession()Creates an empty authentication session.
-
-
Method Details
-
getRefreshToken
Returns the refresh token for this session.- Returns:
- refresh token value
-
getCreatedAt
Returns the creation timestamp of this session.- Returns:
- creation timestamp
-
setCreatedAt
Sets the creation timestamp of this session.- Parameters:
createdAt- creation timestamp to assign
-
getExpiresAt
Returns the expiration timestamp for this session.- Returns:
- expiration timestamp
-
setExpiresAt
Sets the expiration timestamp for this session.- Parameters:
expiresAt- expiration timestamp to assign
-
setRevoked
public void setRevoked(boolean revoked) Marks this session as revoked or active.- Parameters:
revoked-trueto revoke the session
-
isRevoked
public boolean isRevoked()Indicates whether this session has been revoked.- Returns:
trueif revoked
-
getUser
-
setUser
Sets the user that owns this session.- Parameters:
user- session owner
-