Package io.jmix.superset.impl
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 Summary
Modifier and TypeFieldDescriptionprotected final com.fasterxml.jackson.databind.ObjectMapper
-
Constructor Summary
ConstructorDescriptionSupersetTokenManagerImpl
(SupersetClient supersetClient, SupersetProperties supersetProperties) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.fasterxml.jackson.databind.ObjectMapper
The access token is available after Spring context refresh when a "login" request is sent to Superset.Depends onSupersetProperties.isCsrfProtectionEnabled()
application property.protected Long
The refresh token is available after Spring context refresh when a "login" request is sent to Superset.protected boolean
protected boolean
protected Long
parseExpiresIn
(String accessToken) protected void
protected void
protected void
void
Refreshes an access token.void
Depends onSupersetProperties.isCsrfProtectionEnabled()
application property.protected void
updateAccessToken
(String newToken)
-
Field Details
-
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
SupersetTokenManagerImpl
public SupersetTokenManagerImpl(SupersetClient supersetClient, SupersetProperties supersetProperties)
-
-
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 withSupersetProperties.getAccessTokenRefreshSchedule()
delay.- Specified by:
refreshAccessToken
in interfaceSupersetTokenManager
-
refreshCsrfToken
public void refreshCsrfToken()Description copied from interface:SupersetTokenManager
Depends onSupersetProperties.isCsrfProtectionEnabled()
application property. If it's enabled a request will be sent to get a new CSRF token. Then theSupersetTokenManager.getCsrfToken()
method will return new CSRF token.This method is managed by
SupersetTokenScheduleConfigurer
. The Spring scheduler is configured to invoke this method withSupersetProperties.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 interfaceSupersetTokenManager
-
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 interfaceSupersetTokenManager
- Returns:
- access token or
null
if it's not initialized
-
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 interfaceSupersetTokenManager
- Returns:
- refresh token or
null
if it's not initialized
-
getCsrfToken
Description copied from interface:SupersetTokenManager
Depends onSupersetProperties.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 returnnull
.- Specified by:
getCsrfToken
in interfaceSupersetTokenManager
- Returns:
- a CSRF token or
null
if CSRF protection is disabled
-
performLogin
protected void performLogin() -
performRefreshingAccessToken
protected void performRefreshingAccessToken() -
performCsrfTokenRequest
protected void performCsrfTokenRequest() -
updateAccessToken
-
buildObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper buildObjectMapper() -
parseExpiresIn
- 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
-
isCsrfTokenAboutToExpire
protected boolean isCsrfTokenAboutToExpire()
-