Package com.cheetahdigital.corekit.sdk
Class AuthenticatorService
- java.lang.Object
-
- com.cheetahdigital.corekit.sdk.AuthenticatorService
-
public final class AuthenticatorService extends java.lang.Object
Service 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 interface
AuthenticatorService.LoginListener
For 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.String
getAccessToken()
java.lang.String
getRefreshToken()
boolean
isLoggedIn()
boolean
isSendLocationAnonymously()
boolean
isThirdPartyAuth()
Returns a boolean which indicates if the authentication was made by a third party authenticator.boolean
isTokenExpired()
void
login(Authentication authentication)
Save Login state andAuthentication
persistentlyvoid
login(Authentication authentication, AuthenticatorService.LoginListener loginListener)
Save Login state andAuthentication
persistentlyvoid
logout()
Remove Login state andAuthentication
persistent datavoid
saveAuthenticationData(Authentication authentication)
SavesAuthentication
data persistently during Login and Refresh Token scenariosvoid
setResetPassword(boolean value)
Sets the value of the reset password flagvoid
setSendLocationAnonymously(boolean isEnabled)
Sets the value of send location anonymouslyboolean
shouldResetPassword()
-
-
-
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 andAuthentication
persistently- Parameters:
authentication
- the Authentication object to get Access Tokens from
-
login
public void login(Authentication authentication, AuthenticatorService.LoginListener loginListener)
Save Login state andAuthentication
persistently- Parameters:
authentication
- the Authentication object to get Access Tokens fromloginListener
- callback for login actions
-
saveAuthenticationData
public void saveAuthenticationData(Authentication authentication)
SavesAuthentication
data persistently during Login and Refresh Token scenarios- Parameters:
authentication
- theAuthentication
data to persist
-
logout
public void logout()
Remove Login state andAuthentication
persistent 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:
true
if authentication is from third partyfalse
if 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
-
-