Interface UserManager


  • public interface UserManager
    The user manager takes care of user authentication and provides access to the currently logged-in users.

    The following code sample illustrates how to use this class to retrieve the list of logged-in users.

     UserManager userManager = tapkeyServiceFactory.getUserManager();
     List<String> users = userManager.getUsers();
    
     // Now, users contains a list of IDs of all logged-in users. Usually, users.size() will be 1,
     // however, it is possible to log in multiple users at the same time.
     

    The exemplary code below demonstrates how to log in a user:

     UserManager userManager = tapkeyServiceFactory.getUserManager();
     userManager.logInAsync(tapkeyAccessToken, ct);
     
    Implementors have to make sure that a token refresh handler was set via the TapkeyServiceFactory builder prior to logging in any users.

    See Also:
    https://developers.tapkey.io/mobile/authentication/
    • Method Detail

      • getUsers

        List<String> getUsers()
        Returns IDs of the users who are currently logged in.
        Returns:
        the users' IDs.
      • logInAsync

        Promise<String> logInAsync​(String accessToken,
                                   CancellationToken cancellationToken)
        Logs in a user with a Tapkey access token.
        Parameters:
        accessToken - the Tapkey access token to be used for logging in the user.
        cancellationToken - can be used to get notified on cancel events.
        Returns:
        a Promise that resolves to the ID of the user logged in.
      • logOutAsync

        Promise<Void> logOutAsync​(String userId,
                                  CancellationToken cancellationToken)
        Logs out a user with a Tapkey access token.
        Parameters:
        userId - the ID of the user to be logged out.
        cancellationToken - can be used to get notified on cancel events.
        Returns:
        a Promise that resolves after the logout has completed.
      • updateAccessToken

        void updateAccessToken​(String userId,
                               String accessToken)
        Replaces the access token for the specified user.
        Parameters:
        userId - the ID of the user whose access token is to be replaced.
        accessToken - the new access token
      • getHttpAuthenticationProvider

        net.tpky.mc.manager.HttpAuthenticationProvider getHttpAuthenticationProvider()
        Reserved for internal use.