chore: import fully qualified types, lifecycle to verifiedpermissions (#6739)

This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-27 10:15:26 -04:00
1 parent 1f9b3993e2
commit 2eaf268727
10 files changed
+65 -53

No files matched your search

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
import io.github.hectorvent.floci.core.common.AwsException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
@@ -90,7 +91,7 @@ public class Route53ResolverJsonHandler {
"Unknown operation: Route53Resolver." + action))
.build();
};
} catch (io.github.hectorvent.floci.core.common.AwsException e) {
} catch (AwsException e) {
return Response.status(e.getHttpStatus())
.entity(new AwsErrorResponse(e.jsonType(), e.getMessage())).build();
}
@@ -266,7 +266,7 @@ public class SsoAdminJsonHandler {
return Response.ok(response).build();
}
private ObjectNode trustedTokenIssuerMetadataNode(io.github.hectorvent.floci.services.ssoadmin.model.TrustedTokenIssuer issuer) {
private ObjectNode trustedTokenIssuerMetadataNode(TrustedTokenIssuer issuer) {
ObjectNode response = mapper.createObjectNode();
response.put("Name", issuer.name());
response.put("TrustedTokenIssuerArn", issuer.trustedTokenIssuerArn());
@@ -304,7 +304,7 @@ public class SsoAdminJsonHandler {
return Response.ok(response).build();
}
private ObjectNode regionNode(io.github.hectorvent.floci.services.ssoadmin.model.RegionMetadata region) {
private ObjectNode regionNode(RegionMetadata region) {
ObjectNode response = mapper.createObjectNode();
response.put("AddedDate", service.regionAddedDateEpochSeconds(region));
response.put("IsPrimaryRegion", region.primaryRegion());
@@ -123,10 +123,12 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.IntFunction;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -540,7 +542,7 @@ public class AslExecutor {
Future<?> f = executor.submit(() -> runUnderExecutionAccount(sm,
() -> doExecute(sm, exec, history, onUpdate, maxExecutionDeadlineNanos)));
f.get(maxExecutionDeadlineNanos - nanoTime.getAsLong(), TimeUnit.NANOSECONDS);
} catch (java.util.concurrent.TimeoutException e) {
} catch (TimeoutException e) {
answerTimedOutUnlessEnded(exec, history, onUpdate);
} catch (Exception e) {
LOG.warnv("Sync execution wait failed for {0}: {1}", exec.getExecutionArn(), e.getMessage());
@@ -1103,7 +1105,7 @@ public class AslExecutor {
heartbeatDeadlineNanos(taskToken, heartbeatSeconds)));
try {
return future.get(wakeAtNanos - nanoTime.getAsLong(), TimeUnit.NANOSECONDS);
} catch (java.util.concurrent.TimeoutException e) {
} catch (TimeoutException e) {
TokenWait decision = sfnService.get().expirePendingToken(taskToken, nanoTime.getAsLong(),
executionDeadlineNanos, timeoutDeadlineNanos, heartbeatSeconds);
if (decision.timeout() == TokenTimeout.CLAIMED) {
@@ -1716,7 +1718,7 @@ public class AslExecutor {
throw new FailStateException("Sfn.InvalidArnException",
"StateMachineArn is required for StartExecution");
}
io.github.hectorvent.floci.services.stepfunctions.model.Execution exec;
Execution exec;
try {
exec = sfnService.get().startExecution(smArn, input.path("Name").asText(null),
sdkPayload(input.path("Input")), region);
@@ -1907,7 +1909,7 @@ public class AslExecutor {
throw new FailStateException("Sfn.InvalidArnException",
"StateMachineArn is required for StartSyncExecution");
}
io.github.hectorvent.floci.services.stepfunctions.model.Execution exec;
Execution exec;
try {
exec = sfnService.get().startSyncExecution(smArn, input.path("Name").asText(null),
sdkPayload(input.path("Input")), region);
@@ -3269,7 +3271,7 @@ public class AslExecutor {
iterationChains.add(distributed ? HistoryChain.ofChildExecution() : chain.fork());
}
java.util.function.IntFunction<Callable<JsonNode>> makeTask = (i) -> () -> {
IntFunction<Callable<JsonNode>> makeTask = (i) -> () -> {
HistoryChain iterationChain = iterationChains.get(i);
boolean batchedChild = batches != null;
JsonNode item = batchedChild ? batches.get(i) : items.get(i);
@@ -3354,7 +3356,7 @@ public class AslExecutor {
i -> () -> callUnderExecutionAccount(sm, makeTask.apply(i)),
executionDeadlineNanos,
i -> cutIteration(iterationChains.get(i), i, cutIterations));
} catch (java.util.concurrent.TimeoutException e) {
} catch (TimeoutException e) {
// The only deadline the scheduler is given is the state machine's budget, so its
// expiry ends the execution rather than failing the Map state.
throw new ExecutionTimedOutException();
@@ -3881,10 +3883,10 @@ public class AslExecutor {
record.put("RedriveCount", 0);
record.put("RedriveStatus", "NOT_REDRIVABLE");
record.put("RedriveStatusReason", "Execution is SUCCEEDED and cannot be redriven");
record.put("StartDate", java.time.Instant.ofEpochMilli(start).toString());
record.put("StartDate", Instant.ofEpochMilli(start).toString());
record.put("StateMachineArn", childSmArn);
record.put("Status", "SUCCEEDED");
record.put("StopDate", java.time.Instant.ofEpochMilli(stop).toString());
record.put("StopDate", Instant.ofEpochMilli(stop).toString());
}
return out;
}
@@ -4293,7 +4295,7 @@ public class AslExecutor {
execution.put("Id", exec.getExecutionArn());
execution.put("Name", exec.getName());
execution.put("RoleArn", sm.getRoleArn());
execution.put("StartTime", java.time.Instant.ofEpochMilli((long) (exec.getStartDate() * 1000)).toString());
execution.put("StartTime", Instant.ofEpochMilli((long) (exec.getStartDate() * 1000)).toString());
if (exec.getInput() != null) {
execution.set("Input", parseInput(exec.getInput()));
}
@@ -4313,7 +4315,7 @@ public class AslExecutor {
ObjectNode context = (ObjectNode) execContext;
ObjectNode state = objectMapper.createObjectNode();
state.put("Name", stateName);
state.put("EnteredTime", java.time.Instant.now().toString());
state.put("EnteredTime", Instant.now().toString());
state.put("RetryCount", 0);
context.set("State", state);
}
@@ -5350,7 +5352,7 @@ public class AslExecutor {
yield objectMapper.getNodeFactory().booleanNode(contains);
}
case "States.UUID" -> {
yield objectMapper.getNodeFactory().textNode(java.util.UUID.randomUUID().toString());
yield objectMapper.getNodeFactory().textNode(UUID.randomUUID().toString());
}
case "States.JsonMerge" -> {
List<String> parts = splitIntrinsicArgs(argsStr);
@@ -1,10 +1,13 @@
package io.github.hectorvent.floci.services.verifiedpermissions;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.PaginatedResult;
import io.github.hectorvent.floci.services.verifiedpermissions.model.EntityIdentifier;
import io.github.hectorvent.floci.services.verifiedpermissions.model.IdentitySource;
import io.github.hectorvent.floci.services.verifiedpermissions.model.Policy;
import io.github.hectorvent.floci.services.verifiedpermissions.model.PolicyStore;
@@ -15,6 +18,8 @@ import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -193,11 +198,11 @@ public class VerifiedPermissionsJsonHandler {
if (!parsed.isObject()) {
return List.of();
}
java.util.ArrayList<String> names = new java.util.ArrayList<>();
ArrayList<String> names = new ArrayList<>();
parsed.fieldNames().forEachRemaining(names::add);
names.sort(String::compareTo);
return names;
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
} catch (JsonProcessingException e) {
throw new IllegalStateException("Stored Verified Permissions schema is not valid JSON", e);
}
}
@@ -259,7 +264,7 @@ public class VerifiedPermissionsJsonHandler {
}
ObjectNode out = objectMapper.createObjectNode();
ArrayNode results = out.putArray("results");
io.github.hectorvent.floci.services.verifiedpermissions.model.EntityIdentifier principal = null;
EntityIdentifier principal = null;
for (JsonNode item : requests) {
ObjectNode single = objectMapper.createObjectNode();
single.put("policyStoreId", storeIdentifier);
@@ -480,7 +485,7 @@ public class VerifiedPermissionsJsonHandler {
String policy = VerifiedPermissionsService.requiredText(item, "policyId");
try {
results.add(policyDetail(service.getPolicy(store, policy, region), region));
} catch (io.github.hectorvent.floci.core.common.AwsException e) {
} catch (AwsException e) {
ObjectNode error = errors.addObject();
error.put("policyStoreId", store);
error.put("policyId", policy);
@@ -500,10 +505,10 @@ public class VerifiedPermissionsJsonHandler {
private boolean storeExists(String id, String region) {
try { service.getPolicyStore(id, region); return true; }
catch (io.github.hectorvent.floci.core.common.AwsException e) { return false; }
catch (AwsException e) { return false; }
}
private static void addEntity(ObjectNode out, String field, io.github.hectorvent.floci.services.verifiedpermissions.model.EntityIdentifier entity) {
private static void addEntity(ObjectNode out, String field, EntityIdentifier entity) {
if (entity == null) {
return;
}
@@ -548,7 +553,7 @@ public class VerifiedPermissionsJsonHandler {
if (!node.isObject()) {
throw VerifiedPermissionsService.validation("tags is required.");
}
Map<String, String> out = new java.util.LinkedHashMap<>();
Map<String, String> out = new LinkedHashMap<>();
node.fields().forEachRemaining(e -> {
if (!e.getValue().isTextual()) {
throw VerifiedPermissionsService.validation("Tag values must be strings.");
@@ -562,7 +567,7 @@ public class VerifiedPermissionsJsonHandler {
if (!node.isArray()) {
throw VerifiedPermissionsService.validation("tagKeys is required.");
}
java.util.ArrayList<String> out = new java.util.ArrayList<>();
ArrayList<String> out = new ArrayList<>();
node.forEach(v -> {
if (!v.isTextual()) {
throw VerifiedPermissionsService.validation("tagKeys must contain strings.");
@@ -33,6 +33,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.regex.Pattern;
@@ -740,7 +741,7 @@ public class VerifiedPermissionsService implements Resettable {
private String requestFingerprint(JsonNode request) {
JsonNode copy = request.deepCopy();
if (copy.isObject()) {
((com.fasterxml.jackson.databind.node.ObjectNode) copy).remove("clientToken");
((ObjectNode) copy).remove("clientToken");
}
try {
return canonical(copy);
@@ -751,7 +752,7 @@ public class VerifiedPermissionsService implements Resettable {
private String canonical(JsonNode node) throws JsonProcessingException {
if (node.isObject()) {
java.util.TreeMap<String, JsonNode> sorted = new java.util.TreeMap<>();
TreeMap<String, JsonNode> sorted = new TreeMap<>();
node.fields().forEachRemaining(e -> sorted.put(e.getKey(), e.getValue()));
StringBuilder b = new StringBuilder("{");
boolean first = true;
@@ -1077,7 +1078,7 @@ public class VerifiedPermissionsService implements Resettable {
if (node == null || !node.isObject()) {
throw validation("The Cedar schema must be a JSON object.");
}
} catch (io.github.hectorvent.floci.core.common.AwsException e) {
} catch (AwsException e) {
throw e;
} catch (Exception e) {
throw validation("The Cedar schema is invalid: " + safeMessage(e));