mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(kms): add EnableKey support (#1381)
This commit is contained in:
1 parent
660a8bceb3
commit
ca5fb043a7
4 files changed
+105
No files matched your search
@@ -69,6 +69,7 @@ public class KmsJsonHandler {
|
||||
case "GetKeyRotationStatus" -> handleGetKeyRotationStatus(request, region);
|
||||
case "EnableKeyRotation" -> handleEnableKeyRotation(request, region);
|
||||
case "DisableKeyRotation" -> handleDisableKeyRotation(request, region);
|
||||
case "EnableKey" -> handleEnableKey(request, region);
|
||||
case "DisableKey" -> handleDisableKey(request, region);
|
||||
case "RotateKeyOnDemand" -> handleRotateKeyOnDemand(request, region);
|
||||
default -> Response.status(400)
|
||||
@@ -511,6 +512,11 @@ public class KmsJsonHandler {
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
}
|
||||
|
||||
private Response handleEnableKey(JsonNode request, String region) {
|
||||
service.enableKey(request.path("KeyId").asText(), region);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
}
|
||||
|
||||
private Response handleDisableKey(JsonNode request, String region) {
|
||||
service.disableKey(request.path("KeyId").asText(), region);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
|
||||
@@ -523,6 +523,18 @@ public class KmsService {
|
||||
LOG.infov("Disabled key rotation for KMS key: {0} in {1}", key.getKeyId(), region);
|
||||
}
|
||||
|
||||
public void enableKey(String keyId, String region) {
|
||||
KmsKey key = resolveKey(keyId, region);
|
||||
if ("PendingDeletion".equals(key.getKeyState())) {
|
||||
throw new AwsException("KMSInvalidStateException",
|
||||
"KMS key " + key.getKeyId() + " is pending deletion.", 400);
|
||||
}
|
||||
key.setEnabled(true);
|
||||
key.setKeyState("Enabled");
|
||||
keyStore.put(region + "::" + key.getKeyId(), key);
|
||||
LOG.infov("Enabled KMS key: {0} in {1}", key.getKeyId(), region);
|
||||
}
|
||||
|
||||
public void disableKey(String keyId, String region) {
|
||||
KmsKey key = resolveKey(keyId, region);
|
||||
key.setEnabled(false);
|
||||
|
||||
Reference in new issue
Block a user