WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
Authenticate API
editAuthenticate API
editExecution
editAuthenticating and retrieving information about a user can be performed
using the security().authenticate() method:
AuthenticateResponse response = client.security().authenticate(RequestOptions.DEFAULT);
This method does not require a request object. The client waits for the
AuthenticateResponse to be returned before continuing with code execution.
Response
editThe returned AuthenticateResponse contains four fields. The user field
, accessed with getUser, contains all the information about this
authenticated user. The field enabled, tells if this user is actually
usable or has been temporarily deactivated. The field authentication_realm,
accessed with getAuthenticationRealm contains the name and type of the
Realm that has authenticated the user and the field lookup_realm,
accessed with getLookupRealm contains the name and type of the Realm where
the user information were retrieved from.
User user = response.getUser(); boolean enabled = response.enabled(); final String authenticationRealmName = response.getAuthenticationRealm().getName(); final String authenticationRealmType = response.getAuthenticationRealm().getType(); final String lookupRealmName = response.getLookupRealm().getName(); final String lookupRealmType = response.getLookupRealm().getType(); final String authenticationType = response.getAuthenticationType(); final Map<String, Object> tokenInfo = response.getToken();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Asynchronous Execution
editThis request can also be executed asynchronously:
|
The |
The asynchronous method does not block and returns immediately. Once the request
has completed the ActionListener is called back using the onResponse method
if the execution completed successfully or using the onFailure method if
it failed.
A typical listener for a AuthenticateResponse looks like: