public class UserClient
extends java.lang.Object
The UserClient handles user authentication for a Gluon Mobile application. It loads the list of login methods
that are available for the configured Gluon CloudLink application. When authentication is started through the
authenticate
method, it will load an available implementation of
AuthenticationView
that provides a way to let the user login using one of the login methods. The view is loaded
by calling AuthenticationView.authenticate(Authenticator)
and passing a proper implementation of the
authenticator
. During the authentication process, proper methods on the authenticator
should be called by the AuthenticationView
.
Note: authenticated user information will be stored in the private storage location for the application
on the device. This information lets the user sign in automatically, the next time the application is opened. As a
result, the UserClient depends on the StorageService
, so make sure that the
storage plugin has been enabled in your Gluon Mobile application build configuration:
jfxmobile { downConfig { plugins = 'storage', ... } }
Authenticator
,
AuthenticationView
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<User> |
authenticatedUser
A property that holds the currently authenticated user.
|
Constructor and Description |
---|
UserClient()
Create an instance of a UserClient.
|
Modifier and Type | Method and Description |
---|---|
void |
authenticate(java.util.function.Consumer<User> successConsumer)
Start the authentication flow.
|
void |
authenticate(java.util.function.Consumer<User> successConsumer,
java.util.function.Consumer<java.lang.String> failureConsumer)
Start the authentication flow.
|
javafx.beans.property.ReadOnlyObjectProperty<User> |
authenticatedUserProperty()
A property that holds the currently authenticated user.
|
User |
getAuthenticatedUser()
Gets the value of the property authenticatedUser.
|
boolean |
isAuthenticated()
Check whether the application is successfully authenticated with a user.
|
void |
signOut()
Sign out the currently logged in user.
|
public javafx.beans.property.ReadOnlyObjectProperty<User> authenticatedUserProperty
null
value if no
user is currently authenticated.getAuthenticatedUser()
public UserClient()
AuthenticationView
. If a valid implementation is found, it creates an instance of
AuthenticationProvider
and sets it on the view. When no valid implementation could be constructed,
authentication will not be enabled for this UserClient instance.public boolean isAuthenticated()
true
when an authenticated user is available, false
otherwise.public User getAuthenticatedUser()
null
when no user is
currently authenticated.null
if no user is authenticated.public javafx.beans.property.ReadOnlyObjectProperty<User> authenticatedUserProperty()
null
value if no
user is currently authenticated.getAuthenticatedUser()
public void authenticate(java.util.function.Consumer<User> successConsumer)
successConsumer
- a consumer that will be called when authentication has completed successfullypublic void authenticate(java.util.function.Consumer<User> successConsumer, java.util.function.Consumer<java.lang.String> failureConsumer)
Both the successConsumer
and the failureConsumer
can be null
. If a
consumer is null
no notification will be available on the caller of this method.
successConsumer
- a consumer that will be called when authentication has completed successfullyfailureConsumer
- a consumer that will be called when authentication has failed or was aborted by the userpublic void signOut()