Class AuthSessionRepository

java.lang.Object
com.serinity.accesscontrol.repository.base.BaseRepository<AuthSession, Long>
com.serinity.accesscontrol.repository.AuthSessionRepository

public class AuthSessionRepository extends BaseRepository<AuthSession, Long>
Repository class for performing CRUD operations on AuthSession entities.
Since:
2026-02-04
Version:
1.0
Author:
@ZouariOmar (zouariomar20@gmail.com)
See Also:
  • 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

      public AuthSession findByRefreshToken(String refreshToken)
      Finds an AuthSession by its refresh token value.
      Parameters:
      refreshToken - the refresh token to look up
      Returns:
      the matching session, or null if not found
    • findByUserId

      public List<AuthSession> findByUserId(UUID userId)
      Returns all sessions belonging to a given user.
      Parameters:
      userId - the UUID of the user
      Returns:
      list of sessions for the user, or null on error
    • findValidByRefreshToken

      public AuthSession findValidByRefreshToken(String refreshToken)
      Finds a valid (non-revoked, non-expired) session by refresh token.
      Parameters:
      refreshToken - the refresh token to validate
      Returns:
      the active session, or null if none found
    • findActiveSession

      public Optional<AuthSession> findActiveSession(User user)
      Finds the currently active (non-revoked, non-expired) session for a user.
      Parameters:
      user - the user whose active session to find
      Returns:
      an Optional containing the active session, or empty if none
    • existsActiveSession

      public boolean existsActiveSession(User user)
      Checks whether the user has at least one active (non-revoked, non-expired) session.
      Parameters:
      user - the user to check
      Returns:
      true if an active session exists