Skip to content

Commit

Permalink
refactor tir list implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
javieralvarezin2 committed Oct 16, 2024
1 parent 616a75b commit 6b77fc3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 44 deletions.
27 changes: 0 additions & 27 deletions src/main/java/es/in2/vcverifier/model/enums/Profile.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import es.in2.vcverifier.config.ApiConfig;
import es.in2.vcverifier.config.properties.ClientRepositoryProperties;
import es.in2.vcverifier.exception.InvalidSpringProfile;
import es.in2.vcverifier.exception.RemoteFileFetchException;
import es.in2.vcverifier.model.enums.Profile;
import es.in2.vcverifier.service.AllowedClientsService;
import es.in2.vcverifier.util.Constants;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -22,7 +19,6 @@
@RequiredArgsConstructor
public class AllowedClientsServiceImpl implements AllowedClientsService {
private final ClientRepositoryProperties clientRepositoryProperties;
private final ApiConfig apiConfig;

private static final HttpClient HTTP_CLIENT = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.ALWAYS) // Habilitar seguimiento de redirecciones
Expand All @@ -31,23 +27,13 @@ public class AllowedClientsServiceImpl implements AllowedClientsService {
@Override
public String fetchAllowedClient() {
try {
return fetchRemoteFile(clientRepositoryProperties.uri() + getExternalYamlProfile() + Constants.YAML_FILE_SUFFIX);
return fetchRemoteFile(clientRepositoryProperties.uri());
} catch (IOException | InterruptedException e) {
Thread.currentThread().interrupt();
throw new RemoteFileFetchException("Error reading clients list from GitHub.", e);
}
}

private String getExternalYamlProfile() {
String profile = apiConfig.getCurrentEnvironment();

if (profile == null || profile.isBlank()) {
throw new InvalidSpringProfile("Environment variable SPRING_PROFILES_ACTIVE is not set");
}
Profile resolvedProfile = Profile.fromString(profile);
return resolvedProfile.getAbbreviation();
}

private String fetchRemoteFile(String fileUrl) throws IOException, InterruptedException {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(fileUrl))
Expand Down
1 change: 0 additions & 1 deletion src/main/java/es/in2/vcverifier/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ private Constants() {
public static final String AUTHORIZATION_RESPONSE_ENDPOINT= "/oid4vp/auth-response";
public static final long MSB = 0x80L;
public static final long MSBALL = 0xFFFFFF80L;
public static final String YAML_FILE_SUFFIX = ".yaml";

}
2 changes: 1 addition & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ security:
cronUnit: "MINUTES"

clientsRepository:
uri: "https://raw.githubusercontent.com/DOME-Marketplace/dome-services-directory/refs/heads/main/trusted-service-list-"
uri: "https://raw.githubusercontent.com/in2workspace/in2-dome-gitops/refs/heads/main/trust-framework/trusted_services_list.yaml"

trustedIssuerList:
uri: "http://localhost:8080/v4/issuers/"
Expand Down

0 comments on commit 6b77fc3

Please sign in to comment.