change-password.asciidoc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. [[java-rest-high-security-change-password]]
  2. === Change Password API
  3. [[java-rest-high-security-change-password-execution]]
  4. ==== Execution
  5. A user's password can be changed using the `security().changePassword()`
  6. method:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/SecurityDocumentationIT.java[change-password-execute]
  10. --------------------------------------------------
  11. [[java-rest-high-change-password-response]]
  12. ==== Response
  13. The returned `Boolean` indicates the request status.
  14. [[java-rest-high-x-pack-security-change-password-async]]
  15. ==== Asynchronous Execution
  16. This request can be executed asynchronously:
  17. ["source","java",subs="attributes,callouts,macros"]
  18. --------------------------------------------------
  19. include-tagged::{doc-tests}/SecurityDocumentationIT.java[change-password-execute-async]
  20. --------------------------------------------------
  21. <1> The `ChangePassword` request to execute and the `ActionListener` to use when
  22. the execution completes.
  23. The asynchronous method does not block and returns immediately. Once the request
  24. has completed the `ActionListener` is called back using the `onResponse` method
  25. if the execution successfully completed or using the `onFailure` method if
  26. it failed.
  27. A typical listener for a `Boolean` looks like:
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests}/SecurityDocumentationIT.java[change-password-execute-listener]
  31. --------------------------------------------------
  32. <1> Called when the execution is successfully completed. The response is
  33. provided as an argument.
  34. <2> Called in case of failure. The raised exception is provided as an argument.