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 boolean
Flag indicating whether expiration settings were changed.protected boolean
Flag indicating whether stateless data were get.protected boolean
Flag indicating whether stateless data were set.protected B
The stateless session data stored in the JWT session id.protected SessionDataSaveStrategy
<B> Stateless session data save strategy.protected String
The JWT session token id (i.e.Fields inherited from class io.inverno.mod.session.AbstractSession
creationTime, expirationTime, id, invalidated, lastAccessedTime, maxInactiveInterval, originalId, sessionIdGenerator, sessionStore
Fields inherited from interface io.inverno.mod.session.Session
DEFAULT_MAX_INACTIVE_INTERVAL
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractJWTSession
(JWTSessionIdGenerator<A, B> sessionIdGenerator, JWTSessionStore<A, B> sessionStore, Long maxInactiveInterval, Long expirationTime, SessionDataSaveStrategy<B> statelessSessionDataSaveStrategy) Creates a new JWT session.protected
AbstractJWTSession
(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.protected
AbstractJWTSession
(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.boolean
Determines whether the session has expired.refreshId
(boolean force) Refreshes the session id.void
setExpirationTime
(long expirationTime) Sets the session expiration time in milliseconds.protected void
setLastAccessedTime
(long lastAccessedTime) Sets the last accessed time.void
setMaxInactiveInterval
(long maxInactiveInterval) Sets the maximum inactive interval in milliseconds.void
setStatelessData
(B statelessSessionData) Sets the stateless session data.Methods inherited from class io.inverno.mod.session.AbstractSession
getCreationTime, getExpirationTime, getId, getLastAccessedTime, getMaxInactiveInterval, getOriginalId, isInvalidated, save
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.session.jwt.JWTSession
getStatelessData
Methods 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:AbstractSession
Sets the last accessed time.
- Overrides:
setLastAccessedTime
in classAbstractSession<A,
JWTSession<A, B>> - Parameters:
lastAccessedTime
- the last accessed time
-
setStatelessData
Description copied from interface:JWTSession
Sets the stateless session data.
- Specified by:
setStatelessData
in interfaceJWTSession<A,
B> - Parameters:
statelessSessionData
- the stateless session data
-
getStatelessData
Description copied from interface:JWTSession
Returns the stateless session data.
- Specified by:
getStatelessData
in 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:Session
Sets the maximum inactive interval in milliseconds.
The maximum inactive interval replaces the expiration time if any was set.
- Specified by:
setMaxInactiveInterval
in interfaceSession<A>
- Overrides:
setMaxInactiveInterval
in classAbstractSession<A,
JWTSession<A, B>> - Parameters:
maxInactiveInterval
- a maximum inactive interval in milliseconds
-
setExpirationTime
public void setExpirationTime(long expirationTime) Description copied from interface:Session
Sets the session expiration time in milliseconds.
The expiration time replaces the maximum inactive interval if any was set.
- Specified by:
setExpirationTime
in interfaceSession<A>
- Overrides:
setExpirationTime
in classAbstractSession<A,
JWTSession<A, B>> - Parameters:
expirationTime
- an expiration time in milliseconds
-
isExpired
public boolean isExpired()Description copied from interface:Session
Determines whether the session has expired.
- Specified by:
isExpired
in interfaceSession<A>
- Overrides:
isExpired
in classAbstractSession<A,
JWTSession<A, B>> - Returns:
- true if the session has expired, false otherwise
-
refreshId
Description copied from interface:Session
Refreshes the session id.
- Specified by:
refreshId
in interfaceSession<A>
- Overrides:
refreshId
in 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:Session
Invalidates the session.
- Specified by:
invalidate
in interfaceSession<A>
- Overrides:
invalidate
in classAbstractSession<A,
JWTSession<A, B>> - Returns:
- a mono which completes when the session is invalidated
-