io.quarkus
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index 31ca3a7bb9..517ecb0d6c 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -44,6 +44,7 @@ public interface EmulatorConfig {
CloudWatchLogsStorageConfig cloudwatchlogs();
CloudWatchMetricsStorageConfig cloudwatchmetrics();
SecretsManagerStorageConfig secretsmanager();
+ AcmStorageConfig acm();
}
interface SsmStorageConfig {
@@ -112,6 +113,14 @@ public interface EmulatorConfig {
long flushIntervalMs();
}
+ interface AcmStorageConfig {
+ @WithDefault("memory")
+ String mode();
+
+ @WithDefault("5000")
+ long flushIntervalMs();
+ }
+
interface WalConfig {
@WithDefault("30000")
long compactionIntervalMs();
@@ -150,6 +159,7 @@ public interface EmulatorConfig {
CognitoServiceConfig cognito();
StepFunctionsServiceConfig stepfunctions();
CloudFormationServiceConfig cloudformation();
+ AcmServiceConfig acm();
}
interface SsmServiceConfig {
@@ -295,6 +305,15 @@ public interface EmulatorConfig {
boolean enabled();
}
+ interface AcmServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+
+ /** Seconds to wait before transitioning from PENDING_VALIDATION to ISSUED (0 = immediate) */
+ @WithDefault("0")
+ int validationWaitSeconds();
+ }
+
interface LambdaServiceConfig {
@WithDefault("true")
boolean enabled();
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java
index 1be4ebd328..9aeacb97d3 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java
@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.core.common;
+import io.github.hectorvent.floci.services.acm.AcmJsonHandler;
import io.github.hectorvent.floci.services.apigatewayv2.ApiGatewayV2JsonHandler;
import io.github.hectorvent.floci.services.cloudwatch.logs.CloudWatchLogsHandler;
import io.github.hectorvent.floci.services.cognito.CognitoJsonHandler;
@@ -40,6 +41,7 @@ public class AwsJson11Controller {
private static final String APIGW_V2_TARGET_PREFIX = "AmazonApiGatewayV2.";
private static final String KMS_TARGET_PREFIX = "TrentService.";
private static final String COGNITO_TARGET_PREFIX = "AWSCognitoIdentityProviderService.";
+ private static final String ACM_TARGET_PREFIX = "CertificateManager.";
private final ObjectMapper objectMapper;
private final RegionResolver regionResolver;
@@ -51,6 +53,7 @@ public class AwsJson11Controller {
private final ApiGatewayV2JsonHandler apigwV2JsonHandler;
private final KmsJsonHandler kmsJsonHandler;
private final CognitoJsonHandler cognitoJsonHandler;
+ private final AcmJsonHandler acmJsonHandler;
@Inject
public AwsJson11Controller(ObjectMapper objectMapper, RegionResolver regionResolver,
@@ -59,7 +62,8 @@ public class AwsJson11Controller {
SecretsManagerJsonHandler secretsManagerJsonHandler,
KinesisJsonHandler kinesisJsonHandler,
ApiGatewayV2JsonHandler apigwV2JsonHandler,
- KmsJsonHandler kmsJsonHandler, CognitoJsonHandler cognitoJsonHandler) {
+ KmsJsonHandler kmsJsonHandler, CognitoJsonHandler cognitoJsonHandler,
+ AcmJsonHandler acmJsonHandler) {
this.objectMapper = objectMapper;
this.regionResolver = regionResolver;
this.ssmJsonHandler = ssmJsonHandler;
@@ -70,6 +74,7 @@ public class AwsJson11Controller {
this.apigwV2JsonHandler = apigwV2JsonHandler;
this.kmsJsonHandler = kmsJsonHandler;
this.cognitoJsonHandler = cognitoJsonHandler;
+ this.acmJsonHandler = acmJsonHandler;
}
@POST
@@ -111,6 +116,9 @@ public class AwsJson11Controller {
} else if (target.startsWith(COGNITO_TARGET_PREFIX)) {
prefix = COGNITO_TARGET_PREFIX;
serviceName = "Cognito";
+ } else if (target.startsWith(ACM_TARGET_PREFIX)) {
+ prefix = ACM_TARGET_PREFIX;
+ serviceName = "ACM";
} else {
return Response.status(400)
.entity(new AwsErrorResponse("UnknownOperationException",
@@ -134,6 +142,7 @@ public class AwsJson11Controller {
case "ApiGatewayV2" -> apigwV2JsonHandler.handle(action, request, region);
case "KMS" -> kmsJsonHandler.handle(action, request, region);
case "Cognito" -> cognitoJsonHandler.handle(action, request, region);
+ case "ACM" -> acmJsonHandler.handle(action, request, region);
default -> null;
};
} catch (AwsException e) {
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/BouncyCastleInitializer.java b/src/main/java/io/github/hectorvent/floci/core/common/BouncyCastleInitializer.java
new file mode 100644
index 0000000000..095cf5fcfa
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/core/common/BouncyCastleInitializer.java
@@ -0,0 +1,43 @@
+package io.github.hectorvent.floci.core.common;
+
+import io.quarkus.runtime.Startup;
+import jakarta.enterprise.context.ApplicationScoped;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.jboss.logging.Logger;
+
+import java.security.Security;
+
+/**
+ * Ensures BouncyCastle security provider is registered before any CDI beans are injected.
+ *
+ * This class uses a static initializer block to guarantee the provider is registered
+ * during class loading, which happens before CDI injection. The {@code @Startup} annotation
+ * ensures this class is loaded early in the application lifecycle.
+ *
+ * Design decision: Using static initializer + @Startup instead of @Observes StartupEvent
+ * because StartupEvent observers run after CDI context is ready, which may be too late if
+ * other beans depend on BouncyCastle during their construction.
+ *
+ * @see Quarkus CDI Startup
+ */
+@ApplicationScoped
+@Startup
+public class BouncyCastleInitializer {
+
+ private static final Logger LOG = Logger.getLogger(BouncyCastleInitializer.class);
+
+ static {
+ if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
+ Security.addProvider(new BouncyCastleProvider());
+ LOG.info("Registered BouncyCastle security provider (static initializer)");
+ }
+ }
+
+ /**
+ * No-op constructor. The actual initialization happens in the static block above.
+ * This bean exists solely to trigger class loading via {@code @Startup}.
+ */
+ public BouncyCastleInitializer() {
+ // Static initializer has already run by the time this constructor is called
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java b/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java
index 946804f6cb..178a5d1370 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java
@@ -45,6 +45,7 @@ public class ServiceRegistry {
case "cognito-idp" -> config.services().cognito().enabled();
case "states" -> config.services().stepfunctions().enabled();
case "cloudformation" -> config.services().cloudformation().enabled();
+ case "acm" -> config.services().acm().enabled();
default -> true;
};
}
@@ -71,6 +72,7 @@ public class ServiceRegistry {
if (config.services().cognito().enabled()) enabled.add("cognito-idp");
if (config.services().stepfunctions().enabled()) enabled.add("states");
if (config.services().cloudformation().enabled()) enabled.add("cloudformation");
+ if (config.services().acm().enabled()) enabled.add("acm");
return enabled;
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/acm/AcmJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/acm/AcmJsonHandler.java
new file mode 100644
index 0000000000..71966cbca9
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/acm/AcmJsonHandler.java
@@ -0,0 +1,446 @@
+package io.github.hectorvent.floci.services.acm;
+
+import io.github.hectorvent.floci.core.common.AwsErrorResponse;
+import io.github.hectorvent.floci.services.acm.model.*;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.core.Response;
+import org.jboss.logging.Logger;
+
+import java.util.*;
+
+/**
+ * JSON handler for AWS Certificate Manager (ACM) API operations.
+ *
+ * Implements the AWS JSON 1.1 protocol for ACM operations including
+ * certificate request, import, export, listing, and lifecycle management.
+ *
+ * @see AWS ACM API Reference
+ */
+@ApplicationScoped
+public class AcmJsonHandler {
+
+ private static final Logger LOG = Logger.getLogger(AcmJsonHandler.class);
+
+ private final AcmService service;
+ private final ObjectMapper objectMapper;
+
+ @Inject
+ public AcmJsonHandler(AcmService service, ObjectMapper objectMapper) {
+ this.service = service;
+ this.objectMapper = objectMapper;
+ }
+
+ public Response handle(String action, JsonNode request, String region) {
+ return switch (action) {
+ case "RequestCertificate" -> handleRequestCertificate(request, region);
+ case "DescribeCertificate" -> handleDescribeCertificate(request, region);
+ case "GetCertificate" -> handleGetCertificate(request, region);
+ case "ListCertificates" -> handleListCertificates(request, region);
+ case "DeleteCertificate" -> handleDeleteCertificate(request, region);
+ case "ImportCertificate" -> handleImportCertificate(request, region);
+ case "ExportCertificate" -> handleExportCertificate(request, region);
+ case "AddTagsToCertificate" -> handleAddTagsToCertificate(request, region);
+ case "ListTagsForCertificate" -> handleListTagsForCertificate(request, region);
+ case "RemoveTagsFromCertificate" -> handleRemoveTagsFromCertificate(request, region);
+ case "GetAccountConfiguration" -> handleGetAccountConfiguration(request, region);
+ case "PutAccountConfiguration" -> handlePutAccountConfiguration(request, region);
+ default -> Response.status(400)
+ .entity(new AwsErrorResponse("UnsupportedOperation", "Operation " + action + " is not supported."))
+ .build();
+ };
+ }
+
+ private Response handleRequestCertificate(JsonNode request, String region) {
+ String domainName = request.path("DomainName").asText(null);
+ if (domainName == null || domainName.isBlank()) {
+ return Response.status(400)
+ .entity(new AwsErrorResponse("ValidationException",
+ "Value null at 'domainName' failed to satisfy constraint: Member must not be null"))
+ .build();
+ }
+ List sans = parseStringList(request.path("SubjectAlternativeNames"));
+ ValidationMethod validationMethod = parseValidationMethod(request.path("ValidationMethod").asText(null));
+ String idempotencyToken = request.path("IdempotencyToken").asText(null);
+ KeyAlgorithm keyAlgorithm = KeyAlgorithm.fromAwsName(request.path("KeyAlgorithm").asText(null));
+ String certAuthorityArn = request.path("CertificateAuthorityArn").asText(null);
+ CertificateOptions options = parseOptions(request.path("Options"));
+ Map tags = parseTags(request.path("Tags"));
+
+ Certificate cert = service.requestCertificate(domainName, sans, validationMethod,
+ idempotencyToken, keyAlgorithm, certAuthorityArn, options, tags, region);
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.put("CertificateArn", cert.getArn());
+ return Response.ok(response).build();
+ }
+
+ private Response handleDescribeCertificate(JsonNode request, String region) {
+ String certificateArn = request.path("CertificateArn").asText();
+ Certificate cert = service.describeCertificate(certificateArn, region);
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.set("Certificate", buildCertificateDetail(cert));
+ return Response.ok(response).build();
+ }
+
+ private Response handleGetCertificate(JsonNode request, String region) {
+ String certificateArn = request.path("CertificateArn").asText();
+ Certificate cert = service.getCertificate(certificateArn, region);
+
+ // AWS returns RequestInProgressException for certificates still pending validation
+ if (cert.getStatus() == CertificateStatus.PENDING_VALIDATION) {
+ throw new io.github.hectorvent.floci.core.common.AwsException(
+ "RequestInProgressException",
+ "The certificate request is in progress. The certificate body is not yet available.",
+ 400);
+ }
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.put("Certificate", cert.getCertificateBody());
+ if (cert.getCertificateChain() != null) {
+ response.put("CertificateChain", cert.getCertificateChain());
+ }
+ return Response.ok(response).build();
+ }
+
+ private Response handleListCertificates(JsonNode request, String region) {
+ List statuses = parseCertificateStatuses(request.path("CertificateStatuses"));
+ List keyTypes = parseKeyTypes(request.path("Includes").path("keyTypes"));
+ int maxItems = request.path("MaxItems").asInt(100);
+ String nextToken = request.path("NextToken").asText(null);
+
+ ListResult result = service.listCertificates(statuses, keyTypes, region, maxItems, nextToken);
+
+ ObjectNode response = objectMapper.createObjectNode();
+ ArrayNode summaryList = objectMapper.createArrayNode();
+ for (Certificate cert : result.certificates()) {
+ summaryList.add(buildCertificateSummary(cert));
+ }
+ response.set("CertificateSummaryList", summaryList);
+ if (result.nextToken() != null) {
+ response.put("NextToken", result.nextToken());
+ }
+ return Response.ok(response).build();
+ }
+
+ private Response handleDeleteCertificate(JsonNode request, String region) {
+ String certificateArn = request.path("CertificateArn").asText();
+ service.deleteCertificate(certificateArn, region);
+ return Response.ok(objectMapper.createObjectNode()).build();
+ }
+
+ private Response handleImportCertificate(JsonNode request, String region) {
+ String certificate = request.path("Certificate").asText();
+ String privateKey = request.path("PrivateKey").asText();
+ String chain = request.path("CertificateChain").asText(null);
+ String existingArn = request.path("CertificateArn").asText(null);
+ Map tags = parseTags(request.path("Tags"));
+
+ Certificate cert = service.importCertificate(certificate, privateKey, chain, existingArn, tags, region);
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.put("CertificateArn", cert.getArn());
+ return Response.ok(response).build();
+ }
+
+ private Response handleExportCertificate(JsonNode request, String region) {
+ String certificateArn = request.path("CertificateArn").asText();
+ String passphrase = request.path("Passphrase").asText();
+
+ Certificate cert = service.exportCertificate(certificateArn, passphrase, region);
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.put("Certificate", cert.getCertificateBody());
+ if (cert.getCertificateChain() != null) {
+ response.put("CertificateChain", cert.getCertificateChain());
+ }
+ response.put("PrivateKey", cert.getPrivateKey());
+ return Response.ok(response).build();
+ }
+
+ private Response handleAddTagsToCertificate(JsonNode request, String region) {
+ String certificateArn = request.path("CertificateArn").asText();
+ Map tags = parseTags(request.path("Tags"));
+
+ service.addTagsToCertificate(certificateArn, tags, region);
+ return Response.ok(objectMapper.createObjectNode()).build();
+ }
+
+ private Response handleListTagsForCertificate(JsonNode request, String region) {
+ String certificateArn = request.path("CertificateArn").asText();
+ Map tags = service.listTagsForCertificate(certificateArn, region);
+
+ ObjectNode response = objectMapper.createObjectNode();
+ ArrayNode tagsArray = objectMapper.createArrayNode();
+ for (Map.Entry entry : tags.entrySet()) {
+ ObjectNode tagNode = objectMapper.createObjectNode();
+ tagNode.put("Key", entry.getKey());
+ tagNode.put("Value", entry.getValue());
+ tagsArray.add(tagNode);
+ }
+ response.set("Tags", tagsArray);
+ return Response.ok(response).build();
+ }
+
+ private Response handleRemoveTagsFromCertificate(JsonNode request, String region) {
+ String certificateArn = request.path("CertificateArn").asText();
+ List