Package com.cheetahdigital.corekit.sdk
Class AuthenticatorService
- java.lang.Object
-
- com.cheetahdigital.corekit.sdk.AuthenticatorService
-
public final class AuthenticatorService extends java.lang.ObjectService class for Authenticating users via API. Handles User Login state, Access Token validation, and persistence fromAuthentication.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAuthenticatorService.LoginListenerFor Custom Login Implementation
-
Constructor Summary
Constructors Constructor Description AuthenticatorService(SharedPrefsHelper settings, AuthenticatorService.LoginListener loginListener)Constructor for the AuthenticatorService
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAccessToken()java.lang.StringgetRefreshToken()booleanisLoggedIn()booleanisSendLocationAnonymously()booleanisThirdPartyAuth()Returns a boolean which indicates if the authentication was made by a third party authenticator.booleanisTokenExpired()voidlogin(Authentication authentication)Save Login state andAuthenticationpersistentlyvoidlogin(Authentication authentication, AuthenticatorService.LoginListener loginListener)Save Login state andAuthenticationpersistentlyvoidlogout()Remove Login state andAuthenticationpersistent datavoidsaveAuthenticationData(Authentication authentication)SavesAuthenticationdata persistently during Login and Refresh Token scenariosvoidsetResetPassword(boolean value)Sets the value of the reset password flagvoidsetSendLocationAnonymously(boolean isEnabled)Sets the value of send location anonymouslybooleanshouldResetPassword()
-
-
-
Constructor Detail
-
AuthenticatorService
public AuthenticatorService(SharedPrefsHelper settings, AuthenticatorService.LoginListener loginListener)
Constructor for the AuthenticatorService- Parameters:
settings- SharedPreferences of the settingsloginListener- Callback to be called after a successful login
-
-
Method Detail
-
login
public void login(Authentication authentication)
Save Login state andAuthenticationpersistently- Parameters:
authentication- the Authentication object to get Access Tokens from
-
login
public void login(Authentication authentication, AuthenticatorService.LoginListener loginListener)
Save Login state andAuthenticationpersistently- Parameters:
authentication- the Authentication object to get Access Tokens fromloginListener- callback for login actions
-
saveAuthenticationData
public void saveAuthenticationData(Authentication authentication)
SavesAuthenticationdata persistently during Login and Refresh Token scenarios- Parameters:
authentication- theAuthenticationdata to persist
-
logout
public void logout()
Remove Login state andAuthenticationpersistent data
-
isLoggedIn
public boolean isLoggedIn()
- Returns:
- true if user is logged in, else false
-
isTokenExpired
public boolean isTokenExpired()
- Returns:
- true if token is expired, else false
-
getAccessToken
public java.lang.String getAccessToken()
- Returns:
- current access token
-
isThirdPartyAuth
public boolean isThirdPartyAuth()
Returns a boolean which indicates if the authentication was made by a third party authenticator.- Returns:
trueif authentication is from third partyfalseif authentication is from loyalty
-
getRefreshToken
public java.lang.String getRefreshToken()
-
shouldResetPassword
public boolean shouldResetPassword()
- Returns:
- true if reset password screen is needed, else false
-
setResetPassword
public void setResetPassword(boolean value)
Sets the value of the reset password flag- Parameters:
value- true to enable force reset password, else false
-
isSendLocationAnonymously
public boolean isSendLocationAnonymously()
- Returns:
- true if sending location anonymously is allowed, else false
-
setSendLocationAnonymously
public void setSendLocationAnonymously(boolean isEnabled)
Sets the value of send location anonymously- Parameters:
isEnabled- true to enable send location anonymously, else false
-
-