authenticate.asciidoc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --
  2. :api: authenticate
  3. :response: AuthenticateResponse
  4. --
  5. [id="{upid}-{api}"]
  6. === Authenticate API
  7. [id="{upid}-{api}-sync"]
  8. ==== Execution
  9. Authenticating and retrieving information about a user can be performed
  10. using the `security().authenticate()` method:
  11. ["source","java",subs="attributes,callouts,macros"]
  12. --------------------------------------------------
  13. include-tagged::{doc-tests-file}[{api}-execute]
  14. --------------------------------------------------
  15. This method does not require a request object. The client waits for the
  16. +{response}+ to be returned before continuing with code execution.
  17. [id="{upid}-{api}-response"]
  18. ==== Response
  19. The returned +{response}+ contains four fields. The `user` field
  20. , accessed with `getUser`, contains all the information about this
  21. authenticated user. The field `enabled`, tells if this user is actually
  22. usable or has been temporarily deactivated. The field `authentication_realm`,
  23. accessed with `getAuthenticationRealm` contains the name and type of the
  24. Realm that has authenticated the user and the field `lookup_realm`,
  25. accessed with `getLookupRealm` contains the name and type of the Realm where
  26. the user information were retrieved from.
  27. ["source","java",subs="attributes,callouts,macros"]
  28. --------------------------------------------------
  29. include-tagged::{doc-tests-file}[{api}-response]
  30. --------------------------------------------------
  31. <1> `getUser` retrieves the `User` instance containing the information,
  32. see {javadoc-client}/security/user/User.html.
  33. <2> `enabled` tells if this user is usable or is deactivated.
  34. <3> `getAuthenticationRealm().getName()` retrieves the name of the realm that authenticated the user.
  35. <4> `getAuthenticationRealm().getType()` retrieves the type of the realm that authenticated the user.
  36. <5> `getLookupRealm().getName()` retrieves the name of the realm from where the user information is looked up.
  37. <6> `getLookupRealm().getType()` retrieves the type of the realm from where the user information is looked up.
  38. [id="{upid}-{api}-async"]
  39. ==== Asynchronous Execution
  40. This request can also be executed asynchronously:
  41. ["source","java",subs="attributes,callouts,macros"]
  42. --------------------------------------------------
  43. include-tagged::{doc-tests-file}[{api}-execute-async]
  44. --------------------------------------------------
  45. <1> The `ActionListener` to use when the execution completes. This method does
  46. not require a request object.
  47. The asynchronous method does not block and returns immediately. Once the request
  48. has completed the `ActionListener` is called back using the `onResponse` method
  49. if the execution completed successfully or using the `onFailure` method if
  50. it failed.
  51. A typical listener for a +{response}+ looks like:
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests-file}[{api}-execute-listener]
  55. --------------------------------------------------
  56. <1> Called when the execution completed successfully. The response is
  57. provided as an argument.
  58. <2> Called in case of a failure. The exception is provided as an argument.