Record Class RealmExpiration

java.lang.Object
java.lang.Record
org.keycloak.models.utils.RealmExpiration
Record Components:
lifespan - The regular user session lifespan in seconds.
maxIdle - The regular user session max-idle in seconds.
offlineLifespan - The offline user session lifespan in seconds.
offlineMaxIdle - The offline user session max-idle in seconds.
rememberMeLifespan - The regular user session, in seconds, when remember me is enabled for the session.
rememberMeMaxIdle - the regular user session, in seconds, when remember me is enabled for the session.

public record RealmExpiration(int lifespan, int maxIdle, int offlineLifespan, int offlineMaxIdle, int rememberMeLifespan, int rememberMeMaxIdle) extends Record
A record with the RealmModel expiration settings.
  • Constructor Details

    • RealmExpiration

      public RealmExpiration(int lifespan, int maxIdle, int offlineLifespan, int offlineMaxIdle, int rememberMeLifespan, int rememberMeMaxIdle)
      Creates an instance of a RealmExpiration record class.
      Parameters:
      lifespan - the value for the lifespan record component
      maxIdle - the value for the maxIdle record component
      offlineLifespan - the value for the offlineLifespan record component
      offlineMaxIdle - the value for the offlineMaxIdle record component
      rememberMeLifespan - the value for the rememberMeLifespan record component
      rememberMeMaxIdle - the value for the rememberMeMaxIdle record component
  • Method Details

    • getLifespan

      public int getLifespan(boolean rememberMe)
      Returns the lifespan for a regular session.
      Parameters:
      rememberMe - If the session has remember_me enabled.
      Returns:
      The computed lifespan for a regular session, in seconds.
    • getMaxIdle

      public int getMaxIdle(boolean rememberMe)
      Returns the max-idle for a regular session.
      Parameters:
      rememberMe - If the session has remember_me enabled.
      Returns:
      The computed max-idle for a regular session, in seconds.
    • calculateOfflineLifespanTimestamp

      public long calculateOfflineLifespanTimestamp(long created)
      Computes the time, in milliseconds, in which the offline session is expired via max lifetime.
      Parameters:
      created - The timestamp, in milliseconds, when the session was created.
      Returns:
      The timestamp, in milliseconds, since when this session is not longer valid.
    • calculateRegularLifespanTimestamp

      public long calculateRegularLifespanTimestamp(long created, boolean rememberMe)
      Computes the time, in milliseconds, in which the regular session is expired via max lifetime.
      Parameters:
      created - The timestamp, in milliseconds, when the session was created.
      rememberMe - Set to true if the session has remember me enabled.
      Returns:
      The timestamp, in milliseconds, since when this session is not longer valid.
    • calculateOfflineMaxIdleTimestamp

      public long calculateOfflineMaxIdleTimestamp(long lastRefresh)
      Computes the time, in milliseconds, in which the offline session is expired via max idle.
      Parameters:
      lastRefresh - timestamp when the session was created
      Returns:
      The timestamp, in milliseconds, since when this session is not long valid.
    • calculateRegularMaxIdleTimestamp

      public long calculateRegularMaxIdleTimestamp(long lastRefresh, boolean rememberMe)
      Computes the time, in milliseconds, in which the offline session is expired via max idle.
      Parameters:
      lastRefresh - timestamp when the session was created
      rememberMe - Set to true if the session has remember me enabled.
      Returns:
      The timestamp, in milliseconds, since when this session is not long valid.
    • fromRealm

      public static RealmExpiration fromRealm(RealmModel realm)
      Creates a new RealmExpiration instance from the RealmModel instance.
      Parameters:
      realm - The RealmModel instance to get the expiration settings.
      Returns:
      A new RealmExpiration.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • lifespan

      public int lifespan()
      Returns the value of the lifespan record component.
      Returns:
      the value of the lifespan record component
    • maxIdle

      public int maxIdle()
      Returns the value of the maxIdle record component.
      Returns:
      the value of the maxIdle record component
    • offlineLifespan

      public int offlineLifespan()
      Returns the value of the offlineLifespan record component.
      Returns:
      the value of the offlineLifespan record component
    • offlineMaxIdle

      public int offlineMaxIdle()
      Returns the value of the offlineMaxIdle record component.
      Returns:
      the value of the offlineMaxIdle record component
    • rememberMeLifespan

      public int rememberMeLifespan()
      Returns the value of the rememberMeLifespan record component.
      Returns:
      the value of the rememberMeLifespan record component
    • rememberMeMaxIdle

      public int rememberMeMaxIdle()
      Returns the value of the rememberMeMaxIdle record component.
      Returns:
      the value of the rememberMeMaxIdle record component