Class 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 from Authentication.
    • Constructor Detail

      • AuthenticatorService

        public AuthenticatorService​(SharedPrefsHelper settings,
                                    AuthenticatorService.LoginListener loginListener)
        Constructor for the AuthenticatorService
        Parameters:
        settings - SharedPreferences of the settings
        loginListener - Callback to be called after a successful login
    • Method Detail

      • login

        public void login​(Authentication authentication)
        Save Login state and Authentication persistently
        Parameters:
        authentication - the Authentication object to get Access Tokens from
      • saveAuthenticationData

        public void saveAuthenticationData​(Authentication authentication)
        Saves Authentication data persistently during Login and Refresh Token scenarios
        Parameters:
        authentication - the Authentication data to persist
      • logout

        public void logout()
        Remove Login state and Authentication 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 party false 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