Class SessionExpirationUtils

java.lang.Object
org.keycloak.models.utils.SessionExpirationUtils

public class SessionExpirationUtils extends Object

Shared methods to calculate the session expiration and idle.

Author:
rmartinc
  • Constructor Details

    • SessionExpirationUtils

      public SessionExpirationUtils()
  • Method Details

    • calculateUserSessionMaxLifespanTimestamp

      public static long calculateUserSessionMaxLifespanTimestamp(boolean offline, boolean isRememberMe, long created, RealmModel realm)
      Calculates the time in which the session is expired via max lifetime configuration.
      Parameters:
      offline - is the session offline?
      isRememberMe - is the session remember me?
      created - timestamp when the session was created
      realm - The realm model
      Returns:
      The time when the user session is expired or -1 if does not expire
    • calculateUserSessionIdleTimestamp

      public static long calculateUserSessionIdleTimestamp(boolean offline, boolean isRememberMe, long lastRefreshed, RealmModel realm)
      Calculates the time in which the user session is expired via the idle configuration.
      Parameters:
      offline - is the session offline?
      isRememberMe - is the session remember me?
      lastRefreshed - The last time the session was refreshed
      realm - The realm model
      Returns:
      The time in which the user session is expired by idle timeout
    • calculateClientSessionMaxLifespanTimestamp

      public static long calculateClientSessionMaxLifespanTimestamp(boolean offline, boolean isRememberMe, long clientSessionCreated, long userSessionCreated, RealmModel realm, ClientModel client)
      Calculates the time in which the client session is expired via lifespan configuration in the realm and client.
      Parameters:
      offline - is the session offline?
      isRememberMe - is the session remember me?
      clientSessionCreated - timestamp when the client session was created
      userSessionCreated - timestamp when the user session was created
      realm - The realm model
      client - The client model
      Returns:
      The time when the client session is expired or -1 if does not expire
    • calculateClientSessionIdleTimestamp

      public static long calculateClientSessionIdleTimestamp(boolean offline, boolean isRememberMe, long lastRefreshed, RealmModel realm, ClientModel client)
      Calculates the time in which the user session is expired via the idle configuration in the realm and client.
      Parameters:
      offline - is the session offline?
      isRememberMe - is the session remember me?
      lastRefreshed - the last time the client session was refreshed
      realm - the realm model
      client - the client model
      Returns:
      The time in which the client session is expired by idle timeout