Module io.inverno.mod.session
Class JWTSSessionIdGenerator<A,B>
java.lang.Object
io.inverno.mod.session.internal.jwt.JWTSSessionIdGenerator<A,B>
- Type Parameters:
A
- the session data typeB
- the stateless session data type
- All Implemented Interfaces:
JWTSessionIdGenerator<A,
,B> SessionIdGenerator<A,
JWTSession<A, B>>
A JWT session id generator that generates JWT as JWS which guarantees the integrity of the stateless session data within the session id.
When specified, the issuer is validated when reading JWT session identifier.
- Since:
- 1.13
- Author:
- Jeremy Kuhn
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String
The JWT issuer.protected final JWTService
The JWT service.Fields inherited from interface io.inverno.mod.session.jwt.JWTSessionIdGenerator
CLAIM_MAX_INACTIVE_INTERVAL, CLAIM_SESSION_DATA
-
Constructor Summary
ConstructorsConstructorDescriptionJWTSSessionIdGenerator
(JWTService jwtService, Consumer<JWSHeaderConfigurator<?>> headerConfigurer) Creates a JWS JWT session id generator.JWTSSessionIdGenerator
(JWTService jwtService, Consumer<JWSHeaderConfigurator<?>> headerConfigurer, String issuer) Creates a JWS JWT session id generator. -
Method Summary
Modifier and TypeMethodDescriptionprotected Mono
<JWS<JWTClaimsSet>> doGenerateJWT
(JWTClaimsSet.Builder<JWTClaimsSet, ?> jwtClaimsSetBuilder) Generates the JWT from the prefilled JWT claims set builder.protected Mono
<JWS<JWTClaimsSet>> Reads the JWT session id and returns the corresponding JWT object.generateJWT
(JWTSession<A, B> session) Generates a JWT session identifier for the specified JWT session.Returns the JWT issuer.Validates and decrypts the specified JWT session identifier.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.JWTSessionIdGenerator
generate
-
Field Details
-
jwtService
The JWT service. -
issuer
The JWT issuer.
-
-
Constructor Details
-
JWTSSessionIdGenerator
public JWTSSessionIdGenerator(JWTService jwtService, Consumer<JWSHeaderConfigurator<?>> headerConfigurer) Creates a JWS JWT session id generator.
- Parameters:
jwtService
- the JWT serviceheaderConfigurer
- a JWS header configurer
-
JWTSSessionIdGenerator
public JWTSSessionIdGenerator(JWTService jwtService, Consumer<JWSHeaderConfigurator<?>> headerConfigurer, String issuer) Creates a JWS JWT session id generator.
- Parameters:
jwtService
- the JWT serviceheaderConfigurer
- a JWS header configurerissuer
- the issuer
-
-
Method Details
-
doGenerateJWT
protected Mono<JWS<JWTClaimsSet>> doGenerateJWT(JWTClaimsSet.Builder<JWTClaimsSet, ?> jwtClaimsSetBuilder) Generates the JWT from the prefilled JWT claims set builder.
- Parameters:
jwtClaimsSetBuilder
- a prefilled JWT claims set builder- Returns:
- a mono generating the JWT
-
doReadJWT
Reads the JWT session id and returns the corresponding JWT object.
- Parameters:
sessionId
- a JWT session id- Returns:
- a mono emitting the JWT corresponding object
-
getIssuer
Returns the JWT issuer.
- Returns:
- the issuer
-
generateJWT
Description copied from interface:JWTSessionIdGenerator
Generates a JWT session identifier for the specified JWT session.
Implementors should ensure that JWT are generated with unique JWT token identifiers (i.e. JTI) to prevent against replay attack.
- Specified by:
generateJWT
in interfaceJWTSessionIdGenerator<A,
B> - Parameters:
session
- a JWT session- Returns:
- a mono generating a JWT
-
readJWT
Description copied from interface:JWTSessionIdGenerator
Validates and decrypts the specified JWT session identifier.
- Specified by:
readJWT
in interfaceJWTSessionIdGenerator<A,
B> - Parameters:
sessionId
- a JWT session identifier- Returns:
- a mono reading a JWT session identifier
-