Class JwtSessionManager

java.lang.Object
com.predic8.membrane.core.interceptor.session.SessionManager
com.predic8.membrane.core.interceptor.session.JwtSessionManager

public class JwtSessionManager extends SessionManager
Take care - this session manager saves values in the session for internal use -> those are reserved keywords and cannot be used The keywords are "iss","exp","nbf","iat".
  • Constructor Details

    • JwtSessionManager

      public JwtSessionManager()
  • Method Details

    • init

      public void init(Router router) throws Exception
      Specified by:
      init in class SessionManager
      Throws:
      Exception
    • cookieValueToAttributes

      protected Map<String,Object> cookieValueToAttributes(String cookie)
      Description copied from class: SessionManager
      Transforms a cookie value into its attributes. The cookie should be assumed valid as @isValidCookieForThisSessionManager was called beforehand
      Specified by:
      cookieValueToAttributes in class SessionManager
    • getCookieValues

      protected Map<Session,String> getCookieValues(Session... sessions)
      Description copied from class: SessionManager
      Get the String identifier of the sessions to be used as cookie value.
      Specified by:
      getCookieValues in class SessionManager
    • getInvalidCookies

      public List<String> getInvalidCookies(Exchange exc, String validCookie)
      Description copied from class: SessionManager
      Get all cookies String representations from the request that are not valid anymore, e.g. because the cookie is a self contained value and has changed or expired (e.g. jwt). Should return cookie values in the form of key=value.
      Specified by:
      getInvalidCookies in class SessionManager
      validCookie - is the cookie value representation of the currently active session. Is key=value
    • isValidCookieForThisSessionManager

      protected boolean isValidCookieForThisSessionManager(String cookie)
      Description copied from class: SessionManager
      Gets called for every cookie value. Returns if the cookie value is valid and managed by this manager instance, e.g. jwt session manager checks if the cookie is a jwt, if it has the correct issuer, if it is not expired and if the signature is valid. Cookie is in format key=value
      Specified by:
      isValidCookieForThisSessionManager in class SessionManager
    • cookieRenewalNeeded

      protected boolean cookieRenewalNeeded(String originalCookie)
      Description copied from class: SessionManager
      Gets called when session was not modified. Should check, if session needs to be renewed (e.g. jwt expiration).
      Specified by:
      cookieRenewalNeeded in class SessionManager
      Parameters:
      originalCookie - the original cookie from which the session was created (can be different from current session)
      Returns:
    • getJwk

      public JwtSessionManager.Jwk getJwk()
    • setJwk

      public void setJwk(JwtSessionManager.Jwk jwk)
    • isVerbose

      public boolean isVerbose()
    • setVerbose

      public void setVerbose(boolean verbose)
    • getValidTime

      public Duration getValidTime()
    • setValidTime

      public void setValidTime(Duration validTime)
    • getRenewalTime

      public Duration getRenewalTime()
    • setRenewalTime

      public void setRenewalTime(Duration renewalTime)
    • getJwtCacheTime

      public Duration getJwtCacheTime()
    • setJwtCacheTime

      public void setJwtCacheTime(Duration jwtCacheTime)