Class StatelessSessionManager
- java.lang.Object
-
- org.forgerock.openam.sso.providers.stateless.StatelessSessionManager
-
public class StatelessSessionManager extends Object
Responsible for creating StatelessSession and SessionInfo instances from JWT tokens. These operations are crucial for the Stateless Session implementation. Also provides logic methods to determine whether a SessionID/Token ID or HttpServletRequest contains a JWT token.- Since:
- 13.0.0
-
-
Constructor Summary
Constructors Constructor Description StatelessSessionManager(StatelessJWTCache cache, SessionServerConfig sessionServerConfig, SessionServiceConfig sessionServiceConfig)Guice initialised constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsJwt(SessionID sid)Determines whether the given session id contains a client-side JWT.booleancontainsJwt(jakarta.servlet.http.HttpServletRequest request)booleancontainsJwt(String tokenId)Determines whether the given token id contains a client-side JWT.StatelessSessiongenerate(InternalSession internalSession)StatelessSessiongenerate(SessionID sessionID)StatelessSessiongenerate(SessionInfo info)Generates a StatelessSession by converting the SessionInfo into a JWT token which can then be used to build up the StatelessSession.StatelessSessiongenerate(String tokenId)Generates a StatelessSession based on the String which is assumed to contain a Jwt token.static StringgetJWTFromSessionID(SessionID sessionID, boolean cleanupC66Encoding)Understands the detail around extracting the encoded JWT from the SessionID.SessionInfogetSessionInfo(SessionID sessionID)Will create the SessionInfo from the JWT contained within the SessionID.
-
-
-
Constructor Detail
-
StatelessSessionManager
@Inject public StatelessSessionManager(StatelessJWTCache cache, SessionServerConfig sessionServerConfig, SessionServiceConfig sessionServiceConfig)
Guice initialised constructor.- Parameters:
cache- Non null.sessionServerConfig- Non null.sessionServiceConfig- Non null.
-
-
Method Detail
-
containsJwt
public boolean containsJwt(jakarta.servlet.http.HttpServletRequest request) throws SessionException- Parameters:
request- Non null.- Returns:
- True if the HttpServletRequest contained the Jwt Token.
- Throws:
SessionException- If there was any expected error.
-
containsJwt
public boolean containsJwt(String tokenId)
Determines whether the given token id contains a client-side JWT.- Parameters:
tokenId- the token id to check.- Returns:
trueif the token contains a client-side session JWT.
-
containsJwt
public boolean containsJwt(SessionID sid)
Determines whether the given session id contains a client-side JWT.- Parameters:
sid- the session id to check.- Returns:
trueif the session id contains a client-side session JWT.
-
generate
public StatelessSession generate(String tokenId) throws SessionException
Generates a StatelessSession based on the String which is assumed to contain a Jwt token. This will be parsed and used to generate the StatelessSession. Side Effect: calls #getSessionInfo which may cache the JWT/SessionInfo.- Parameters:
tokenId- Non null TokenID to use for parsing.- Returns:
- A non null StatelessSessionID.
- Throws:
SessionException- if the stateless session cannot be generated
-
getSessionInfo
public SessionInfo getSessionInfo(SessionID sessionID) throws SessionException
Will create the SessionInfo from the JWT contained within the SessionID. Side Effect: Will cache the generated JWT and SessionInfo combination.- Parameters:
sessionID- Maybe null SessionID.- Returns:
- SessionInfo Non null SessionInfo which corresponds to the SessionID.
- Throws:
SessionException- If there was any problem with getting the SessionInfo from the JWT within with SessionID
-
generate
public StatelessSession generate(SessionInfo info) throws SessionException
Generates a StatelessSession by converting the SessionInfo into a JWT token which can then be used to build up the StatelessSession. Note: Will cache this generated JWT as a side effect.- Parameters:
info- The SessionInfo to generate the StatelessSession from. Non null.- Returns:
- A non null StatelessSession.
- Throws:
SessionException- If there was an unexpected error.
-
generate
public StatelessSession generate(InternalSession internalSession) throws SessionException
- Parameters:
internalSession- Non null Internal Session to convert to a StatelessSession.- Returns:
- Non null StatelessSession.
- Throws:
SessionException- If anything unexpected failed.
-
generate
public StatelessSession generate(SessionID sessionID) throws SessionException
- Parameters:
sessionID- Non null SessionID to convert to a StatelessSession.- Returns:
- Non null StatelessSession.
- Throws:
SessionException- If anything unexpected failed.
-
getJWTFromSessionID
public static String getJWTFromSessionID(SessionID sessionID, boolean cleanupC66Encoding)
Understands the detail around extracting the encoded JWT from the SessionID.- Parameters:
sessionID- Possibly null SessionID.cleanupC66Encoding- Whether to undo damage done to the JWT by c66 decoding if detected.- Returns:
- Null if there was no JWT present, otherwise a valid JWT.
-
-