Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/main/java/com/uid2/core/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Config extends com.uid2.shared.Const.Config {
public static final String KmsAccessKeyIdProp = "kms_aws_access_key_id";
public static final String KmsSecretAccessKeyProp = "kms_aws_secret_access_key";
public static final String KmsEndpointProp = "kms_aws_endpoint";
public static final String OperatorConfigPathProp = "operator_config_path";
}

public static final String OPERATOR_CONFIG_PATH = "conf/operator-config.json";
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/uid2/core/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
import java.lang.management.ManagementFactory;
import java.util.*;

import static com.uid2.core.Const.Config.OperatorConfigPathProp;
import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;

public class Main {

private static final int vertxServiceInstances = 1;
Expand Down Expand Up @@ -162,8 +165,12 @@ public static void main(String[] args) {
);

JwtService jwtService = new JwtService(config);

FileSystem fileSystem = vertx.fileSystem();
coreVerticle = new CoreVerticle(cloudStorage, operatorKeyProvider, attestationService, attestationTokenService, enclaveIdProvider, operatorJWTTokenProvider, jwtService, cloudEncryptionKeyProvider, fileSystem);

String operatorConfigPath = config.getString(OperatorConfigPathProp, OPERATOR_CONFIG_PATH);

coreVerticle = new CoreVerticle(cloudStorage, operatorKeyProvider, attestationService, attestationTokenService, enclaveIdProvider, operatorJWTTokenProvider, jwtService, cloudEncryptionKeyProvider, fileSystem, operatorConfigPath);
} catch (Exception e) {
System.out.println("failed to initialize core verticle: " + e.getMessage());
System.exit(-1);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/uid2/core/vertx/CoreVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class CoreVerticle extends AbstractVerticle {
private final RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider;

private final FileSystem fileSystem;
private final String operatorConfigPath;

public CoreVerticle(ICloudStorage cloudStorage,
IAuthorizableProvider authProvider,
Expand All @@ -92,7 +93,7 @@ public CoreVerticle(ICloudStorage cloudStorage,
OperatorJWTTokenProvider operatorJWTTokenProvider,
JwtService jwtService,
RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider,
FileSystem fileSystem) throws Exception {
FileSystem fileSystem, String operatorConfigPath) throws Exception {
this.operatorJWTTokenProvider = operatorJWTTokenProvider;
this.healthComponent.setHealthStatus(false, "not started");

Expand All @@ -105,6 +106,7 @@ public CoreVerticle(ICloudStorage cloudStorage,
this.cloudEncryptionKeyProvider = cloudEncryptionKeyProvider;

this.fileSystem = fileSystem;
this.operatorConfigPath = operatorConfigPath;

final String jwtAudience = ConfigStore.Global.get(Const.Config.CorePublicUrlProp);
final String jwtIssuer = ConfigStore.Global.get(Const.Config.CorePublicUrlProp);
Expand Down Expand Up @@ -138,8 +140,8 @@ public CoreVerticle(ICloudStorage cloudStorage,
IEnclaveIdentifierProvider enclaveIdentifierProvider,
OperatorJWTTokenProvider jwtTokenProvider,
JwtService jwtService,
FileSystem fileSystem) throws Exception {
this(cloudStorage, authorizableProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, jwtTokenProvider, jwtService, null, fileSystem);
FileSystem fileSystem, String operatorConfigPath) throws Exception {
this(cloudStorage, authorizableProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, jwtTokenProvider, jwtService, null, fileSystem, operatorConfigPath);
}

@Override
Expand Down Expand Up @@ -209,7 +211,7 @@ private Router createRoutesSetup() {
}

private void handleGetConfig(RoutingContext rc) {
fileSystem.readFile(com.uid2.core.Const.OPERATOR_CONFIG_PATH, ar -> {
fileSystem.readFile(operatorConfigPath, ar -> {
if (ar.succeeded()) {
try {
String fileContent = ar.result().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;

@ExtendWith(VertxExtension.class)
public class TestClientSideKeypairMetadataPath {
Expand Down Expand Up @@ -75,7 +76,7 @@ void deployVerticle(Vertx vertx, VertxTestContext testContext) throws Throwable
fileSystem = vertx.fileSystem();
SecretStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testGlobalMetadata/test-secrets.json"))));
MockitoAnnotations.initMocks(this);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem, OPERATOR_CONFIG_PATH);
vertx.deployVerticle(verticle, testContext.succeeding(id -> testContext.completeNow()));
}

Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/uid2/core/vertx/TestCoreVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;

import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;
import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -122,20 +123,20 @@ void deployVerticle(TestInfo info, Vertx vertx, VertxTestContext testContext) th
}
});

operatorConfig = Files.readString(Paths.get(com.uid2.core.Const.OPERATOR_CONFIG_PATH)).trim();
operatorConfig = Files.readString(Paths.get(OPERATOR_CONFIG_PATH)).trim();

when(fileSystem.readFile(anyString(), any())).thenAnswer(invocation -> {
String path = invocation.getArgument(0);
Handler<AsyncResult<Buffer>> handler = invocation.getArgument(1);
if (Objects.equals(path, com.uid2.core.Const.OPERATOR_CONFIG_PATH)) {
if (Objects.equals(path, OPERATOR_CONFIG_PATH)) {
handler.handle(Future.succeededFuture(Buffer.buffer(operatorConfig)));
} else {
handler.handle(Future.failedFuture(new RuntimeException("Failed to read file: " + path)));
}
return null;
});

CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, cloudEncryptionKeyProvider, fileSystem);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, cloudEncryptionKeyProvider, fileSystem, OPERATOR_CONFIG_PATH);
vertx.deployVerticle(verticle, testContext.succeeding(id -> testContext.completeNow()));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.net.URL;
import java.util.HashSet;

import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;
import static com.uid2.shared.Utils.readToEndAsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -74,7 +75,7 @@ void deployVerticle(Vertx vertx, VertxTestContext testContext) throws Throwable
fileSystem = vertx.fileSystem();
SecretStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testGlobalMetadata/test-secrets.json"))));
MockitoAnnotations.initMocks(this);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem, OPERATOR_CONFIG_PATH);
vertx.deployVerticle(verticle, testContext.succeeding(id -> testContext.completeNow()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.net.URL;
import java.util.HashSet;

import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;
import static com.uid2.shared.Utils.readToEndAsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -74,7 +75,7 @@ void deployVerticle(Vertx vertx, VertxTestContext testContext) throws Throwable
fileSystem = vertx.fileSystem();
SecretStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testGlobalMetadata/test-secrets.json"))));
MockitoAnnotations.initMocks(this);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem, OPERATOR_CONFIG_PATH);
vertx.deployVerticle(verticle, testContext.succeeding(id -> testContext.completeNow()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.net.URL;
import java.util.HashSet;

import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;
import static com.uid2.shared.Utils.readToEndAsString;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
Expand Down Expand Up @@ -73,7 +74,7 @@ void deployVerticle(Vertx vertx, VertxTestContext testContext) throws Throwable
SecretStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testSiteSpecificMetadata/test-secrets.json"))));
ConfigStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testSiteSpecificMetadata/test-configs-provide-private-site-data.json"))));
MockitoAnnotations.initMocks(this);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem, OPERATOR_CONFIG_PATH);
vertx.deployVerticle(verticle, testContext.succeeding(id -> testContext.completeNow()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.net.URL;
import java.util.HashSet;

import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;
import static com.uid2.shared.Utils.readToEndAsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -75,7 +76,7 @@ void deployVerticle(Vertx vertx, VertxTestContext testContext) throws Throwable
SecretStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testSiteSpecificMetadata/test-secrets.json"))));
ConfigStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testSiteSpecificMetadata/test-configs-stop-providing-private-site-data.json"))));
MockitoAnnotations.initMocks(this);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem, OPERATOR_CONFIG_PATH);
vertx.deployVerticle(verticle, testContext.succeeding(id -> testContext.completeNow()));
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/uid2/core/vertx/TestSitesMetadataPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.net.URL;
import java.util.HashSet;

import static com.uid2.core.Const.OPERATOR_CONFIG_PATH;
import static com.uid2.core.util.MetadataHelper.readToEndAsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -78,7 +79,7 @@ void deployVerticle(Vertx vertx, VertxTestContext testContext) throws Throwable
fileSystem = vertx.fileSystem();
SecretStore.Global.load(((JsonObject) Json.decodeValue(openFile("/com.uid2.core/testGlobalMetadata/test-secrets.json"))));
MockitoAnnotations.initMocks(this);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem);
CoreVerticle verticle = new CoreVerticle(cloudStorage, authProvider, attestationService, attestationTokenService, enclaveIdentifierProvider, operatorJWTTokenProvider, jwtService, fileSystem, OPERATOR_CONFIG_PATH);
vertx.deployVerticle(verticle, testContext.succeeding(id -> testContext.completeNow()));
}

Expand Down
Loading