isCorrectType, String field) {
+ JsonNode value = image.get(member);
+ if (value != null && !value.isNull() && !isCorrectType.test(value)) {
+ throw new AwsException("SerializationException",
+ "Unable to unmarshal request; the value for '" + field + "." + member + "' has the wrong type.", 400);
+ }
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/rekognition/RekognitionService.java b/src/main/java/io/github/hectorvent/floci/services/rekognition/RekognitionService.java
new file mode 100644
index 0000000000..50fd5f6a63
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/rekognition/RekognitionService.java
@@ -0,0 +1,123 @@
+package io.github.hectorvent.floci.services.rekognition;
+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;
+/**
+ * Dummy response builder for Amazon Rekognition. Stateless — every action ignores
+ * the actual image content and returns a fixed but AWS-shaped response.
+ *
+ * Content-listing operations (DetectLabels, DetectText) always return one canned
+ * entry, matching the TextractService stub precedent. Face/moderation operations
+ * (DetectFaces, CompareFaces, DetectModerationLabels) return empty results by
+ * default — an honest "nothing detected" response, rather than fabricating
+ * biometric attributes or a moderation flag for content that was never analyzed,
+ * matching the ComprehendService PII-detection precedent.
+ *
+ * Real detection logic is a planned follow-up; see the tracking issue for scope.
+ *
+ * @see Rekognition API Reference
+ */
+@ApplicationScoped
+public class RekognitionService {
+ static final String MODEL_VERSION = "1.0";
+ private final ObjectMapper objectMapper;
+ @Inject
+ public RekognitionService(ObjectMapper objectMapper) {
+ this.objectMapper = objectMapper;
+ }
+ /**
+ * DetectLabels — always returns a single stub label.
+ * Response shape: https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectLabels.html
+ */
+ public Response detectLabels() {
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode labels = root.putArray("Labels");
+ ObjectNode label = labels.addObject();
+ label.put("Name", "Floci");
+ label.put("Confidence", 99.9);
+ root.put("LabelModelVersion", MODEL_VERSION);
+ return Response.ok(root).build();
+ }
+ /**
+ * DetectFaces — always reports no faces found.
+ * Response shape: https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html
+ */
+ public Response detectFaces() {
+ ObjectNode root = objectMapper.createObjectNode();
+ root.putArray("FaceDetails");
+ return Response.ok(root).build();
+ }
+ /**
+ * DetectText — always returns one stub LINE and its child WORD, matching
+ * Textract's PAGE/LINE/WORD block-hierarchy convention.
+ * Response shape: https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectText.html
+ */
+ public Response detectText() {
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode detections = root.putArray("TextDetections");
+ ObjectNode line = detections.addObject();
+ line.put("DetectedText", "Floci");
+ line.put("Type", "LINE");
+ line.put("Id", 0);
+ line.put("Confidence", 99.9);
+ line.set("Geometry", buildGeometry(0.1, 0.1, 0.15, 0.05));
+ ObjectNode word = detections.addObject();
+ word.put("DetectedText", "Floci");
+ word.put("Type", "WORD");
+ word.put("Id", 1);
+ word.put("ParentId", 0);
+ word.put("Confidence", 99.9);
+ word.set("Geometry", buildGeometry(0.1, 0.1, 0.15, 0.05));
+ root.put("TextModelVersion", MODEL_VERSION);
+ return Response.ok(root).build();
+ }
+ /**
+ * CompareFaces — always reports no matches (SourceImageFace is optional and
+ * legitimately omitted when no face is found in the source image).
+ * Response shape: https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CompareFaces.html
+ */
+ public Response compareFaces() {
+ ObjectNode root = objectMapper.createObjectNode();
+ root.putArray("FaceMatches");
+ root.putArray("UnmatchedFaces");
+ return Response.ok(root).build();
+ }
+ /**
+ * DetectModerationLabels — always reports no moderation labels found.
+ * Response shape: https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectModerationLabels.html
+ */
+ public Response detectModerationLabels() {
+ ObjectNode root = objectMapper.createObjectNode();
+ root.putArray("ModerationLabels");
+ root.put("ModerationModelVersion", MODEL_VERSION);
+ return Response.ok(root).build();
+ }
+ // Private helpers
+ /**
+ * Builds a Geometry object with BoundingBox and a 4-point Polygon — the same
+ * shape Textract uses (Rekognition's Geometry shape is structurally identical).
+ * @see Geometry
+ */
+ private ObjectNode buildGeometry(double left, double top, double width, double height) {
+ ObjectNode geometry = objectMapper.createObjectNode();
+ ObjectNode bbox = geometry.putObject("BoundingBox");
+ bbox.put("Width", width);
+ bbox.put("Height", height);
+ bbox.put("Left", left);
+ bbox.put("Top", top);
+ ArrayNode polygon = geometry.putArray("Polygon");
+ addPoint(polygon, left, top);
+ addPoint(polygon, left + width, top);
+ addPoint(polygon, left + width, top + height);
+ addPoint(polygon, left, top + height);
+ return geometry;
+ }
+ private void addPoint(ArrayNode polygon, double x, double y) {
+ ObjectNode point = polygon.addObject();
+ point.put("X", x);
+ point.put("Y", y);
+ }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 9304d659e8..a8dc3b6077 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -508,6 +508,8 @@ floci:
enabled: true
comprehend:
enabled: true
+ rekognition:
+ enabled: true
pricing:
enabled: true
transcribe:
diff --git a/src/test/java/io/github/hectorvent/floci/services/rekognition/RekognitionIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/rekognition/RekognitionIntegrationTest.java
new file mode 100644
index 0000000000..1de699d23a
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/rekognition/RekognitionIntegrationTest.java
@@ -0,0 +1,205 @@
+package io.github.hectorvent.floci.services.rekognition;
+import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.*;
+/**
+ * Integration tests for the Amazon Rekognition stub.
+ * Validates AWS-compatible wire format using RestAssured.
+ * Protocol: JSON 1.1 — Content-Type: application/x-amz-json-1.1, X-Amz-Target: RekognitionService.
+ */
+@QuarkusTest
+class RekognitionIntegrationTest {
+ @BeforeAll
+ static void configureRestAssured() {
+ RestAssuredJsonUtils.configureAwsContentTypes();
+ }
+ private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
+ private static final String AUTH_HEADER =
+ "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/rekognition/aws4_request";
+ private static final String S3_IMAGE =
+ "{\"S3Object\":{\"Bucket\":\"my-bucket\",\"Name\":\"photo.jpg\"}}";
+ @Test
+ void detectLabels_returnsStubLabel() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":" + S3_IMAGE + "}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("Labels", hasSize(1))
+ .body("Labels[0].Name", equalTo("Floci"))
+ .body("Labels[0].Confidence", notNullValue())
+ .body("LabelModelVersion", equalTo("1.0"));
+ }
+ @Test
+ void detectLabels_missingImage_returns400() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("InvalidParameterException"));
+ }
+ @Test
+ void detectLabels_imageWithoutBytesOrS3Object_returns400() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":{}}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("InvalidParameterException"));
+ }
+ @Test
+ void detectLabels_nonObjectImage_returnsSerializationException() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":\"banana\"}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("SerializationException"));
+ }
+ @Test
+ void detectLabels_nonStringBytes_returnsSerializationException() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":{\"Bytes\":12345}}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("SerializationException"));
+ }
+ @Test
+ void detectLabels_nonObjectS3Object_returnsSerializationException() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":{\"S3Object\":\"not-an-object\"}}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("SerializationException"));
+ }
+ @Test
+ void detectLabels_bothBytesAndS3ObjectAccepted() {
+ // Neither field's content is read, and nothing in the Rekognition model
+ // declares supplying both invalid.
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":{\"Bytes\":\"aGVsbG8=\",\"S3Object\":{\"Bucket\":\"my-bucket\",\"Name\":\"photo.jpg\"}}}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("Labels", hasSize(1));
+ }
+ @Test
+ void detectFaces_returnsEmptyFaceDetails() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectFaces")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":" + S3_IMAGE + "}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("FaceDetails", hasSize(0));
+ }
+ @Test
+ void detectText_returnsLineAndWordDetections() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectText")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":" + S3_IMAGE + "}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("TextDetections", hasSize(2))
+ .body("TextDetections.Type", hasItems("LINE", "WORD"))
+ .body("TextDetections.findAll { it.Type == 'LINE' }.DetectedText", hasItem("Floci"))
+ .body("TextDetections[0].Geometry.BoundingBox.Width", notNullValue())
+ .body("TextDetections[0].Geometry.Polygon", hasSize(4))
+ .body("TextModelVersion", equalTo("1.0"));
+ }
+ @Test
+ void compareFaces_returnsEmptyMatches() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.CompareFaces")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"SourceImage\":" + S3_IMAGE + ",\"TargetImage\":" + S3_IMAGE + "}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("FaceMatches", hasSize(0))
+ .body("UnmatchedFaces", hasSize(0));
+ }
+ @Test
+ void compareFaces_missingTargetImage_returns400() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.CompareFaces")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"SourceImage\":" + S3_IMAGE + "}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("InvalidParameterException"));
+ }
+ @Test
+ void detectModerationLabels_returnsEmptyLabels() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.DetectModerationLabels")
+ .header("Authorization", AUTH_HEADER)
+ .body("{\"Image\":" + S3_IMAGE + "}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("ModerationLabels", hasSize(0))
+ .body("ModerationModelVersion", equalTo("1.0"));
+ }
+ @Test
+ void unknownAction_returnsUnknownOperationError() {
+ given()
+ .contentType(CONTENT_TYPE)
+ .header("X-Amz-Target", "RekognitionService.IndexFaces")
+ .header("Authorization", AUTH_HEADER)
+ .body("{}")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("UnknownOperationException"));
+ }
+}
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index 7df748f452..1fd20634b7 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -298,6 +298,8 @@ floci:
enabled: true
comprehend:
enabled: true
+ rekognition:
+ enabled: true
pricing:
enabled: true
ce:
diff --git a/tools/docs/services.yaml b/tools/docs/services.yaml
index 6940695a9b..ce1d74cb98 100644
--- a/tools/docs/services.yaml
+++ b/tools/docs/services.yaml
@@ -38,6 +38,10 @@ services:
doc: docs/services/comprehend.md
sources:
- { path: src/main/java/io/github/hectorvent/floci/services/comprehend/ComprehendJsonHandler.java, mode: switch }
+ - service: rekognition
+ doc: docs/services/rekognition.md
+ sources:
+ - { path: src/main/java/io/github/hectorvent/floci/services/rekognition/RekognitionJsonHandler.java, mode: switch }
- service: docdb
doc: docs/services/docdb.md
sources: