Class SupersetTokenManagerImpl

java.lang.Object
io.jmix.superset.impl.SupersetTokenManagerImpl
All Implemented Interfaces:
SupersetTokenManager

@Component("sprset_SupersetTokenManagerImpl") public class SupersetTokenManagerImpl extends Object implements SupersetTokenManager
  • Field Details

    • objectMapper

      protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
  • Constructor Details

  • Method Details

    • refreshAccessToken

      public void refreshAccessToken()
      Description copied from interface: SupersetTokenManager
      Refreshes an access token. It sends a "login" request for the first time and then sends "refresh" requests. A refresh request is sent only when the difference between expiration time and current time is less than or equal to one minute.

      This method is managed by SupersetTokenScheduleConfigurer. The Spring scheduler is configured to invoke this method with SupersetProperties.getAccessTokenRefreshSchedule() delay.

      Specified by:
      refreshAccessToken in interface SupersetTokenManager
    • refreshCsrfToken

      public void refreshCsrfToken()
      Description copied from interface: SupersetTokenManager
      Depends on SupersetProperties.isCsrfProtectionEnabled() application property. If it's enabled a request will be sent to get a new CSRF token. Then the SupersetTokenManager.getCsrfToken() method will return new CSRF token.

      This method is managed by SupersetTokenScheduleConfigurer. The Spring scheduler is configured to invoke this method with SupersetProperties.getCsrfTokenRefreshSchedule() delay.

      Note, that CSRF token does not encode the expiration time so the schedule delay duration is configured almost equal to a default value of CSRF token expiration in Superset (WTF_CSRF_TIME_LIMIT property). If the value of expiration time is changed in Superset, the SupersetProperties.getCsrfTokenRefreshSchedule() should be changed too.

      Specified by:
      refreshCsrfToken in interface SupersetTokenManager
    • getAccessToken

      @Nullable public String getAccessToken()
      Description copied from interface: SupersetTokenManager
      The access token is available after Spring context refresh when a "login" request is sent to Superset.
      Specified by:
      getAccessToken in interface SupersetTokenManager
      Returns:
      access token or null if it's not initialized
    • getRefreshToken

      @Nullable public String getRefreshToken()
      Description copied from interface: SupersetTokenManager
      The refresh token is available after Spring context refresh when a "login" request is sent to Superset.
      Specified by:
      getRefreshToken in interface SupersetTokenManager
      Returns:
      refresh token or null if it's not initialized
    • getCsrfToken

      @Nullable public String getCsrfToken()
      Description copied from interface: SupersetTokenManager
      Depends on SupersetProperties.isCsrfProtectionEnabled() application property. If it's enabled a CSRF token will be fetched on Spring context refresh. Otherwise, no CSRF token will be fetched and method will return null.
      Specified by:
      getCsrfToken in interface SupersetTokenManager
      Returns:
      a CSRF token or null if CSRF protection is disabled
    • performLogin

      protected void performLogin()
    • performRefreshingAccessToken

      protected void performRefreshingAccessToken()
    • performCsrfTokenRequest

      protected void performCsrfTokenRequest()
    • updateAccessToken

      protected void updateAccessToken(String newToken)
    • buildObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper buildObjectMapper()
    • parseExpiresIn

      @Nullable protected Long parseExpiresIn(String accessToken)
      Parameters:
      accessToken - access token to parse
      Returns:
      expiration time in milliseconds or null if an error occurs while parsing token
    • isAccessTokenAboutToExpire

      protected boolean isAccessTokenAboutToExpire()
    • getFallbackExpirationTime

      protected Long getFallbackExpirationTime()
    • isCsrfTokenAboutToExpire

      protected boolean isCsrfTokenAboutToExpire()