Class AuthSessionRepository
java.lang.Object
com.serinity.accesscontrol.repository.base.BaseRepository<AuthSession, Long>
com.serinity.accesscontrol.repository.AuthSessionRepository
Repository class for performing CRUD operations on
AuthSession entities.- Since:
- 2026-02-04
- Version:
- 1.0
- Author:
- @ZouariOmar (zouariomar20@gmail.com)
- See Also:
-
Field Summary
Fields inherited from class BaseRepository
em, entityClass -
Constructor Summary
ConstructorsConstructorDescriptionAuthSessionRepository(org.zouarioss.skinnedratorm.core.EntityManager em) Creates a repository instance for auth sessions. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexistsActiveSession(User user) Checks whether the user has at least one active (non-revoked, non-expired) session.findActiveSession(User user) Finds the currently active (non-revoked, non-expired) session for a user.findByRefreshToken(String refreshToken) Finds anAuthSessionby its refresh token value.findByUserId(UUID userId) Returns all sessions belonging to a given user.findValidByRefreshToken(String refreshToken) Finds a valid (non-revoked, non-expired) session by refresh token.Methods inherited from class BaseRepository
delete, deleteById, findAll, findById, save, update
-
Constructor Details
-
AuthSessionRepository
public AuthSessionRepository(org.zouarioss.skinnedratorm.core.EntityManager em) Creates a repository instance for auth sessions.- Parameters:
em- entity manager used for persistence operations
-
-
Method Details
-
findByRefreshToken
Finds anAuthSessionby its refresh token value.- Parameters:
refreshToken- the refresh token to look up- Returns:
- the matching session, or
nullif not found
-
findByUserId
Returns all sessions belonging to a given user.- Parameters:
userId- the UUID of the user- Returns:
- list of sessions for the user, or
nullon error
-
findValidByRefreshToken
Finds a valid (non-revoked, non-expired) session by refresh token.- Parameters:
refreshToken- the refresh token to validate- Returns:
- the active session, or
nullif none found
-
findActiveSession
Finds the currently active (non-revoked, non-expired) session for a user.- Parameters:
user- the user whose active session to find- Returns:
- an
Optionalcontaining the active session, or empty if none
-
existsActiveSession
Checks whether the user has at least one active (non-revoked, non-expired) session.- Parameters:
user- the user to check- Returns:
trueif an active session exists
-