authenticate.asciidoc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 two fields. Firstly, the `user` field
  20. , accessed with `getUser`, contains all the information about this
  21. authenticated user. The other field, `enabled`, tells if this user is actually
  22. usable or has been temporalily deactivated.
  23. ["source","java",subs="attributes,callouts,macros"]
  24. --------------------------------------------------
  25. include-tagged::{doc-tests-file}[{api}-response]
  26. --------------------------------------------------
  27. <1> `getUser` retrieves the `User` instance containing the information,
  28. see {javadoc-client}/security/user/User.html.
  29. <2> `enabled` tells if this user is usable or is deactivated.
  30. [id="{upid}-{api}-async"]
  31. ==== Asynchronous Execution
  32. This request can also be executed asynchronously:
  33. ["source","java",subs="attributes,callouts,macros"]
  34. --------------------------------------------------
  35. include-tagged::{doc-tests-file}[{api}-execute-async]
  36. --------------------------------------------------
  37. <1> The `ActionListener` to use when the execution completes. This method does
  38. not require a request object.
  39. The asynchronous method does not block and returns immediately. Once the request
  40. has completed the `ActionListener` is called back using the `onResponse` method
  41. if the execution completed successfully or using the `onFailure` method if
  42. it failed.
  43. A typical listener for a +{response}+ looks like:
  44. ["source","java",subs="attributes,callouts,macros"]
  45. --------------------------------------------------
  46. include-tagged::{doc-tests-file}[{api}-execute-listener]
  47. --------------------------------------------------
  48. <1> Called when the execution completed successfully. The response is
  49. provided as an argument.
  50. <2> Called in case of a failure. The exception is provided as an argument.