mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(paymentcryptography): the Payment Cryptography control plane (#7090)
This commit is contained in:
1 parent
9e270fbfe1
commit
6906759c9a
41 files changed
+3268
-25
No files matched your search
@@ -25,6 +25,9 @@
|
||||
# by tools/aws/regen_ecs_shapes.py.
|
||||
# src/main/resources/aws/ecr-request-shapes.json, the ECR request constraints, is generated
|
||||
# from botocore's ECR model by tools/aws/regen_ecr_shapes.py.
|
||||
# src/main/resources/aws/payment-cryptography-request-shapes.json, the Payment Cryptography
|
||||
# request constraints, is generated from botocore's model by
|
||||
# tools/aws/regen_payment_cryptography_shapes.py.
|
||||
# src/main/resources/aws/rds-ca-certificates.json, each Region's RDS certificate authorities, is
|
||||
# generated from the certificate bundles AWS publishes by tools/aws/regen_rds_ca_certificates.py.
|
||||
# src/main/resources/aws/iam-request-shapes.json, the IAM request constraints of the operations
|
||||
@@ -257,6 +260,7 @@ aws-data-sync-botocore: ## Regenerate only the AWS data derived from botocore, s
|
||||
$(PYTHON) tools/aws/regen_redshift_serverless_shapes.py
|
||||
$(PYTHON) tools/aws/regen_resource_groups_shapes.py
|
||||
$(PYTHON) tools/aws/regen_ecr_shapes.py
|
||||
$(PYTHON) tools/aws/regen_payment_cryptography_shapes.py
|
||||
$(PYTHON) tools/aws/regen_iam_shapes.py
|
||||
$(PYTHON) tools/aws/regen_sts_shapes.py
|
||||
$(PYTHON) tools/aws/regen_apigateway_types.py
|
||||
@@ -335,6 +339,12 @@ aws-data-check-botocore: ## The AWS data derived from botocore must match a fres
|
||||
echo " Run 'make aws-data-sync' and commit the result."; \
|
||||
exit 1; \
|
||||
}
|
||||
@$(PYTHON) tools/aws/regen_payment_cryptography_shapes.py --check || { \
|
||||
echo ""; \
|
||||
echo "error: src/main/resources/aws/payment-cryptography-request-shapes.json is out of date."; \
|
||||
echo " Run 'make aws-data-sync' and commit the result."; \
|
||||
exit 1; \
|
||||
}
|
||||
@$(PYTHON) tools/aws/regen_apigateway_types.py --check || { \
|
||||
echo "error: API Gateway integration types are out of date; run 'make aws-data-sync'."; \
|
||||
exit 1; \
|
||||
|
||||
@@ -296,7 +296,7 @@ Floci supports local emulation for application services, data services, eventing
|
||||
|
||||
| Category | Services |
|
||||
|---|---|
|
||||
| Core app services | S3, SQS, SNS, DynamoDB, Lambda, Lambda MicroVMs, Lambda Web Functions, IAM, STS, KMS, Secrets Manager, SSM |
|
||||
| Core app services | S3, SQS, SNS, DynamoDB, Lambda, Lambda MicroVMs, Lambda Web Functions, IAM, STS, KMS, Payment Cryptography, Secrets Manager, SSM |
|
||||
| Events and workflows | EventBridge, EventBridge V2, EventBridge Pipes, EventBridge Scheduler, Step Functions, SWF, CloudWatch Logs, CloudWatch Metrics, CloudWatch OAM, CloudWatch RUM, Managed Prometheus (AMP) |
|
||||
| API and identity | API Gateway REST, API Gateway v2, AppSync, Cognito, Cognito Identity, ACM, Route53, Route 53 Resolver, Cloud Map, Global Accelerator |
|
||||
| Containers and compute | ECS, EC2, Lightsail, EKS, MWAA, ECR, EFS, CodeBuild, CodeDeploy, CodePipeline, CodeGuru Reviewer, CodeArtifact, AWS Batch, Auto Scaling, Application Auto Scaling, Elastic Beanstalk, ELB v2, ELB Classic |
|
||||
@@ -327,6 +327,7 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/
|
||||
| IAM | In-process | Users, roles, groups, policies, instance profiles, access keys; STS AssumeRole, WebIdentity, SAML, GetFederationToken, GetSessionToken |
|
||||
| Cognito | In-process | User pools, app clients, auth flows, JWKS and OpenID well-known endpoints |
|
||||
| KMS | In-process | Encrypt, decrypt, sign, verify, data keys, aliases |
|
||||
| Payment Cryptography | In-process | Keys with real AES-256 material and check values, aliases, tagging |
|
||||
| Kinesis | In-process | Streams, shards, enhanced fan-out, split and merge |
|
||||
| Secrets Manager | In-process | Versioning, resource policies, tagging |
|
||||
| Step Functions | In-process | ASL execution, task tokens, execution history |
|
||||
|
||||
@@ -152,6 +152,10 @@
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>kms</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>paymentcryptography</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>cognitoidentityprovider</artifactId>
|
||||
|
||||
@@ -106,6 +106,7 @@ import software.amazon.awssdk.services.neptune.NeptuneClient;
|
||||
import software.amazon.awssdk.services.oam.OamClient;
|
||||
import software.amazon.awssdk.services.opensearch.OpenSearchClient;
|
||||
import software.amazon.awssdk.services.organizations.OrganizationsClient;
|
||||
import software.amazon.awssdk.services.paymentcryptography.PaymentCryptographyClient;
|
||||
import software.amazon.awssdk.services.pipes.PipesClient;
|
||||
import software.amazon.awssdk.services.ram.RamClient;
|
||||
import software.amazon.awssdk.services.rds.RdsClient;
|
||||
@@ -1085,6 +1086,23 @@ public final class TestFixtures {
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Payment Cryptography control plane. The real service is an awsJson 1.0 service
|
||||
* that signs for {@code payment-cryptography}, and the SDK talks to it through the
|
||||
* {@code PaymentCryptographyControlPlane} target prefix.
|
||||
*/
|
||||
public static PaymentCryptographyClient paymentCryptographyClient() {
|
||||
return paymentCryptographyClient(REGION);
|
||||
}
|
||||
|
||||
public static PaymentCryptographyClient paymentCryptographyClient(Region region) {
|
||||
return PaymentCryptographyClient.builder()
|
||||
.endpointOverride(ENDPOINT)
|
||||
.region(region)
|
||||
.credentialsProvider(CREDENTIALS)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static SecretsManagerClient secretsManagerClient() {
|
||||
return SecretsManagerClient.builder()
|
||||
.endpointOverride(ENDPOINT)
|
||||
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
package com.floci.test;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.awscore.exception.AwsServiceException;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.paymentcryptography.PaymentCryptographyClient;
|
||||
import software.amazon.awssdk.services.paymentcryptography.model.Alias;
|
||||
import software.amazon.awssdk.services.paymentcryptography.model.Key;
|
||||
import software.amazon.awssdk.services.paymentcryptography.model.KeyAlgorithm;
|
||||
import software.amazon.awssdk.services.paymentcryptography.model.KeyAttributes;
|
||||
import software.amazon.awssdk.services.paymentcryptography.model.KeyCheckValueAlgorithm;
|
||||
import software.amazon.awssdk.services.paymentcryptography.model.KeyClass;
|
||||
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.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* The Payment Cryptography control plane through the AWS SDK.
|
||||
*
|
||||
* <p>The real service is an awsJson 1.0 service whose operations are targeted by
|
||||
* {@code PaymentCryptographyControlPlane.<Operation>}, so a real client is the only way to
|
||||
* prove that the wire format, the request shape and the answer shape all agree.
|
||||
*/
|
||||
@DisplayName("Payment Cryptography")
|
||||
class PaymentCryptographyTest {
|
||||
|
||||
private static PaymentCryptographyClient client;
|
||||
private static final List<String> keyArns = new ArrayList<>();
|
||||
private static final List<String> aliasNames = new ArrayList<>();
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
client = TestFixtures.paymentCryptographyClient();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void cleanup() {
|
||||
if (client == null) {
|
||||
return;
|
||||
}
|
||||
for (String alias : aliasNames) {
|
||||
try {
|
||||
client.deleteAlias(a -> a.aliasName(alias));
|
||||
} catch (Exception ignored) {
|
||||
// The key may already be gone, and real AWS refuses to delete an alias of one.
|
||||
}
|
||||
}
|
||||
for (String arn : keyArns) {
|
||||
try {
|
||||
client.deleteKey(k -> k.keyIdentifier(arn));
|
||||
} catch (Exception ignored) {
|
||||
// Real AWS wants a key disabled before it is deleted, and wants it gone by now.
|
||||
}
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
|
||||
private static Key createAesKey() {
|
||||
Key key = client.createKey(r -> r
|
||||
.keyAttributes(a -> a
|
||||
.keyAlgorithm(KeyAlgorithm.AES_256)
|
||||
.keyClass(KeyClass.SYMMETRIC_KEY)
|
||||
.keyUsage(KeyUsage.TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY)
|
||||
.keyModesOfUse(m -> m.encrypt(true).decrypt(true)))
|
||||
.exportable(true))
|
||||
.key();
|
||||
keyArns.add(key.keyArn());
|
||||
return key;
|
||||
}
|
||||
|
||||
/** The key identifier of an ARN: the part after the last slash. */
|
||||
private static String keyIdOf(String arn) {
|
||||
return arn.substring(arn.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyIsCreatedAndReadBackWithItsModesOfUse() {
|
||||
Key created = createAesKey();
|
||||
|
||||
assertThat(created.keyArn()).isNotBlank();
|
||||
assertThat(created.keyState()).isEqualTo(KeyState.CREATE_COMPLETE);
|
||||
assertThat(created.keyCheckValueAlgorithm()).isEqualTo(KeyCheckValueAlgorithm.CMAC);
|
||||
assertThat(created.keyCheckValue()).isNotBlank();
|
||||
assertThat(created.enabled()).isTrue();
|
||||
assertThat(created.exportable()).isTrue();
|
||||
|
||||
KeyAttributes attributes = created.keyAttributes();
|
||||
assertThat(attributes.keyAlgorithm()).isEqualTo(KeyAlgorithm.AES_256);
|
||||
assertThat(attributes.keyClass()).isEqualTo(KeyClass.SYMMETRIC_KEY);
|
||||
assertThat(attributes.keyUsage()).isEqualTo(KeyUsage.TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY);
|
||||
// The modes of use are a nested structure, and the answer must carry the ones asked for.
|
||||
assertThat(attributes.keyModesOfUse()).isNotNull();
|
||||
assertThat(attributes.keyModesOfUse().encrypt()).isTrue();
|
||||
assertThat(attributes.keyModesOfUse().decrypt()).isTrue();
|
||||
|
||||
Key read = client.getKey(k -> k.keyIdentifier(created.keyArn())).key();
|
||||
assertThat(read.keyArn()).isEqualTo(created.keyArn());
|
||||
assertThat(read.keyAttributes().keyAlgorithm()).isEqualTo(KeyAlgorithm.AES_256);
|
||||
assertThat(read.keyAttributes().keyModesOfUse().encrypt()).isTrue();
|
||||
assertThat(read.keyAttributes().keyModesOfUse().decrypt()).isTrue();
|
||||
assertThat(read.keyCheckValue()).isEqualTo(created.keyCheckValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyIsCreatedDisabledAndWithTags() {
|
||||
Key key = client.createKey(r -> r
|
||||
.keyAttributes(a -> a
|
||||
.keyAlgorithm(KeyAlgorithm.AES_256)
|
||||
.keyClass(KeyClass.SYMMETRIC_KEY)
|
||||
.keyUsage(KeyUsage.TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY)
|
||||
.keyModesOfUse(m -> m.encrypt(true)))
|
||||
.exportable(false)
|
||||
.enabled(false)
|
||||
.tags(Tag.builder().key("owner").value("team").build()))
|
||||
.key();
|
||||
keyArns.add(key.keyArn());
|
||||
|
||||
assertThat(key.enabled()).isFalse();
|
||||
assertThat(key.exportable()).isFalse();
|
||||
|
||||
Map<String, String> tags = client.listTagsForResource(t -> t.resourceArn(key.keyArn())).tags()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Tag::key, Tag::value, (a, b) -> a));
|
||||
assertThat(tags).containsEntry("owner", "team");
|
||||
}
|
||||
|
||||
@Test
|
||||
void theKeysAreListedAPageAtATime() {
|
||||
createAesKey();
|
||||
createAesKey();
|
||||
|
||||
ListKeysResponse first = client.listKeys(r -> r.maxResults(1));
|
||||
assertThat(first.keys()).hasSize(1);
|
||||
assertThat(first.nextToken()).isNotNull();
|
||||
|
||||
ListKeysResponse second = client.listKeys(r -> r.maxResults(1).nextToken(first.nextToken()));
|
||||
assertThat(second.keys()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void theKeysOfTheRegionAreListed() {
|
||||
Key key = createAesKey();
|
||||
|
||||
assertThat(client.listKeys(r -> r.maxResults(100)).keys())
|
||||
.anySatisfy(listed -> assertThat(listed.keyArn()).isEqualTo(key.keyArn()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theAliasOfAKeyIsCreatedAndReadBack() {
|
||||
Key key = createAesKey();
|
||||
String alias = "alias/compat/" + keyIdOf(key.keyArn());
|
||||
aliasNames.add(alias);
|
||||
|
||||
client.createAlias(a -> a.aliasName(alias).keyArn(key.keyArn()));
|
||||
|
||||
Alias read = client.getAlias(a -> a.aliasName(alias)).alias();
|
||||
assertThat(read.aliasName()).isEqualTo(alias);
|
||||
assertThat(read.keyArn()).isEqualTo(key.keyArn());
|
||||
assertThat(client.listAliases(r -> r.maxResults(100)).aliases())
|
||||
.anySatisfy(listed -> assertThat(listed.aliasName()).isEqualTo(alias));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyIsTaggedAndTheTagsAreListed() {
|
||||
Key key = createAesKey();
|
||||
|
||||
client.tagResource(t -> t
|
||||
.resourceArn(key.keyArn())
|
||||
.tags(Tag.builder().key("owner").value("compat").build()));
|
||||
|
||||
Map<String, String> tags = client.listTagsForResource(t -> t.resourceArn(key.keyArn())).tags()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Tag::key, Tag::value, (a, b) -> a));
|
||||
assertThat(tags).containsEntry("owner", "compat");
|
||||
}
|
||||
|
||||
/**
|
||||
* A delete answers with the key it deleted, its state DELETE_PENDING and the
|
||||
* moment it is deleted, so a caller reads the key and not an empty answer.
|
||||
*/
|
||||
@Test
|
||||
void aDeletedKeyIsAnsweredWithTheKey() {
|
||||
Key created = createAesKey();
|
||||
|
||||
Key deleted = client.deleteKey(k -> k.keyIdentifier(created.keyArn())).key();
|
||||
|
||||
assertThat(deleted).isNotNull();
|
||||
assertThat(deleted.keyArn()).isEqualTo(created.keyArn());
|
||||
assertThat(deleted.keyState()).isEqualTo(KeyState.DELETE_PENDING);
|
||||
assertThat(deleted.deletePendingTimestamp()).isNotNull();
|
||||
assertThat(deleted.enabled()).isFalse();
|
||||
}
|
||||
|
||||
/** A listing names the state of the keys it wants, and the service answers with those keys alone. */
|
||||
@Test
|
||||
void theKeysAreListedByTheirState() {
|
||||
Key key = createAesKey();
|
||||
|
||||
assertThat(client.listKeys(r -> r.keyState(KeyState.CREATE_COMPLETE).maxResults(100)).keys())
|
||||
.anySatisfy(listed -> assertThat(listed.keyArn()).isEqualTo(key.keyArn()));
|
||||
assertThat(client.listKeys(r -> r.keyState(KeyState.DELETE_PENDING).maxResults(100)).keys())
|
||||
.noneSatisfy(listed -> assertThat(listed.keyArn()).isEqualTo(key.keyArn()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The key of an alias is optional, so an update naming no key removes the key
|
||||
* the alias names, and the alias stays.
|
||||
*/
|
||||
@Test
|
||||
void anAliasIsDetachedFromItsKeyByAnUpdateNamingNoKey() {
|
||||
Key key = createAesKey();
|
||||
String alias = "alias/compat/detached-" + keyIdOf(key.keyArn());
|
||||
aliasNames.add(alias);
|
||||
|
||||
client.createAlias(a -> a.aliasName(alias).keyArn(key.keyArn()));
|
||||
|
||||
Alias detached = client.updateAlias(a -> a.aliasName(alias)).alias();
|
||||
|
||||
assertThat(detached.aliasName()).isEqualTo(alias);
|
||||
assertThat(detached.keyArn()).isNull();
|
||||
assertThat(client.getAlias(a -> a.aliasName(alias)).alias().aliasName()).isEqualTo(alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* A region the creating client did not sign for. It has to differ from the
|
||||
* region of the suite, or the key would be in that region too and the key
|
||||
* would be found.
|
||||
*/
|
||||
private static Region anotherRegion() {
|
||||
Region region = TestFixtures.region();
|
||||
if (region.id().startsWith("cn-")) {
|
||||
return region.id().equals("cn-northwest-1")
|
||||
? Region.of("cn-north-1") : Region.of("cn-northwest-1");
|
||||
}
|
||||
return Region.US_WEST_2.equals(region) ? Region.US_EAST_1 : Region.US_WEST_2;
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyOfOneRegionIsNotFoundInAnother() {
|
||||
Key key = createAesKey();
|
||||
PaymentCryptographyClient elsewhere = TestFixtures.paymentCryptographyClient(anotherRegion());
|
||||
try {
|
||||
// The key is named by its ARN, as the model takes it: a bare id names no key at all.
|
||||
assertThatThrownBy(() -> elsewhere.getKey(k -> k.keyIdentifier(key.keyArn())))
|
||||
.isInstanceOf(AwsServiceException.class)
|
||||
.satisfies(thrown -> assertThat(((AwsServiceException) thrown).awsErrorDetails()
|
||||
.errorCode()).isEqualTo("ResourceNotFoundException"));
|
||||
} finally {
|
||||
elsewhere.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +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 | 29 |
|
||||
| [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 | 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 |
|
||||
| [SWF](swf.md) | `POST /` + `X-Amz-Target: SimpleWorkflowService.*` | JSON 1.0 | 39 |
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# Payment Cryptography
|
||||
|
||||
**Protocol:** JSON 1.0 (`X-Amz-Target: PaymentCryptographyControlPlane.*`)
|
||||
**Endpoint:** `POST http://localhost:4566/`
|
||||
|
||||
## Supported Actions
|
||||
|
||||
<!-- floci:actions:start -->
|
||||
| Action | Description |
|
||||
| --- | --- |
|
||||
| `CreateKey` | Create a key with fresh AES-256 material |
|
||||
| `GetKey` | Get a key's attributes, state and check value |
|
||||
| `ListKeys` | List the keys of a region |
|
||||
| `DeleteKey` | Delete a key |
|
||||
| `CreateAlias` | Point an alias name at a key |
|
||||
| `GetAlias` | Get the key an alias name points at |
|
||||
| `ListAliases` | List the aliases of a region |
|
||||
| `UpdateAlias` | Point an alias name at another key |
|
||||
| `DeleteAlias` | Remove an alias name |
|
||||
| `TagResource` | Add tags to a key |
|
||||
| `UntagResource` | Remove tags from a key |
|
||||
| `ListTagsForResource` | List the tags of a key |
|
||||
<!-- floci:actions:end -->
|
||||
|
||||
## Emulation Behavior
|
||||
|
||||
- **Real key material:** `CreateKey` generates 32 bytes of AES-256 material, and the
|
||||
`KeyCheckValue` is the leftmost three bytes of the CMAC of sixteen zero bytes under
|
||||
it, which is what the service computes for a `CMAC` check value. The material is
|
||||
held by the key while the emulator runs and is not written to the store.
|
||||
- **Regional:** keys, aliases and tags all live in the region they were made in. The
|
||||
service is regional, and so is this.
|
||||
- **Alias names are unique in a region, not in an account:** the same name may name a
|
||||
key in two regions, and the two are two aliases. A name that is already taken in
|
||||
the key's own region is a `ConflictException`.
|
||||
- **Tags are the region's:** they are not part of the replication process, so a key in
|
||||
another region carries its own tag set, and tagging one leaves the others alone.
|
||||
- **Deletion:** `DeleteKey` removes the key and the aliases that name it, and answers
|
||||
with the key, its state `DELETE_PENDING` and the moment its deletion takes effect.
|
||||
A key that is gone does not come back: a tagging request for it is refused. The
|
||||
service deletes a key the moment it is asked to, so the waiting period of
|
||||
`DeleteKeyInDays` is read and checked but not waited for.
|
||||
- **Creating a key:** `CreateKey` takes `Exportable`, `Enabled` and `Tags`, and a key
|
||||
created disabled or with tags comes back that way. The `KeyUsage` and the
|
||||
`KeyModesOfUse` of the key are required, as the reference requires them. The answer
|
||||
carries every mode of use the reference gives a key, the ones the key was not made
|
||||
with as false, so a caller reading them finds a boolean for each of them. The check
|
||||
value is a CMAC, which is the only algorithm this service computes, so a request
|
||||
naming another one is refused.
|
||||
- **Which key a request may name:** `KeyIdentifier` takes the ARN of a key, the ARN of
|
||||
an alias or the name of an alias, while `KeyArn` and `ResourceArn` take the ARN of
|
||||
a key alone, as the reference states them. A request naming a key another way is
|
||||
refused, and the permission check reads the same member the request does.
|
||||
- **Listing by state:** `ListKeys` takes a `KeyState` and answers with the keys in
|
||||
that state alone, and with every key when it names none.
|
||||
- **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
|
||||
only the name.
|
||||
- **Paging:** `ListKeys`, `ListAliases` and `ListTagsForResource` take `MaxResults`
|
||||
and `NextToken`, and answer with one page and the token that asks for the next.
|
||||
- **Not yet emulated:** the data plane (`POST /encrypt` and the rest), the import and
|
||||
export formats, and the multi-region replication operations.
|
||||
|
||||
## Configuration
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `FLOCI_SERVICES_PAYMENTCRYPTOGRAPHY_ENABLED` | `true` | Enable or disable the service |
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
export AWS_ENDPOINT_URL=http://localhost:4566
|
||||
|
||||
# Create a key
|
||||
KEY_ARN=$(aws payment-cryptography create-key \
|
||||
--key-attributes 'KeyAlgorithm=AES_256,KeyClass=SYMMETRIC_KEY,KeyUsage=TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY,KeyModesOfUse={Encrypt=true,Decrypt=true}' \
|
||||
--exportable \
|
||||
--query Key.KeyArn --output text)
|
||||
|
||||
# Name it
|
||||
aws payment-cryptography create-alias \
|
||||
--alias-name alias/team/card-key --key-arn "$KEY_ARN"
|
||||
|
||||
# Tag it
|
||||
aws payment-cryptography tag-resource \
|
||||
--resource-arn "$KEY_ARN" \
|
||||
--tags Key=Origin,Value=PRIMARY
|
||||
|
||||
# Read it back
|
||||
aws payment-cryptography get-key --key-identifier "$KEY_ARN"
|
||||
```
|
||||
@@ -170,6 +170,7 @@ nav:
|
||||
- AppIntegrations: services/appintegrations.md
|
||||
- Amazon Data Lifecycle Manager: services/dlm.md
|
||||
- ACM: services/acm.md
|
||||
- Payment Cryptography: services/payment-cryptography.md
|
||||
- ECS: services/ecs.md
|
||||
- ECR: services/ecr.md
|
||||
- AWS Resource Groups: services/resource-groups.md
|
||||
|
||||
@@ -366,6 +366,7 @@ public interface EmulatorConfig {
|
||||
CloudWatchLogsStorageConfig cloudwatchlogs();
|
||||
CloudWatchMetricsStorageConfig cloudwatchmetrics();
|
||||
SecretsManagerStorageConfig secretsmanager();
|
||||
PaymentCryptographyStorageConfig paymentcryptography();
|
||||
AcmStorageConfig acm();
|
||||
OpenSearchStorageConfig opensearch();
|
||||
AppConfigStorageConfig appconfig();
|
||||
@@ -488,6 +489,13 @@ public interface EmulatorConfig {
|
||||
long flushIntervalMs();
|
||||
}
|
||||
|
||||
interface PaymentCryptographyStorageConfig {
|
||||
Optional<String> mode();
|
||||
|
||||
@WithDefault("5000")
|
||||
long flushIntervalMs();
|
||||
}
|
||||
|
||||
interface AcmStorageConfig {
|
||||
Optional<String> mode();
|
||||
|
||||
@@ -771,6 +779,7 @@ public interface EmulatorConfig {
|
||||
CloudWatchLogsServiceConfig cloudwatchlogs();
|
||||
CloudWatchMetricsServiceConfig cloudwatchmetrics();
|
||||
SecretsManagerServiceConfig secretsmanager();
|
||||
PaymentCryptographyServiceConfig paymentcryptography();
|
||||
ApiGatewayV2ServiceConfig apigatewayv2();
|
||||
KinesisServiceConfig kinesis();
|
||||
FirehoseServiceConfig firehose();
|
||||
@@ -2112,6 +2121,11 @@ public interface EmulatorConfig {
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface PaymentCryptographyServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface SecretsManagerServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.github.hectorvent.floci.services.dynamodb.DynamoDbResponses;
|
||||
import io.github.hectorvent.floci.services.dynamodb.DynamoDbStreamsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.marketplace.MarketplaceJsonHandler;
|
||||
import io.github.hectorvent.floci.services.networkfirewall.NetworkFirewallJsonHandler;
|
||||
import io.github.hectorvent.floci.services.paymentcryptography.PaymentCryptographyJsonHandler;
|
||||
import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.stepfunctions.StepFunctionsJsonHandler;
|
||||
@@ -62,6 +63,7 @@ public class AwsJsonController {
|
||||
private final CloudControlJsonHandler cloudControlJsonHandler;
|
||||
private final SwfJsonHandler swfJsonHandler;
|
||||
private final NetworkFirewallJsonHandler networkFirewallJsonHandler;
|
||||
private final PaymentCryptographyJsonHandler paymentCryptographyJsonHandler;
|
||||
private final MarketplaceJsonHandler marketplaceJsonHandler;
|
||||
private final VerifiedPermissionsJsonHandler verifiedPermissionsJsonHandler;
|
||||
private final BcmPricingCalculatorJsonHandler bcmPricingCalculatorJsonHandler;
|
||||
@@ -78,6 +80,7 @@ public class AwsJsonController {
|
||||
CloudControlJsonHandler cloudControlJsonHandler,
|
||||
SwfJsonHandler swfJsonHandler,
|
||||
NetworkFirewallJsonHandler networkFirewallJsonHandler,
|
||||
PaymentCryptographyJsonHandler paymentCryptographyJsonHandler,
|
||||
MarketplaceJsonHandler marketplaceJsonHandler,
|
||||
VerifiedPermissionsJsonHandler verifiedPermissionsJsonHandler,
|
||||
BcmPricingCalculatorJsonHandler bcmPricingCalculatorJsonHandler,
|
||||
@@ -95,6 +98,7 @@ public class AwsJsonController {
|
||||
this.cloudControlJsonHandler = cloudControlJsonHandler;
|
||||
this.swfJsonHandler = swfJsonHandler;
|
||||
this.networkFirewallJsonHandler = networkFirewallJsonHandler;
|
||||
this.paymentCryptographyJsonHandler = paymentCryptographyJsonHandler;
|
||||
this.marketplaceJsonHandler = marketplaceJsonHandler;
|
||||
this.verifiedPermissionsJsonHandler = verifiedPermissionsJsonHandler;
|
||||
this.bcmPricingCalculatorJsonHandler = bcmPricingCalculatorJsonHandler;
|
||||
@@ -187,6 +191,10 @@ public class AwsJsonController {
|
||||
action, request, region, regionResolver.getAccountId());
|
||||
case "network-firewall" -> networkFirewallJsonHandler.handle(
|
||||
action, request, region, regionResolver.getAccountId());
|
||||
// The control plane of Payment Cryptography is an awsJson 1.0 service: the
|
||||
// AWS SDK sends application/x-amz-json-1.0 and targets
|
||||
// PaymentCryptographyControlPlane.<Operation>.
|
||||
case "paymentcryptography" -> paymentCryptographyJsonHandler.handle(action, request, region);
|
||||
case "marketplace" -> marketplaceJsonHandler.handle(action, request, region);
|
||||
case "verifiedpermissions" -> verifiedPermissionsJsonHandler.handle(action, request, region);
|
||||
case "bcm-pricing-calculator" -> bcmPricingCalculatorJsonHandler.handle(action, request, region);
|
||||
|
||||
@@ -78,6 +78,7 @@ public final class RequestConstraintCheck {
|
||||
case "structure", "map" -> value.isObject();
|
||||
case "list" -> value.isArray();
|
||||
case "string" -> value.isTextual();
|
||||
case "boolean" -> value.isBoolean();
|
||||
case "integer", "long" -> value.isIntegralNumber() && value.canConvertToLong();
|
||||
default -> false;
|
||||
};
|
||||
|
||||
@@ -374,22 +374,23 @@ public final class RequestResources {
|
||||
}
|
||||
|
||||
/**
|
||||
* The ARN of a resource of a type whose service follows its name with an id it mints: the one {@code stored}
|
||||
* finds the caller's resource of that name under in the Region, or else the ARN with that id open; any other
|
||||
* type's as rendered.
|
||||
* The ARN of a resource the namespace's service stores under the name the request gives: the one {@code stored}
|
||||
* finds the caller's resource of that name under in the Region.
|
||||
*
|
||||
* <p>The service is asked for every type of the namespace, not only for the ones whose ARN carries an id it
|
||||
* mints, so a service may answer for a type whose ARN it does not mint: a key an alias names is the key the
|
||||
* alias points at. A type whose service follows its name with an id it mints has that id open when the service
|
||||
* stores none, and any other type's is as rendered.
|
||||
*/
|
||||
private static String withId(String arn, RequestResourceMembers.ArnFormat format, String type,
|
||||
Map<String, String> filling, StoredResourceArns stored, String region) {
|
||||
if (!format.minted()) {
|
||||
return arn;
|
||||
}
|
||||
if (stored != null && filling.size() == 1) {
|
||||
Optional<String> found = stored.find(type, List.of(filling.values().iterator().next()), region);
|
||||
if (found.isPresent()) {
|
||||
return found.get();
|
||||
}
|
||||
}
|
||||
return arn + "/*";
|
||||
return format.minted() ? arn + "/*" : arn;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -290,6 +290,16 @@ public class ResolvedServiceCatalog {
|
||||
protocols(ServiceProtocol.QUERY, ServiceProtocol.JSON, ServiceProtocol.CBOR),
|
||||
Set.of("GraniteServiceVersion20100801."), Set.of("monitoring"),
|
||||
Set.of("GraniteServiceVersion20100801"), Set.of(), "CloudWatchVersion20130116."),
|
||||
descriptor("paymentcryptography", "paymentcryptography",
|
||||
config.services().paymentcryptography().enabled(), true,
|
||||
"paymentcryptography",
|
||||
storageMode(config.storage().services().paymentcryptography().mode(),
|
||||
config.storage().mode()),
|
||||
config.storage().services().paymentcryptography().flushIntervalMs(), null,
|
||||
ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("PaymentCryptographyControlPlane."), Set.of("payment-cryptography"),
|
||||
Set.of(), Set.of()),
|
||||
descriptor("secretsmanager", "secretsmanager", config.services().secretsmanager().enabled(), true,
|
||||
"secretsmanager", storageMode(config.storage().services().secretsmanager().mode(), config.storage().mode()),
|
||||
config.storage().services().secretsmanager().flushIntervalMs(), null, ServiceProtocol.JSON,
|
||||
|
||||
@@ -4,15 +4,20 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Finds the ARN a service stores a resource under, for a type of the request-resources table whose ARN carries an id
|
||||
* the service mints, which only the service knows: after the name a request gives ({@code connection/<name>/<id>}),
|
||||
* or as all of it, a request naming the resource by members its ARN does not hold
|
||||
* Finds the ARN a service stores a resource under, for a type of the request-resources table whose ARN only that
|
||||
* service knows: after the name a request gives ({@code connection/<name>/<id>}), or as all of it, a request naming
|
||||
* the resource by members its ARN does not hold
|
||||
* ({@code scalable-target/<id>}, named by its service namespace, resource id and scalable dimension;
|
||||
* {@code workgroup/<id>}, named by its name).
|
||||
*
|
||||
* <p>The reader asks for every type of the namespace, not only for the ones whose ARN carries an id the service
|
||||
* mints, so a service may answer for a type whose ARN it does not mint: a key an alias names is the key the alias
|
||||
* points at.
|
||||
*
|
||||
* <p>Implemented by the service that owns such resources or whose requests name them (EventBridge, for its
|
||||
* connections and API destinations; Application Auto Scaling, for its scalable targets; Redshift Data, for the
|
||||
* Redshift Serverless workgroups it runs statements on); looked up lazily by {@code ResourceArnBuilder} through
|
||||
* Redshift Serverless workgroups it runs statements on; Payment Cryptography, for the key an alias names);
|
||||
* looked up lazily by {@code ResourceArnBuilder} through
|
||||
* {@code Instance<StoredResourceArns>} for the namespace a request is of, so IAM never depends on that service
|
||||
* directly.</p>
|
||||
*/
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The cryptography a key record needs: its material, and its check value.
|
||||
*
|
||||
* <p>The check value of an AES key is the leftmost three bytes of the CMAC of
|
||||
* sixteen zero bytes under the key. That is what the service computes for a
|
||||
* CMAC check value, and what the reference implementation its samples use
|
||||
* computes.
|
||||
*
|
||||
* <p>The CMAC is the one RFC 4493 gives, so a key's check value is the one
|
||||
* the standard's vectors give and a message of any length is authenticated
|
||||
* the way the standard says.
|
||||
*/
|
||||
final class PaymentCryptographyCrypto {
|
||||
|
||||
/** The block size of AES, in bytes. */
|
||||
private static final int BLOCK_SIZE = 16;
|
||||
|
||||
private static final byte[] ZERO_BLOCK = new byte[BLOCK_SIZE];
|
||||
|
||||
/** The Rijndael constant the subkey derivation exclusive-oreds in when the shift carries out. */
|
||||
private static final int RB = 0x87;
|
||||
|
||||
private PaymentCryptographyCrypto() {
|
||||
}
|
||||
|
||||
/** Fresh AES-256 material, as hexadecimal. */
|
||||
static String randomAes256Hex(SecureRandom random) {
|
||||
byte[] material = new byte[32];
|
||||
random.nextBytes(material);
|
||||
return toHex(material);
|
||||
}
|
||||
|
||||
/** The check value of an AES key: the leftmost three bytes of the CMAC of sixteen zero bytes. */
|
||||
static String checkValue(String keyHex) {
|
||||
byte[] mac = cmac(fromHex(keyHex), ZERO_BLOCK);
|
||||
return toHex(Arrays.copyOf(mac, 3)).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
/**
|
||||
* The AES-CMAC of a message under a key, as RFC 4493 gives it.
|
||||
*
|
||||
* <p>The message is divided into blocks and chained as CBC-MAC. A last
|
||||
* block of the block size is exclusive-ored with K1, and one shorter is
|
||||
* padded with a single one bit and exclusive-ored with K2, as the RFC
|
||||
* says.
|
||||
*/
|
||||
static byte[] cmac(byte[] key, byte[] message) {
|
||||
try {
|
||||
byte[] k1 = shiftLeft(encrypt(ZERO_BLOCK, key));
|
||||
byte[] k2 = shiftLeft(k1);
|
||||
int blocks = (message.length + BLOCK_SIZE - 1) / BLOCK_SIZE;
|
||||
boolean complete = message.length > 0 && message.length % BLOCK_SIZE == 0;
|
||||
if (blocks == 0) {
|
||||
blocks = 1;
|
||||
}
|
||||
byte[] last = new byte[BLOCK_SIZE];
|
||||
int offset = (blocks - 1) * BLOCK_SIZE;
|
||||
if (complete) {
|
||||
System.arraycopy(message, offset, last, 0, BLOCK_SIZE);
|
||||
last = xor(last, k1);
|
||||
} else {
|
||||
int remaining = message.length - offset;
|
||||
System.arraycopy(message, offset, last, 0, remaining);
|
||||
last[remaining] = (byte) 0x80;
|
||||
last = xor(last, k2);
|
||||
}
|
||||
byte[] chain = ZERO_BLOCK;
|
||||
for (int i = 0; i < blocks - 1; i++) {
|
||||
byte[] block = new byte[BLOCK_SIZE];
|
||||
System.arraycopy(message, i * BLOCK_SIZE, block, 0, BLOCK_SIZE);
|
||||
chain = encrypt(xor(chain, block), key);
|
||||
}
|
||||
return encrypt(xor(chain, last), key);
|
||||
} catch (GeneralSecurityException e) {
|
||||
throw new IllegalStateException("the AES key could not be used", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A block shifted left by one bit, with Rijndael's Rb exclusive-ored in
|
||||
* when the shift carried out of the top.
|
||||
*
|
||||
* <p>The bit that falls off the top of the block comes from the byte
|
||||
* above it, so the carry travels down the block.
|
||||
*/
|
||||
private static byte[] shiftLeft(byte[] block) {
|
||||
byte[] shifted = new byte[BLOCK_SIZE];
|
||||
int carry = 0;
|
||||
for (int i = BLOCK_SIZE - 1; i >= 0; i--) {
|
||||
int nextCarry = (block[i] & 0x80) != 0 ? 1 : 0;
|
||||
shifted[i] = (byte) (((block[i] << 1) | carry) & 0xff);
|
||||
carry = nextCarry;
|
||||
}
|
||||
if ((block[0] & 0x80) != 0) {
|
||||
shifted[BLOCK_SIZE - 1] ^= (byte) RB;
|
||||
}
|
||||
return shifted;
|
||||
}
|
||||
|
||||
private static byte[] xor(byte[] left, byte[] right) {
|
||||
byte[] out = new byte[left.length];
|
||||
for (int i = 0; i < left.length; i++) {
|
||||
out[i] = (byte) (left[i] ^ right[i % right.length]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** One block of AES in ECB mode, the block cipher the CMAC is built on. */
|
||||
private static byte[] encrypt(byte[] input, byte[] key) throws GeneralSecurityException {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
|
||||
return cipher.doFinal(input);
|
||||
}
|
||||
|
||||
static String toHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder(bytes.length * 2);
|
||||
for (byte b : bytes) {
|
||||
sb.append(Character.forDigit((b >> 4) & 0x0f, 16));
|
||||
sb.append(Character.forDigit(b & 0x0f, 16));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static byte[] fromHex(String hex) {
|
||||
int length = hex.length() / 2;
|
||||
byte[] out = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
out[i] = (byte) Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
+362
@@ -0,0 +1,362 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.services.paymentcryptography.model.PaymentCryptographyAlias;
|
||||
import io.github.hectorvent.floci.services.paymentcryptography.model.PaymentCryptographyKey;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The Payment Cryptography control plane.
|
||||
*
|
||||
* <p>The service's control plane is JSON 1.1: the operation is named in the
|
||||
* {@code X-Amz-Target} header and the body is a JSON object.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class PaymentCryptographyJsonHandler {
|
||||
|
||||
/** The error a bad page size or a bad token is refused with. */
|
||||
private static final String PAGINATION_ERROR = "ValidationException";
|
||||
|
||||
private final PaymentCryptographyService service;
|
||||
|
||||
@Inject
|
||||
public PaymentCryptographyJsonHandler(PaymentCryptographyService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
/** The actions whose requests are checked against the vendored model constraints first. */
|
||||
private static final Set<String> MODEL_CHECKED = Set.of(
|
||||
"CreateKey", "GetKey", "ListKeys", "DeleteKey",
|
||||
"CreateAlias", "GetAlias", "ListAliases", "UpdateAlias", "DeleteAlias",
|
||||
"TagResource", "UntagResource", "ListTagsForResource");
|
||||
|
||||
public Response handle(String action, JsonNode request, String region) {
|
||||
if (MODEL_CHECKED.contains(action)) {
|
||||
PaymentCryptographyRequestShapes.check(action, request);
|
||||
}
|
||||
return switch (action) {
|
||||
case "CreateKey" -> Response.ok(createKey(request, region)).build();
|
||||
case "GetKey" -> Response.ok(getKey(request, region)).build();
|
||||
case "ListKeys" -> Response.ok(listKeys(request, region)).build();
|
||||
case "DeleteKey" -> Response.ok(deleteKey(request, region)).build();
|
||||
case "CreateAlias" -> Response.ok(createAlias(request, region)).build();
|
||||
case "GetAlias" -> Response.ok(getAlias(request, region)).build();
|
||||
case "ListAliases" -> Response.ok(listAliases(request, region)).build();
|
||||
case "UpdateAlias" -> Response.ok(updateAlias(request, region)).build();
|
||||
case "DeleteAlias" -> Response.ok(deleteAlias(request, region)).build();
|
||||
case "TagResource" -> Response.ok(tagResource(request, region)).build();
|
||||
case "UntagResource" -> Response.ok(untagResource(request, region)).build();
|
||||
case "ListTagsForResource" -> Response.ok(listTagsForResource(request, region)).build();
|
||||
default -> throw new AwsException("UnknownOperationException",
|
||||
"Operation " + action + " is not supported by floci", 400);
|
||||
};
|
||||
}
|
||||
|
||||
// ---- keys ---------------------------------------------------------------
|
||||
|
||||
private Map<String, Object> createKey(JsonNode request, String region) {
|
||||
JsonNode attributes = request.get("KeyAttributes");
|
||||
if (attributes == null || !attributes.isObject()) {
|
||||
throw new AwsException("ValidationException", "KeyAttributes is required", 400);
|
||||
}
|
||||
// The service requires the usage and the modes of use of a key, as the
|
||||
// reference does: a key without them says nothing about what it is for.
|
||||
if (!attributes.hasNonNull("KeyUsage")) {
|
||||
throw new AwsException("ValidationException", "KeyAttributes.KeyUsage is required", 400);
|
||||
}
|
||||
if (!attributes.hasNonNull("KeyModesOfUse")) {
|
||||
throw new AwsException("ValidationException", "KeyAttributes.KeyModesOfUse is required", 400);
|
||||
}
|
||||
Map<String, Object> declared = new LinkedHashMap<>();
|
||||
attributes.fields().forEachRemaining(entry -> {
|
||||
// KeyModesOfUse is a nested structure, not a name: it is read below
|
||||
// as its own map, and stringifying it here would lose the modes.
|
||||
if (!"KeyModesOfUse".equals(entry.getKey())) {
|
||||
declared.put(entry.getKey(), entry.getValue().asText());
|
||||
}
|
||||
});
|
||||
// The check value of an AES key is a CMAC, which is the only algorithm this
|
||||
// service computes, so a request naming another one is refused rather than
|
||||
// answered with a check value of another kind.
|
||||
if (request.hasNonNull("KeyCheckValueAlgorithm")
|
||||
&& !"CMAC".equals(request.get("KeyCheckValueAlgorithm").asText())) {
|
||||
throw new AwsException("ValidationException",
|
||||
"KeyCheckValueAlgorithm must be CMAC", 400);
|
||||
}
|
||||
// A key may be created disabled, and it may be created with tags.
|
||||
boolean enabled = request.has("Enabled") ? request.path("Enabled").asBoolean(true) : true;
|
||||
PaymentCryptographyKey key = service.createKey(region, declared, modesOfUse(attributes),
|
||||
request.path("Exportable").asBoolean(false), enabled, tagsOf(request));
|
||||
return Map.of("Key", keyObject(key));
|
||||
}
|
||||
|
||||
/** The key operations name their key in {@code KeyIdentifier}. */
|
||||
private static final String KEY_IDENTIFIER = "KeyIdentifier";
|
||||
|
||||
/** The alias operations name the key they point at in {@code KeyArn}. */
|
||||
private static final String KEY_ARN = "KeyArn";
|
||||
|
||||
/** The tagging operations name their key in {@code ResourceArn}. */
|
||||
private static final String RESOURCE_ARN = "ResourceArn";
|
||||
|
||||
/** The modes of use a key has, as the reference names them; the ones not asked for are false. */
|
||||
private static final List<String> MODES_OF_USE = List.of("Encrypt", "Decrypt", "Wrap", "Unwrap", "Generate",
|
||||
"Sign", "Verify", "DeriveKey", "NoRestrictions");
|
||||
|
||||
private Map<String, Object> getKey(JsonNode request, String region) {
|
||||
PaymentCryptographyKey key = requiredKey(request, region, KEY_IDENTIFIER);
|
||||
return Map.of("Key", keyObject(key));
|
||||
}
|
||||
|
||||
private Map<String, Object> listKeys(JsonNode request, String region) {
|
||||
String state = request.hasNonNull("KeyState") ? request.get("KeyState").asText() : null;
|
||||
PaginatedResult<PaymentCryptographyKey> page = service.listKeys(region, state,
|
||||
Pagination.parseMaxResults(request, "MaxResults", PAGINATION_ERROR),
|
||||
Pagination.parseNextToken(request, "NextToken", PAGINATION_ERROR));
|
||||
List<Map<String, Object>> keys = new ArrayList<>();
|
||||
for (PaymentCryptographyKey key : page.items()) {
|
||||
keys.add(keyObject(key));
|
||||
}
|
||||
Map<String, Object> out = new LinkedHashMap<>();
|
||||
out.put("Keys", keys);
|
||||
if (page.nextToken() != null) {
|
||||
out.put("NextToken", page.nextToken());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a key and answers with the key, as the reference does.
|
||||
*
|
||||
* <p>The waiting period the reference offers is read, and the key is
|
||||
* deleted at once all the same: the service deletes a key the moment it
|
||||
* is asked to.
|
||||
*/
|
||||
private Map<String, Object> deleteKey(JsonNode request, String region) {
|
||||
PaymentCryptographyKey key = service.deleteKey(requiredKey(request, region, KEY_IDENTIFIER));
|
||||
return Map.of("Key", keyObject(key));
|
||||
}
|
||||
|
||||
// ---- aliases ------------------------------------------------------------
|
||||
|
||||
private Map<String, Object> createAlias(JsonNode request, String region) {
|
||||
String aliasName = aliasName(request);
|
||||
// The model requires only the name of an alias, but the reference refuses one
|
||||
// without a key, so the request is refused the way it refuses it.
|
||||
if (!request.hasNonNull(KEY_ARN)) {
|
||||
throw new AwsException("ValidationException",
|
||||
"You can't create an alias without a key.", 400);
|
||||
}
|
||||
PaymentCryptographyKey key = requiredKey(request, region, KEY_ARN);
|
||||
PaymentCryptographyAlias alias = service.createAlias(aliasName, key);
|
||||
return Map.of("Alias", aliasObject(alias));
|
||||
}
|
||||
|
||||
private Map<String, Object> getAlias(JsonNode request, String region) {
|
||||
String aliasName = aliasName(request);
|
||||
PaymentCryptographyAlias alias = service.findAlias(region, aliasName);
|
||||
if (alias == null) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Alias " + aliasName + " is not found", 400);
|
||||
}
|
||||
return Map.of("Alias", aliasObject(alias));
|
||||
}
|
||||
|
||||
private Map<String, Object> listAliases(JsonNode request, String region) {
|
||||
String keyArn = request.hasNonNull("KeyArn") ? request.get("KeyArn").asText() : null;
|
||||
PaginatedResult<PaymentCryptographyAlias> page = service.listAliases(region,
|
||||
keyArn, Pagination.parseMaxResults(request, "MaxResults", PAGINATION_ERROR),
|
||||
Pagination.parseNextToken(request, "NextToken", PAGINATION_ERROR));
|
||||
List<Map<String, Object>> aliases = new ArrayList<>();
|
||||
for (PaymentCryptographyAlias alias : page.items()) {
|
||||
aliases.add(aliasObject(alias));
|
||||
}
|
||||
Map<String, Object> out = new LinkedHashMap<>();
|
||||
out.put("Aliases", aliases);
|
||||
if (page.nextToken() != null) {
|
||||
out.put("NextToken", page.nextToken());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Points an alias at a key, or removes the key it names when the request
|
||||
* names no key, as the reference does: the key of an alias is optional.
|
||||
*/
|
||||
private Map<String, Object> updateAlias(JsonNode request, String region) {
|
||||
String aliasName = aliasName(request);
|
||||
if (!request.hasNonNull(KEY_ARN)) {
|
||||
return Map.of("Alias", aliasObject(service.detachAlias(region, aliasName)));
|
||||
}
|
||||
PaymentCryptographyKey key = requiredKey(request, region, KEY_ARN);
|
||||
PaymentCryptographyAlias alias = service.updateAlias(aliasName, key);
|
||||
return Map.of("Alias", aliasObject(alias));
|
||||
}
|
||||
|
||||
private Map<String, Object> deleteAlias(JsonNode request, String region) {
|
||||
service.deleteAlias(region, aliasName(request));
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
// ---- tags ---------------------------------------------------------------
|
||||
|
||||
private Map<String, Object> tagResource(JsonNode request, String region) {
|
||||
PaymentCryptographyKey key = requiredKey(request, region, RESOURCE_ARN);
|
||||
service.tag(key, tagsOf(request));
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
private Map<String, Object> untagResource(JsonNode request, String region) {
|
||||
PaymentCryptographyKey key = requiredKey(request, region, RESOURCE_ARN);
|
||||
List<String> tagKeys = new ArrayList<>();
|
||||
JsonNode declared = request.get("TagKeys");
|
||||
if (declared != null && declared.isArray()) {
|
||||
for (JsonNode tagKey : declared) {
|
||||
tagKeys.add(tagKey.asText());
|
||||
}
|
||||
}
|
||||
service.untag(key, tagKeys);
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
private Map<String, Object> listTagsForResource(JsonNode request, String region) {
|
||||
PaymentCryptographyKey key = requiredKey(request, region, RESOURCE_ARN);
|
||||
PaginatedResult<Map.Entry<String, String>> page = service.listTags(key,
|
||||
Pagination.parseMaxResults(request, "MaxResults", PAGINATION_ERROR),
|
||||
Pagination.parseNextToken(request, "NextToken", PAGINATION_ERROR));
|
||||
List<Map<String, Object>> tags = new ArrayList<>();
|
||||
for (Map.Entry<String, String> tag : page.items()) {
|
||||
tags.add(Map.of("Key", tag.getKey(), "Value", tag.getValue()));
|
||||
}
|
||||
Map<String, Object> out = new LinkedHashMap<>();
|
||||
out.put("Tags", tags);
|
||||
if (page.nextToken() != null) {
|
||||
out.put("NextToken", page.nextToken());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** The tags of a request, as the name and the value of each. */
|
||||
private static Map<String, String> tagsOf(JsonNode request) {
|
||||
Map<String, String> tags = new LinkedHashMap<>();
|
||||
JsonNode declared = request.get("Tags");
|
||||
if (declared != null && declared.isArray()) {
|
||||
for (JsonNode tag : declared) {
|
||||
String tagKey = tag.path("Key").asText();
|
||||
if (tagKey.isEmpty()) {
|
||||
throw new AwsException("ValidationException", "each Tag requires Key", 400);
|
||||
}
|
||||
tags.put(tagKey, tag.path("Value").asText());
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
// ---- helpers ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The key's modes of use, as the request states them.
|
||||
*
|
||||
* <p>The attributes are read as text, and a mode is a boolean, so the
|
||||
* modes are read from the request itself rather than from the flattened
|
||||
* attributes: a boolean read as text is a string, and the key would come
|
||||
* back with no modes at all.
|
||||
*/
|
||||
private static Map<String, Boolean> modesOfUse(JsonNode attributes) {
|
||||
Map<String, Boolean> modes = new LinkedHashMap<>();
|
||||
JsonNode declared = attributes.get("KeyModesOfUse");
|
||||
if (declared != null && declared.isObject()) {
|
||||
declared.fields().forEachRemaining(entry -> {
|
||||
if (MODES_OF_USE.contains(entry.getKey())) {
|
||||
modes.put(entry.getKey(), entry.getValue().asBoolean());
|
||||
}
|
||||
});
|
||||
}
|
||||
return modes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The modes of use a key answers with: every mode the reference gives a key, the ones the key does not
|
||||
* have as false, so a caller reading them finds a boolean for each of them and none of them is null.
|
||||
*/
|
||||
private static Map<String, Boolean> answeredModes(PaymentCryptographyKey key) {
|
||||
Map<String, Boolean> modes = new LinkedHashMap<>();
|
||||
for (String mode : MODES_OF_USE) {
|
||||
modes.put(mode, Boolean.FALSE);
|
||||
}
|
||||
modes.putAll(key.getKeyModesOfUse());
|
||||
return modes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The key an operation names, in the member that operation names it in.
|
||||
*
|
||||
* <p>The key is named in a different member by each operation:
|
||||
* {@code KeyIdentifier} by the key operations, {@code KeyArn} by the alias ones, and
|
||||
* {@code ResourceArn} by the tagging ones. Only that member is read, so a request cannot
|
||||
* name one key for the permission check and another for the change: the IAM check reads
|
||||
* the same member this reads.
|
||||
*/
|
||||
private PaymentCryptographyKey requiredKey(JsonNode request, String region, String member) {
|
||||
String identifier = request.path(member).asText();
|
||||
if (identifier.isEmpty()) {
|
||||
throw new AwsException("ValidationException", member + " is required", 400);
|
||||
}
|
||||
PaymentCryptographyKey key = service.findKey(region, identifier);
|
||||
if (key == null) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Key not found: " + identifier, 400);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
private static String aliasName(JsonNode request) {
|
||||
return request.path("AliasName").asText();
|
||||
}
|
||||
|
||||
private static Map<String, Object> keyObject(PaymentCryptographyKey key) {
|
||||
Map<String, Object> out = new LinkedHashMap<>();
|
||||
out.put("KeyArn", key.getArn());
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
attributes.put("KeyAlgorithm", key.getKeyAlgorithm());
|
||||
attributes.put("KeyClass", key.getKeyClass());
|
||||
attributes.put("KeyUsage", key.getKeyUsage());
|
||||
attributes.put("KeyModesOfUse", answeredModes(key));
|
||||
out.put("KeyAttributes", attributes);
|
||||
out.put("KeyCheckValue", key.getKeyCheckValue());
|
||||
out.put("KeyCheckValueAlgorithm", key.getKeyCheckValueAlgorithm());
|
||||
out.put("KeyState", key.getKeyState());
|
||||
out.put("KeyOrigin", key.getKeyOrigin());
|
||||
out.put("Enabled", key.isEnabled());
|
||||
out.put("Exportable", key.isExportable());
|
||||
out.put("CreateTimestamp", key.getCreateTimestamp());
|
||||
out.put("UsageStartTimestamp", key.getUsageStartTimestamp());
|
||||
if (key.getDeletePendingTimestamp() > 0) {
|
||||
out.put("DeletePendingTimestamp", key.getDeletePendingTimestamp());
|
||||
}
|
||||
if (key.getDeleteTimestamp() > 0) {
|
||||
out.put("DeleteTimestamp", key.getDeleteTimestamp());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static Map<String, Object> aliasObject(PaymentCryptographyAlias alias) {
|
||||
Map<String, Object> out = new LinkedHashMap<>();
|
||||
out.put("AliasName", alias.getAliasName());
|
||||
if (alias.getKeyArn() != null) {
|
||||
out.put("KeyArn", alias.getKeyArn());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import jakarta.enterprise.context.RequestScoped;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* What this request resolved, kept for the request.
|
||||
*
|
||||
* <p>An alias names a key, and another request may move that alias to another key while this one
|
||||
* is running. The permission check resolves the alias to the key it names, and the request must act
|
||||
* on that key: a key resolved again afterwards could be one no policy was checked against.
|
||||
*/
|
||||
@RequestScoped
|
||||
public class PaymentCryptographyRequestContext {
|
||||
|
||||
/** The key an alias named, by the alias's name and the Region it is in. */
|
||||
private final Map<String, String> aliasKeyIds = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* The id of the key the alias named when this request resolved it, an empty one when it named
|
||||
* no key, and null when this request has not resolved the alias yet.
|
||||
*/
|
||||
String aliasKeyId(String region, String aliasName) {
|
||||
return aliasKeyIds.get(key(region, aliasName));
|
||||
}
|
||||
|
||||
/** Remembers the key the alias named, so that the request acts on that key and not another. */
|
||||
void pinAliasKeyId(String region, String aliasName, String keyId) {
|
||||
aliasKeyIds.put(key(region, aliasName), keyId);
|
||||
}
|
||||
|
||||
private static String key(String region, String aliasName) {
|
||||
return region + SEPARATOR + aliasName;
|
||||
}
|
||||
|
||||
/** The separator between the Region and the alias name, which neither of them carries. */
|
||||
private static final String SEPARATOR = "\u0000";
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RequestConstraintCheck;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Checks a Payment Cryptography request against the constraints vendored in
|
||||
* {@code aws/payment-cryptography-request-shapes.json} by
|
||||
* {@code tools/aws/regen_payment_cryptography_shapes.py}.
|
||||
*
|
||||
* <p>The patterns are what settle which key a request may name: {@code KeyIdentifier} takes the ARN
|
||||
* of a key, the ARN of an alias or the name of an alias, while {@code KeyArn} and {@code ResourceArn}
|
||||
* take the ARN of a key alone. A violation is a {@code ValidationException}, with the member's path
|
||||
* from the request's top level.
|
||||
*/
|
||||
final class PaymentCryptographyRequestShapes {
|
||||
|
||||
private static final RequestConstraintCheck CHECK = RequestConstraintCheck.load(
|
||||
"aws/payment-cryptography-request-shapes.json", "Payment Cryptography request shapes",
|
||||
new RequestConstraintCheck.Messages() {
|
||||
@Override
|
||||
public AwsException type(String path, String type) {
|
||||
return invalid(path, "Member must be a " + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AwsException bounds(String path, String type, Long min, Long max, long size) {
|
||||
String measure = "integer".equals(type) || "long".equals(type) ? "value" : "length";
|
||||
return min != null && size < min
|
||||
? invalid(path, "Member must have " + measure + " greater than or equal to " + min)
|
||||
: invalid(path, "Member must have " + measure + " less than or equal to " + max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AwsException pattern(String path, String pattern) {
|
||||
return invalid(path, "must satisfy regular expression '" + pattern + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AwsException enumValue(String path, List<String> values) {
|
||||
return invalid(path, "Member must satisfy enum value set: " + values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AwsException required(String path) {
|
||||
return invalid(path, "Member must not be null");
|
||||
}
|
||||
});
|
||||
|
||||
private PaymentCryptographyRequestShapes() {
|
||||
}
|
||||
|
||||
static void check(String operation, JsonNode request) {
|
||||
CHECK.check(operation, request);
|
||||
}
|
||||
|
||||
/** The member's path below the operation, with list elements folded into their list. */
|
||||
private static AwsException invalid(String path, String rule) {
|
||||
int dot = path.indexOf('.');
|
||||
String member = (dot < 0 ? "" : path.substring(dot + 1)).replace("[]", "");
|
||||
return new AwsException("ValidationException",
|
||||
"Invalid parameter at '" + member + "' failed to satisfy constraint: '" + rule + "'", 400);
|
||||
}
|
||||
}
|
||||
+474
@@ -0,0 +1,474 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.core.common.StoredResourceArns;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.paymentcryptography.model.PaymentCryptographyAlias;
|
||||
import io.github.hectorvent.floci.services.paymentcryptography.model.PaymentCryptographyKey;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The Payment Cryptography key store.
|
||||
*
|
||||
* <p>Keys, aliases and tags all live in the region they were made in. The
|
||||
* service is regional, and an alias name is unique in an account and a region
|
||||
* rather than in an account, so the same name may name a key in two regions
|
||||
* and the two are two aliases.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class PaymentCryptographyService implements Resettable, StoredResourceArns {
|
||||
|
||||
/** The storage key, which is the one the catalog's descriptor names. */
|
||||
private static final String STORAGE_KEY = "paymentcryptography";
|
||||
|
||||
/** The service in the ARN, which is the service's own name. */
|
||||
private static final String SERVICE = "payment-cryptography";
|
||||
|
||||
/** The number of results a listing returns when the caller asks for none. */
|
||||
private static final int DEFAULT_PAGE_SIZE = 50;
|
||||
|
||||
/** The most results a listing returns when the caller asks for a number. */
|
||||
private static final int MAX_RESULTS = 100;
|
||||
|
||||
/** The error a bad page size or a bad token is refused with. */
|
||||
private static final String PAGINATION_ERROR = "ValidationException";
|
||||
|
||||
/** The only algorithm this service makes material for. */
|
||||
private static final String SUPPORTED_ALGORITHM = "AES_256";
|
||||
|
||||
/** The only class this service makes material for. */
|
||||
private static final String SUPPORTED_CLASS = "SYMMETRIC_KEY";
|
||||
|
||||
private final StorageBackend<String, PaymentCryptographyKey> keyStore;
|
||||
private final StorageBackend<String, PaymentCryptographyAlias> aliasStore;
|
||||
private final RegionResolver regionResolver;
|
||||
private final SecureRandom secureRandom;
|
||||
private final PaymentCryptographyRequestContext requestContext;
|
||||
|
||||
@Inject
|
||||
public PaymentCryptographyService(StorageFactory storageFactory, RegionResolver regionResolver,
|
||||
PaymentCryptographyRequestContext requestContext) {
|
||||
this(storageFactory.create(STORAGE_KEY, "payment-cryptography-keys.json",
|
||||
new TypeReference<>() {}),
|
||||
storageFactory.create(STORAGE_KEY, "payment-cryptography-aliases.json",
|
||||
new TypeReference<>() {}),
|
||||
regionResolver,
|
||||
new SecureRandom(),
|
||||
requestContext);
|
||||
}
|
||||
|
||||
PaymentCryptographyService(StorageBackend<String, PaymentCryptographyKey> keyStore,
|
||||
StorageBackend<String, PaymentCryptographyAlias> aliasStore,
|
||||
RegionResolver regionResolver,
|
||||
PaymentCryptographyRequestContext requestContext) {
|
||||
this(keyStore, aliasStore, regionResolver, new SecureRandom(), requestContext);
|
||||
}
|
||||
|
||||
PaymentCryptographyService(StorageBackend<String, PaymentCryptographyKey> keyStore,
|
||||
StorageBackend<String, PaymentCryptographyAlias> aliasStore,
|
||||
RegionResolver regionResolver,
|
||||
SecureRandom secureRandom,
|
||||
PaymentCryptographyRequestContext requestContext) {
|
||||
this.keyStore = keyStore;
|
||||
this.aliasStore = aliasStore;
|
||||
this.regionResolver = regionResolver;
|
||||
this.secureRandom = secureRandom;
|
||||
this.requestContext = requestContext;
|
||||
}
|
||||
|
||||
// ---- keys ---------------------------------------------------------------
|
||||
|
||||
/** Creates a key with fresh AES-256 material. */
|
||||
public PaymentCryptographyKey createKey(String region, Map<String, Object> attributes,
|
||||
Map<String, Boolean> modesOfUse, boolean exportable,
|
||||
boolean enabled, Map<String, String> tags) {
|
||||
String algorithm = string(attributes, "KeyAlgorithm", "AES_256");
|
||||
String keyClass = string(attributes, "KeyClass", "SYMMETRIC_KEY");
|
||||
// The material is AES-256 and symmetric, so a key that says otherwise would be a key
|
||||
// whose attributes do not describe it.
|
||||
if (!SUPPORTED_ALGORITHM.equals(algorithm)) {
|
||||
throw new AwsException("ValidationException",
|
||||
"KeyAlgorithm '" + algorithm + "' is not supported, this service makes "
|
||||
+ SUPPORTED_ALGORITHM + " keys", 400);
|
||||
}
|
||||
if (!SUPPORTED_CLASS.equals(keyClass)) {
|
||||
throw new AwsException("ValidationException",
|
||||
"KeyClass '" + keyClass + "' is not supported, this service makes "
|
||||
+ SUPPORTED_CLASS + " keys", 400);
|
||||
}
|
||||
PaymentCryptographyKey key = new PaymentCryptographyKey();
|
||||
key.setKeyId(UUID.randomUUID().toString().replace("-", ""));
|
||||
key.setRegion(region);
|
||||
key.setArn(regionResolver.buildArn(SERVICE, region, "key/" + key.getKeyId()));
|
||||
key.setKeyAlgorithm(algorithm);
|
||||
key.setKeyClass(keyClass);
|
||||
key.setKeyUsage(usage(attributes));
|
||||
key.setKeyModesOfUse(modesOfUse);
|
||||
key.setExportable(exportable);
|
||||
key.setEnabled(enabled);
|
||||
key.setTags(new LinkedHashMap<>(tags));
|
||||
key.setKeyState("CREATE_COMPLETE");
|
||||
key.setKeyMaterialHex(PaymentCryptographyCrypto.randomAes256Hex(secureRandom));
|
||||
key.setKeyCheckValue(PaymentCryptographyCrypto.checkValue(key.getKeyMaterialHex()));
|
||||
key.setKeyCheckValueAlgorithm("CMAC");
|
||||
long now = Instant.now().getEpochSecond();
|
||||
key.setCreateTimestamp(now);
|
||||
key.setUsageStartTimestamp(now);
|
||||
keyStore.put(key.getKeyId(), key);
|
||||
return key;
|
||||
}
|
||||
|
||||
/** The key an identifier names, or null when there is none. */
|
||||
public PaymentCryptographyKey findKey(String region, String identifier) {
|
||||
if (identifier == null || identifier.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (identifier.startsWith("alias/")) {
|
||||
return keyOfAlias(region, identifier);
|
||||
}
|
||||
if (AwsArnUtils.looksLikeArn(identifier)) {
|
||||
Optional<String> resource = AwsArnUtils.resourceIfArnFor(identifier, SERVICE);
|
||||
if (resource.isPresent() && resource.get().startsWith("alias/")) {
|
||||
// The ARN names the alias in the Region, the account and the partition it was
|
||||
// minted in, so an alias of another one is not this Region's alias.
|
||||
String name = "alias/" + resource.get().substring("alias/".length());
|
||||
if (!identifier.equals(aliasArn(region, name))) {
|
||||
return null;
|
||||
}
|
||||
return keyOfAlias(region, name);
|
||||
}
|
||||
for (PaymentCryptographyKey key : keyStore.scan(k -> true)) {
|
||||
if (identifier.equals(key.getArn()) && region.equals(key.getRegion())) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
PaymentCryptographyKey byId = keyStore.get(identifier).orElse(null);
|
||||
return byId != null && region.equals(byId.getRegion()) ? byId : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The keys of a region, a page at a time.
|
||||
*
|
||||
* <p>The service answers with as many keys as the caller asks for, and a
|
||||
* token that asks for the page after that one. The key's own ARN is the
|
||||
* cursor, so a page can be resumed after the key it stopped at.
|
||||
*
|
||||
* <p>A request naming a state is answered with the keys in that state
|
||||
* only, and with every key when it names none.
|
||||
*/
|
||||
public PaginatedResult<PaymentCryptographyKey> listKeys(String region, String keyState,
|
||||
Integer maxResults, String nextToken) {
|
||||
return Pagination.paginate(listKeys(region, keyState), PaymentCryptographyKey::getArn,
|
||||
maxResults, nextToken, DEFAULT_PAGE_SIZE, MAX_RESULTS, PAGINATION_ERROR);
|
||||
}
|
||||
|
||||
/** The keys of a region, in the state the request names, or in any when it names none. */
|
||||
public List<PaymentCryptographyKey> listKeys(String region, String keyState) {
|
||||
List<PaymentCryptographyKey> out = new ArrayList<>();
|
||||
for (PaymentCryptographyKey key : keyStore.scan(k -> true)) {
|
||||
if (region.equals(key.getRegion()) && (keyState == null || keyState.equals(key.getKeyState()))) {
|
||||
out.add(key);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a key and answers the key as the service does when a deletion is
|
||||
* scheduled: the key's own metadata, its state {@code DELETE_PENDING} and
|
||||
* the pending timestamp of that deletion.
|
||||
*
|
||||
* <p>The service deletes a key the moment it is asked to, so the waiting
|
||||
* period the service offers is not one: the key is gone when the answer
|
||||
* goes out. The answer carries only the pending timestamp of that
|
||||
* deletion; the delete timestamp stays unset, because the key is already
|
||||
* gone when the answer goes out.
|
||||
*
|
||||
* <p>The lock is the same one the tagging operations take, so a key that
|
||||
* is being tagged cannot be written back after it was deleted.
|
||||
*/
|
||||
public synchronized PaymentCryptographyKey deleteKey(PaymentCryptographyKey key) {
|
||||
long now = Instant.now().getEpochSecond();
|
||||
key.setKeyState("DELETE_PENDING");
|
||||
key.setEnabled(false);
|
||||
key.setDeletePendingTimestamp(now);
|
||||
keyStore.delete(key.getKeyId());
|
||||
for (PaymentCryptographyAlias alias : aliasStore.scan(a -> true)) {
|
||||
if (key.getKeyId().equals(alias.getKeyId())) {
|
||||
aliasStore.delete(aliasKey(alias.getAliasName(), alias.getRegion()));
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
// ---- aliases ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The alias of a name in a region.
|
||||
*
|
||||
* <p>The alias belongs to the region of the key it names, so the lookup is
|
||||
* by name and region together.
|
||||
*/
|
||||
public PaymentCryptographyAlias findAlias(String region, String aliasName) {
|
||||
return aliasStore.get(aliasKey(aliasName, region)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The key an alias names, as this request resolved it.
|
||||
*
|
||||
* <p>The alias is resolved once for the request, and the resolution is kept: the
|
||||
* permission check resolves the alias to the key it names, and the request must act on
|
||||
* that key. Another request may move the alias in between, and a key resolved again
|
||||
* afterwards could be one no policy was checked against.
|
||||
*/
|
||||
private PaymentCryptographyKey keyOfAlias(String region, String aliasName) {
|
||||
String keyId = requestContext.aliasKeyId(region, aliasName);
|
||||
if (keyId == null) {
|
||||
PaymentCryptographyAlias alias = findAlias(region, aliasName);
|
||||
keyId = alias == null || alias.getKeyId() == null ? "" : alias.getKeyId();
|
||||
requestContext.pinAliasKeyId(region, aliasName, keyId);
|
||||
}
|
||||
return keyId.isEmpty() ? null : keyStore.get(keyId).orElse(null);
|
||||
}
|
||||
|
||||
/** Points a name at a key. The name must be free in the key's region. */
|
||||
public synchronized PaymentCryptographyAlias createAlias(String aliasName, PaymentCryptographyKey key) {
|
||||
liveKey(key);
|
||||
if (findAlias(key.getRegion(), aliasName) != null) {
|
||||
throw new AwsException("ConflictException",
|
||||
"Alias " + aliasName + " already exists", 400);
|
||||
}
|
||||
PaymentCryptographyAlias alias = new PaymentCryptographyAlias(
|
||||
aliasName, key.getRegion(), key.getArn(), key.getKeyId());
|
||||
aliasStore.put(aliasKey(aliasName, alias.getRegion()), alias);
|
||||
return alias;
|
||||
}
|
||||
|
||||
/** Points a name at another key, in the same region. */
|
||||
public synchronized PaymentCryptographyAlias updateAlias(String aliasName, PaymentCryptographyKey key) {
|
||||
liveKey(key);
|
||||
PaymentCryptographyAlias existing = findAlias(key.getRegion(), aliasName);
|
||||
if (existing == null) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Alias " + aliasName + " is not found", 400);
|
||||
}
|
||||
existing.setKeyArn(key.getArn());
|
||||
existing.setKeyId(key.getKeyId());
|
||||
aliasStore.put(aliasKey(aliasName, existing.getRegion()), existing);
|
||||
return existing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the key an alias names, leaving the alias itself.
|
||||
*
|
||||
* <p>The service answers an update that names no key this way: the alias
|
||||
* names no key afterwards, and it answers with the alias alone.
|
||||
*/
|
||||
public synchronized PaymentCryptographyAlias detachAlias(String region, String aliasName) {
|
||||
PaymentCryptographyAlias existing = findAlias(region, aliasName);
|
||||
if (existing == null) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Alias " + aliasName + " is not found", 400);
|
||||
}
|
||||
existing.setKeyArn(null);
|
||||
existing.setKeyId(null);
|
||||
aliasStore.put(aliasKey(aliasName, existing.getRegion()), existing);
|
||||
return existing;
|
||||
}
|
||||
|
||||
/** Removes a name from a region. */
|
||||
public synchronized void deleteAlias(String region, String aliasName) {
|
||||
if (findAlias(region, aliasName) == null) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Alias " + aliasName + " is not found", 400);
|
||||
}
|
||||
aliasStore.delete(aliasKey(aliasName, region));
|
||||
}
|
||||
|
||||
/**
|
||||
* The aliases of a region, or of one key, a page at a time.
|
||||
*
|
||||
* <p>The service answers with as many aliases as the caller asks for, and
|
||||
* a token that asks for the page after that one.
|
||||
*/
|
||||
public PaginatedResult<PaymentCryptographyAlias> listAliases(String region, String keyArn,
|
||||
Integer maxResults, String nextToken) {
|
||||
return Pagination.paginate(listAliases(region, keyArn), PaymentCryptographyAlias::getAliasName,
|
||||
maxResults, nextToken, DEFAULT_PAGE_SIZE, MAX_RESULTS, PAGINATION_ERROR);
|
||||
}
|
||||
|
||||
/** The aliases of a region, or of one key. */
|
||||
public List<PaymentCryptographyAlias> listAliases(String region, String keyArn) {
|
||||
List<PaymentCryptographyAlias> out = new ArrayList<>();
|
||||
for (PaymentCryptographyAlias alias : aliasStore.scan(a -> true)) {
|
||||
if (!region.equals(alias.getRegion())) {
|
||||
continue;
|
||||
}
|
||||
if (keyArn != null && !keyArn.equals(alias.getKeyArn())) {
|
||||
continue;
|
||||
}
|
||||
out.add(alias);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// ---- tags ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Adds tags to a key.
|
||||
*
|
||||
* <p>The tags are the region's: they are not part of the replication
|
||||
* process, so a key in another region carries its own tag set.
|
||||
*/
|
||||
public synchronized void tag(PaymentCryptographyKey key, Map<String, String> tags) {
|
||||
PaymentCryptographyKey current = liveKey(key);
|
||||
current.getTags().putAll(tags);
|
||||
keyStore.put(current.getKeyId(), current);
|
||||
}
|
||||
|
||||
/**
|
||||
* The key as it is in the store now.
|
||||
*
|
||||
* <p>The caller looked the key up before it asked for the change, and the
|
||||
* key may be gone by the time the change is made. Writing the looked-up
|
||||
* object back would put a deleted key into the store again, so the key is
|
||||
* read again under the lock and the request fails if it is not there.
|
||||
*/
|
||||
private PaymentCryptographyKey liveKey(PaymentCryptographyKey key) {
|
||||
PaymentCryptographyKey current = keyStore.get(key.getKeyId()).orElse(null);
|
||||
if (current == null) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Key " + key.getArn() + " is not found", 400);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/** Removes tags from a key, in this region only. */
|
||||
public synchronized void untag(PaymentCryptographyKey key, List<String> tagKeys) {
|
||||
PaymentCryptographyKey current = liveKey(key);
|
||||
for (String tagKey : tagKeys) {
|
||||
current.getTags().remove(tagKey);
|
||||
}
|
||||
keyStore.put(current.getKeyId(), current);
|
||||
}
|
||||
|
||||
/**
|
||||
* The tags of a key.
|
||||
*
|
||||
* <p>The copy takes the lock the tagging operations take, so it cannot read the map while
|
||||
* another request is writing to it.
|
||||
*/
|
||||
public synchronized Map<String, String> listTags(PaymentCryptographyKey key) {
|
||||
return new LinkedHashMap<>(key.getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* The tags of a key, a page at a time.
|
||||
*
|
||||
* <p>The service answers with as many tags as the caller asks for, and a
|
||||
* token that asks for the page after that one.
|
||||
*/
|
||||
public PaginatedResult<Map.Entry<String, String>> listTags(PaymentCryptographyKey key,
|
||||
Integer maxResults, String nextToken) {
|
||||
return Pagination.paginate(new ArrayList<>(listTags(key).entrySet()), Map.Entry::getKey,
|
||||
maxResults, nextToken, DEFAULT_PAGE_SIZE, MAX_RESULTS, PAGINATION_ERROR);
|
||||
}
|
||||
|
||||
// ---- helpers ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The namespace of the resource types this service finds, as the request-resources table names it.
|
||||
*/
|
||||
@Override
|
||||
public String namespace() {
|
||||
return "payment-cryptography";
|
||||
}
|
||||
|
||||
/**
|
||||
* The ARN the caller's key or alias of the name in the Region is stored under.
|
||||
*
|
||||
* <p>A key is named by its id or by an alias, and an alias names the key it points at, so a
|
||||
* request naming a key by an alias is checked on the key the alias names, as the handler
|
||||
* resolves it: an {@code Allow} scoped to that key passes and a {@code Deny} scoped to it
|
||||
* holds, whichever of the two names the request used.
|
||||
*
|
||||
* <p>An alias's ARN is the name it was given, which the request carries with the
|
||||
* {@code alias/} its own name starts with, so the ARN is that name without the prefix the
|
||||
* alias's own resource part carries.
|
||||
*/
|
||||
@Override
|
||||
public Optional<String> find(String type, List<String> names, String region) {
|
||||
if (names.size() != 1 || names.getFirst() == null || names.getFirst().isBlank()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
String name = names.getFirst();
|
||||
return switch (type) {
|
||||
case "key" -> Optional.ofNullable(findKey(region, name)).map(PaymentCryptographyKey::getArn);
|
||||
case "alias" -> Optional.of(aliasArn(region, name));
|
||||
default -> Optional.empty();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The ARN of the alias of the name in the Region, which the name gives whether or not the
|
||||
* alias exists yet, as a create names the alias it makes.
|
||||
*/
|
||||
private String aliasArn(String region, String name) {
|
||||
String alias = name.startsWith("alias/") ? name.substring("alias/".length()) : name;
|
||||
return regionResolver.buildArn(SERVICE, region, "alias/" + alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* The storage key of an alias.
|
||||
*
|
||||
* <p>The name and the region together, because the name is unique in the
|
||||
* region and not in the account.
|
||||
*/
|
||||
private static String aliasKey(String aliasName, String region) {
|
||||
return region + "\u0000" + aliasName;
|
||||
}
|
||||
|
||||
private static String string(Map<String, Object> attributes, String name, String fallback) {
|
||||
Object value = attributes.get(name);
|
||||
return value == null ? fallback : String.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The usage of the key the attributes name.
|
||||
*
|
||||
* <p>The service requires it, as the reference does: a key's usage says
|
||||
* what the key is for, and a key without one is not a key.
|
||||
*/
|
||||
private static String usage(Map<String, Object> attributes) {
|
||||
Object value = attributes.get("KeyUsage");
|
||||
if (value == null || String.valueOf(value).isBlank()) {
|
||||
throw new AwsException("ValidationException", "KeyUsage is required", 400);
|
||||
}
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
keyStore.clear();
|
||||
aliasStore.clear();
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/**
|
||||
* A Payment Cryptography alias.
|
||||
*
|
||||
* <p>An alias name is unique in an account and a region, not in an account:
|
||||
* the same name may name a key in another region, and a program that creates
|
||||
* keys in two regions uses the same name in both. The alias therefore
|
||||
* carries the region it belongs to.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class PaymentCryptographyAlias {
|
||||
private String aliasName;
|
||||
private String region;
|
||||
private String keyArn;
|
||||
private String keyId;
|
||||
|
||||
public PaymentCryptographyAlias() {
|
||||
}
|
||||
|
||||
public PaymentCryptographyAlias(String aliasName, String region, String keyArn, String keyId) {
|
||||
this.aliasName = aliasName;
|
||||
this.region = region;
|
||||
this.keyArn = keyArn;
|
||||
this.keyId = keyId;
|
||||
}
|
||||
|
||||
public String getAliasName() { return aliasName; }
|
||||
public void setAliasName(String aliasName) { this.aliasName = aliasName; }
|
||||
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
|
||||
public String getKeyArn() { return keyArn; }
|
||||
public void setKeyArn(String keyArn) { this.keyArn = keyArn; }
|
||||
|
||||
public String getKeyId() { return keyId; }
|
||||
public void setKeyId(String keyId) { this.keyId = keyId; }
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A Payment Cryptography key.
|
||||
*
|
||||
* <p>The material is kept as hexadecimal, the way the service's own import and
|
||||
* export formats carry it, so a key that arrives from an import is the same
|
||||
* key that leaves from an export.
|
||||
*
|
||||
* <p>The material is not written to the store: it is held by the key while the
|
||||
* emulator runs, and no operation of this service returns it or needs it, so
|
||||
* leaving it out of the persisted key keeps it off the disk. A key read back
|
||||
* from a store has no material, and the slice that exports a key decides how
|
||||
* one is kept.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class PaymentCryptographyKey {
|
||||
private String keyId;
|
||||
private String arn;
|
||||
private String region;
|
||||
private String keyAlgorithm;
|
||||
private String keyClass;
|
||||
private String keyUsage;
|
||||
private Map<String, Boolean> keyModesOfUse = new HashMap<>();
|
||||
private String keyOrigin = "AWS_PAYMENT_CRYPTOGRAPHY";
|
||||
private String keyCheckValue;
|
||||
private String keyCheckValueAlgorithm = "CMAC";
|
||||
private String keyState = "CREATE_COMPLETE";
|
||||
private boolean exportable;
|
||||
private boolean enabled = true;
|
||||
private String keyMaterialHex;
|
||||
private long createTimestamp;
|
||||
private long usageStartTimestamp;
|
||||
private long deletePendingTimestamp;
|
||||
private long deleteTimestamp;
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
|
||||
public String getKeyId() { return keyId; }
|
||||
public void setKeyId(String keyId) { this.keyId = keyId; }
|
||||
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
|
||||
public String getKeyAlgorithm() { return keyAlgorithm; }
|
||||
public void setKeyAlgorithm(String keyAlgorithm) { this.keyAlgorithm = keyAlgorithm; }
|
||||
|
||||
public String getKeyClass() { return keyClass; }
|
||||
public void setKeyClass(String keyClass) { this.keyClass = keyClass; }
|
||||
|
||||
public String getKeyUsage() { return keyUsage; }
|
||||
public void setKeyUsage(String keyUsage) { this.keyUsage = keyUsage; }
|
||||
|
||||
public Map<String, Boolean> getKeyModesOfUse() { return keyModesOfUse; }
|
||||
public void setKeyModesOfUse(Map<String, Boolean> keyModesOfUse) { this.keyModesOfUse = keyModesOfUse; }
|
||||
|
||||
public String getKeyOrigin() { return keyOrigin; }
|
||||
public void setKeyOrigin(String keyOrigin) { this.keyOrigin = keyOrigin; }
|
||||
|
||||
public String getKeyCheckValue() { return keyCheckValue; }
|
||||
public void setKeyCheckValue(String keyCheckValue) { this.keyCheckValue = keyCheckValue; }
|
||||
|
||||
public String getKeyCheckValueAlgorithm() { return keyCheckValueAlgorithm; }
|
||||
public void setKeyCheckValueAlgorithm(String keyCheckValueAlgorithm) {
|
||||
this.keyCheckValueAlgorithm = keyCheckValueAlgorithm;
|
||||
}
|
||||
|
||||
public String getKeyState() { return keyState; }
|
||||
public void setKeyState(String keyState) { this.keyState = keyState; }
|
||||
|
||||
public boolean isExportable() { return exportable; }
|
||||
public void setExportable(boolean exportable) { this.exportable = exportable; }
|
||||
|
||||
public boolean isEnabled() { return enabled; }
|
||||
public void setEnabled(boolean enabled) { this.enabled = enabled; }
|
||||
|
||||
/** The material of the key, which is held by the key and never written to the store. */
|
||||
@JsonIgnore
|
||||
public String getKeyMaterialHex() { return keyMaterialHex; }
|
||||
public void setKeyMaterialHex(String keyMaterialHex) { this.keyMaterialHex = keyMaterialHex; }
|
||||
|
||||
public long getCreateTimestamp() { return createTimestamp; }
|
||||
public void setCreateTimestamp(long createTimestamp) { this.createTimestamp = createTimestamp; }
|
||||
|
||||
public long getUsageStartTimestamp() { return usageStartTimestamp; }
|
||||
public void setUsageStartTimestamp(long usageStartTimestamp) {
|
||||
this.usageStartTimestamp = usageStartTimestamp;
|
||||
}
|
||||
|
||||
/** When the key is deleted, zero while it is not scheduled for deletion. */
|
||||
public long getDeletePendingTimestamp() { return deletePendingTimestamp; }
|
||||
public void setDeletePendingTimestamp(long deletePendingTimestamp) {
|
||||
this.deletePendingTimestamp = deletePendingTimestamp;
|
||||
}
|
||||
|
||||
/** When the key was deleted, zero while it is not. */
|
||||
public long getDeleteTimestamp() { return deleteTimestamp; }
|
||||
public void setDeleteTimestamp(long deleteTimestamp) { this.deleteTimestamp = deleteTimestamp; }
|
||||
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
}
|
||||
@@ -240,6 +240,8 @@ floci:
|
||||
flush-interval-ms: 15000
|
||||
cloudwatchmetrics:
|
||||
flush-interval-ms: 5000
|
||||
paymentcryptography:
|
||||
flush-interval-ms: 5000
|
||||
secretsmanager:
|
||||
flush-interval-ms: 5000
|
||||
acm:
|
||||
@@ -634,6 +636,8 @@ floci:
|
||||
max-stored-events: 20000
|
||||
cloudwatchmetrics:
|
||||
enabled: true
|
||||
paymentcryptography:
|
||||
enabled: true
|
||||
secretsmanager:
|
||||
enabled: true
|
||||
default-recovery-window-days: 30
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.113 (installed package)", "retrieved": "2026-11-01", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."},
|
||||
"namespaces": {"acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "cur": ["cur"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "kinesisanalytics": ["kinesisanalyticsv2"], "redshift-data": ["redshift-data"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"]},
|
||||
"_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.113 (installed package)", "retrieved": "2026-11-02", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."},
|
||||
"namespaces": {"acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "cur": ["cur"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "kinesisanalytics": ["kinesisanalyticsv2"], "payment-cryptography": ["payment-cryptography", "payment-cryptography-data"], "redshift-data": ["redshift-data"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"]},
|
||||
"clientsNotRead": {"kinesisanalytics": "Kinesis Data Analytics v1, SQL applications on the KinesisAnalytics_20150814 target, which Floci does not serve (it serves v2, kinesisanalyticsv2); its operations share v2's names and name their resources by other members"},
|
||||
"handBuilt": ["apigateway", "bedrock", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts"],
|
||||
"notCovered": {"access-analyzer": "REST: its requests name their resources in the path, which RequestResources does not read yet", "account": "REST: its requests name their resources in the path, which RequestResources does not read yet", "airflow": "REST: its requests name their resources in the path, which RequestResources does not read yet", "app-integrations": "REST: its requests name their resources in the path, which RequestResources does not read yet", "appconfig": "REST: its requests name their resources in the path, which RequestResources does not read yet", "appsync": "REST: its requests name their resources in the path, which RequestResources does not read yet", "aps": "REST: its requests name their resources in the path, which RequestResources does not read yet", "autoscaling": "not read yet: AWS's group and launch configuration ARNs carry an id the service mints, `autoScalingGroup:<id>:autoScalingGroupName/<name>`, while Floci mints `autoScalingGroup:<name>`, which other services (ECS capacity providers) read back; the mint is fixed first", "aws-marketplace": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "backup": "REST: its requests name their resources in the path, which RequestResources does not read yet", "batch": "REST: its requests name their resources in the path, which RequestResources does not read yet", "bedrock-agentcore": "REST: its requests name their resources in the path, which RequestResources does not read yet", "cloudformation": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudfront": "REST: its requests name their resources in the path, which RequestResources does not read yet", "cloudhsm": "not read yet: its ARN formats end in ${CloudHsmClusterInstanceName} and ${CloudHsmBackupInstanceName}, names, while its requests give ClusterId and BackupId, ids, which the rule does not fill a name from, so nearly every operation needs a correction", "cloudwatch": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeartifact": "REST: its requests name their resources in the path, which RequestResources does not read yet", "codedeploy": "not read yet: the Service Reference gives an on-premises instance's ARN as `instance:${InstanceName}`, while the CodeDeploy permissions reference gives arn:aws:codedeploy:region:account-id:instance/instance-ID and AWS's GetOnPremisesInstance example answers instance/<name>_<id>, an id the service mints after the name; reading it needs that format corrected", "codeguru-reviewer": "REST: its requests name their resources in the path, which RequestResources does not read yet", "comprehend": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "config": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "connect": "REST: its requests name their resources in the path, which RequestResources does not read yet", "controlcatalog": "REST: its requests name their resources in the path, which RequestResources does not read yet", "controltower": "REST: its requests name their resources in the path, which RequestResources does not read yet", "datasync": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "detective": "REST: its requests name their resources in the path, which RequestResources does not read yet", "dlm": "REST: its requests name their resources in the path, which RequestResources does not read yet", "dms": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ec2": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ecs": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticache": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticbeanstalk": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticfilesystem": "REST: its requests name their resources in the path, which RequestResources does not read yet", "elasticmapreduce": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "emr-serverless": "REST: its requests name their resources in the path, which RequestResources does not read yet", "es": "REST: its requests name their resources in the path, which RequestResources does not read yet", "execute-api": "REST: its requests name their resources in the path, which RequestResources does not read yet", "fis": "REST: its requests name their resources in the path, which RequestResources does not read yet", "glue": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "guardduty": "REST: its requests name their resources in the path, which RequesLine truncated
|
||||
"otherNamespaces": ["a4b", "account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifybackend", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "application-signals-mcp", "appmesh", "appmesh-preview", "apprunner", "appstream", "apptest", "arc-region-switch", "arc-zonal-shift", "artifact", "assurance", "auditmanager", "aws-external-anthropic", "b2bi", "backup-gateway", "backup-search", "bedrock-mantle", "bedrock-websearch", "billing", "billingconductor", "braket", "bugbust", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "clouddirectory", "cloudfront-keyvaluestore", "cloudsearch", "cloudshell", "cloudtrail-data", "codecatalyst", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "codewhisperer", "cognito-sync", "connect-campaigns", "consoleapp", "continuum", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "devicefarm", "devops-guru", "directconnect", "docdb-elastic", "drs", "ds", "ds-data", "ebs", "ec2-instance-connect", "ecr-public", "eks-auth", "elastictranscoder", "elemental-appliances-software", "elemental-inference", "elemental-support-cases", "emr-containers", "end-user-messaging", "entityresolution", "evs", "finspace", "finspace-api", "fms", "forecast", "frauddetector", "freertos", "fsx", "gamelift", "gameliftstreams", "geo", "geo-maps", "geo-places", "geo-routes", "glacier", "grafana", "greengrass", "groundstation", "health", "health-agent", "healthlake", "honeycode", "identity-sync", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotanalytics", "iotdeviceadvisor", "iotfleethub", "iotfleetwise", "iotjobsdata", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "iq", "iq-permission", "ivs", "ivschat", "kafka-cluster", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "lookoutmetrics", "lookoutvision", "m2", "machinelearning", "managedblockchain", "mapcredits", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgh", "mgn", "migrationhub-orchestrator", "mobiletargeting", "monitron", "mpa", "neptune-db", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "nimble", "notifications", "notifications-contacts", "nova-act", "observabilityadmin", "odb", "omics", "one", "opensearch", "opsworks", "osis", "outposts", "panorama", "partnercentral", "payment-cryptography", "payments", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "private-networks", "profile", "proton", "purchase-orders", "q", "qapps", "qbusiness", "qdeveloper", "qldb", "quicksight", "rbin", "rds-db", "refactor-spaces", "repostspace", "resiliencehub", "robomaker", "rolesanywhere", "route53-recovery-cluster", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3-object-lambda", "s3-outposts", "s3express", "s3files", "sagemaker-geospatial", "sagemaker-mlflow", "savingsplans", "schemas", "scn", "sdb", "security-ir", "securityagent", "securitylake", "serverlessrepo", "shield", "signer", "simspaceweaver", "sms-voice", "snow-device-management", "social-messaging", "sqlworkbench", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "tnb", "transform", "transform-custom", "trustedadvisor", "ts", "vendor-insights", "voiceid", "vpc-lattice", "vpc-lattice-svcs", "vpce", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workdocs", "worklink", "workmail", "workmailmessageflow", "workspaces", "workspaces-instances", "workspaces-web", "xray"],
|
||||
"arnFormats": {"acm": {"acme-domain-validation": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-domain-validation/${AcmeDomainValidationId}", "acme-endpoint": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}", "acme-external-account-binding": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-external-account-binding/${ExternalAccountBindingId}", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/${CertificateId}"}, "application-autoscaling": {"ScalableTarget": "arn:${Partition}:application-autoscaling:${Region}:${Account}:scalable-target/${ResourceId}"}, "athena": {"capacity-reservation": "arn:${Partition}:athena:${Region}:${Account}:capacity-reservation/${CapacityReservationName}", "datacatalog": "arn:${Partition}:athena:${Region}:${Account}:datacatalog/${DataCatalogName}", "session": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}/session/${SessionId}", "workgroup": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}"}, "bcm-data-exports": {"billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "export": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:export/${Identifier}", "table": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:table/${Identifier}"}, "bcm-pricing-calculator": {"bill-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-estimate/${BillEstimateId}", "bill-scenario": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-scenario/${BillScenarioId}", "workload-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:workload-estimate/${WorkloadEstimateId}"}, "budgets": {"budget": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}", "budgetAction": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}/action/${ActionId}"}, "ce": {"anomalymonitor": "arn:${Partition}:ce::${Account}:anomalymonitor/${Identifier}", "anomalysubscription": "arn:${Partition}:ce::${Account}:anomalysubscription/${Identifier}", "billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "costcategory": "arn:${Partition}:ce::${Account}:costcategory/${Identifier}"}, "cloudtrail": {"channel": "arn:${Partition}:cloudtrail:${Region}:${Account}:channel/${ChannelId}", "dashboard": "arn:${Partition}:cloudtrail:${Region}:${Account}:dashboard/${DashboardName}", "eventdatastore": "arn:${Partition}:cloudtrail:${Region}:${Account}:eventdatastore/${EventDataStoreId}", "trail": "arn:${Partition}:cloudtrail:${Region}:${Account}:trail/${TrailName}"}, "codebuild": {"build": "arn:${Partition}:codebuild:${Region}:${Account}:build/${BuildId}", "build-batch": "arn:${Partition}:codebuild:${Region}:${Account}:build-batch/${BuildBatchId}", "fleet": "arn:${Partition}:codebuild:${Region}:${Account}:fleet/${FleetName}:${FleetId}", "project": "arn:${Partition}:codebuild:${Region}:${Account}:project/${ProjectName}", "report": "arn:${Partition}:codebuild:${Region}:${Account}:report/${ReportGroupName}:${ReportId}", "report-group": "arn:${Partition}:codebuild:${Region}:${Account}:report-group/${ReportGroupName}", "sandbox": "arn:${Partition}:codebuild:${Region}:${Account}:sandbox/${SandboxId}"}, "codepipeline": {"action": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}/${ActionName}", "actiontype": "arn:${Partition}:codepipeline:${Region}:${Account}:actiontype:${Owner}/${Category}/${Provider}/${Version}", "pipeline": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}", "stage": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}", "webhook": "arn:${Partition}:codepipeline:${Region}:${Account}:webhook:${WebhookName}"}, "cognito-identity": {"identitypool": "arn:${Partition}:cognito-identity:${Region}:${Account}:identitypool/${IdentityPoolId}"}, "cognito-idp": {"userpool": "arn:${Partition}:cognito-idp:${Region}:${Account}:userpool/${UserPoolId}", "webacl": "arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/webacl/${Name}/${Id}"}, "cur": {"cur": "arn:${Partition}:cur:${Region}:${Account}:definition/${ReportName}"}, "ecr": {"repository": "arn:${Partition}:ecr:${Region}:${Account}:repository/${RepositoryName}"}, "elasticloadbalancing": {"listener-rule/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener-rule/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/gwy": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/gwy/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/net": "arn:${Partition}:elasticloadbalancing:${Region}:${AccoLine truncated
|
||||
"otherNamespaces": ["a4b", "account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifybackend", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "application-signals-mcp", "appmesh", "appmesh-preview", "apprunner", "appstream", "apptest", "arc-region-switch", "arc-zonal-shift", "artifact", "assurance", "auditmanager", "aws-external-anthropic", "b2bi", "backup-gateway", "backup-search", "bedrock-mantle", "bedrock-websearch", "billing", "billingconductor", "braket", "bugbust", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "clouddirectory", "cloudfront-keyvaluestore", "cloudsearch", "cloudshell", "cloudtrail-data", "codecatalyst", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "codewhisperer", "cognito-sync", "connect-campaigns", "consoleapp", "continuum", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "devicefarm", "devops-guru", "directconnect", "docdb-elastic", "drs", "ds", "ds-data", "ebs", "ec2-instance-connect", "ecr-public", "eks-auth", "elastictranscoder", "elemental-appliances-software", "elemental-inference", "elemental-support-cases", "emr-containers", "end-user-messaging", "entityresolution", "evs", "finspace", "finspace-api", "fms", "forecast", "frauddetector", "freertos", "fsx", "gamelift", "gameliftstreams", "geo", "geo-maps", "geo-places", "geo-routes", "glacier", "grafana", "greengrass", "groundstation", "health", "health-agent", "healthlake", "honeycode", "identity-sync", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotanalytics", "iotdeviceadvisor", "iotfleethub", "iotfleetwise", "iotjobsdata", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "iq", "iq-permission", "ivs", "ivschat", "kafka-cluster", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "lookoutmetrics", "lookoutvision", "m2", "machinelearning", "managedblockchain", "mapcredits", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgh", "mgn", "migrationhub-orchestrator", "mobiletargeting", "monitron", "mpa", "neptune-db", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "nimble", "notifications", "notifications-contacts", "nova-act", "observabilityadmin", "odb", "omics", "one", "opensearch", "opsworks", "osis", "outposts", "panorama", "partnercentral", "payments", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "private-networks", "profile", "proton", "purchase-orders", "q", "qapps", "qbusiness", "qdeveloper", "qldb", "quicksight", "rbin", "rds-db", "refactor-spaces", "repostspace", "resiliencehub", "robomaker", "rolesanywhere", "route53-recovery-cluster", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3-object-lambda", "s3-outposts", "s3express", "s3files", "sagemaker-geospatial", "sagemaker-mlflow", "savingsplans", "schemas", "scn", "sdb", "security-ir", "securityagent", "securitylake", "serverlessrepo", "shield", "signer", "simspaceweaver", "sms-voice", "snow-device-management", "social-messaging", "sqlworkbench", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "tnb", "transform", "transform-custom", "trustedadvisor", "ts", "vendor-insights", "voiceid", "vpc-lattice", "vpc-lattice-svcs", "vpce", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workdocs", "worklink", "workmail", "workmailmessageflow", "workspaces", "workspaces-instances", "workspaces-web", "xray"],
|
||||
"arnFormats": {"acm": {"acme-domain-validation": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-domain-validation/${AcmeDomainValidationId}", "acme-endpoint": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}", "acme-external-account-binding": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-external-account-binding/${ExternalAccountBindingId}", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/${CertificateId}"}, "application-autoscaling": {"ScalableTarget": "arn:${Partition}:application-autoscaling:${Region}:${Account}:scalable-target/${ResourceId}"}, "athena": {"capacity-reservation": "arn:${Partition}:athena:${Region}:${Account}:capacity-reservation/${CapacityReservationName}", "datacatalog": "arn:${Partition}:athena:${Region}:${Account}:datacatalog/${DataCatalogName}", "session": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}/session/${SessionId}", "workgroup": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}"}, "bcm-data-exports": {"billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "export": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:export/${Identifier}", "table": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:table/${Identifier}"}, "bcm-pricing-calculator": {"bill-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-estimate/${BillEstimateId}", "bill-scenario": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-scenario/${BillScenarioId}", "workload-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:workload-estimate/${WorkloadEstimateId}"}, "budgets": {"budget": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}", "budgetAction": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}/action/${ActionId}"}, "ce": {"anomalymonitor": "arn:${Partition}:ce::${Account}:anomalymonitor/${Identifier}", "anomalysubscription": "arn:${Partition}:ce::${Account}:anomalysubscription/${Identifier}", "billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "costcategory": "arn:${Partition}:ce::${Account}:costcategory/${Identifier}"}, "cloudtrail": {"channel": "arn:${Partition}:cloudtrail:${Region}:${Account}:channel/${ChannelId}", "dashboard": "arn:${Partition}:cloudtrail:${Region}:${Account}:dashboard/${DashboardName}", "eventdatastore": "arn:${Partition}:cloudtrail:${Region}:${Account}:eventdatastore/${EventDataStoreId}", "trail": "arn:${Partition}:cloudtrail:${Region}:${Account}:trail/${TrailName}"}, "codebuild": {"build": "arn:${Partition}:codebuild:${Region}:${Account}:build/${BuildId}", "build-batch": "arn:${Partition}:codebuild:${Region}:${Account}:build-batch/${BuildBatchId}", "fleet": "arn:${Partition}:codebuild:${Region}:${Account}:fleet/${FleetName}:${FleetId}", "project": "arn:${Partition}:codebuild:${Region}:${Account}:project/${ProjectName}", "report": "arn:${Partition}:codebuild:${Region}:${Account}:report/${ReportGroupName}:${ReportId}", "report-group": "arn:${Partition}:codebuild:${Region}:${Account}:report-group/${ReportGroupName}", "sandbox": "arn:${Partition}:codebuild:${Region}:${Account}:sandbox/${SandboxId}"}, "codepipeline": {"action": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}/${ActionName}", "actiontype": "arn:${Partition}:codepipeline:${Region}:${Account}:actiontype:${Owner}/${Category}/${Provider}/${Version}", "pipeline": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}", "stage": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}", "webhook": "arn:${Partition}:codepipeline:${Region}:${Account}:webhook:${WebhookName}"}, "cognito-identity": {"identitypool": "arn:${Partition}:cognito-identity:${Region}:${Account}:identitypool/${IdentityPoolId}"}, "cognito-idp": {"userpool": "arn:${Partition}:cognito-idp:${Region}:${Account}:userpool/${UserPoolId}", "webacl": "arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/webacl/${Name}/${Id}"}, "cur": {"cur": "arn:${Partition}:cur:${Region}:${Account}:definition/${ReportName}"}, "ecr": {"repository": "arn:${Partition}:ecr:${Region}:${Account}:repository/${RepositoryName}"}, "elasticloadbalancing": {"listener-rule/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener-rule/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/gwy": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/gwy/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/net": "arn:${Partition}:elasticloadbalancing:${Region}:${AccoLine truncated
|
||||
"unqualified": {"states": ["statemachine"]},
|
||||
"mintedIds": {"events": ["api-destination", "connection"]},
|
||||
"operations": {
|
||||
@@ -884,6 +884,53 @@
|
||||
"kinesisanalytics:UntagResource": {"action": "kinesisanalytics:UntagResource", "types": ["application"], "resources": [{"types": ["application"], "arn": "ResourceARN"}]},
|
||||
"kinesisanalytics:UpdateApplication": {"action": "kinesisanalytics:UpdateApplication", "types": ["application"], "resources": [{"type": "application", "fill": {"ApplicationName": "ApplicationName"}}]},
|
||||
"kinesisanalytics:UpdateApplicationMaintenanceConfiguration": {"action": "kinesisanalytics:UpdateApplicationMaintenanceConfiguration", "types": ["application"], "resources": [{"type": "application", "fill": {"ApplicationName": "ApplicationName"}}]},
|
||||
"payment-cryptography:AddKeyReplicationRegions": {"action": "payment-cryptography:AddKeyReplicationRegions", "types": ["alias", "key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:AssociateMpaTeam": {"action": "payment-cryptography:AssociateMpaTeam", "types": ["approval-team"], "resources": [{"types": ["approval-team"], "arn": "MpaTeamArn"}]},
|
||||
"payment-cryptography:CreateAlias": {"action": "payment-cryptography:CreateAlias", "types": ["alias", "key"], "resources": [{"types": ["alias", "key"], "arn": "KeyArn"}, {"type": "alias", "fill": {"Alias": "AliasName"}, "made": true}]},
|
||||
"payment-cryptography:CreateKey": {"action": "payment-cryptography:CreateKey", "types": [], "resources": []},
|
||||
"payment-cryptography:DecryptData": {"action": "payment-cryptography:DecryptData", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:DeleteAlias": {"action": "payment-cryptography:DeleteAlias", "types": ["alias"], "resources": [{"type": "alias", "fill": {"Alias": "AliasName"}}]},
|
||||
"payment-cryptography:DeleteKey": {"action": "payment-cryptography:DeleteKey", "types": ["key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:DeleteResourcePolicy": {"action": "payment-cryptography:DeleteResourcePolicy", "types": ["key"], "resources": [{"types": ["key"], "arn": "ResourceArn"}]},
|
||||
"payment-cryptography:DisableDefaultKeyReplicationRegions": {"action": "payment-cryptography:DisableDefaultKeyReplicationRegions", "types": [], "resources": []},
|
||||
"payment-cryptography:DisassociateMpaTeam": {"action": "payment-cryptography:DisassociateMpaTeam", "types": ["approval-team"], "resources": []},
|
||||
"payment-cryptography:EnableDefaultKeyReplicationRegions": {"action": "payment-cryptography:EnableDefaultKeyReplicationRegions", "types": [], "resources": []},
|
||||
"payment-cryptography:EncryptData": {"action": "payment-cryptography:EncryptData", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:ExportKey": {"action": "payment-cryptography:ExportKey", "types": ["key"], "resources": []},
|
||||
"payment-cryptography:GenerateAs2805KekValidation": {"action": "payment-cryptography:GenerateAs2805KekValidation", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:GenerateAuthRequestCryptogram": {"action": "payment-cryptography:GenerateAuthRequestCryptogram", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:GenerateCardValidationData": {"action": "payment-cryptography:GenerateCardValidationData", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:GenerateMac": {"action": "payment-cryptography:GenerateMac", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:GenerateMacEmvPinChange": {"action": "payment-cryptography:GenerateMacEmvPinChange", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:GeneratePinData": {"action": "payment-cryptography:GeneratePinData", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:GetAlias": {"action": "payment-cryptography:GetAlias", "types": ["alias", "key"], "resources": [{"type": "alias", "fill": {"Alias": "AliasName"}}]},
|
||||
"payment-cryptography:GetCertificateSigningRequest": {"action": "payment-cryptography:GetCertificateSigningRequest", "types": ["alias", "key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:GetDefaultKeyReplicationRegions": {"action": "payment-cryptography:GetDefaultKeyReplicationRegions", "types": [], "resources": []},
|
||||
"payment-cryptography:GetKey": {"action": "payment-cryptography:GetKey", "types": ["key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:GetMpaTeamAssociation": {"action": "payment-cryptography:GetMpaTeamAssociation", "types": ["approval-team"], "resources": []},
|
||||
"payment-cryptography:GetParametersForExport": {"action": "payment-cryptography:GetParametersForExport", "types": [], "resources": []},
|
||||
"payment-cryptography:GetParametersForImport": {"action": "payment-cryptography:GetParametersForImport", "types": [], "resources": []},
|
||||
"payment-cryptography:GetPublicKeyCertificate": {"action": "payment-cryptography:GetPublicKeyCertificate", "types": ["key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:GetResourcePolicy": {"action": "payment-cryptography:GetResourcePolicy", "types": ["key"], "resources": [{"types": ["key"], "arn": "ResourceArn"}]},
|
||||
"payment-cryptography:ImportKey": {"action": "payment-cryptography:ImportKey", "types": [], "resources": []},
|
||||
"payment-cryptography:ListAliases": {"action": "payment-cryptography:ListAliases", "types": [], "resources": []},
|
||||
"payment-cryptography:ListKeys": {"action": "payment-cryptography:ListKeys", "types": [], "resources": []},
|
||||
"payment-cryptography:ListTagsForResource": {"action": "payment-cryptography:ListTagsForResource", "types": ["key"], "resources": [{"types": ["key"], "arn": "ResourceArn"}]},
|
||||
"payment-cryptography:PutResourcePolicy": {"action": "payment-cryptography:PutResourcePolicy", "types": ["key"], "resources": [{"types": ["key"], "arn": "ResourceArn"}]},
|
||||
"payment-cryptography:ReEncryptData": {"action": "payment-cryptography:ReEncryptData", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:RemoveKeyReplicationRegions": {"action": "payment-cryptography:RemoveKeyReplicationRegions", "types": ["alias", "key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:RestoreKey": {"action": "payment-cryptography:RestoreKey", "types": ["key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:StartKeyUsage": {"action": "payment-cryptography:StartKeyUsage", "types": ["key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:StopKeyUsage": {"action": "payment-cryptography:StopKeyUsage", "types": ["key"], "resources": [{"type": "key", "fill": {"KeyId": "KeyIdentifier"}}]},
|
||||
"payment-cryptography:TagResource": {"action": "payment-cryptography:TagResource", "types": ["key"], "resources": [{"types": ["key"], "arn": "ResourceArn"}]},
|
||||
"payment-cryptography:TranslateKeyMaterial": {"action": "payment-cryptography:TranslateKeyMaterial", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:TranslatePinData": {"action": "payment-cryptography:TranslatePinData", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:UntagResource": {"action": "payment-cryptography:UntagResource", "types": ["key"], "resources": [{"types": ["key"], "arn": "ResourceArn"}]},
|
||||
"payment-cryptography:UpdateAlias": {"action": "payment-cryptography:UpdateAlias", "types": ["alias", "key"], "resources": [{"types": ["alias", "key"], "arn": "KeyArn"}, {"type": "alias", "fill": {"Alias": "AliasName"}}]},
|
||||
"payment-cryptography:VerifyAuthRequestCryptogram": {"action": "payment-cryptography:VerifyAuthRequestCryptogram", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:VerifyCardValidationData": {"action": "payment-cryptography:VerifyCardValidationData", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:VerifyMac": {"action": "payment-cryptography:VerifyMac", "types": ["alias", "key"], "resources": []},
|
||||
"payment-cryptography:VerifyPinData": {"action": "payment-cryptography:VerifyPinData", "types": ["alias", "key"], "resources": []},
|
||||
"redshift-data:BatchExecuteStatement": {"action": "redshift-data:BatchExecuteStatement", "types": ["cluster", "workgroup"], "resources": [{"types": ["cluster", "workgroup"], "arn": "SecretArn"}, {"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "workgroup", "fill": {}, "find": ["WorkgroupName"]}]},
|
||||
"redshift-data:CancelStatement": {"action": "redshift-data:CancelStatement", "types": [], "resources": []},
|
||||
"redshift-data:DescribeStatement": {"action": "redshift-data:DescribeStatement", "types": [], "resources": []},
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"_source": {"generator": "tools/aws/regen_iam_tag_on_create.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.113 (installed package)", "retrieved": "2026-10-24", "note": "make iam-tag-on-create-check re-derives every member from botocore; make iam-tag-on-create-verify checks every operation against AWS."},
|
||||
"namespaces": {"acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "autoscaling": ["autoscaling"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudformation": ["cloudformation"], "cloudhsm": ["cloudhsmv2"], "cloudtrail": ["cloudtrail"], "cloudwatch": ["cloudwatch", "cloudwatchomni"], "codedeploy": ["codedeploy"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "comprehend": ["comprehend"], "config": ["config"], "cur": ["cur"], "datasync": ["datasync"], "dms": ["dms"], "dsql": ["dsql"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "eks": ["eks"], "elasticache": ["elasticache"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "glue": ["glue"], "iam": ["iam"], "kinesis": ["kinesis"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "kms": ["kms"], "lambda": ["lambda", "lambda-core", "lambda-microvms", "lambda-web"], "lightsail": ["lightsail"], "logs": ["logs"], "memorydb": ["memorydb"], "network-firewall": ["network-firewall"], "organizations": ["organizations"], "pipes": ["pipes"], "rds": ["docdb", "neptune", "rds"], "redshift": ["redshift"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-groups": ["resource-groups"], "route53resolver": ["route53resolver"], "sagemaker": ["sagemaker"], "scheduler": ["scheduler"], "secretsmanager": ["secretsmanager"], "servicediscovery": ["servicediscovery"], "ses": ["mailmanager", "pinpoint-email", "ses", "sesv2"], "sns": ["sns"], "sqs": ["sqs"], "ssm": ["ssm"], "sso": ["sso-admin"], "states": ["stepfunctions"], "sts": ["sts"], "swf": ["swf"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "transcribe": ["transcribe"], "transfer": ["transfer"], "translate": ["translate"], "wafv2": ["wafv2"]},
|
||||
"_source": {"generator": "tools/aws/regen_iam_tag_on_create.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.113 (installed package)", "retrieved": "2026-11-02", "note": "make iam-tag-on-create-check re-derives every member from botocore; make iam-tag-on-create-verify checks every operation against AWS."},
|
||||
"namespaces": {"acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "autoscaling": ["autoscaling"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudformation": ["cloudformation"], "cloudhsm": ["cloudhsmv2"], "cloudtrail": ["cloudtrail"], "cloudwatch": ["cloudwatch", "cloudwatchomni"], "codedeploy": ["codedeploy"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "comprehend": ["comprehend"], "config": ["config"], "cur": ["cur"], "datasync": ["datasync"], "dms": ["dms"], "dsql": ["dsql"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "eks": ["eks"], "elasticache": ["elasticache"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "glue": ["glue"], "iam": ["iam"], "kinesis": ["kinesis"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "kms": ["kms"], "lambda": ["lambda", "lambda-core", "lambda-microvms", "lambda-web"], "lightsail": ["lightsail"], "logs": ["logs"], "memorydb": ["memorydb"], "network-firewall": ["network-firewall"], "organizations": ["organizations"], "payment-cryptography": ["payment-cryptography"], "pipes": ["pipes"], "rds": ["docdb", "neptune", "rds"], "redshift": ["redshift"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-groups": ["resource-groups"], "route53resolver": ["route53resolver"], "sagemaker": ["sagemaker"], "scheduler": ["scheduler"], "secretsmanager": ["secretsmanager"], "servicediscovery": ["servicediscovery"], "ses": ["mailmanager", "pinpoint-email", "ses", "sesv2"], "sns": ["sns"], "sqs": ["sqs"], "ssm": ["ssm"], "sso": ["sso-admin"], "states": ["stepfunctions"], "sts": ["sts"], "swf": ["swf"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "transcribe": ["transcribe"], "transfer": ["transfer"], "translate": ["translate"], "wafv2": ["wafv2"]},
|
||||
"notCovered": {"access-analyzer": "REST routes no rule maps yet", "airflow": "REST routes no rule maps yet", "app-integrations": "REST routes no rule maps yet", "appconfig": "REST routes no rule maps yet", "appsync": "REST routes no rule maps yet", "aps": "REST routes no rule maps yet", "aws-marketplace": "REST routes no rule maps yet", "backup": "REST routes no rule maps yet", "batch": "REST routes no rule maps yet", "bedrock": "REST routes no rule maps yet", "bedrock-agentcore": "REST routes no rule maps yet", "cloudfront": "REST routes no rule maps yet", "codeguru-reviewer": "REST routes no rule maps yet", "connect": "REST routes no rule maps yet", "controltower": "REST routes no rule maps yet", "detective": "REST routes no rule maps yet", "dlm": "REST routes no rule maps yet", "elasticfilesystem": "REST routes no rule maps yet", "emr-serverless": "REST routes no rule maps yet", "es": "REST routes no rule maps yet", "fis": "REST routes no rule maps yet", "guardduty": "REST routes no rule maps yet", "inspector2": "REST routes no rule maps yet", "iot": "REST routes no rule maps yet", "kafka": "REST routes no rule maps yet", "macie2": "REST routes no rule maps yet", "mq": "REST routes no rule maps yet", "oam": "REST routes no rule maps yet", "ram": "REST routes no rule maps yet", "resource-explorer-2": "REST routes no rule maps yet", "rum": "REST routes no rule maps yet", "s3": "authorized by route; S3 checks s3:PutObjectTagging for an object it creates with tags itself", "s3tables": "REST routes no rule maps yet", "securityhub": "REST routes no rule maps yet", "servicecatalog": "its operations that tag are AppRegistry's, whose REST routes no rule maps yet"},
|
||||
"otherNamespaces": ["account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "appmesh", "apprunner", "appstream", "arc-region-switch", "artifact", "auditmanager", "b2bi", "backup-gateway", "backup-search", "bcm-dashboards", "billing", "billingconductor", "braket", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "connect-campaigns", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "directconnect", "docdb-elastic", "drs", "ds", "ebs", "ecr-public", "elemental-inference", "emr-containers", "entityresolution", "evs", "fms", "forecast", "frauddetector", "fsx", "gamelift", "gameliftstreams", "geo", "grafana", "greengrass", "groundstation", "health-agent", "healthlake", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotdeviceadvisor", "iotfleetwise", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "ivs", "ivschat", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "m2", "managedblockchain", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgn", "migrationhub-orchestrator", "mobiletargeting", "mpa", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "notifications", "notifications-contacts", "observabilityadmin", "odb", "omics", "opensearch", "osis", "outposts", "partnercentral", "payment-cryptography", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "profile", "proton", "qbusiness", "quicksight", "rbin", "refactor-spaces", "repostspace", "resiliencehub", "rolesanywhere", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3files", "sagemaker-geospatial", "savingsplans", "schemas", "scn", "security-ir", "securityagent", "securitylake", "shield", "signer", "sms-voice", "snow-device-management", "social-messaging", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "voiceid", "vpc-lattice", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workspaces", "workspaces-instances", "workspaces-web", "xray"],
|
||||
"otherNamespaces": ["account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "appmesh", "apprunner", "appstream", "arc-region-switch", "artifact", "auditmanager", "b2bi", "backup-gateway", "backup-search", "bcm-dashboards", "billing", "billingconductor", "braket", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "connect-campaigns", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "directconnect", "docdb-elastic", "drs", "ds", "ebs", "ecr-public", "elemental-inference", "emr-containers", "entityresolution", "evs", "fms", "forecast", "frauddetector", "fsx", "gamelift", "gameliftstreams", "geo", "grafana", "greengrass", "groundstation", "health-agent", "healthlake", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotdeviceadvisor", "iotfleetwise", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "ivs", "ivschat", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "m2", "managedblockchain", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgn", "migrationhub-orchestrator", "mobiletargeting", "mpa", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "notifications", "notifications-contacts", "observabilityadmin", "odb", "omics", "opensearch", "osis", "outposts", "partnercentral", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "profile", "proton", "qbusiness", "quicksight", "rbin", "refactor-spaces", "repostspace", "resiliencehub", "rolesanywhere", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3files", "sagemaker-geospatial", "savingsplans", "schemas", "scn", "security-ir", "securityagent", "securitylake", "shield", "signer", "sms-voice", "snow-device-management", "social-messaging", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "voiceid", "vpc-lattice", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workspaces", "workspaces-instances", "workspaces-web", "xray"],
|
||||
"resourceArns": {"ec2": {"application-status-check": "arn:${Partition}:ec2:${Region}:${Account}:application-status-check/*", "capacity-block": "arn:${Partition}:ec2:${Region}:${Account}:capacity-block/*", "capacity-manager-data-export": "arn:${Partition}:ec2:${Region}:${Account}:capacity-manager-data-export/*", "capacity-reservation": "arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation/*", "capacity-reservation-cancellation-quote": "arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation-cancellation-quote/*", "capacity-reservation-fleet": "arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation-fleet/*", "carrier-gateway": "arn:${Partition}:ec2:${Region}:${Account}:carrier-gateway/*", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/*", "client-vpn-endpoint": "arn:${Partition}:ec2:${Region}:${Account}:client-vpn-endpoint/*", "coip-pool": "arn:${Partition}:ec2:${Region}:${Account}:coip-pool/*", "customer-gateway": "arn:${Partition}:ec2:${Region}:${Account}:customer-gateway/*", "declarative-policies-report": "arn:${Partition}:ec2:${Region}:${Account}:declarative-policies-report/*", "dedicated-host": "arn:${Partition}:ec2:${Region}:${Account}:dedicated-host/*", "dhcp-options": "arn:${Partition}:ec2:${Region}:${Account}:dhcp-options/*", "egress-only-internet-gateway": "arn:${Partition}:ec2:${Region}:${Account}:egress-only-internet-gateway/*", "elastic-gpu": "arn:${Partition}:ec2:${Region}:${Account}:elastic-gpu/*", "elastic-inference": "arn:${Partition}:elastic-inference:${Region}:${Account}:elastic-inference-accelerator/*", "elastic-ip": "arn:${Partition}:ec2:${Region}:${Account}:elastic-ip/*", "export-image-task": "arn:${Partition}:ec2:${Region}:${Account}:export-image-task/*", "export-instance-task": "arn:${Partition}:ec2:${Region}:${Account}:export-instance-task/*", "fleet": "arn:${Partition}:ec2:${Region}:${Account}:fleet/*", "fpga-image": "arn:${Partition}:ec2:${Region}:${Account}:fpga-image/*", "group": "arn:${Partition}:resource-groups:${Region}:${Account}:group/*", "host-reservation": "arn:${Partition}:ec2:${Region}:${Account}:host-reservation/*", "image": "arn:${Partition}:ec2:${Region}::image/*", "image-usage-report": "arn:${Partition}:ec2:${Region}:${Account}:image-usage-report/*", "import-image-task": "arn:${Partition}:ec2:${Region}:${Account}:import-image-task/*", "import-snapshot-task": "arn:${Partition}:ec2:${Region}:${Account}:import-snapshot-task/*", "instance": "arn:${Partition}:ec2:${Region}:${Account}:instance/*", "instance-connect-endpoint": "arn:${Partition}:ec2:${Region}:${Account}:instance-connect-endpoint/*", "instance-event-window": "arn:${Partition}:ec2:${Region}:${Account}:instance-event-window/*", "internet-gateway": "arn:${Partition}:ec2:${Region}:${Account}:internet-gateway/*", "ipam": "arn:${Partition}:ec2::${Account}:ipam/*", "ipam-external-resource-verification-token": "arn:${Partition}:ec2::${Account}:ipam-external-resource-verification-token/*", "ipam-internet-registry-association": "arn:${Partition}:ec2::${Account}:ipam-internet-registry-association/*", "ipam-policy": "arn:${Partition}:ec2::${Account}:ipam-policy/*", "ipam-pool": "arn:${Partition}:ec2::${Account}:ipam-pool/*", "ipam-pool-allocation": "arn:${Partition}:ec2:${Region}:${Account}:ipam-pool-allocation/*", "ipam-prefix-list-resolver": "arn:${Partition}:ec2::${Account}:ipam-prefix-list-resolver/*", "ipam-prefix-list-resolver-target": "arn:${Partition}:ec2::${Account}:ipam-prefix-list-resolver-target/*", "ipam-resource-discovery": "arn:${Partition}:ec2::${Account}:ipam-resource-discovery/*", "ipam-resource-discovery-association": "arn:${Partition}:ec2::${Account}:ipam-resource-discovery-association/*", "ipam-scope": "arn:${Partition}:ec2::${Account}:ipam-scope/*", "ipv4pool-ec2": "arn:${Partition}:ec2:${Region}:${Account}:ipv4pool-ec2/*", "ipv6pool-ec2": "arn:${Partition}:ec2:${Region}:${Account}:ipv6pool-ec2/*", "key-pair": "arn:${Partition}:ec2:${Region}:${Account}:key-pair/*", "launch-template": "arn:${Partition}:ec2:${Region}:${Account}:launch-template/*", "license-configuration": "arn:${Partition}:license-manager:${Region}:${Account}:license-configuration:*", "local-gateway": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway/*", "local-gateway-route-table": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-route-table/*", "local-gateway-route-table-virtual-interface-group-association": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-route-table-virtual-interface-group-association/*", "local-gateway-route-table-vpc-association": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-route-table-vpc-association/*", "local-gateway-virtual-interface": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-virtual-interface/*", "local-gateway-virtual-interface-group": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-virtual-interface-group/*", "mac-modification-task": "arn:${Partition}:ec2:${Region}:${Account}:mac-modification-tasLine truncated
|
||||
"operations": {
|
||||
"acm:ImportCertificate": {"tagging": ["acm:AddTagsToCertificate"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
@@ -373,6 +373,8 @@
|
||||
"organizations:InviteAccountToOrganization": {"tagging": ["organizations:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"organizations:InviteOrganizationToTransferResponsibility": {"tagging": ["organizations:TagResource"], "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"organizations:PutResourcePolicy": {"tagging": ["organizations:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"payment-cryptography:CreateKey": {"tagging": ["payment-cryptography:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"payment-cryptography:ImportKey": {"tagging": ["payment-cryptography:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"pipes:CreatePipe": {"tagging": ["pipes:TagResource"], "requestTags": true, "tags": [{"member": "Tags{}"}]},
|
||||
"rds:CopyDBClusterParameterGroup": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]},
|
||||
"rds:CopyDBClusterSnapshot": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]},
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
{
|
||||
"_source": {
|
||||
"generator": "tools/aws/regen_payment_cryptography_shapes.py",
|
||||
"botocore": "botocore 1.43.113 (installed package)"
|
||||
},
|
||||
"operations": {
|
||||
"CreateKey": "CreateKeyInput",
|
||||
"GetKey": "GetKeyInput",
|
||||
"ListKeys": "ListKeysInput",
|
||||
"DeleteKey": "DeleteKeyInput",
|
||||
"CreateAlias": "CreateAliasInput",
|
||||
"GetAlias": "GetAliasInput",
|
||||
"ListAliases": "ListAliasesInput",
|
||||
"UpdateAlias": "UpdateAliasInput",
|
||||
"DeleteAlias": "DeleteAliasInput",
|
||||
"TagResource": "TagResourceInput",
|
||||
"UntagResource": "UntagResourceInput",
|
||||
"ListTagsForResource": "ListTagsForResourceInput"
|
||||
},
|
||||
"shapes": {
|
||||
"AliasName": {
|
||||
"type": "string",
|
||||
"min": 7,
|
||||
"max": 256,
|
||||
"pattern": "alias/[a-zA-Z0-9/_-]+"
|
||||
},
|
||||
"Boolean": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"CreateAliasInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"AliasName"
|
||||
],
|
||||
"members": {
|
||||
"AliasName": "AliasName",
|
||||
"KeyArn": "KeyArn"
|
||||
}
|
||||
},
|
||||
"CreateKeyInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"KeyAttributes",
|
||||
"Exportable"
|
||||
],
|
||||
"members": {
|
||||
"KeyAttributes": "KeyAttributes",
|
||||
"KeyCheckValueAlgorithm": "KeyCheckValueAlgorithm",
|
||||
"Exportable": "Boolean",
|
||||
"Enabled": "Boolean",
|
||||
"Tags": "Tags",
|
||||
"DeriveKeyUsage": "DeriveKeyUsage",
|
||||
"ReplicationRegions": "Regions"
|
||||
}
|
||||
},
|
||||
"DeleteAliasInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"AliasName"
|
||||
],
|
||||
"members": {
|
||||
"AliasName": "AliasName"
|
||||
}
|
||||
},
|
||||
"DeleteKeyInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"KeyIdentifier"
|
||||
],
|
||||
"members": {
|
||||
"KeyIdentifier": "KeyArnOrKeyAliasType",
|
||||
"DeleteKeyInDays": "DeleteKeyInputDeleteKeyInDaysInteger"
|
||||
}
|
||||
},
|
||||
"DeleteKeyInputDeleteKeyInDaysInteger": {
|
||||
"type": "integer",
|
||||
"min": 3,
|
||||
"max": 180
|
||||
},
|
||||
"DeriveKeyUsage": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"TR31_B0_BASE_DERIVATION_KEY",
|
||||
"TR31_C0_CARD_VERIFICATION_KEY",
|
||||
"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY",
|
||||
"TR31_E0_EMV_MKEY_APP_CRYPTOGRAMS",
|
||||
"TR31_E1_EMV_MKEY_CONFIDENTIALITY",
|
||||
"TR31_E2_EMV_MKEY_INTEGRITY",
|
||||
"TR31_E4_EMV_MKEY_DYNAMIC_NUMBERS",
|
||||
"TR31_E5_EMV_MKEY_CARD_PERSONALIZATION",
|
||||
"TR31_E6_EMV_MKEY_OTHER",
|
||||
"TR31_K0_KEY_ENCRYPTION_KEY",
|
||||
"TR31_K1_KEY_BLOCK_PROTECTION_KEY",
|
||||
"TR31_M3_ISO_9797_3_MAC_KEY",
|
||||
"TR31_M1_ISO_9797_1_MAC_KEY",
|
||||
"TR31_M6_ISO_9797_5_CMAC_KEY",
|
||||
"TR31_M7_HMAC_KEY",
|
||||
"TR31_P0_PIN_ENCRYPTION_KEY",
|
||||
"TR31_P1_PIN_GENERATION_KEY",
|
||||
"TR31_V1_IBM3624_PIN_VERIFICATION_KEY",
|
||||
"TR31_V2_VISA_PIN_VERIFICATION_KEY"
|
||||
]
|
||||
},
|
||||
"GetAliasInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"AliasName"
|
||||
],
|
||||
"members": {
|
||||
"AliasName": "AliasName"
|
||||
}
|
||||
},
|
||||
"GetKeyInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"KeyIdentifier"
|
||||
],
|
||||
"members": {
|
||||
"KeyIdentifier": "KeyArnOrKeyAliasType"
|
||||
}
|
||||
},
|
||||
"KeyAlgorithm": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"TDES_2KEY",
|
||||
"TDES_3KEY",
|
||||
"AES_128",
|
||||
"AES_192",
|
||||
"AES_256",
|
||||
"HMAC_SHA256",
|
||||
"HMAC_SHA384",
|
||||
"HMAC_SHA512",
|
||||
"HMAC_SHA224",
|
||||
"RSA_2048",
|
||||
"RSA_3072",
|
||||
"RSA_4096",
|
||||
"ECC_NIST_P256",
|
||||
"ECC_NIST_P384",
|
||||
"ECC_NIST_P521"
|
||||
]
|
||||
},
|
||||
"KeyArn": {
|
||||
"type": "string",
|
||||
"min": 70,
|
||||
"max": 150,
|
||||
"pattern": "arn:aws[a-z0-9-]*:payment-cryptography:[a-z]{2}-[a-z]{1,16}-[0-9]+:[0-9]{12}:key/[0-9a-zA-Z]{16,64}"
|
||||
},
|
||||
"KeyArnOrKeyAliasType": {
|
||||
"type": "string",
|
||||
"min": 7,
|
||||
"max": 322,
|
||||
"pattern": "arn:aws[a-z0-9-]*:payment-cryptography:[a-z]{2}-[a-z]{1,16}-[0-9]+:[0-9]{12}:(key/[0-9a-zA-Z]{16,64}|alias/[a-zA-Z0-9/_-]+)$|^alias/[a-zA-Z0-9/_-]+"
|
||||
},
|
||||
"KeyAttributes": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"KeyUsage",
|
||||
"KeyClass",
|
||||
"KeyAlgorithm",
|
||||
"KeyModesOfUse"
|
||||
],
|
||||
"members": {
|
||||
"KeyUsage": "KeyUsage",
|
||||
"KeyClass": "KeyClass",
|
||||
"KeyAlgorithm": "KeyAlgorithm",
|
||||
"KeyModesOfUse": "KeyModesOfUse"
|
||||
}
|
||||
},
|
||||
"KeyCheckValueAlgorithm": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"CMAC",
|
||||
"ANSI_X9_24",
|
||||
"HMAC",
|
||||
"SHA_1"
|
||||
]
|
||||
},
|
||||
"KeyClass": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"SYMMETRIC_KEY",
|
||||
"ASYMMETRIC_KEY_PAIR",
|
||||
"PRIVATE_KEY",
|
||||
"PUBLIC_KEY"
|
||||
]
|
||||
},
|
||||
"KeyModesOfUse": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"Encrypt": "PrimitiveBoolean",
|
||||
"Decrypt": "PrimitiveBoolean",
|
||||
"Wrap": "PrimitiveBoolean",
|
||||
"Unwrap": "PrimitiveBoolean",
|
||||
"Generate": "PrimitiveBoolean",
|
||||
"Sign": "PrimitiveBoolean",
|
||||
"Verify": "PrimitiveBoolean",
|
||||
"DeriveKey": "PrimitiveBoolean",
|
||||
"NoRestrictions": "PrimitiveBoolean"
|
||||
}
|
||||
},
|
||||
"KeyState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"CREATE_IN_PROGRESS",
|
||||
"CREATE_COMPLETE",
|
||||
"DELETE_PENDING",
|
||||
"DELETE_COMPLETE"
|
||||
]
|
||||
},
|
||||
"KeyUsage": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"TR31_B0_BASE_DERIVATION_KEY",
|
||||
"TR31_C0_CARD_VERIFICATION_KEY",
|
||||
"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY",
|
||||
"TR31_D1_ASYMMETRIC_KEY_FOR_DATA_ENCRYPTION",
|
||||
"TR31_E0_EMV_MKEY_APP_CRYPTOGRAMS",
|
||||
"TR31_E1_EMV_MKEY_CONFIDENTIALITY",
|
||||
"TR31_E2_EMV_MKEY_INTEGRITY",
|
||||
"TR31_E4_EMV_MKEY_DYNAMIC_NUMBERS",
|
||||
"TR31_E5_EMV_MKEY_CARD_PERSONALIZATION",
|
||||
"TR31_E6_EMV_MKEY_OTHER",
|
||||
"TR31_K0_KEY_ENCRYPTION_KEY",
|
||||
"TR31_K1_KEY_BLOCK_PROTECTION_KEY",
|
||||
"TR31_K3_ASYMMETRIC_KEY_FOR_KEY_AGREEMENT",
|
||||
"TR31_M0_ISO_16609_MAC_KEY",
|
||||
"TR31_M3_ISO_9797_3_MAC_KEY",
|
||||
"TR31_M1_ISO_9797_1_MAC_KEY",
|
||||
"TR31_M6_ISO_9797_5_CMAC_KEY",
|
||||
"TR31_M7_HMAC_KEY",
|
||||
"TR31_P0_PIN_ENCRYPTION_KEY",
|
||||
"TR31_P1_PIN_GENERATION_KEY",
|
||||
"TR31_S0_ASYMMETRIC_KEY_FOR_DIGITAL_SIGNATURE",
|
||||
"TR31_V1_IBM3624_PIN_VERIFICATION_KEY",
|
||||
"TR31_V2_VISA_PIN_VERIFICATION_KEY",
|
||||
"TR31_K2_TR34_ASYMMETRIC_KEY"
|
||||
]
|
||||
},
|
||||
"ListAliasesInput": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"KeyArn": "KeyArn",
|
||||
"NextToken": "NextToken",
|
||||
"MaxResults": "MaxResults"
|
||||
}
|
||||
},
|
||||
"ListKeysInput": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"KeyState": "KeyState",
|
||||
"NextToken": "NextToken",
|
||||
"MaxResults": "MaxResults"
|
||||
}
|
||||
},
|
||||
"ListTagsForResourceInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"ResourceArn"
|
||||
],
|
||||
"members": {
|
||||
"ResourceArn": "ResourceArn",
|
||||
"NextToken": "NextToken",
|
||||
"MaxResults": "MaxResults"
|
||||
}
|
||||
},
|
||||
"MaxResults": {
|
||||
"type": "integer",
|
||||
"min": 1,
|
||||
"max": 100
|
||||
},
|
||||
"NextToken": {
|
||||
"type": "string",
|
||||
"min": 1,
|
||||
"max": 8192
|
||||
},
|
||||
"PrimitiveBoolean": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Region": {
|
||||
"type": "string",
|
||||
"pattern": "[a-z]{2}-[a-z]{1,16}-[0-9]+"
|
||||
},
|
||||
"Regions": {
|
||||
"type": "list",
|
||||
"member": "Region"
|
||||
},
|
||||
"ResourceArn": {
|
||||
"type": "string",
|
||||
"min": 70,
|
||||
"max": 150,
|
||||
"pattern": "arn:aws[a-z0-9-]*:payment-cryptography:[a-z]{2}-[a-z]{1,16}-[0-9]+:[0-9]{12}:key/[0-9a-zA-Z]{16,64}"
|
||||
},
|
||||
"Tag": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"Key",
|
||||
"Value"
|
||||
],
|
||||
"members": {
|
||||
"Key": "TagKey",
|
||||
"Value": "TagValue"
|
||||
}
|
||||
},
|
||||
"TagKey": {
|
||||
"type": "string",
|
||||
"min": 1,
|
||||
"max": 128
|
||||
},
|
||||
"TagKeys": {
|
||||
"type": "list",
|
||||
"min": 0,
|
||||
"max": 200,
|
||||
"member": "TagKey"
|
||||
},
|
||||
"TagResourceInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"ResourceArn",
|
||||
"Tags"
|
||||
],
|
||||
"members": {
|
||||
"ResourceArn": "ResourceArn",
|
||||
"Tags": "Tags"
|
||||
}
|
||||
},
|
||||
"TagValue": {
|
||||
"type": "string",
|
||||
"min": 1,
|
||||
"max": 256
|
||||
},
|
||||
"Tags": {
|
||||
"type": "list",
|
||||
"min": 0,
|
||||
"max": 200,
|
||||
"member": "Tag"
|
||||
},
|
||||
"UntagResourceInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"ResourceArn",
|
||||
"TagKeys"
|
||||
],
|
||||
"members": {
|
||||
"ResourceArn": "ResourceArn",
|
||||
"TagKeys": "TagKeys"
|
||||
}
|
||||
},
|
||||
"UpdateAliasInput": {
|
||||
"type": "structure",
|
||||
"required": [
|
||||
"AliasName"
|
||||
],
|
||||
"members": {
|
||||
"AliasName": "AliasName",
|
||||
"KeyArn": "KeyArn"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -43,7 +43,8 @@ class AwsJsonControllerSerializationTest {
|
||||
when(sqs.handle(eq("Test"), any(), eq("us-east-1"))).thenReturn(original);
|
||||
|
||||
AwsJsonController controller = new AwsJsonController(mapper, catalog, regionResolver,
|
||||
null, null, sqs, null, null, null, null, null, null, null, null, null, null);
|
||||
null, null, sqs, null, null, null,
|
||||
null, null, null, null, null, null, null, null);
|
||||
Response result = controller.handleJsonRequest("AmazonSQS.Test", headers, "{}");
|
||||
|
||||
assertSame(original, result);
|
||||
|
||||
+24
-1
@@ -48,7 +48,8 @@ class PartitionCrossServiceSmokeIntegrationTest {
|
||||
"ecr", "ecs", "efs", "eks", "elasticache", "elasticbeanstalk", "elb", "elbv2", "emr", "emrserverless",
|
||||
"eventbridge", "eventbridgev2", "firehose", "fis", "glue", "guardduty", "iot", "kinesis", "kinesisanalytics", "lambda",
|
||||
"lambdamicrovms", "lambdaweb", "memorydb", "msk", "mwaa", "networkfirewall", "oam", "opensearch", "organizations",
|
||||
"pipes", "ram", "rds", "redshift", "redshiftserverless", "resourceexplorer2", "resourcegroups", "route53resolver",
|
||||
"paymentcryptography", "pipes", "ram", "rds", "redshift", "redshiftserverless",
|
||||
"resourceexplorer2", "resourcegroups", "route53resolver",
|
||||
"s3tables", "s3vectors", "sagemaker", "scheduler", "secretsmanager", "servicequotas", "ses", "sns", "sqs",
|
||||
"stepfunctions", "timestreaminfluxdb", "transfer", "verifiedpermissions", "wafv2");
|
||||
|
||||
@@ -80,6 +81,28 @@ class PartitionCrossServiceSmokeIntegrationTest {
|
||||
PartitionMatrix.assertArnIn(partitionCase, arn);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource(PartitionMatrix.NON_COMMERCIAL_CASES)
|
||||
void paymentCryptographyKeyArn(PartitionCase partitionCase) {
|
||||
String region = offered(partitionCase, "payment-cryptography");
|
||||
String arn = signed(region, "payment-cryptography")
|
||||
.header("X-Amz-Target", "PaymentCryptographyControlPlane.CreateKey")
|
||||
.contentType("application/x-amz-json-1.0")
|
||||
.body("{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\","
|
||||
+ "\"KeyClass\":\"SYMMETRIC_KEY\","
|
||||
+ "\"KeyUsage\":\"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY\","
|
||||
+ "\"KeyModesOfUse\":{\"Encrypt\":true,\"Decrypt\":true}},"
|
||||
+ "\"Exportable\":true}")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
cleanup.register(() -> signed(region, "payment-cryptography")
|
||||
.header("X-Amz-Target", "PaymentCryptographyControlPlane.DeleteKey")
|
||||
.contentType("application/x-amz-json-1.0")
|
||||
.body("{\"KeyIdentifier\":\"" + arn + "\"}")
|
||||
.when().post("/"));
|
||||
PartitionMatrix.assertArnIn(partitionCase, arn);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource(PartitionMatrix.NON_COMMERCIAL_CASES)
|
||||
void snsTopicArn(PartitionCase partitionCase) {
|
||||
|
||||
@@ -423,6 +423,52 @@ class RequestResourcesTest {
|
||||
+ "connection/web/1234\"}"), "aws", "us-east-1", "000000000000", stored));
|
||||
}
|
||||
|
||||
/**
|
||||
* A key is named by its id or by an alias, and an alias names the key it points at, so a request naming a key by
|
||||
* an alias is checked on the key the alias names, as the handler resolves it: an allow scoped to that key passes
|
||||
* and a deny scoped to it holds, whichever of the two names the request used. The alias itself is checked on its
|
||||
* own ARN, and the tagging operations on the key their {@code ResourceArn} names.
|
||||
*/
|
||||
@Test
|
||||
void aKeyIsCheckedOnTheKeyItsNameNames() {
|
||||
String key = "arn:aws:payment-cryptography:us-east-1:000000000000:key/abc123";
|
||||
String alias = "arn:aws:payment-cryptography:us-east-1:000000000000:alias/team/card-key";
|
||||
StoredResourceArns stored = new StoredResourceArns() {
|
||||
@Override
|
||||
public String namespace() {
|
||||
return "payment-cryptography";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> find(String type, List<String> names, String region) {
|
||||
if (!"us-east-1".equals(region)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return switch (type) {
|
||||
case "key" -> List.of("alias/team/card-key").equals(names) || List.of("abc123").equals(names)
|
||||
? Optional.of(key) : Optional.empty();
|
||||
case "alias" -> List.of("alias/team/card-key").equals(names) ? Optional.of(alias) : Optional.empty();
|
||||
default -> Optional.empty();
|
||||
};
|
||||
}
|
||||
};
|
||||
// A key named by an alias is checked on the key the alias points at.
|
||||
assertEquals(List.of(key), RequestResources.of("payment-cryptography:GetKey",
|
||||
json("{\"KeyIdentifier\":\"alias/team/card-key\"}"), "aws", "us-east-1", "000000000000", stored));
|
||||
// A key named by its id is checked on that key.
|
||||
assertEquals(List.of(key), RequestResources.of("payment-cryptography:GetKey",
|
||||
json("{\"KeyIdentifier\":\"abc123\"}"), "aws", "us-east-1", "000000000000", stored));
|
||||
// A key named by its ARN is checked on that ARN.
|
||||
assertEquals(List.of(key), RequestResources.of("payment-cryptography:GetKey",
|
||||
json("{\"KeyIdentifier\":\"" + key + "\"}"), "aws", "us-east-1", "000000000000", stored));
|
||||
// The alias operations are checked on the alias they name.
|
||||
assertEquals(List.of(alias), RequestResources.of("payment-cryptography:GetAlias",
|
||||
json("{\"AliasName\":\"alias/team/card-key\"}"), "aws", "us-east-1", "000000000000", stored));
|
||||
// The tagging operations are checked on the key their ResourceArn names.
|
||||
assertEquals(List.of(key), RequestResources.of("payment-cryptography:TagResource",
|
||||
json("{\"ResourceArn\":\"" + key + "\"}"), "aws", "us-east-1", "000000000000", stored));
|
||||
}
|
||||
|
||||
/**
|
||||
* A scalable target's ARN is all the id Application Auto Scaling mints, while its requests name it by its service
|
||||
* namespace, resource id and scalable dimension: it is the one stored under those, or else has its id open, as a
|
||||
|
||||
+73
@@ -33,6 +33,7 @@ import static io.github.hectorvent.floci.testing.EnforcementFixtures.auth;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@@ -516,6 +517,49 @@ class IamRequestResourceEnforcementIntegrationTest {
|
||||
refusedJson(describeUserPool(user, id + "x"), "cognito-idp:DescribeUserPool");
|
||||
}
|
||||
|
||||
/**
|
||||
* A key is named by its id or by an alias, and an alias names the key it points at, so a request naming a key by
|
||||
* an alias is checked on the key the alias names, as the handler resolves it: a grant on that key allows it, a
|
||||
* grant on the alias alone does not, and a deny on the key holds.
|
||||
*/
|
||||
@Test
|
||||
void aKeyNamedByAnAliasIsCheckedOnTheKeyTheAliasNames() {
|
||||
String key = createPaymentKey();
|
||||
String alias = "alias/res-card-" + suffix();
|
||||
createPaymentAlias(alias, key).statusCode(200);
|
||||
|
||||
User user = user("res-key");
|
||||
user.policy(allowOn("payment-cryptography:GetKey", key));
|
||||
getPaymentKey(user, alias).statusCode(200);
|
||||
getPaymentKey(user, key).statusCode(200);
|
||||
refusedJson(getPaymentKey(user, "alias/res-other-" + suffix()), "payment-cryptography:GetKey");
|
||||
|
||||
user.policy(allowOn("payment-cryptography:GetKey", "*") + ",{\"Effect\":\"Deny\",\"Action\":"
|
||||
+ "\"payment-cryptography:GetKey\",\"Resource\":\"" + key + "\"}");
|
||||
refusedJson(getPaymentKey(user, alias), "payment-cryptography:GetKey");
|
||||
}
|
||||
|
||||
/**
|
||||
* A tagging request names its key by the ARN of one, as the reference takes it there, so a request naming it by
|
||||
* its id names no key for the check and is refused: a deny on the key is not skipped by naming it another way.
|
||||
*/
|
||||
@Test
|
||||
void aTaggingRequestNamesItsKeyByItsArn() {
|
||||
String key = createPaymentKey();
|
||||
String id = key.substring(key.lastIndexOf('/') + 1);
|
||||
|
||||
User user = user("res-key-tag");
|
||||
user.policy(allowOn("payment-cryptography:TagResource", "*") + ",{\"Effect\":\"Deny\",\"Action\":"
|
||||
+ "\"payment-cryptography:TagResource\",\"Resource\":\"" + key + "\"}");
|
||||
// The key's own ARN is checked on the key, and the deny holds.
|
||||
refusedJson(tagPaymentKey(user, key), "payment-cryptography:TagResource");
|
||||
// Its id names no ARN for the check, so the request is refused rather than tagging the denied key.
|
||||
tagPaymentKey(user, id).statusCode(400).body(containsString("ValidationException"));
|
||||
admin("payment-cryptography").header("X-Amz-Target", "PaymentCryptographyControlPlane.ListTagsForResource")
|
||||
.contentType("application/x-amz-json-1.0").body("{\"ResourceArn\":\"" + key + "\"}")
|
||||
.post("/").then().statusCode(200).body("Tags", hasSize(0));
|
||||
}
|
||||
|
||||
/** A repository is checked on the ARN its name gives, whether or not it exists. */
|
||||
@Test
|
||||
void aRepositoryIsCheckedOnTheArnItsNameGives() {
|
||||
@@ -1591,6 +1635,35 @@ class IamRequestResourceEnforcementIntegrationTest {
|
||||
.body("{\"stateMachineArn\":\"" + arn + "\"}").post("/").then();
|
||||
}
|
||||
|
||||
/** A key of the account, made as the administrator. */
|
||||
private String createPaymentKey() {
|
||||
return admin("payment-cryptography").header("X-Amz-Target", "PaymentCryptographyControlPlane.CreateKey")
|
||||
.contentType("application/x-amz-json-1.0").body("{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\","
|
||||
+ "\"KeyClass\":\"SYMMETRIC_KEY\",\"KeyUsage\":\"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY\","
|
||||
+ "\"KeyModesOfUse\":{\"Encrypt\":true,\"Decrypt\":true}},\"Exportable\":true}")
|
||||
.post("/").then().statusCode(200).extract().path("Key.KeyArn");
|
||||
}
|
||||
|
||||
/** An alias naming a key, made as the administrator. */
|
||||
private static ValidatableResponse createPaymentAlias(String alias, String key) {
|
||||
return admin("payment-cryptography").header("X-Amz-Target", "PaymentCryptographyControlPlane.CreateAlias")
|
||||
.contentType("application/x-amz-json-1.0")
|
||||
.body("{\"AliasName\":\"" + alias + "\",\"KeyArn\":\"" + key + "\"}").post("/").then();
|
||||
}
|
||||
|
||||
/** A tagging request naming its key the way the request gives it. */
|
||||
private static ValidatableResponse tagPaymentKey(User user, String resource) {
|
||||
return user.json("payment-cryptography", "PaymentCryptographyControlPlane.TagResource", "1.0")
|
||||
.body("{\"ResourceArn\":\"" + resource + "\",\"Tags\":[{\"Key\":\"owner\",\"Value\":\"team\"}]}")
|
||||
.post("/").then();
|
||||
}
|
||||
|
||||
/** A read of the key a request names by its id, its alias or its ARN. */
|
||||
private static ValidatableResponse getPaymentKey(User user, String identifier) {
|
||||
return user.json("payment-cryptography", "PaymentCryptographyControlPlane.GetKey", "1.0")
|
||||
.body("{\"KeyIdentifier\":\"" + identifier + "\"}").post("/").then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse describeUserPool(User user, String id) {
|
||||
return user.json("cognito-idp", "AWSCognitoIdentityProviderService.DescribeUserPool", "1.1")
|
||||
.body("{\"UserPoolId\":\"" + id + "\"}").post("/").then();
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsRegions;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.RequestContext;
|
||||
import io.github.hectorvent.floci.core.common.StoredResourceArns;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.services.eks.EksService;
|
||||
@@ -1167,6 +1168,29 @@ class ResourceArnBuilderTest {
|
||||
return new ResourceArnBuilder(new ObjectMapper(), null, null, null, null, instance);
|
||||
}
|
||||
|
||||
/** A builder reading the stored ARNs of a namespace, for a request of that namespace. */
|
||||
private static ResourceArnBuilder reading(StoredResourceArns stored) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Instance<StoredResourceArns> instance = mock(Instance.class);
|
||||
when(instance.iterator()).thenReturn(List.of(stored).iterator());
|
||||
return new ResourceArnBuilder(new ObjectMapper(), null, null, null, null, null, instance);
|
||||
}
|
||||
|
||||
/** The finder of the stored ARNs of a namespace, answering one name of one type with one ARN. */
|
||||
private static StoredResourceArns stored(String namespace, String type, String name, String arn) {
|
||||
return new StoredResourceArns() {
|
||||
@Override
|
||||
public String namespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> find(String found, List<String> wanted, String region) {
|
||||
return type.equals(found) && List.of(name).equals(wanted) ? Optional.of(arn) : Optional.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The gap issue 6256 describes. KMS is a JSON protocol on {@code /} with the key in the body,
|
||||
* so reading a {@code /keys/<id>} path segment named nothing and every call was evaluated
|
||||
@@ -1196,6 +1220,24 @@ class ResourceArnBuilderTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static final String PC_KEY_ARN =
|
||||
"arn:aws:payment-cryptography:us-east-1:000000000000:key/abc123";
|
||||
|
||||
/**
|
||||
* A key named by an alias is authorized against the key it points at, as the handler resolves
|
||||
* it. Otherwise an {@code Allow} scoped to {@code key/*} passes while an {@code Deny} scoped
|
||||
* to the key the alias names is missed, and the caller reads or deletes a key it was denied.
|
||||
*/
|
||||
@Test
|
||||
void paymentCryptographyResolvesAnAliasToTheKeyItPointsAt() {
|
||||
ResourceArnBuilder reading = reading(stored("payment-cryptography", "key", "alias/team/card-key", PC_KEY_ARN));
|
||||
|
||||
setJsonBody("{\"KeyIdentifier\":\"alias/team/card-key\"}");
|
||||
assertEquals(List.of(PC_KEY_ARN),
|
||||
reading.buildResources("payment-cryptography", "payment-cryptography:GetKey", ctx,
|
||||
"us-east-1", ACCOUNT, "aws"));
|
||||
}
|
||||
|
||||
/** A key named by an alias is authorized against the key it points at, as the handler resolves it. */
|
||||
@Test
|
||||
void kmsResolvesAnAliasToTheKeyItPointsAt() {
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* The AES-CMAC of RFC 4493, against the examples the RFC gives.
|
||||
*
|
||||
* <p>The examples cover the three cases the algorithm has: a message of no
|
||||
* length, which is padded and masked with K2; a message of whole blocks, which
|
||||
* is masked with K1; and a message of blocks and a part, whose last block is
|
||||
* padded and masked with K2.
|
||||
*/
|
||||
class PaymentCryptographyCryptoTest {
|
||||
|
||||
/** The key of every example the RFC gives. */
|
||||
private static final String KEY = "2B7E151628AED2A6ABF7158809CF4F3C";
|
||||
|
||||
/** The CMAC of a message under {@link #KEY}, as hexadecimal. */
|
||||
private static String cmac(String message) {
|
||||
return PaymentCryptographyCrypto.toHex(
|
||||
PaymentCryptographyCrypto.cmac(PaymentCryptographyCrypto.fromHex(KEY),
|
||||
PaymentCryptographyCrypto.fromHex(message)));
|
||||
}
|
||||
|
||||
/** RFC 4493's example 1: a message of no length. */
|
||||
@Test
|
||||
void anEmptyMessageIsTheMacTheRfcGives() {
|
||||
assertEquals("bb1d6929e95937287fa37d129b756746", cmac(""));
|
||||
}
|
||||
|
||||
/** RFC 4493's example 2: a message of one whole block. */
|
||||
@Test
|
||||
void aWholeBlockIsTheMacTheRfcGives() {
|
||||
assertEquals("070a16b46b4d4144f79bdd9dd04a287c", cmac("6bc1bee22e409f96e93d7e117393172a"));
|
||||
}
|
||||
|
||||
/** RFC 4493's example 3: two whole blocks and a padded one. */
|
||||
@Test
|
||||
void wholeBlocksAndAPaddedOneAreTheMacTheRfcGives() {
|
||||
assertEquals("dfa66747de9ae63030ca32611497c827", cmac(
|
||||
"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51"
|
||||
+ "30c81c46a35ce411"));
|
||||
}
|
||||
|
||||
/** RFC 4493's example 4: four whole blocks. */
|
||||
@Test
|
||||
void severalWholeBlocksAreTheMacTheRfcGives() {
|
||||
assertEquals("51f0bebf7e3b9d92fc49741779363cfe", cmac(
|
||||
"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51"
|
||||
+ "30c81c46a35ce411e5fbc1191a0a52ef"
|
||||
+ "f69f2445df4f9b17ad2b417be66c3710"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The check value of a key is the leftmost three bytes of the CMAC of
|
||||
* sixteen zero bytes under it, which is the CMAC of one whole block.
|
||||
*/
|
||||
@Test
|
||||
void theCheckValueIsTheLeftmostThreeBytesOfTheMacOfSixteenZeroBytes() {
|
||||
assertEquals("7AD386", PaymentCryptographyCrypto.checkValue(KEY));
|
||||
}
|
||||
}
|
||||
+414
@@ -0,0 +1,414 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.Response;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.aMapWithSize;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
@QuarkusTest
|
||||
class PaymentCryptographyIntegrationTest {
|
||||
|
||||
// The control plane of Payment Cryptography is an awsJson 1.0 service: the AWS SDK
|
||||
// sends this content type and targets PaymentCryptographyControlPlane.<Operation>.
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.0";
|
||||
private static final String TARGET = "PaymentCryptographyControlPlane.";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
private static Response call(String action, String body) {
|
||||
return given()
|
||||
.header("X-Amz-Target", TARGET + action)
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body(body)
|
||||
.when().post("/");
|
||||
}
|
||||
|
||||
private static final String CREATE_KEY = """
|
||||
{"KeyAttributes":{"KeyAlgorithm":"AES_256","KeyClass":"SYMMETRIC_KEY",
|
||||
"KeyUsage":"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY",
|
||||
"KeyModesOfUse":{"Encrypt":true,"Decrypt":true}},
|
||||
"Exportable":true}""";
|
||||
|
||||
@Test
|
||||
void aKeyIsCreatedAndReadBack() {
|
||||
String arn = call("CreateKey", CREATE_KEY)
|
||||
.then().statusCode(200)
|
||||
.body("Key.KeyArn", matchesPattern(
|
||||
"arn:aws:payment-cryptography:[a-z0-9-]+:[0-9]+:key/[0-9a-f]+"))
|
||||
.body("Key.KeyState", equalTo("CREATE_COMPLETE"))
|
||||
.body("Key.KeyCheckValue", matchesPattern("[0-9A-F]{6}"))
|
||||
.body("Key.KeyCheckValueAlgorithm", equalTo("CMAC"))
|
||||
.body("Key.Enabled", equalTo(true))
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("GetKey", "{\"KeyIdentifier\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Key.KeyArn", equalTo(arn))
|
||||
.body("Key.KeyAttributes.KeyAlgorithm", equalTo("AES_256"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theKeysOfARegionAreListed() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("ListKeys", "{}")
|
||||
.then().statusCode(200)
|
||||
.body("Keys", hasSize(greaterThanOrEqualTo(1)))
|
||||
.body("Keys.KeyArn", hasItem(equalTo(arn)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAliasIsCreatedAndListed() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/card-key\",\"KeyArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Alias.AliasName", equalTo("alias/team/card-key"))
|
||||
.body("Alias.KeyArn", equalTo(arn));
|
||||
|
||||
call("GetAlias", "{\"AliasName\":\"alias/team/card-key\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Alias.KeyArn", equalTo(arn));
|
||||
|
||||
call("ListAliases", "{}")
|
||||
.then().statusCode(200)
|
||||
.body("Aliases.AliasName", hasItem(equalTo("alias/team/card-key")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAliasNameIsUniqueInARegion() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/duplicate\",\"KeyArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200);
|
||||
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/duplicate\",\"KeyArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ConflictException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyIsTaggedAndUntagged() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\","
|
||||
+ "\"Tags\":[{\"Key\":\"Origin\",\"Value\":\"PRIMARY\"}]}")
|
||||
.then().statusCode(200);
|
||||
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Tags", hasSize(1))
|
||||
.body("Tags.Key", contains(equalTo("Origin")))
|
||||
.body("Tags.Value", contains(equalTo("PRIMARY")));
|
||||
|
||||
call("UntagResource", "{\"ResourceArn\":\"" + arn + "\",\"TagKeys\":[\"Origin\"]}")
|
||||
.then().statusCode(200);
|
||||
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Tags", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyThatDoesNotExistIsNotFound() {
|
||||
call("GetKey", "{\"KeyIdentifier\":\"arn:aws:payment-cryptography:us-east-1:000000000000:key/"
|
||||
+ "0123456789abcdef0123456789abcdef\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyIsDeleted() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("DeleteKey", "{\"KeyIdentifier\":\"" + arn + "\"}")
|
||||
.then().statusCode(200);
|
||||
|
||||
call("GetKey", "{\"KeyIdentifier\":\"" + arn + "\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnsupportedOperationIsRefused() {
|
||||
call("EncryptKey", "{}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("UnknownOperationException"));
|
||||
}
|
||||
|
||||
/**
|
||||
* A key is created with the usage and the modes of use the reference
|
||||
* requires, and a request without either of them is refused.
|
||||
*/
|
||||
@Test
|
||||
void aKeyWithoutItsUsageOrItsModesIsRefused() {
|
||||
call("CreateKey", "{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\",\"KeyClass\":\"SYMMETRIC_KEY\","
|
||||
+ "\"KeyModesOfUse\":{\"Encrypt\":true}},\"Exportable\":true}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
call("CreateKey", "{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\",\"KeyClass\":\"SYMMETRIC_KEY\","
|
||||
+ "\"KeyUsage\":\"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY\"},\"Exportable\":true}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
}
|
||||
|
||||
/**
|
||||
* A delete answers with the key, its state DELETE_PENDING and the moment it
|
||||
* is deleted, as the reference does.
|
||||
*/
|
||||
@Test
|
||||
void aDeletedKeyIsAnsweredWithTheKey() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("DeleteKey", "{\"KeyIdentifier\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Key.KeyArn", equalTo(arn))
|
||||
.body("Key.KeyState", equalTo("DELETE_PENDING"))
|
||||
.body("Key.Enabled", equalTo(false))
|
||||
.body("Key.DeletePendingTimestamp", notNullValue())
|
||||
.body("Key.DeleteTimestamp", nullValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* The waiting period the reference offers is read, and a request naming one
|
||||
* outside it is refused.
|
||||
*/
|
||||
@Test
|
||||
void aWaitingPeriodOutsideTheServiceRangeIsRefused() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("DeleteKey", "{\"KeyIdentifier\":\"" + arn + "\",\"DeleteKeyInDays\":1}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
call("DeleteKey", "{\"KeyIdentifier\":\"" + arn + "\",\"DeleteKeyInDays\":7}")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* A listing names the state of the keys it wants, and a request naming
|
||||
* another state than the service knows is refused.
|
||||
*/
|
||||
@Test
|
||||
void theKeysAreListedByTheirState() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("ListKeys", "{\"KeyState\":\"CREATE_COMPLETE\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Keys.KeyArn", hasItem(equalTo(arn)));
|
||||
call("ListKeys", "{\"KeyState\":\"DELETE_PENDING\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Keys", hasSize(0));
|
||||
call("ListKeys", "{\"KeyState\":\"NO_SUCH_STATE\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The key of an alias is optional, so an update naming no key removes the
|
||||
* key the alias names, and the alias stays.
|
||||
*/
|
||||
@Test
|
||||
void anAliasIsDetachedFromItsKeyByAnUpdateNamingNoKey() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/detached\",\"KeyArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200);
|
||||
|
||||
call("UpdateAlias", "{\"AliasName\":\"alias/team/detached\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Alias.AliasName", equalTo("alias/team/detached"))
|
||||
.body("Alias.KeyArn", nullValue());
|
||||
|
||||
call("GetAlias", "{\"AliasName\":\"alias/team/detached\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Alias.AliasName", equalTo("alias/team/detached"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyIsCreatedDisabledAndWithTags() {
|
||||
call("CreateKey", "{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\",\"KeyClass\":\"SYMMETRIC_KEY\","
|
||||
+ "\"KeyUsage\":\"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY\","
|
||||
+ "\"KeyModesOfUse\":{\"Encrypt\":true}},\"Exportable\":false,\"Enabled\":false,"
|
||||
+ "\"Tags\":[{\"Key\":\"owner\",\"Value\":\"team\"}]}")
|
||||
.then().statusCode(200)
|
||||
.body("Key.Enabled", equalTo(false))
|
||||
.body("Key.Exportable", equalTo(false));
|
||||
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Tags", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTaggingRequestNamesItsKeyInResourceArnOnly() {
|
||||
String named = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
String other = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
// The request names one key and another besides it. The change follows the member
|
||||
// the operation names its key in, which is the member the permission check reads.
|
||||
call("TagResource", "{\"ResourceArn\":\"" + other + "\",\"KeyIdentifier\":\"" + named + "\","
|
||||
+ "\"Tags\":[{\"Key\":\"owner\",\"Value\":\"team\"}]}")
|
||||
.then().statusCode(200);
|
||||
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + other + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Tags", hasSize(1));
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + named + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Tags", hasSize(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* The key operations name their key by the ARN of a key, the ARN of an alias or the name of an alias, as the
|
||||
* reference takes it there, so a bare id names no key and is refused.
|
||||
*/
|
||||
@Test
|
||||
void aKeyIsNamedByItsArnOrByAnAliasAndNotByABareId() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
String id = arn.substring(arn.lastIndexOf('/') + 1);
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/named\",\"KeyArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200);
|
||||
String aliasArn = "arn:aws:payment-cryptography:us-east-1:000000000000:alias/team/named";
|
||||
|
||||
for (String named : List.of(arn, "alias/team/named", aliasArn)) {
|
||||
call("GetKey", "{\"KeyIdentifier\":\"" + named + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Key.KeyArn", equalTo(arn));
|
||||
}
|
||||
call("GetKey", "{\"KeyIdentifier\":\"" + id + "\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The model of an alias requires only its name, but the reference refuses an alias without a key, so the
|
||||
* request is refused the way it refuses it.
|
||||
*/
|
||||
@Test
|
||||
void anAliasMayNotBeCreatedWithoutAKey() {
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/reserved\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"))
|
||||
.body("message", containsString("You can't create an alias without a key."));
|
||||
|
||||
// The name was not taken by the refused request.
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/reserved\",\"KeyArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Alias.AliasName", equalTo("alias/team/reserved"))
|
||||
.body("Alias.KeyArn", equalTo(arn));
|
||||
}
|
||||
|
||||
/**
|
||||
* The check value of an AES key is a CMAC, which is the only algorithm this service computes, so a request
|
||||
* naming another one is refused rather than answered with a check value of another kind.
|
||||
*/
|
||||
@Test
|
||||
void aCheckValueAlgorithmOtherThanCmacIsRefused() {
|
||||
call("CreateKey", "{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\",\"KeyClass\":\"SYMMETRIC_KEY\","
|
||||
+ "\"KeyUsage\":\"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY\","
|
||||
+ "\"KeyModesOfUse\":{\"Encrypt\":true}},\"KeyCheckValueAlgorithm\":\"ANSI_X9_24\","
|
||||
+ "\"Exportable\":true}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
|
||||
call("CreateKey", "{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\",\"KeyClass\":\"SYMMETRIC_KEY\","
|
||||
+ "\"KeyUsage\":\"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY\","
|
||||
+ "\"KeyModesOfUse\":{\"Encrypt\":true}},\"KeyCheckValueAlgorithm\":\"CMAC\","
|
||||
+ "\"Exportable\":true}")
|
||||
.then().statusCode(200)
|
||||
.body("Key.KeyCheckValueAlgorithm", equalTo("CMAC"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The answer carries every mode of use, the ones the request did not ask for as false, so a caller reading them
|
||||
* finds a boolean for each of them.
|
||||
*/
|
||||
@Test
|
||||
void everyModeOfUseIsAnswered() {
|
||||
call("CreateKey", "{\"KeyAttributes\":{\"KeyAlgorithm\":\"AES_256\",\"KeyClass\":\"SYMMETRIC_KEY\","
|
||||
+ "\"KeyUsage\":\"TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY\","
|
||||
+ "\"KeyModesOfUse\":{\"Encrypt\":true}},\"Exportable\":true}")
|
||||
.then().statusCode(200)
|
||||
.body("Key.KeyAttributes.KeyModesOfUse", aMapWithSize(9))
|
||||
.body("Key.KeyAttributes.KeyModesOfUse.Encrypt", equalTo(true))
|
||||
.body("Key.KeyAttributes.KeyModesOfUse.Decrypt", equalTo(false))
|
||||
.body("Key.KeyAttributes.KeyModesOfUse.NoRestrictions", equalTo(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* The tagging operations name their key by the ARN of one, as the reference takes it there, so a request naming
|
||||
* it by its id or by an alias names no key for the permission check and is refused.
|
||||
*/
|
||||
@Test
|
||||
void aTaggingRequestNamingItsKeyByAnIdOrAnAliasIsRefused() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
String id = arn.substring(arn.lastIndexOf('/') + 1);
|
||||
call("CreateAlias", "{\"AliasName\":\"alias/team/tagged\",\"KeyArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200);
|
||||
|
||||
for (String named : List.of(id, "alias/team/tagged")) {
|
||||
call("TagResource", "{\"ResourceArn\":\"" + named + "\","
|
||||
+ "\"Tags\":[{\"Key\":\"owner\",\"Value\":\"team\"}]}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
}
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Tags", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTaggingRequestWithoutItsKeyIsRefused() {
|
||||
call("TagResource", "{\"KeyIdentifier\":\"abc\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("ValidationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theKeysAreListedAPageAtATime() {
|
||||
call("CreateKey", CREATE_KEY).then().statusCode(200);
|
||||
call("CreateKey", CREATE_KEY).then().statusCode(200);
|
||||
|
||||
String first = call("ListKeys", "{\"MaxResults\":1}").then().statusCode(200)
|
||||
.body("Keys", hasSize(1))
|
||||
.extract().path("NextToken");
|
||||
|
||||
call("ListKeys", "{\"MaxResults\":1,\"NextToken\":\"" + first + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("Keys", hasSize(1));
|
||||
}
|
||||
}
|
||||
+357
@@ -0,0 +1,357 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.services.paymentcryptography.model.PaymentCryptographyAlias;
|
||||
import io.github.hectorvent.floci.services.paymentcryptography.model.PaymentCryptographyKey;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class PaymentCryptographyServiceTest {
|
||||
|
||||
private PaymentCryptographyService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new PaymentCryptographyService(
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", "000000000000"),
|
||||
new PaymentCryptographyRequestContext());
|
||||
}
|
||||
|
||||
private PaymentCryptographyKey createKey(String region) {
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
attributes.put("KeyAlgorithm", "AES_256");
|
||||
attributes.put("KeyClass", "SYMMETRIC_KEY");
|
||||
attributes.put("KeyUsage", "TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY");
|
||||
Map<String, Boolean> modes = new LinkedHashMap<>();
|
||||
modes.put("Encrypt", Boolean.TRUE);
|
||||
modes.put("Decrypt", Boolean.TRUE);
|
||||
return service.createKey(region, attributes, modes, true, true, Map.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aCreatedKeyIsInItsRegionAndCarriesMaterial() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
|
||||
assertTrue(key.getArn().startsWith("arn:aws:payment-cryptography:us-east-1:000000000000:key/"),
|
||||
key.getArn());
|
||||
assertEquals("CREATE_COMPLETE", key.getKeyState());
|
||||
assertEquals(64, key.getKeyMaterialHex().length());
|
||||
assertNotNull(key.getKeyCheckValue());
|
||||
assertEquals(6, key.getKeyCheckValue().length());
|
||||
}
|
||||
|
||||
@Test
|
||||
void theCheckValueIsTheLeftmostThreeBytesOfTheCmac() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
|
||||
// The CMAC of sixteen zero bytes under the key, leftmost three bytes.
|
||||
assertEquals(PaymentCryptographyCrypto.checkValue(key.getKeyMaterialHex()),
|
||||
key.getKeyCheckValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void theKeyCarriesTheModesItWasAskedFor() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
|
||||
assertEquals(Boolean.TRUE, key.getKeyModesOfUse().get("Encrypt"));
|
||||
assertEquals(Boolean.TRUE, key.getKeyModesOfUse().get("Decrypt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyInAnotherRegionIsNotThisRegionsKey() {
|
||||
PaymentCryptographyKey west = createKey("us-west-2");
|
||||
|
||||
assertNull(service.findKey("us-east-1", west.getArn()),
|
||||
"a key in another region was found in this one");
|
||||
assertNull(service.findKey("us-east-1", west.getKeyId()),
|
||||
"a key in another region was found in this one");
|
||||
assertNotNull(service.findKey("us-west-2", west.getArn()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void twoKeysGetDifferentMaterial() {
|
||||
PaymentCryptographyKey first = createKey("us-east-1");
|
||||
PaymentCryptographyKey second = createKey("us-east-1");
|
||||
|
||||
assertTrue(!first.getKeyMaterialHex().equals(second.getKeyMaterialHex()),
|
||||
"two keys share their material");
|
||||
// The check value is three bytes of the CMAC of the key, so two keys may
|
||||
// legitimately share one. Only the material has to differ.
|
||||
}
|
||||
|
||||
@Test
|
||||
void theAliasNameIsUniqueInARegion() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.createAlias("alias/team/card-key", key);
|
||||
|
||||
AwsException conflict = assertThrows(AwsException.class,
|
||||
() -> service.createAlias("alias/team/card-key", createKey("us-east-1")));
|
||||
assertEquals("ConflictException", conflict.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void theSameAliasNameInAnotherRegionIsAnotherAlias() {
|
||||
service.createAlias("alias/team/card-key", createKey("us-east-1"));
|
||||
PaymentCryptographyAlias second = service.createAlias("alias/team/card-key",
|
||||
createKey("us-west-2"));
|
||||
|
||||
assertEquals("us-west-2", second.getRegion());
|
||||
assertEquals(1, service.listAliases("us-east-1", null).size());
|
||||
assertEquals(1, service.listAliases("us-west-2", null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void theTagsAreTheKeysOwn() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.tag(key, Map.of("Origin", "PRIMARY"));
|
||||
|
||||
assertEquals("PRIMARY", service.listTags(key).get("Origin"));
|
||||
assertEquals(1, service.listTags(key).size());
|
||||
|
||||
service.untag(key, List.of("Origin"));
|
||||
assertTrue(service.listTags(key).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyIsFoundByItsArnAndByItsAlias() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.createAlias("alias/team/card-key", key);
|
||||
|
||||
assertEquals(key.getKeyId(), service.findKey("us-east-1", key.getArn()).getKeyId());
|
||||
assertEquals(key.getKeyId(),
|
||||
service.findKey("us-east-1", "alias/team/card-key").getKeyId());
|
||||
assertNull(service.findKey("us-west-2", "alias/team/card-key"),
|
||||
"an alias of one region is not an alias of another");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDeletedKeyTakesItsAliasesWithIt() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.createAlias("alias/team/card-key", key);
|
||||
service.deleteKey(key);
|
||||
|
||||
assertNull(service.findKey("us-east-1", key.getArn()));
|
||||
assertNull(service.findAlias("us-east-1", "alias/team/card-key"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyMayBeCreatedDisabledAndWithTags() {
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
attributes.put("KeyAlgorithm", "AES_256");
|
||||
attributes.put("KeyClass", "SYMMETRIC_KEY");
|
||||
attributes.put("KeyUsage", "TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY");
|
||||
|
||||
PaymentCryptographyKey key = service.createKey("us-east-1", attributes, Map.of(), false,
|
||||
false, Map.of("owner", "team"));
|
||||
|
||||
assertFalse(key.isEnabled(), "the key is enabled although it was created disabled");
|
||||
assertEquals("team", key.getTags().get("owner"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDeletedKeyDoesNotComeBackWhenItIsTagged() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.deleteKey(key);
|
||||
|
||||
AwsException gone = assertThrows(AwsException.class,
|
||||
() -> service.tag(key, Map.of("owner", "team")));
|
||||
assertEquals("ResourceNotFoundException", gone.getErrorCode());
|
||||
assertNull(service.findKey("us-east-1", key.getKeyId()),
|
||||
"the key is in the store again after it was deleted");
|
||||
}
|
||||
|
||||
@Test
|
||||
void theKeysAreListedAPageAtATime() {
|
||||
createKey("us-east-1");
|
||||
createKey("us-east-1");
|
||||
createKey("us-east-1");
|
||||
|
||||
PaginatedResult<PaymentCryptographyKey> first = service.listKeys("us-east-1", null, 2, null);
|
||||
assertEquals(2, first.items().size());
|
||||
assertNotNull(first.nextToken(), "there are more keys, so there is a token");
|
||||
|
||||
PaginatedResult<PaymentCryptographyKey> second =
|
||||
service.listKeys("us-east-1", null, 2, first.nextToken());
|
||||
assertEquals(1, second.items().size());
|
||||
assertNull(second.nextToken(), "the last page has no token");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyThatAsksForMaterialTheServiceDoesNotMakeIsRefused() {
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
attributes.put("KeyAlgorithm", "AES_128");
|
||||
attributes.put("KeyClass", "SYMMETRIC_KEY");
|
||||
attributes.put("KeyUsage", "TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY");
|
||||
|
||||
AwsException bad = assertThrows(AwsException.class,
|
||||
() -> service.createKey("us-east-1", attributes, Map.of(), true, true, Map.of()));
|
||||
assertEquals("ValidationException", bad.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aPageSizeBelowOneIsRefused() {
|
||||
createKey("us-east-1");
|
||||
|
||||
AwsException bad = assertThrows(AwsException.class,
|
||||
() -> service.listKeys("us-east-1", null, 0, null));
|
||||
assertEquals("ValidationException", bad.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTokenThatNamesNoPageIsRefused() {
|
||||
createKey("us-east-1");
|
||||
|
||||
AwsException bad = assertThrows(AwsException.class,
|
||||
() -> service.listKeys("us-east-1", null, 2, "not a token"));
|
||||
assertEquals("ValidationException", bad.getErrorCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* A key's usage says what the key is for, and the service requires it, as
|
||||
* the reference does.
|
||||
*/
|
||||
@Test
|
||||
void aKeyWithoutItsUsageIsRefused() {
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
attributes.put("KeyAlgorithm", "AES_256");
|
||||
attributes.put("KeyClass", "SYMMETRIC_KEY");
|
||||
|
||||
AwsException bad = assertThrows(AwsException.class,
|
||||
() -> service.createKey("us-east-1", attributes, Map.of(), true, true, Map.of()));
|
||||
assertEquals("ValidationException", bad.getErrorCode());
|
||||
}
|
||||
|
||||
/** A request naming a state is answered with the keys in that state only. */
|
||||
@Test
|
||||
void theKeysAreListedByTheirState() {
|
||||
createKey("us-east-1");
|
||||
createKey("us-east-1");
|
||||
|
||||
assertEquals(2, service.listKeys("us-east-1", "CREATE_COMPLETE").size());
|
||||
assertEquals(0, service.listKeys("us-east-1", "DELETE_PENDING").size());
|
||||
assertEquals(0, service.listKeys("us-east-1", "CREATE_IN_PROGRESS").size());
|
||||
}
|
||||
|
||||
/**
|
||||
* A deleted key is answered with the key, its state DELETE_PENDING and the
|
||||
* moment it is deleted.
|
||||
*/
|
||||
@Test
|
||||
void aDeletedKeyIsAnsweredWithTheKeyItWas() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
|
||||
PaymentCryptographyKey deleted = service.deleteKey(key);
|
||||
|
||||
assertEquals(key.getArn(), deleted.getArn());
|
||||
assertEquals("DELETE_PENDING", deleted.getKeyState());
|
||||
assertFalse(deleted.isEnabled());
|
||||
assertTrue(deleted.getDeletePendingTimestamp() > 0);
|
||||
assertEquals(0, deleted.getDeleteTimestamp(),
|
||||
"a key that is pending deletion carries no deletion timestamp");
|
||||
}
|
||||
|
||||
/**
|
||||
* An update naming no key removes the key the alias names, and the alias
|
||||
* stays.
|
||||
*/
|
||||
@Test
|
||||
void anAliasIsDetachedFromItsKey() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.createAlias("alias/team/card-key", key);
|
||||
|
||||
PaymentCryptographyAlias detached = service.detachAlias("us-east-1", "alias/team/card-key");
|
||||
|
||||
assertEquals("alias/team/card-key", detached.getAliasName());
|
||||
assertNull(detached.getKeyArn());
|
||||
assertNull(service.findKey("us-east-1", "alias/team/card-key"),
|
||||
"a detached alias still names a key");
|
||||
assertNotNull(service.findAlias("us-east-1", "alias/team/card-key"));
|
||||
}
|
||||
|
||||
/** The namespace of the resource types the service finds, as the request-resources table names it. */
|
||||
@Test
|
||||
void theNamespaceIsTheOneTheTableNames() {
|
||||
assertEquals("payment-cryptography", service.namespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* A key is named by its id or by an alias, and an alias names the key it points at, so a request naming a key by
|
||||
* an alias is checked on the key the alias names, as the handler resolves it.
|
||||
*/
|
||||
@Test
|
||||
void aKeyIsFoundUnderItsIdAndUnderTheAliasThatNamesIt() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.createAlias("alias/team/card-key", key);
|
||||
|
||||
assertEquals(Optional.of(key.getArn()), service.find("key", List.of(key.getKeyId()), "us-east-1"));
|
||||
assertEquals(Optional.of(key.getArn()), service.find("key", List.of("alias/team/card-key"), "us-east-1"));
|
||||
assertEquals(Optional.of(key.getArn()), service.find("key", List.of(key.getArn()), "us-east-1"));
|
||||
assertEquals(Optional.empty(), service.find("key", List.of("alias/team/no-such-key"), "us-east-1"));
|
||||
assertEquals(Optional.empty(), service.find("key", List.of("no-such-key"), "us-east-1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias ARN names the alias in the Region, the account and the partition it was minted in, so an alias ARN
|
||||
* of another Region names no alias here and the key of this Region's alias is not the one it would select.
|
||||
*/
|
||||
@Test
|
||||
void anAliasArnOfAnotherRegionNamesNoAliasHere() {
|
||||
PaymentCryptographyKey key = createKey("us-east-1");
|
||||
service.createAlias("alias/team/card-key", key);
|
||||
String aliasArn = "arn:aws:payment-cryptography:us-east-1:000000000000:alias/team/card-key";
|
||||
|
||||
assertEquals(key, service.findKey("us-east-1", aliasArn));
|
||||
assertNull(service.findKey("us-east-1",
|
||||
"arn:aws:payment-cryptography:us-west-2:000000000000:alias/team/card-key"),
|
||||
"an alias ARN of another Region selected this Region's key");
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias is resolved once for the request, so that the request acts on the key the permission check was
|
||||
* made on: an alias moved to another key in between would otherwise let the request act on a key no policy
|
||||
* was checked against.
|
||||
*/
|
||||
@Test
|
||||
void anAliasIsResolvedOnceForTheRequest() {
|
||||
PaymentCryptographyKey allowed = createKey("us-east-1");
|
||||
PaymentCryptographyKey denied = createKey("us-east-1");
|
||||
service.createAlias("alias/team/card-key", allowed);
|
||||
|
||||
// The permission check resolves the alias, which is the key the request is checked on.
|
||||
assertEquals(Optional.of(allowed.getArn()), service.find("key", List.of("alias/team/card-key"), "us-east-1"));
|
||||
|
||||
// The alias is moved to another key while the request runs.
|
||||
service.updateAlias("alias/team/card-key", denied);
|
||||
|
||||
assertEquals(allowed, service.findKey("us-east-1", "alias/team/card-key"),
|
||||
"the request did not act on the key the permission check was made on");
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias's ARN is the name it was given, which carries the {@code alias/} its own resource part carries too,
|
||||
* so it is that name without the prefix.
|
||||
*/
|
||||
@Test
|
||||
void anAliasIsFoundUnderItsName() {
|
||||
assertEquals(Optional.of("arn:aws:payment-cryptography:us-east-1:000000000000:alias/team/card-key"),
|
||||
service.find("alias", List.of("alias/team/card-key"), "us-east-1"));
|
||||
assertEquals(Optional.empty(), service.find("approval-team", List.of("whatever"), "us-east-1"));
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package io.github.hectorvent.floci.services.paymentcryptography.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* How a key is written to the store.
|
||||
*/
|
||||
class PaymentCryptographyKeyTest {
|
||||
|
||||
/**
|
||||
* The material of a key is held by the key while the emulator runs, and is
|
||||
* not written to the store: no operation of the service returns it, so
|
||||
* leaving it out of the persisted key keeps it off the disk.
|
||||
*/
|
||||
@Test
|
||||
void theMaterialOfAKeyIsNotWrittenToTheStore() throws Exception {
|
||||
PaymentCryptographyKey key = new PaymentCryptographyKey();
|
||||
key.setKeyId("abc123");
|
||||
key.setKeyMaterialHex("0f1e2d3c4b5a69788796a5b4c3d2e1f0");
|
||||
key.setKeyCheckValue("7AD386");
|
||||
|
||||
String written = new ObjectMapper().writeValueAsString(key);
|
||||
|
||||
assertFalse(written.contains("keyMaterialHex"), written);
|
||||
assertFalse(written.contains("0f1e2d3c4b5a69788796a5b4c3d2e1f0"), written);
|
||||
assertTrue(written.contains("keyCheckValue"), written);
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,8 @@ floci:
|
||||
flush-interval-ms: 60000
|
||||
cloudwatchmetrics:
|
||||
flush-interval-ms: 60000
|
||||
paymentcryptography:
|
||||
flush-interval-ms: 60000
|
||||
secretsmanager:
|
||||
flush-interval-ms: 60000
|
||||
acm:
|
||||
@@ -281,6 +283,8 @@ floci:
|
||||
max-events-per-query: 10000
|
||||
cloudwatchmetrics:
|
||||
enabled: true
|
||||
paymentcryptography:
|
||||
enabled: true
|
||||
secretsmanager:
|
||||
enabled: true
|
||||
default-recovery-window-days: 30
|
||||
|
||||
@@ -130,8 +130,8 @@ OUTPUT = REPO_ROOT / "src/main/resources/aws/iam-request-resources.json"
|
||||
# are the ones its handlers mint.
|
||||
NAMESPACES = ("acm", "application-autoscaling", "athena", "bcm-data-exports", "bcm-pricing-calculator", "budgets", "ce", "cloudtrail",
|
||||
"codebuild", "codepipeline", "cognito-identity", "cognito-idp", "cur", "ecr", "elasticloadbalancing",
|
||||
"events", "firehose", "globalaccelerator", "kinesisanalytics", "redshift-data", "servicediscovery",
|
||||
"servicequotas", "states", "textract", "timestream-influxdb", "translate")
|
||||
"events", "firehose", "globalaccelerator", "kinesisanalytics", "payment-cryptography", "redshift-data",
|
||||
"servicediscovery", "servicequotas", "states", "textract", "timestream-influxdb", "translate")
|
||||
|
||||
# SDK clients the reference lists for a namespace's operations whose requests Floci does not serve, and why: their
|
||||
# members are not read.
|
||||
|
||||
@@ -98,7 +98,8 @@ NAMESPACES = (
|
||||
"cognito-identity", "cognito-idp", "comprehend", "config", "cur", "datasync", "dms", "dsql", "dynamodb",
|
||||
"ec2", "ecr", "ecs", "eks", "elasticache", "elasticloadbalancing", "elasticmapreduce", "events",
|
||||
"firehose", "globalaccelerator", "glue", "iam", "kinesis", "kinesisanalytics", "kms", "lambda",
|
||||
"lightsail", "logs", "memorydb", "network-firewall", "organizations", "pipes", "rds", "redshift",
|
||||
"lightsail", "logs", "memorydb", "network-firewall", "organizations", "payment-cryptography", "pipes",
|
||||
"rds", "redshift",
|
||||
"redshift-serverless", "rekognition", "resource-groups", "route53resolver", "sagemaker", "scheduler",
|
||||
"secretsmanager", "servicediscovery", "ses", "sns", "sqs", "ssm", "sso", "states", "sts", "swf", "textract",
|
||||
"timestream-influxdb", "transcribe", "transfer", "translate", "wafv2",
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Vendor Payment Cryptography request constraints from botocore's Apache-2.0 service model.
|
||||
|
||||
`PaymentCryptographyRequestShapes` checks the control plane's actions against the vendored file
|
||||
through the shared `RequestConstraintCheck`: member types, required members, lengths and counts,
|
||||
patterns and enum values, as the model states them. The patterns are what settle which key a
|
||||
request may name: `KeyIdentifier` takes a key ARN, an alias ARN or an alias name, while
|
||||
`KeyArn` and `ResourceArn` take the ARN of a key alone.
|
||||
|
||||
Run from anywhere in the repo:
|
||||
python3 tools/aws/regen_payment_cryptography_shapes.py # rewrite the vendored file in place
|
||||
python3 tools/aws/regen_payment_cryptography_shapes.py --check # exit 1 when the vendored file is stale
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from regen_partitions import resolve_botocore_data, strip_source
|
||||
from request_shapes import REPO_ROOT, build_constraints, load_model
|
||||
|
||||
OUTPUT = REPO_ROOT / "src/main/resources/aws/payment-cryptography-request-shapes.json"
|
||||
MODEL = Path("payment-cryptography/2021-09-14")
|
||||
OPERATIONS = (
|
||||
"CreateKey", "GetKey", "ListKeys", "DeleteKey",
|
||||
"CreateAlias", "GetAlias", "ListAliases", "UpdateAlias", "DeleteAlias",
|
||||
"TagResource", "UntagResource", "ListTagsForResource",
|
||||
)
|
||||
|
||||
# The partition the model writes in its ARN patterns, and the one the service writes in
|
||||
# every partition it serves.
|
||||
COMMERCIAL = "arn:aws:"
|
||||
EVERY_PARTITION = "arn:aws[a-z0-9-]*:"
|
||||
|
||||
|
||||
def widen_partition(doc: dict) -> dict:
|
||||
"""The model's patterns, with the partition they name widened to every partition.
|
||||
|
||||
The model writes the commercial partition, as the service's own model need not name the
|
||||
others, but the service mints and takes the ARN of the partition a key is in, so the check
|
||||
must not refuse the ARN of a key outside the commercial one.
|
||||
"""
|
||||
for shape in doc["shapes"].values():
|
||||
pattern = shape.get("pattern")
|
||||
if pattern and COMMERCIAL in pattern:
|
||||
shape["pattern"] = pattern.replace(COMMERCIAL, EVERY_PARTITION)
|
||||
return doc
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("--check", action="store_true", help="exit 1 when the vendored file differs from a fresh generation")
|
||||
parser.add_argument("--botocore-data", type=Path, help="botocore data directory")
|
||||
args = parser.parse_args(argv)
|
||||
data, provenance = resolve_botocore_data(args.botocore_data)
|
||||
doc = widen_partition(build_constraints(load_model(data, MODEL), OPERATIONS, provenance,
|
||||
"tools/aws/regen_payment_cryptography_shapes.py"))
|
||||
fresh = json.dumps(doc, indent=2) + "\n"
|
||||
if args.check:
|
||||
if not OUTPUT.exists() or strip_source(OUTPUT.read_text(encoding="utf-8")) != strip_source(fresh):
|
||||
print(f"{OUTPUT} is stale (generated from {provenance}).", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
OUTPUT.write_text(fresh, encoding="utf-8")
|
||||
print(f"wrote {OUTPUT.relative_to(REPO_ROOT)} from {provenance}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -22,6 +22,7 @@ import regen_ecr_shapes
|
||||
import regen_ecs_shapes
|
||||
import regen_emr_serverless_shapes
|
||||
import regen_iam_shapes
|
||||
import regen_payment_cryptography_shapes
|
||||
import regen_resource_groups_shapes
|
||||
import regen_sesv2_shapes
|
||||
import regen_sts_shapes
|
||||
@@ -353,7 +354,8 @@ def vendored(script) -> tuple[str, ...]:
|
||||
|
||||
|
||||
@pytest.mark.parametrize("script", [
|
||||
regen_ecr_shapes, regen_iam_shapes, regen_resource_groups_shapes, regen_sts_shapes,
|
||||
regen_ecr_shapes, regen_iam_shapes, regen_payment_cryptography_shapes,
|
||||
regen_resource_groups_shapes, regen_sts_shapes,
|
||||
])
|
||||
def test_each_vendored_constraints_file_carries_its_operations_and_resolves_its_shapes(script):
|
||||
doc = json.loads(script.OUTPUT.read_text(encoding="utf-8"))
|
||||
@@ -372,3 +374,28 @@ def test_ecr_shapes_name_the_ecr_model_and_its_registry_setting_actions():
|
||||
assert regen_ecr_shapes.MODEL == Path("ecr/2015-09-21")
|
||||
assert regen_ecr_shapes.OUTPUT.name == "ecr-request-shapes.json"
|
||||
assert "PutReplicationConfiguration" in regen_ecr_shapes.OPERATIONS
|
||||
|
||||
|
||||
def test_payment_cryptography_shapes_name_its_model_and_its_control_plane_actions():
|
||||
assert regen_payment_cryptography_shapes.MODEL == Path("payment-cryptography/2021-09-14")
|
||||
assert regen_payment_cryptography_shapes.OUTPUT.name == "payment-cryptography-request-shapes.json"
|
||||
assert "TagResource" in regen_payment_cryptography_shapes.OPERATIONS
|
||||
assert "UpdateAlias" in regen_payment_cryptography_shapes.OPERATIONS
|
||||
|
||||
|
||||
def test_payment_cryptography_shapes_widen_the_partition_the_model_writes():
|
||||
doc = json.loads(regen_payment_cryptography_shapes.OUTPUT.read_text(encoding="utf-8"))
|
||||
|
||||
# The model writes the commercial partition; the service writes every partition it serves.
|
||||
assert regen_payment_cryptography_shapes.COMMERCIAL not in doc["shapes"]["KeyArn"]["pattern"]
|
||||
assert regen_payment_cryptography_shapes.EVERY_PARTITION in doc["shapes"]["KeyArn"]["pattern"]
|
||||
assert regen_payment_cryptography_shapes.EVERY_PARTITION in doc["shapes"]["ResourceArn"]["pattern"]
|
||||
|
||||
|
||||
def test_payment_cryptography_shapes_take_the_key_an_arn_only_member_names():
|
||||
doc = json.loads(regen_payment_cryptography_shapes.OUTPUT.read_text(encoding="utf-8"))
|
||||
|
||||
# KeyArn and ResourceArn take the ARN of a key alone; KeyIdentifier also takes an alias.
|
||||
assert doc["shapes"]["KeyArn"]["pattern"].endswith("key/[0-9a-zA-Z]{16,64}")
|
||||
assert "alias/" not in doc["shapes"]["KeyArn"]["pattern"]
|
||||
assert "alias/" in doc["shapes"]["KeyArnOrKeyAliasType"]["pattern"]
|
||||
@@ -37,6 +37,7 @@ aliases:
|
||||
codeguru-reviewer: codegurureviewer # SigV4 signing name is hyphenated; the doc slug is not
|
||||
cognito-identity: cognitoidentity # SigV4 signing name is hyphenated; the doc slug is not
|
||||
app-integrations: appintegrations # SigV4 signing name is hyphenated; the doc slug is not
|
||||
paymentcryptography: payment-cryptography
|
||||
servicecatalog: service-catalog
|
||||
cognito-idp: cognito # Cognito's SigV4 signing name
|
||||
states: step-functions # Step Functions' SigV4 signing name
|
||||
|
||||
@@ -25,6 +25,10 @@ services:
|
||||
doc: docs/services/acm.md
|
||||
sources:
|
||||
- { path: services/acm/AcmJsonHandler.java, mode: switch }
|
||||
- service: paymentcryptography
|
||||
doc: docs/services/payment-cryptography.md
|
||||
sources:
|
||||
- { path: services/paymentcryptography/PaymentCryptographyJsonHandler.java, mode: switch }
|
||||
- service: applicationautoscaling
|
||||
doc: docs/services/applicationautoscaling.md
|
||||
sources:
|
||||
|
||||
Reference in new issue
Block a user