1

I'm creating a small web application to make the lives of some ElasticSearch admins easier in ES 5.x. I'm familiar with Java but have never used cURL before.

The setup is a Thymeleaf website using Java and Maven.

In 5.x the roles can only be fetched from the console in kibana, which is executed with the curl statement curl -XGET "(url)/_xpack/security/role, but with some username params.

I've done some research but I'm not sure if any of these solutions fit my criteria. The closest answer I found was https://stackoverflow.com/a/2587534/7137657 but the binding is in version 0.2 and with no real documentation or explanation.

The other solutions suggest using java.net.URL and java.net.URLConnection classes, but I don't see how to use those with a password and username, let alone use the kibana console once connected and return the JSON.

This is only be beginning of the process. They already have access to kibana. I want to use the JSON to let them edit the security groups in YAML after (will also be done in the web application).

Any insight is appreciated!

Community
  • 1
  • 1
Brandon
  • 17
  • 7

1 Answers1

0

Have a look at answer to this question on how to use authentication with URL/URLConnection: https://stackoverflow.com/a/496707/780998

Complete example HERE

Community
  • 1
  • 1
Deven Phillips
  • 1,129
  • 14
  • 39
  • that looks good for authentication! I'm still unsure how to execute the console command and return the JSON through. – Brandon Jan 31 '17 at 20:43
  • cURL is ALSO a library that you can use from Java, aside from a command-line tool. The response above is NOT about cURL though, it is about using URL/URLConnection as detailed in the answer you linked in your original question. If you combine the answer I linked with the answer in your question, you should have a viable solution. If you're looking for a cut-n-paste answer, try this: http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html – Deven Phillips Jan 31 '17 at 20:46