- final int portFromShiro = moonServerURL != null ? moonServerURL.getPort() : -1;
- if (portFromShiro <= 0) {
- LOG.debug("moon server was not specified appropriately, cannot authetnicate");
- return null;
- }
-
- final var port = Integer.toString(portFromShiro);
- final var url = String.format("http://%s:%s/moon/auth/tokens", server, port);
- LOG.debug("Moon server is at: {}:{} and will be accessed through {}", server, port, url);
-
- final String output = ClientBuilder.newClient()
- .target(url)
- .request(MediaType.APPLICATION_JSON)
- .post(
- // FIXME: String literal when we have JDK17
- Entity.entity("{\"username\": \"" + username + "\",\n"
- + " \"password\": \"" + password + "\",\n"
- + " \"project\": \"" + domain + "\"\n}",
- MediaType.APPLICATION_JSON),
- String.class);
-
- final var element = JsonParser.parseString(output);
+ final var element = JsonParser.parseString(moon.request(MediaType.APPLICATION_JSON).post(
+ // FIXME: String literal when we have JDK17
+ Entity.entity("{\"username\": \"" + username + "\",\n"
+ + " \"password\": \"" + password + "\",\n"
+ + " \"project\": \"" + domain + "\"\n}",
+ MediaType.APPLICATION_JSON),
+ String.class));