diff --git a/compatibility-tests/sdk-test-awscli/test/payment-cryptography-control-plane.bats b/compatibility-tests/sdk-test-awscli/test/payment-cryptography-control-plane.bats
index 1426e1a112..6e2e17d245 100644
--- a/compatibility-tests/sdk-test-awscli/test/payment-cryptography-control-plane.bats
+++ b/compatibility-tests/sdk-test-awscli/test/payment-cryptography-control-plane.bats
@@ -168,3 +168,26 @@ create_key() {
assert_success
[ "$(json_get "$output" '.Key.DeriveKeyUsage')" = "TR31_K1_KEY_BLOCK_PROTECTION_KEY" ]
}
+
+@test "Payment Cryptography control plane: a Multi-Party Approval team is associated and removed" {
+ # The team's ARN is kept as the request names it: the emulator has no Multi-Party
+ # Approval service to check it against.
+ local team="arn:aws:mpa:us-east-1:000000000000:approval-team/team-alpha"
+
+ run aws_cmd payment-cryptography associate-mpa-team \
+ --action IMPORT_ROOT_PUBLIC_KEY_CERTIFICATE \
+ --mpa-team-arn "$team"
+ assert_success
+ [ "$(json_get "$output" '.MpaTeamAssociation.MpaTeamArn')" = "$team" ]
+ [ "$(json_get "$output" '.MpaTeamAssociation.AssociationState')" = "ACTIVE" ]
+
+ run aws_cmd payment-cryptography get-mpa-team-association \
+ --action IMPORT_ROOT_PUBLIC_KEY_CERTIFICATE
+ assert_success
+ [ "$(json_get "$output" '.MpaTeamAssociation.MpaTeamArn')" = "$team" ]
+
+ run aws_cmd payment-cryptography disassociate-mpa-team \
+ --action IMPORT_ROOT_PUBLIC_KEY_CERTIFICATE
+ assert_success
+ [ "$(json_get "$output" '.MpaTeamAssociation.AssociationState')" = "DELETE_PENDING" ]
+}
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyTest.java
index 99ab1f7e7a..963624c00a 100644
--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyTest.java
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyTest.java
@@ -15,6 +15,7 @@ import software.amazon.awssdk.services.paymentcryptography.PaymentCryptographyCl
import software.amazon.awssdk.services.paymentcryptography.model.AddKeyReplicationRegionsResponse;
import software.amazon.awssdk.services.paymentcryptography.model.Alias;
import software.amazon.awssdk.services.paymentcryptography.model.As2805KeyVariant;
+import software.amazon.awssdk.services.paymentcryptography.model.AssociationState;
import software.amazon.awssdk.services.paymentcryptography.model.CreateKeyRequest;
import software.amazon.awssdk.services.paymentcryptography.model.DeriveKeyUsage;
import software.amazon.awssdk.services.paymentcryptography.model.EnableDefaultKeyReplicationRegionsResponse;
@@ -34,6 +35,8 @@ import software.amazon.awssdk.services.paymentcryptography.model.KeyReplicationS
import software.amazon.awssdk.services.paymentcryptography.model.KeyState;
import software.amazon.awssdk.services.paymentcryptography.model.KeyUsage;
import software.amazon.awssdk.services.paymentcryptography.model.ListKeysResponse;
+import software.amazon.awssdk.services.paymentcryptography.model.MpaOperation;
+import software.amazon.awssdk.services.paymentcryptography.model.MpaTeamAssociation;
import software.amazon.awssdk.services.paymentcryptography.model.MultiRegionKeyType;
import software.amazon.awssdk.services.paymentcryptography.model.PublicPolicyException;
import software.amazon.awssdk.services.paymentcryptography.model.RemoveKeyReplicationRegionsResponse;
@@ -421,6 +424,27 @@ class PaymentCryptographyTest {
return arn.substring(arn.lastIndexOf('/') + 1);
}
+ @Test
+ void aMultiPartyApprovalTeamIsAssociatedReadAndRemoved() {
+ // The team's ARN is kept as the request names it: the emulator has no Multi-Party
+ // Approval service to check it against.
+ String team = "arn:aws:mpa:us-east-1:000000000000:approval-team/team-alpha";
+
+ MpaTeamAssociation association = client.associateMpaTeam(r -> r
+ .action(MpaOperation.IMPORT_ROOT_PUBLIC_KEY_CERTIFICATE)
+ .mpaTeamArn(team)).mpaTeamAssociation();
+ assertThat(association.mpaTeamArn()).isEqualTo(team);
+ assertThat(association.associationState()).isEqualTo(AssociationState.ACTIVE);
+
+ assertThat(client.getMpaTeamAssociation(r -> r
+ .action(MpaOperation.IMPORT_ROOT_PUBLIC_KEY_CERTIFICATE))
+ .mpaTeamAssociation().mpaTeamArn()).isEqualTo(team);
+
+ assertThat(client.disassociateMpaTeam(r -> r
+ .action(MpaOperation.IMPORT_ROOT_PUBLIC_KEY_CERTIFICATE))
+ .mpaTeamAssociation().associationState()).isEqualTo(AssociationState.DELETE_PENDING);
+ }
+
@Test
void aKeyIsCreatedAndReadBackWithItsModesOfUse() {
Key created = createAesKey();
diff --git a/docs/services/index.md b/docs/services/index.md
index db3a3e1280..2812cf6c72 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -34,7 +34,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [CloudHSM v2](cloudhsmv2.md) | `POST /` + `X-Amz-Target: BaldrApiService.*` | JSON 1.1 | 18 |
| [Kinesis](kinesis.md) | `POST /` + `X-Amz-Target: Kinesis_20131202.*` | JSON 1.1 | 32 |
| [Managed Service for Apache Flink](kinesisanalytics.md) | `POST /` + `X-Amz-Target: KinesisAnalytics_20180523.*` | JSON 1.1 | 15 |
-| [Payment Cryptography](payment-cryptography.md) | `POST /` + `X-Amz-Target: PaymentCryptographyControlPlane.*` | JSON 1.0 | 28 |
+| [Payment Cryptography](payment-cryptography.md) | `POST /` + `X-Amz-Target: PaymentCryptographyControlPlane.*` | JSON 1.0 | 31 |
| [Payment Cryptography data plane](payment-cryptography-data.md) | `POST /keys/{KeyIdentifier}/encrypt` and the rest | REST JSON | 12 |
| [Secrets Manager](secrets-manager.md) | `POST /` + `X-Amz-Target: secretsmanager.*` | JSON 1.1 | 23 |
| [Step Functions](step-functions.md) | `POST /` + `X-Amz-Target: AmazonStatesService.*` | JSON 1.1 | 32 |
diff --git a/docs/services/payment-cryptography.md b/docs/services/payment-cryptography.md
index 29eccbfb87..c98e6c236f 100644
--- a/docs/services/payment-cryptography.md
+++ b/docs/services/payment-cryptography.md
@@ -36,6 +36,9 @@
| `PutResourcePolicy` | Attach or replace the resource-based policy of a key |
| `GetResourcePolicy` | Get the resource-based policy of a key |
| `DeleteResourcePolicy` | Remove the resource-based policy of a key |
+| `AssociateMpaTeam` | Associate a Multi-Party Approval team with a protected operation |
+| `GetMpaTeamAssociation` | The Multi-Party Approval team of a protected operation |
+| `DisassociateMpaTeam` | Remove the Multi-Party Approval team of a protected operation |
## Emulation Behavior
@@ -87,9 +90,25 @@
summary the model names: its identifier, its state, its attributes, its check value,
its two flags and, for a key that is replicated, the kind of key it is and the region
it is the primary of.
-- **The members a request may name that the service does not read:** `ImportKey` takes
- `RequesterComment`, and the service reads none of it. No approval is recorded, because
- the multi-party approval is not emulated.
+- **The members a request may name that the service does not read:** `ImportKey`,
+ `AssociateMpaTeam` and `DisassociateMpaTeam` take `RequesterComment`, and the service
+ reads none of it.
+- **The Multi-Party Approval team of a protected operation:** a protected operation has one
+ team, so a second association replaces the first. The association answers with the
+ operation, the team and the state of the association, and removing it answers with the
+ association as it was, its state now `DELETE_PENDING`, and the association is gone from
+ the service. An operation with no team is refused as the resource the reference cannot
+ find. The team's ARN is kept as the request names it: the emulator has no Multi-Party
+ Approval service to check it against. The requester's comment is read by nobody, so no
+ approval session is recorded.
+- **The approval session itself is not made:** the reference holds the import of a root
+ certificate pending until the team approves it, and answers with a key whose state is
+ `CREATE_IN_PROGRESS` and whose `MpaStatus` carries the session. The emulator has no
+ Multi-Party Approval service to ask, so the import is not held pending and the key is
+ imported at once. The protected operation is the one the reference names, the import of
+ a root public key certificate. The disassociation is not held either: the reference holds
+ it pending the approval of the team that is associated, and the emulator answers it with
+ the state `DELETE_PENDING` and takes the association away at once.
- **An alias may name no key:** `UpdateAlias` names the key of an alias, and an update
that names none removes the key the alias names and leaves the alias. `CreateAlias`
refuses an alias without a key, as the reference does, though its model requires
@@ -269,8 +288,7 @@
to start or stop: the reference does not publish the answer for that case, so the
request is refused with `ConflictException`, which is the code the service uses for a
request that conflicts with the state of a key.
-- **Not yet emulated:** the multi-party approval operations and the certificate signing
- request.
+- **Not yet emulated:** the certificate signing request.
## Configuration
diff --git a/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyJsonHandler.java b/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyJsonHandler.java
index 8b9ea19560..a46a71f53b 100644
--- a/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyJsonHandler.java
+++ b/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyJsonHandler.java
@@ -10,6 +10,7 @@ import io.floci.aws.core.common.Pagination;
import io.floci.aws.services.iam.PolicyDocument;
import io.floci.aws.services.paymentcryptography.model.PaymentCryptographyAlias;
import io.floci.aws.services.paymentcryptography.model.PaymentCryptographyKey;
+import io.floci.aws.services.paymentcryptography.model.PaymentCryptographyMpaTeamAssociation;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
@@ -89,6 +90,9 @@ public class PaymentCryptographyJsonHandler {
case "PutResourcePolicy" -> () -> putResourcePolicy(request, region);
case "GetResourcePolicy" -> () -> getResourcePolicy(request, region);
case "DeleteResourcePolicy" -> () -> deleteResourcePolicy(request, region);
+ case "AssociateMpaTeam" -> () -> associateMpaTeam(request, region);
+ case "GetMpaTeamAssociation" -> () -> getMpaTeamAssociation(request, region);
+ case "DisassociateMpaTeam" -> () -> disassociateMpaTeam(request, region);
default -> throw new AwsException("UnknownOperationException",
"Operation " + action + " is not supported by floci", 400);
};
@@ -483,6 +487,47 @@ public class PaymentCryptographyJsonHandler {
return true;
}
+ // ---- multi-party approval ------------------------------------------------
+
+ /**
+ * Associates a Multi-Party Approval team with a protected operation.
+ *
+ *
An operation has one team, so a second association replaces the first, as the
+ * reference replaces one.
+ */
+ private Map associateMpaTeam(JsonNode request, String region) {
+ PaymentCryptographyMpaTeamAssociation association = service.associateMpaTeam(region,
+ request.path("Action").asText(), request.path("MpaTeamArn").asText());
+ return Map.of("MpaTeamAssociation", mpaAssociation(association));
+ }
+
+ /** The Multi-Party Approval team associated with a protected operation. */
+ private Map getMpaTeamAssociation(JsonNode request, String region) {
+ PaymentCryptographyMpaTeamAssociation association =
+ service.mpaTeamAssociation(region, request.path("Action").asText());
+ return Map.of("MpaTeamAssociation", mpaAssociation(association));
+ }
+
+ /**
+ * Removes the Multi-Party Approval team associated with a protected operation.
+ *
+ * The answer carries the association as it was, its state now {@code DELETE_PENDING}.
+ */
+ private Map disassociateMpaTeam(JsonNode request, String region) {
+ PaymentCryptographyMpaTeamAssociation association =
+ service.disassociateMpaTeam(region, request.path("Action").asText());
+ return Map.of("MpaTeamAssociation", mpaAssociation(association));
+ }
+
+ /** The association, as the model names its members. */
+ private static Map mpaAssociation(PaymentCryptographyMpaTeamAssociation association) {
+ Map out = new LinkedHashMap<>();
+ out.put("Action", association.getAction());
+ out.put("MpaTeamArn", association.getMpaTeamArn());
+ out.put("AssociationState", association.getAssociationState());
+ return out;
+ }
+
/** The tags of a request, as the name and the value of each. */
private static Map tagsOf(JsonNode request) {
Map tags = new LinkedHashMap<>();
diff --git a/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyService.java b/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyService.java
index 8693a61514..287751381a 100644
--- a/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyService.java
+++ b/src/main/java/io/floci/aws/services/paymentcryptography/PaymentCryptographyService.java
@@ -16,6 +16,7 @@ import io.floci.aws.services.acm.CertificateGenerator;
import io.floci.aws.services.paymentcryptography.crypto.DukptCrypto;
import io.floci.aws.services.paymentcryptography.model.PaymentCryptographyAlias;
import io.floci.aws.services.paymentcryptography.model.PaymentCryptographyKey;
+import io.floci.aws.services.paymentcryptography.model.PaymentCryptographyMpaTeamAssociation;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -84,6 +85,7 @@ public class PaymentCryptographyService implements Resettable, StoredResourceArn
private final StorageBackend keyStore;
private final StorageBackend aliasStore;
+ private final StorageBackend mpaTeamStore;
/** The key exchange: the forms a key may leave in, and the certificates that carry them. */
private final PaymentCryptographyKeyExchange exchange;
@@ -104,6 +106,8 @@ public class PaymentCryptographyService implements Resettable, StoredResourceArn
new TypeReference<>() {}),
storageFactory.create(STORAGE_KEY, "payment-cryptography-settings.json",
new TypeReference