DefaultTokenManager

Default implementation for TokenManager. By default this class uses SecuredSharedPreferences to persist the token locally on the device. However, it can be overridden by the builder For example, it can replaced with Android JetPack androidx.security.crypto.EncryptedSharedPreferences

This TokenManager supports AccessToken in-memory caching. To control the caching interval use builder. with the encryption/decryption, disk and Keystore IO, it may drains device CPU and Battery resources. If Application intensively with network operation, setting the this attribute may improve performance.

Constructors

Link copied to clipboard
constructor(@NonNull context: Context, oAuth2Client: OAuth2Client, sharedPreferences: SharedPreferences, cacheIntervalMillis: Long, threshold: Long)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
The OAuth2Client to auto refresh AccessToken
Link copied to clipboard
val ORG_FORGEROCK_V_1_KEYS: String = "org.forgerock.v1.KEYS"
Link copied to clipboard
val ORG_FORGEROCK_V_1_TOKENS: String = "org.forgerock.v1.TOKENS"
Link copied to clipboard
The SharedPreferences to store the tokens
Link copied to clipboard
private val TAG: String = "DefaultTokenManager"
Link copied to clipboard
private val threshold: Long
Threshold to refresh the AccessToken
Link copied to clipboard

Functions

Link copied to clipboard
private open fun cache(accessToken: AccessToken)
Cache the AccessToken in memory and setup a worker thread to clear it after.
Link copied to clipboard
open fun clear()
Remove the stored AccessToken
Link copied to clipboard
open fun exchangeToken(@NonNull token: SSOToken, @NonNull additionalParameters: Map<String, String>, listener: FRListener<AccessToken>)
open fun exchangeToken(code: String, pkce: PKCE, additionalParameters: Map<String, String>, listener: FRListener<AccessToken>)
Sends an authorization request to the authorization service.
Link copied to clipboard
open fun getAccessToken(verifier: AccessTokenVerifier, tokenListener: FRListener<AccessToken>)
Get the AccessToken asynchronously, If the stored AccessToken is expired, auto refresh the token
Link copied to clipboard
Retrieve AccessToken from cache or from storage.
Link copied to clipboard
open fun hasToken(): Boolean
Check if token exists in the storage.
Link copied to clipboard
open fun persist(@NonNull accessToken: AccessToken)
Persist the AccessToken to storage
Link copied to clipboard
open fun refresh(@NonNull accessToken: AccessToken, listener: FRListener<AccessToken>)
Refresh the AccessToken asynchronously, force token refresh, no matter the stored AccessToken is expired or not refresh the token and persist it.
Link copied to clipboard
open fun revoke(listener: FRListener<Void>)
OAuth2 Token Revocation