java.lang.Object
io.inverno.mod.session.AbstractSession<A,JWTSession<A,B>>
io.inverno.mod.session.jwt.AbstractJWTSession<A,B>
- Type Parameters:
A- the session data typeB- the stateless session data type
- All Implemented Interfaces:
JWTSession<A,,B> Session<A>
public abstract class AbstractJWTSession<A,B>
extends AbstractSession<A,JWTSession<A,B>>
implements JWTSession<A,B>
Base JWTSession implementation class.
- Since:
- 1.13
- Author:
- Jeremy Kuhn
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag indicating whether expiration settings were changed.protected booleanFlag indicating whether stateless data were get.protected booleanFlag indicating whether stateless data were set.protected BThe stateless session data stored in the JWT session id.protected SessionDataSaveStrategy<B> Stateless session data save strategy.protected StringThe JWT session token id (i.e.Fields inherited from class io.inverno.mod.session.AbstractSession
creationTime, expirationTime, id, invalidated, lastAccessedTime, maxInactiveInterval, originalId, sessionIdGenerator, sessionStoreFields inherited from interface io.inverno.mod.session.Session
DEFAULT_MAX_INACTIVE_INTERVAL -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractJWTSession(JWTSessionIdGenerator<A, B> sessionIdGenerator, JWTSessionStore<A, B> sessionStore, Long maxInactiveInterval, Long expirationTime, SessionDataSaveStrategy<B> statelessSessionDataSaveStrategy) Creates a new JWT session.protectedAbstractJWTSession(JWTSessionIdGenerator<A, B> sessionIdGenerator, JWTSessionStore<A, B> sessionStore, String id, JWTClaimsSet claimsSet, B statelessSessionData, SessionDataSaveStrategy<B> statelessSessionDataSaveStrategy, long lastAccessedTime, boolean isNew) Creates an existing JWT session.protectedAbstractJWTSession(JWTSessionIdGenerator<A, B> sessionIdGenerator, JWTSessionStore<A, B> sessionStore, String id, String tokenId, long creationTime, long lastAccessedTime, Long maxInactiveInterval, Long expirationTime, B statelessSessionData, SessionDataSaveStrategy<B> statelessSessionDataSaveStrategy, boolean isNew) Creates an existing JWT session. -
Method Summary
Modifier and TypeMethodDescriptionReturns the stateless session data.Returns the JWT token id (i.e.Invalidates the session.booleanDetermines whether the session has expired.refreshId(boolean force) Refreshes the session id.voidsetExpirationTime(long expirationTime) Sets the session expiration time in milliseconds.protected voidsetLastAccessedTime(long lastAccessedTime) Sets the last accessed time.voidsetMaxInactiveInterval(long maxInactiveInterval) Sets the maximum inactive interval in milliseconds.voidsetStatelessData(B statelessSessionData) Sets the stateless session data.Methods inherited from class io.inverno.mod.session.AbstractSession
getCreationTime, getExpirationTime, getId, getLastAccessedTime, getMaxInactiveInterval, getOriginalId, isInvalidated, saveMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.inverno.mod.session.jwt.JWTSession
getStatelessDataMethods inherited from interface io.inverno.mod.session.Session
getCreationTime, getData, getData, getExpirationTime, getId, getLastAccessedTime, getMaxInactiveInterval, getOriginalId, isInvalidated, isNew, refreshId, save, setData
-
Field Details
-
tokenId
The JWT session token id (i.e. JTI) -
statelessSessionData
The stateless session data stored in the JWT session id. -
statelessDataSet
protected boolean statelessDataSetFlag indicating whether stateless data were set. -
statelessDataGet
protected boolean statelessDataGetFlag indicating whether stateless data were get. -
statelessSessionDataSaveStrategy
Stateless session data save strategy. -
expirationSet
protected boolean expirationSetFlag indicating whether expiration settings were changed.
-
-
Constructor Details
-
AbstractJWTSession
protected AbstractJWTSession(JWTSessionIdGenerator<A, B> sessionIdGenerator, JWTSessionStore<A, throws IllegalArgumentExceptionB> sessionStore, Long maxInactiveInterval, Long expirationTime, SessionDataSaveStrategy<B> statelessSessionDataSaveStrategy) Creates a new JWT session.
- Parameters:
sessionIdGenerator- a JWT session id generatorsessionStore- a JWT session storemaxInactiveInterval- the maximum inactive interval in millisecondsexpirationTime- the expiration time in millisecondsstatelessSessionDataSaveStrategy- the stateless session data save strategy- Throws:
IllegalArgumentException- if both maximum inactive interval and expiration time are null
-
AbstractJWTSession
protected AbstractJWTSession(JWTSessionIdGenerator<A, B> sessionIdGenerator, JWTSessionStore<A, throws IllegalArgumentExceptionB> sessionStore, String id, JWTClaimsSet claimsSet, B statelessSessionData, SessionDataSaveStrategy<B> statelessSessionDataSaveStrategy, long lastAccessedTime, boolean isNew) Creates an existing JWT session.
- Parameters:
sessionIdGenerator- a JWT session id generatorsessionStore- a JWT session storeid- the JWT session idclaimsSet- the JWT session claims setstatelessSessionData- the stateless session datastatelessSessionDataSaveStrategy- the stateless session data save strategylastAccessedTime- the last accessed time in millisecondsisNew- true to set the original id to null, false otherwise- Throws:
IllegalArgumentException- if both maximum inactive interval and expiration time are null
-
AbstractJWTSession
protected AbstractJWTSession(JWTSessionIdGenerator<A, B> sessionIdGenerator, JWTSessionStore<A, throws IllegalArgumentExceptionB> sessionStore, String id, String tokenId, long creationTime, long lastAccessedTime, Long maxInactiveInterval, Long expirationTime, B statelessSessionData, SessionDataSaveStrategy<B> statelessSessionDataSaveStrategy, boolean isNew) Creates an existing JWT session.
- Parameters:
sessionIdGenerator- a JWT session id generatorsessionStore- a JWT session storeid- the JWT session idtokenId- tje JWT token id (i.e. JTI)creationTime- the creation time in millisecondslastAccessedTime- the last accessed time in millisecondsmaxInactiveInterval- the maximum inactive interval in millisecondsexpirationTime- the expiration time in millisecondsstatelessSessionData- the stateless session data save strategystatelessSessionDataSaveStrategy- the stateless session data save strategyisNew- true to set the original id to null, false otherwise- Throws:
IllegalArgumentException- if both maximum inactive interval and expiration time are null
-
-
Method Details
-
getTokenId
Returns the JWT token id (i.e. JTI)
- Returns:
- the JWT token id
-
setLastAccessedTime
protected void setLastAccessedTime(long lastAccessedTime) Description copied from class:AbstractSessionSets the last accessed time.
- Overrides:
setLastAccessedTimein classAbstractSession<A,JWTSession<A, B>> - Parameters:
lastAccessedTime- the last accessed time
-
setStatelessData
Description copied from interface:JWTSessionSets the stateless session data.
- Specified by:
setStatelessDatain interfaceJWTSession<A,B> - Parameters:
statelessSessionData- the stateless session data
-
getStatelessData
Description copied from interface:JWTSessionReturns the stateless session data.
- Specified by:
getStatelessDatain interfaceJWTSession<A,B> - Returns:
- the stateless session data or null if exist in the session
-
setMaxInactiveInterval
public void setMaxInactiveInterval(long maxInactiveInterval) Description copied from interface:SessionSets the maximum inactive interval in milliseconds.
The maximum inactive interval replaces the expiration time if any was set.
- Specified by:
setMaxInactiveIntervalin interfaceSession<A>- Overrides:
setMaxInactiveIntervalin classAbstractSession<A,JWTSession<A, B>> - Parameters:
maxInactiveInterval- a maximum inactive interval in milliseconds
-
setExpirationTime
public void setExpirationTime(long expirationTime) Description copied from interface:SessionSets the session expiration time in milliseconds.
The expiration time replaces the maximum inactive interval if any was set.
- Specified by:
setExpirationTimein interfaceSession<A>- Overrides:
setExpirationTimein classAbstractSession<A,JWTSession<A, B>> - Parameters:
expirationTime- an expiration time in milliseconds
-
isExpired
public boolean isExpired()Description copied from interface:SessionDetermines whether the session has expired.
- Specified by:
isExpiredin interfaceSession<A>- Overrides:
isExpiredin classAbstractSession<A,JWTSession<A, B>> - Returns:
- true if the session has expired, false otherwise
-
refreshId
Description copied from interface:SessionRefreshes the session id.
- Specified by:
refreshIdin interfaceSession<A>- Overrides:
refreshIdin classAbstractSession<A,JWTSession<A, B>> - Parameters:
force- true to force refresh, false to only refresh the id if it is stale- Returns:
- a mono that emits the new session identifier or an empty mono if the identifier did not need to be refreshed
-
invalidate
Description copied from interface:SessionInvalidates the session.
- Specified by:
invalidatein interfaceSession<A>- Overrides:
invalidatein classAbstractSession<A,JWTSession<A, B>> - Returns:
- a mono which completes when the session is invalidated
-