Class AuthenticationViewModel
-
- All Implemented Interfaces:
public abstract class AuthenticationViewModel extends ViewModel
Companion ViewModel to AuthenticationActivity which facilitates authentication.
-
-
Field Summary
Fields Modifier and Type Field Description private final LiveEvent<String>onPkceLoginprivate final LiveEvent<Credentials>onCredentialsprivate final LiveEvent<String>onErrorprivate BooleanisReLogin
-
Constructor Summary
Constructors Constructor Description AuthenticationViewModel()
-
Method Summary
Modifier and Type Method Description final LiveEvent<String>getOnPkceLogin()final LiveEvent<Credentials>getOnCredentials()final LiveEvent<String>getOnError()final BooleanisReLogin()true if the session expired or was invalidated and user has to re-login. final UnitsetReLogin(Boolean isReLogin)true if the session expired or was invalidated and user has to re-login. final JobcheckAuthType(String endpoint, AuthConfig authConfig, Function1<AuthType, Unit> onResult)Check which AuthType is supported by the endpoint based on the provided authConfig. final UnitbasicLogin(String username, String password)Function takes username and password and returns result via onCredentials. final UnitpkceLogin(String endpoint, AuthConfig authConfig, String authState)Initiate PKCE login, against endpoint with provided authConfig. UnitonPkceAuthCancelled()Called if the user cancels the login by dismissing the webView. -
-
Method Detail
-
getOnPkceLogin
final LiveEvent<String> getOnPkceLogin()
-
getOnCredentials
final LiveEvent<Credentials> getOnCredentials()
-
getOnError
final LiveEvent<String> getOnError()
-
isReLogin
final Boolean isReLogin()
true if the session expired or was invalidated and user has to re-login.
-
setReLogin
final Unit setReLogin(Boolean isReLogin)
true if the session expired or was invalidated and user has to re-login.
-
checkAuthType
final Job checkAuthType(String endpoint, AuthConfig authConfig, Function1<AuthType, Unit> onResult)
Check which AuthType is supported by the endpoint based on the provided authConfig.
-
basicLogin
final Unit basicLogin(String username, String password)
Function takes username and password and returns result via onCredentials. Note: This function does not provide any credential validation.
-
pkceLogin
final Unit pkceLogin(String endpoint, AuthConfig authConfig, String authState)
Initiate PKCE login, against endpoint with provided authConfig. If an authState is provided the invocation is considered a re-login. On success credentials are provided via onCredentials. On error onError is invoked instead. If the flow is cancelled by the user onPkceAuthCancelled is called.
-
onPkceAuthCancelled
Unit onPkceAuthCancelled()
Called if the user cancels the login by dismissing the webView.
-
-
-
-