Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions horreum-client/src/main/java/io/hyperfoil/tools/HorreumClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
Expand Down Expand Up @@ -160,13 +163,7 @@ public HorreumClient build() throws IllegalStateException {
}
}

ConfigService.KeycloakConfig keycloakConfig;
try {
URL url = new URL(this.horreumUrl.concat(KEYCLOAK_BOOTSTRAP_URL));
keycloakConfig = new ObjectMapper().readValue(url, ConfigService.KeycloakConfig.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
ConfigService.KeycloakConfig keycloakConfig = getKeycloakConfig();

ResteasyClientBuilderImpl clientBuilder = new ResteasyClientBuilderImpl();

Expand Down Expand Up @@ -213,6 +210,26 @@ public HorreumClient build() throws IllegalStateException {
target.proxyBuilder(TestService.class).build(),
target.proxyBuilder(UserService.class).build());
}

private ConfigService.KeycloakConfig getKeycloakConfig() {
ConfigService.KeycloakConfig keycloakConfig;
try {
HttpClient client = HttpClient.newBuilder()
.sslContext(this.sslContext)
.build();

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(this.horreumUrl.concat(KEYCLOAK_BOOTSTRAP_URL)))
.GET()
.build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
keycloakConfig = new ObjectMapper().readValue(response.body(), ConfigService.KeycloakConfig.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
return keycloakConfig;
}
}

}