Skip to content

Commit

Permalink
fix the javadoc plugin
Browse files Browse the repository at this point in the history
remove extra http client and use the built in one from java
  • Loading branch information
mbuckton committed Dec 31, 2024
1 parent 1709bfb commit 1d2275a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
9 changes: 1 addition & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
</execution>
</executions>
<configuration>
<reportOutputDirectory>${project.build.directory}/site/docs</reportOutputDirectory>
<outputDirectory>${project.build.directory}/site/docs</outputDirectory>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
<show>public</show>
<encoding>UTF-8</encoding>
Expand Down Expand Up @@ -1075,13 +1075,6 @@
<version>0.22.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java -->
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>

<!-- Add annotations for not null -->
<dependency>
<groupId>org.jetbrains</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;
import lombok.Getter;

Expand Down Expand Up @@ -54,38 +54,47 @@ public String generate() throws IOException {
try {
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(body);
HttpResponse<JsonNode> response = Unirest.post("https://" + domain + "/oauth/token")
.header("content-type", "application/json")
.body(json)
.asJson();
return response.getBody().getObject().getString("access_token");
} catch (UnirestException e) {
throw new IOException(e);

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://" + domain + "/oauth/token"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

if (response.statusCode() != 200) {
throw new IOException("Failed to fetch token: " + response.body());
}

ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readTree(response.body()).get("access_token").asText();

} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Request interrupted", e);
}
}

private Auth0TokenGenerator(Map<String, Object> properties) {
domain = ((String)properties.get("domain")).trim();
private Auth0TokenGenerator(Map<String, Object> properties) {
domain = ((String) properties.get("domain")).trim();
body = new Auth0TokenBody(properties);
}

@Getter
private static final class Auth0TokenBody {

@Getter
private final String clientId;
@Getter
private final String clientSecret;
@Getter
private final String audience;
@Getter
private final String grantType;

public Auth0TokenBody(Map<String, Object> properties) {
clientId = ((String)properties.get("client_id")).trim();
clientSecret = ((String)properties.get("client_secret")).trim();
audience = "https://" + ((String)properties.get("domain")).trim() + "/api/v2/";
grantType = ((String)properties.get("grant_type")).trim();
public Auth0TokenBody(Map<String, Object> properties) {
clientId = ((String) properties.get("client_id")).trim();
clientSecret = ((String) properties.get("client_secret")).trim();
audience = "https://" + ((String) properties.get("domain")).trim() + "/api/v2/";
grantType = ((String) properties.get("grant_type")).trim();
}
}

}

0 comments on commit 1d2275a

Please sign in to comment.