TokenAuthenticator

@Singleton
class TokenAuthenticator @Inject constructor(val secureSharedPreference: SecureSharedPreference, val configService: ConfigService, val oAuthService: OAuthService, val dispatcherProvider: DispatcherProvider, val accountManager: AccountManager, val context: Context) : HttpAuthenticator

Constructors

Link copied to clipboard
@Inject
constructor(secureSharedPreference: SecureSharedPreference, configService: ConfigService, oAuthService: OAuthService, dispatcherProvider: DispatcherProvider, accountManager: AccountManager, context: Context)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
suspend fun fetchAccessToken(username: String, password: CharArray): Result<OAuthResponse>

This function fetches new access token from the authentication server and then creates a new account if none exists; otherwise it updates the existing account.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun getAuthenticationMethod(): HttpAuthenticationMethod
Link copied to clipboard
fun invalidateSession(onSessionInvalidated: () -> Unit)
Link copied to clipboard
fun isTokenActive(authToken: String?): Boolean

This function checks if token is null or empty or expired

Link copied to clipboard
Link copied to clipboard
fun refreshToken(account: Account, currentRefreshToken: String): String

This function uses the provided currentRefreshToken to get a new auth token or throws HttpException or UnknownHostException exceptions

Link copied to clipboard
Link copied to clipboard
fun validateSavedLoginCredentials(username: String, enteredPassword: CharArray): Boolean