public class AuthenticationService extends CharmService
The service will use the
AuthenticationViewFactory
to try and load an
implementation of the AuthenticationView
.
Authentication will only be possible when an implementation could be
found.
Whenever a user gets authenticated successfully, the information will be stored in the private storage of the device where the application is run. The next time the AuthenticationService is created, it will check if such information is available and automatically authenticate the user with the information that was stored.
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<User> |
authenticatedUser
The user that is currently authenticated, which can be
null
if no user is authenticated. |
gluonClient
Constructor and Description |
---|
AuthenticationService(GluonClient gluonClient)
The AuthenticationService provides a way to authenticate a user within the
application.
|
Modifier and Type | Method and Description |
---|---|
<O> void |
authenticate(java.util.function.Consumer<O> consumer,
O acceptable)
Start the authentication flow.
|
void |
authenticate(java.lang.Runnable runnable)
Start the authentication flow.
|
javafx.beans.property.ReadOnlyObjectProperty<User> |
authenticatedUserProperty()
The user that is currently authenticated, which can be
null
if no user is authenticated. |
User |
getAuthenticatedUser()
Gets the value of the property authenticatedUser.
|
boolean |
isAuthenticated()
Check whether the application is successfully authenticated with a user.
|
getGluonClient
public javafx.beans.property.ReadOnlyObjectProperty<User> authenticatedUserProperty
null
if no user is authenticated.getAuthenticatedUser()
public AuthenticationService(GluonClient gluonClient)
gluonClient
- The GluonClient instance used to connect with Gluon
Cloud.public boolean isAuthenticated()
true
when an authenticated user is available,
false
otherwise.public User getAuthenticatedUser()
null
if no user is
authenticated.public javafx.beans.property.ReadOnlyObjectProperty<User> authenticatedUserProperty()
null
if no user is authenticated.getAuthenticatedUser()
public void authenticate(java.lang.Runnable runnable)
runnable
- a runnable that will be called when authentication is
completed successfullypublic <O> void authenticate(java.util.function.Consumer<O> consumer, O acceptable)
acceptable
object. If a user was already authenticated
when making this call, the consumer will be called immediately.O
- The type of the acceptable object that will be accepted by the
consumer.consumer
- a consumer that will be called when authentication is
completed successfullyacceptable
- the object to pass to the consumer's accept method