Package org.keycloak.models.utils
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 Summary
ConstructorsConstructorDescriptionRealmExpiration(int lifespan, int maxIdle, int offlineLifespan, int offlineMaxIdle, int rememberMeLifespan, int rememberMeMaxIdle) Creates an instance of aRealmExpirationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongcalculateOfflineLifespanTimestamp(long created) Computes the time, in milliseconds, in which the offline session is expired via max lifetime.longcalculateOfflineMaxIdleTimestamp(long lastRefresh) Computes the time, in milliseconds, in which the offline session is expired via max idle.longcalculateRegularLifespanTimestamp(long created, boolean rememberMe) Computes the time, in milliseconds, in which the regular session is expired via max lifetime.longcalculateRegularMaxIdleTimestamp(long lastRefresh, boolean rememberMe) Computes the time, in milliseconds, in which the offline session is expired via max idle.final booleanIndicates whether some other object is "equal to" this one.static RealmExpirationfromRealm(RealmModel realm) Creates a newRealmExpirationinstance from theRealmModelinstance.intgetLifespan(boolean rememberMe) Returns the lifespan for a regular session.intgetMaxIdle(boolean rememberMe) Returns the max-idle for a regular session.final inthashCode()Returns a hash code value for this object.intlifespan()Returns the value of thelifespanrecord component.intmaxIdle()Returns the value of themaxIdlerecord component.intReturns the value of theofflineLifespanrecord component.intReturns the value of theofflineMaxIdlerecord component.intReturns the value of therememberMeLifespanrecord component.intReturns the value of therememberMeMaxIdlerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RealmExpiration
public RealmExpiration(int lifespan, int maxIdle, int offlineLifespan, int offlineMaxIdle, int rememberMeLifespan, int rememberMeMaxIdle) Creates an instance of aRealmExpirationrecord class.- Parameters:
lifespan- the value for thelifespanrecord componentmaxIdle- the value for themaxIdlerecord componentofflineLifespan- the value for theofflineLifespanrecord componentofflineMaxIdle- the value for theofflineMaxIdlerecord componentrememberMeLifespan- the value for therememberMeLifespanrecord componentrememberMeMaxIdle- the value for therememberMeMaxIdlerecord 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 totrueif 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 createdrememberMe- Set totrueif the session has remember me enabled.- Returns:
- The timestamp, in milliseconds, since when this session is not long valid.
-
fromRealm
Creates a newRealmExpirationinstance from theRealmModelinstance.- Parameters:
realm- TheRealmModelinstance to get the expiration settings.- Returns:
- A new
RealmExpiration.
-
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. -
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. -
equals
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 '=='. -
lifespan
public int lifespan()Returns the value of thelifespanrecord component.- Returns:
- the value of the
lifespanrecord component
-
maxIdle
public int maxIdle()Returns the value of themaxIdlerecord component.- Returns:
- the value of the
maxIdlerecord component
-
offlineLifespan
public int offlineLifespan()Returns the value of theofflineLifespanrecord component.- Returns:
- the value of the
offlineLifespanrecord component
-
offlineMaxIdle
public int offlineMaxIdle()Returns the value of theofflineMaxIdlerecord component.- Returns:
- the value of the
offlineMaxIdlerecord component
-
rememberMeLifespan
public int rememberMeLifespan()Returns the value of therememberMeLifespanrecord component.- Returns:
- the value of the
rememberMeLifespanrecord component
-
rememberMeMaxIdle
public int rememberMeMaxIdle()Returns the value of therememberMeMaxIdlerecord component.- Returns:
- the value of the
rememberMeMaxIdlerecord component
-