feat(signer): serve the Signer control plane for profiles, permissions and job records (#7680)

Signer was the last control plane Floci's CloudFormation provisioner stubbed:
SignerCfnProvisioner recorded only the identifiers a template handed it, with
a comment saying Floci has no Signer API. This serves the API, so an SDK, the
CLI or a stack sees the profile it actually created.

Cancellation keeps the profile, as AWS does: it stays readable through
GetSigningProfile with the same ARN and version and the status Canceled, it
stops accepting jobs, and ListSigningProfiles hides it unless includeCanceled
is set or statuses names Canceled. A PutSigningProfile on the same name brings
it back as a new active version.

A signing job fails by default, and says why. Nothing on this machine signs the
artifact, so a succeeded job would advertise a signedObject key that does not
exist and every download of it would fail; the job instead completes as Failed
with a statusReason naming the object that was not written, and RevokeSignature
refuses it because there is no signature to revoke. Metadata-only callers can
set floci.services.signer.mock-signing-jobs=true, which records jobs as
succeeded and is documented as a mock rather than as AWS behaviour.

Signer routes collide with S3's path-style ones, so a request signed for the
signer scope is rewritten onto an internal prefix before matching. That rewrite
used to happen before IAM resolved the action from the path, which left every
Signer call unchecked; IamActionRegistry now strips the internal prefix the
signing service owns, and SignerIamEnforcementIntegrationTest proves a key with
no policy is refused while one with signer:* is allowed.

Co-authored-by: David Guardiola <davidguardiola@gmail.com>
This commit is contained in:
dgl-aiandDavid Guardiola authored and GitHub committed 2026-11-09 09:08:00 -04:00
1 parent a65def00a4
commit 13640785a9
34 files changed
+3804 -38

No files matched your search

@@ -874,6 +874,7 @@ public interface EmulatorConfig {
ConnectServiceConfig connect();
AppIntegrationsServiceConfig appintegrations();
DlmServiceConfig dlm();
SignerServiceConfig signer();
CognitoIdentityServiceConfig cognitoidentity();
GlobalAcceleratorServiceConfig globalaccelerator();
DataSyncServiceConfig datasync();
@@ -951,6 +952,19 @@ public interface EmulatorConfig {
boolean enabled();
}
interface SignerServiceConfig {
@WithDefault("true")
boolean enabled();
/**
* Records signing jobs as succeeded without producing an artifact, for callers that only
* read job metadata. Off by default: a job that reports success must have something to
* download, and Floci does not sign code.
*/
@WithDefault("false")
boolean mockSigningJobs();
}
interface CognitoIdentityServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -101,6 +101,7 @@ import io.floci.aws.services.ses.SesSuppressionController;
import io.floci.aws.services.ses.SesTagController;
import io.floci.aws.services.ses.SesTemplateController;
import io.floci.aws.services.ses.SesTenantController;
import io.floci.aws.services.signer.SignerController;
import io.floci.aws.services.signin.SigninController;
import io.floci.aws.services.ssooidc.SsoOidcController;
import io.floci.aws.services.ssoportal.SsoPortalController;
@@ -777,6 +778,10 @@ public class ResolvedServiceCatalog {
"dlm", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
Set.of(), Set.of("dlm"), Set.of(), Set.of(DlmController.class)),
descriptor("signer", "signer", config.services().signer().enabled(), true,
"signer", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
Set.of(), Set.of("signer"), Set.of(), Set.of(SignerController.class)),
descriptor("cognito-identity", "cognitoidentity",
config.services().cognitoidentity().enabled(), true,
"cognitoidentity", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
@@ -1,26 +1,37 @@
package io.floci.aws.services.cloudformation.provisioners;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import io.floci.aws.core.common.AwsArnUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.services.cloudformation.model.StackResource;
import io.floci.aws.services.signer.SignerPlatforms;
import io.floci.aws.services.signer.SignerService;
import io.floci.aws.services.signer.model.SigningProfile;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern;
/**
* Provisions {@code AWS::Signer::SigningProfile}. Floci has no Signer API, so a profile is only the
* identifiers CloudFormation hands the template: {@code Ref} is the profile ARN, and the attributes
* carry the name, a version and the version ARN a code signing config lists. Every property but
* {@code Tags} is create-only: an update that keeps them keeps the profile, one that changes them
* mints a new one, and one that would keep an explicit name is refused, as CloudFormation refuses
* replacing any custom-named resource. A replaced or deleted profile leaves nothing behind to clean
* up, and a rolled-back replacement points the resource back to the prior profile.
* Provisions {@code AWS::Signer::SigningProfile} through {@link SignerService}, so a profile a stack
* creates is the profile the Signer API serves: {@code aws signer get-signing-profile} returns the
* same ARN the stack hands out as {@code Ref}, with its platform, validity period and tags.
*
* <p>{@code Ref} is the profile ARN and the attributes carry the name, a version and the version ARN
* a code signing config lists. Every property but {@code Tags} is create-only: an update that keeps
* them keeps the profile and re-applies its tags, one that changes them mints a new profile, and one
* that would keep an explicit name is refused, as CloudFormation refuses replacing any custom-named
* resource. A replaced profile is cancelled once the update commits; a rolled-back replacement puts
* the resource back and cancels the profile that update created.
*/
@ApplicationScoped
public class SignerCfnProvisioner implements CfnResourceProvisioner {
@@ -30,8 +41,23 @@ public class SignerCfnProvisioner implements CfnResourceProvisioner {
private static final Pattern PROFILE_NAME = Pattern.compile("[0-9a-zA-Z_]{2,64}");
private static final Map<String, Integer> MAX_VALIDITY = Map.of("DAYS", 4105, "MONTHS", 135, "YEARS", 11);
private static final String ALPHANUMERIC = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static final String PROFILE_RESOURCE = "/signing-profiles/";
/** The create-only properties the profile was minted from, so an update can tell whether it is replaced. */
private static final String CREATE_ONLY_ATTR = "FlociSigningProfileCreateOnly";
/**
* The tags an in-place update is about to replace, with the region they live in, so a rollback
* can put them back. Present only while a tag change is pending: a provision that would write
* the set already stored removes it.
*/
private static final String PRIOR_TAGS_ATTR = "FlociSigningProfilePriorTags";
private static final ObjectMapper MAPPER = new ObjectMapper();
private final SignerService signerService;
@Inject
public SignerCfnProvisioner(SignerService signerService) {
this.signerService = signerService;
}
@Override
public Set<String> resourceTypes() {
@@ -52,7 +78,7 @@ public class SignerCfnProvisioner implements CfnResourceProvisioner {
TYPE + " ProfileName must be 2 to 64 characters from [0-9a-zA-Z_], got " + explicitName, 400);
}
JsonNode period = ctx.engine().resolveNodeOmittingNoValue(props.path("SignatureValidityPeriod"));
validatePeriod(period, ctx);
Integer validityValue = validatePeriod(period, ctx);
String createOnly = platformId + "|" + Objects.toString(explicitName, "") + "|"
+ period.path("Type").asText() + "|" + period.path("Value").asText();
if (!createOnly.equals(r.getAttributes().get(CREATE_ONLY_ATTR))) {
@@ -61,7 +87,9 @@ public class SignerCfnProvisioner implements CfnResourceProvisioner {
"CloudFormation cannot update a stack when a custom-named resource requires "
+ "replacing. Rename " + explicitName + " and update the stack again.", 400);
}
mint(r, ctx, explicitName, createOnly);
mint(r, ctx, platformId, explicitName, period, validityValue, createOnly, tags(ctx, props));
} else {
replaceTags(r, ctx, tags(ctx, props));
}
ReplacementCleanup.record(r, ctx, attributesBefore);
}
@@ -70,9 +98,9 @@ public class SignerCfnProvisioner implements CfnResourceProvisioner {
* Signer's checks on a supplied validity period, in its order and with its messages: a known unit,
* then a value above zero and at most the unit's cap. An omitted period keeps Signer's default.
*/
private static void validatePeriod(JsonNode period, ProvisionContext ctx) {
private static Integer validatePeriod(JsonNode period, ProvisionContext ctx) {
if (period.isMissingNode()) {
return;
return null;
}
String type = period.path("Type").asText(null);
if (type == null || !MAX_VALIDITY.containsKey(type)) {
@@ -87,22 +115,159 @@ public class SignerCfnProvisioner implements CfnResourceProvisioner {
throw new AwsException("ValidationError", "Signature validity period value for " + type
+ " must be less than or equal to " + MAX_VALIDITY.get(type), 400);
}
return value;
}
private static void mint(StackResource r, ProvisionContext ctx, String explicitName, String createOnly) {
private void mint(StackResource r, ProvisionContext ctx, String platformId, String explicitName,
JsonNode period, Integer validityValue, String createOnly, Map<String, String> tags) {
String name = explicitName != null ? explicitName
: r.getLogicalId().substring(0, Math.min(r.getLogicalId().length(), 51)) + "_" + random(12);
String arn = AwsArnUtils.Arn.of("signer", ctx.region(), ctx.accountId(), "/signing-profiles/" + name)
.toString();
String version = random(10);
r.setPhysicalId(arn);
r.getAttributes().put("Arn", arn);
r.getAttributes().put("ProfileName", name);
r.getAttributes().put("ProfileVersion", version);
r.getAttributes().put("ProfileVersionArn", arn + "/" + version);
if (explicitName != null && signerService.findSigningProfile(explicitName, ctx.region()).isPresent()) {
throw new AwsException("ValidationError", TYPE + " " + explicitName
+ " already exists in " + ctx.region()
+ "; a stack cannot take over a signing profile it did not create.", 400);
}
SigningProfile profile = signerService.putSigningProfile(
name,
platformId,
period.isMissingNode() ? null : period.path("Type").asText(null),
validityValue,
tags,
ctx.region());
r.setPhysicalId(profile.getArn());
r.getAttributes().put("Arn", profile.getArn());
r.getAttributes().put("ProfileName", profile.getProfileName());
r.getAttributes().put("ProfileVersion", profile.getProfileVersion());
r.getAttributes().put("ProfileVersionArn", profile.getProfileVersionArn());
r.getAttributes().put(CREATE_ONLY_ATTR, createOnly);
}
/**
* A tags-only update. CloudFormation sets the resource's tags to exactly what the template
* declares, so this replaces the set rather than merging into it, and it does not mint a profile
* version: on AWS, tagging a signing profile is not a change to the profile.
*/
private void replaceTags(StackResource r, ProvisionContext ctx, Map<String, String> tags) {
String name = r.getAttributes().get("ProfileName");
if (name == null) {
return;
}
Optional<SigningProfile> stored = signerService.findSigningProfile(name, ctx.region());
if (stored.isEmpty()) {
adopt(r, ctx, name);
signerService.replaceTags(name, tags, ctx.region());
return;
}
if (stored.get().getTags().equals(tags)) {
r.getAttributes().remove(PRIOR_TAGS_ATTR);
return;
}
snapshotTags(r, ctx, stored.get().getTags());
signerService.replaceTags(name, tags, ctx.region());
}
/**
* Writes the service record for a resource this stack provisioned before the service existed,
* keeping the identifiers the stack already handed out. The create-only property string the
* provisioner recorded carries the platform and the validity period, which is all a later tag
* update needs.
*/
private void adopt(StackResource r, ProvisionContext ctx, String name) {
String createOnly = r.getAttributes().get(CREATE_ONLY_ATTR);
String[] parts = createOnly == null ? new String[0] : createOnly.split("\\|", -1);
String platformId = parts.length > 0 ? parts[0] : null;
if (platformId == null || SignerPlatforms.find(platformId).isEmpty()) {
return;
}
String validityType = parts.length > 2 && !parts[2].isEmpty() ? parts[2] : null;
Integer validityValue = null;
if (validityType != null && parts.length > 3) {
try {
validityValue = Integer.valueOf(parts[3]);
} catch (NumberFormatException ignored) {
validityValue = null;
}
}
signerService.adoptSigningProfile(name, platformId, r.getAttributes().get("ProfileVersion"),
validityType, validityValue, ctx.region());
}
private static void snapshotTags(StackResource r, ProvisionContext ctx, Map<String, String> tags) {
ObjectNode snapshot = MAPPER.createObjectNode();
snapshot.put("region", ctx.region());
ObjectNode stored = snapshot.putObject("tags");
tags.forEach(stored::put);
try {
r.getAttributes().put(PRIOR_TAGS_ATTR, MAPPER.writeValueAsString(snapshot));
} catch (JsonProcessingException e) {
throw new AwsException("ValidationError", "Could not record the profile's prior tags: "
+ e.getMessage(), 400);
}
}
private void restorePriorTags(StackResource r, String snapshotJson) {
try {
JsonNode snapshot = MAPPER.readTree(snapshotJson);
String region = snapshot.path("region").asText(null);
String name = r.getAttributes().get("ProfileName");
if (region == null || name == null) {
return;
}
Map<String, String> tags = new LinkedHashMap<>();
snapshot.path("tags").fields().forEachRemaining(entry -> tags.put(entry.getKey(), entry.getValue().asText()));
signerService.replaceTags(name, tags, region);
} catch (JsonProcessingException e) {
throw new AwsException("ValidationError", "Could not restore the profile's prior tags: "
+ e.getMessage(), 400);
}
}
/**
* The template's {@code Tags}, with every key and value resolved: a {@code Ref}, an
* {@code Fn::Sub} or a {@code Fn::If} inside a tag is a reference to something the engine owns,
* and reading the raw node would store the intrinsic document as the tag.
*/
private static Map<String, String> tags(ProvisionContext ctx, JsonNode props) {
JsonNode tags = ctx.engine().resolveNodeOmittingNoValue(props.path("Tags"));
if (tags.isMissingNode() || tags.isNull() || !tags.isArray()) {
return new LinkedHashMap<>();
}
Map<String, String> resolved = new LinkedHashMap<>();
for (JsonNode tag : tags) {
String key = ctx.engine().resolveNodeOmittingNoValue(tag.path("Key")).asText(null);
if (key == null || key.isEmpty()) {
continue;
}
resolved.put(key, ctx.engine().resolveNodeOmittingNoValue(tag.path("Value")).asText(""));
}
return resolved;
}
@Override
public void delete(String resourceType, String physicalId, String region) {
String name = profileNameOf(physicalId);
if (name == null) {
return;
}
CfnDeletes.safeDelete("Signing profile", physicalId,
() -> signerService.cancelSigningProfile(name, region),
"ResourceNotFoundException");
}
/** The profile name the ARN names, so a delete driven by a physical id alone can cancel it. */
private static String profileNameOf(String physicalId) {
if (physicalId == null) {
return null;
}
int at = physicalId.indexOf(PROFILE_RESOURCE);
if (at < 0) {
return null;
}
String remainder = physicalId.substring(at + PROFILE_RESOURCE.length());
int slash = remainder.indexOf('/');
return slash < 0 ? remainder : remainder.substring(0, slash);
}
@Override
public boolean hasReplacementUpdate(StackResource resource) {
return ReplacementCleanup.hasReplacement(resource);
@@ -115,6 +280,7 @@ public class SignerCfnProvisioner implements CfnResourceProvisioner {
@Override
public UpdateCleanupResult completeUpdate(StackResource resource) {
resource.getAttributes().remove(PRIOR_TAGS_ATTR);
return ReplacementCleanup.complete(resource, this::delete);
}
@@ -123,9 +289,15 @@ public class SignerCfnProvisioner implements CfnResourceProvisioner {
ReplacementCleanup.clear(resource);
}
/** A replacement points back to the prior profile; a tags-only update changed nothing Floci holds. */
/** A replacement points back to the prior profile and cancels the one this update created. */
@Override
public boolean rollbackUpdate(StackResource resource) {
String pendingTags = resource.getAttributes().get(PRIOR_TAGS_ATTR);
if (!ReplacementCleanup.hasReplacement(resource) && pendingTags != null) {
restorePriorTags(resource, pendingTags);
resource.getAttributes().remove(PRIOR_TAGS_ATTR);
return true;
}
ReplacementCleanup.rollback(resource, this::delete);
return true;
}
@@ -0,0 +1,364 @@
package io.floci.aws.services.signer;
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.floci.aws.core.common.JsonErrorResponseUtils;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.services.signer.model.SigningJob;
import io.floci.aws.services.signer.model.SigningProfile;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.util.List;
/**
* The REST JSON routes AWS Signer publishes, mounted under {@link SignerRouteFilter#INTERNAL_PREFIX}.
*
* <p>Signer's public paths are literal ({@code /signing-profiles}, {@code /signing-jobs},
* {@code /signing-platforms}, {@code /revocations}) and S3's path-style routes would otherwise claim
* them as buckets, so {@link SignerRouteFilter} rewrites a request signed for {@code signer} onto the
* internal prefix before route matching. The shared {@code /tags/{resourceArn}} routes are served by
* {@code SharedTagsController} through {@link SignerService} as a {@code TagHandler}.
*/
@Path(SignerRouteFilter.INTERNAL_PREFIX)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class SignerController {
private final SignerService signerService;
private final RegionResolver regionResolver;
private final ObjectMapper objectMapper;
@Inject
public SignerController(SignerService signerService, RegionResolver regionResolver,
ObjectMapper objectMapper) {
this.signerService = signerService;
this.regionResolver = regionResolver;
this.objectMapper = objectMapper;
}
@PUT
@Path("/signing-profiles/{profileName}")
public Response putSigningProfile(@PathParam("profileName") String profileName,
@Context HttpHeaders headers, String body) {
String region = regionResolver.resolveRegion(headers);
SigningProfile profile = signerService.putSigningProfile(profileName, readTree(body), region);
ObjectNode response = objectMapper.createObjectNode();
response.put("arn", profile.getArn());
response.put("profileVersion", profile.getProfileVersion());
response.put("profileVersionArn", profile.getProfileVersionArn());
return Response.ok(response).build();
}
@GET
@Path("/signing-profiles/{profileName}")
public Response getSigningProfile(@PathParam("profileName") String profileName,
@Context HttpHeaders headers) {
String region = regionResolver.resolveRegion(headers);
return Response.ok(profileNode(signerService.getSigningProfile(profileName, region), true))
.build();
}
@GET
@Path("/signing-profiles")
public Response listSigningProfiles(@Context HttpHeaders headers,
@QueryParam("platformId") String platformId,
@QueryParam("statuses") List<String> statuses,
@QueryParam("includeCanceled") Boolean includeCanceled,
@QueryParam("maxResults") Integer maxResults,
@QueryParam("nextToken") String nextToken) {
String region = regionResolver.resolveRegion(headers);
SignerService.Page<SigningProfile> page = signerService.listSigningProfiles(
region, platformId, statuses, includeCanceled, maxResults, nextToken);
ObjectNode response = objectMapper.createObjectNode();
ArrayNode profiles = response.putArray("profiles");
for (SigningProfile profile : page.items()) {
profiles.add(profileNode(profile, false));
}
if (page.nextToken() != null) {
response.put("nextToken", page.nextToken());
}
return Response.ok(response).build();
}
@DELETE
@Path("/signing-profiles/{profileName}")
public Response cancelSigningProfile(@PathParam("profileName") String profileName,
@Context HttpHeaders headers) {
String region = regionResolver.resolveRegion(headers);
signerService.cancelSigningProfile(profileName, region);
return Response.ok().build();
}
@PUT
@Path("/signing-profiles/{profileName}/revoke")
public Response revokeSigningProfile(@PathParam("profileName") String profileName,
@Context HttpHeaders headers, String body) {
String region = regionResolver.resolveRegion(headers);
signerService.revokeSigningProfile(profileName, readTree(body), region);
return Response.ok().build();
}
@POST
@Path("/signing-profiles/{profileName}/permissions")
public Response addProfilePermission(@PathParam("profileName") String profileName,
@Context HttpHeaders headers, String body) {
String region = regionResolver.resolveRegion(headers);
String revisionId = signerService.addProfilePermission(profileName, readTree(body), region);
ObjectNode response = objectMapper.createObjectNode();
response.put("revisionId", revisionId);
return Response.ok(response).build();
}
@GET
@Path("/signing-profiles/{profileName}/permissions")
public Response listProfilePermissions(@PathParam("profileName") String profileName,
@Context HttpHeaders headers) {
String region = regionResolver.resolveRegion(headers);
List<SigningProfile.ProfilePermission> permissions =
signerService.listProfilePermissions(profileName, region);
ObjectNode response = objectMapper.createObjectNode();
response.put("revisionId", signerService.getSigningProfile(profileName, region)
.getRevisionId());
response.put("policySizeBytes", permissions.size() * 128);
ArrayNode entries = response.putArray("permissions");
for (SigningProfile.ProfilePermission permission : permissions) {
ObjectNode entry = entries.addObject();
entry.put("action", permission.getAction());
entry.put("principal", permission.getPrincipal());
entry.put("statementId", permission.getStatementId());
entry.put("profileVersion", permission.getProfileVersion());
}
return Response.ok(response).build();
}
@DELETE
@Path("/signing-profiles/{profileName}/permissions/{statementId}")
public Response removeProfilePermission(@PathParam("profileName") String profileName,
@PathParam("statementId") String statementId,
@QueryParam("revisionId") String revisionId,
@Context HttpHeaders headers) {
String region = regionResolver.resolveRegion(headers);
String newRevisionId = signerService.removeProfilePermission(
profileName, statementId, revisionId, region);
ObjectNode response = objectMapper.createObjectNode();
response.put("revisionId", newRevisionId);
return Response.ok(response).build();
}
@POST
@Path("/signing-jobs")
public Response startSigningJob(@Context HttpHeaders headers, String body) {
String region = regionResolver.resolveRegion(headers);
SigningJob job = signerService.startSigningJob(readTree(body), region);
ObjectNode response = objectMapper.createObjectNode();
response.put("jobId", job.getJobId());
response.put("jobOwner", job.getJobOwner());
return Response.ok(response).build();
}
@GET
@Path("/signing-jobs")
public Response listSigningJobs(@Context HttpHeaders headers,
@QueryParam("status") String status,
@QueryParam("platformId") String platformId,
@QueryParam("isRevoked") Boolean isRevoked,
@QueryParam("maxResults") Integer maxResults,
@QueryParam("nextToken") String nextToken) {
String region = regionResolver.resolveRegion(headers);
SignerService.Page<SigningJob> page = signerService.listSigningJobs(
region, status, platformId, isRevoked, maxResults, nextToken);
ObjectNode response = objectMapper.createObjectNode();
ArrayNode jobs = response.putArray("jobs");
for (SigningJob job : page.items()) {
jobs.add(jobNode(job, false));
}
if (page.nextToken() != null) {
response.put("nextToken", page.nextToken());
}
return Response.ok(response).build();
}
@GET
@Path("/signing-jobs/{jobId}")
public Response describeSigningJob(@PathParam("jobId") String jobId,
@Context HttpHeaders headers) {
String region = regionResolver.resolveRegion(headers);
return Response.ok(jobNode(signerService.describeSigningJob(jobId, region), true)).build();
}
@PUT
@Path("/signing-jobs/{jobId}/revoke")
public Response revokeSignature(@PathParam("jobId") String jobId,
@Context HttpHeaders headers, String body) {
String region = regionResolver.resolveRegion(headers);
signerService.revokeSignature(jobId, readTree(body), region);
return Response.ok().build();
}
@GET
@Path("/revocations")
public Response getRevocationStatus(@Context HttpHeaders headers) {
ObjectNode response = objectMapper.createObjectNode();
ArrayNode revokedEntities = response.putArray("revokedEntities");
for (String entity : signerService.getRevocationStatus()) {
revokedEntities.add(entity);
}
return Response.ok(response).build();
}
@GET
@Path("/signing-platforms")
public Response listSigningPlatforms(@Context HttpHeaders headers,
@QueryParam("category") String category,
@QueryParam("partner") String partner,
@QueryParam("target") String target) {
List<SignerPlatforms.Platform> platforms = signerService.listSigningPlatforms(category);
ObjectNode response = objectMapper.createObjectNode();
ArrayNode entries = response.putArray("platforms");
for (SignerPlatforms.Platform platform : platforms) {
if (partner != null && !partner.equals(platform.partner())) {
continue;
}
if (target != null && !target.equals(platform.target())) {
continue;
}
entries.add(platformNode(platform));
}
return Response.ok(response).build();
}
@GET
@Path("/signing-platforms/{platformId}")
public Response getSigningPlatform(@PathParam("platformId") String platformId,
@Context HttpHeaders headers) {
return Response.ok(platformNode(signerService.getSigningPlatform(platformId))).build();
}
private ObjectNode profileNode(SigningProfile profile, boolean detail) {
ObjectNode node = objectMapper.createObjectNode();
node.put("profileName", profile.getProfileName());
node.put("profileVersion", profile.getProfileVersion());
node.put("profileVersionArn", profile.getProfileVersionArn());
node.put("arn", profile.getArn());
node.put("platformId", profile.getPlatformId());
node.put("platformDisplayName", profile.getPlatformDisplayName());
node.put("status", profile.getStatus());
if (profile.getSigningMaterialCertificateArn() != null) {
node.putObject("signingMaterial")
.put("certificateArn", profile.getSigningMaterialCertificateArn());
}
if (profile.getSignatureValidityPeriodType() != null) {
ObjectNode period = node.putObject("signatureValidityPeriod");
period.put("type", profile.getSignatureValidityPeriodType());
period.put("value", profile.getSignatureValidityPeriodValue());
}
if (profile.getOverrides() != null) {
node.set("overrides", profile.getOverrides());
}
node.set("signingParameters", objectMapper.valueToTree(profile.getSigningParameters()));
node.set("tags", objectMapper.valueToTree(profile.getTags()));
if (detail) {
if (profile.getStatusReason() != null) {
node.put("statusReason", profile.getStatusReason());
}
if (profile.getRevokedAt() != null) {
ObjectNode record = node.putObject("revocationRecord");
record.put("revocationEffectiveFrom", profile.getRevocationEffectiveFrom());
record.put("revokedAt", profile.getRevokedAt());
record.put("revokedBy", profile.getRevokedBy());
}
}
return node;
}
private ObjectNode jobNode(SigningJob job, boolean detail) {
ObjectNode node = objectMapper.createObjectNode();
node.put("jobId", job.getJobId());
node.put("jobArn", job.getJobArn());
ObjectNode sourceS3 = node.putObject("source").putObject("s3");
sourceS3.put("bucketName", job.getSourceBucketName());
sourceS3.put("key", job.getSourceKey());
sourceS3.put("version", job.getSourceVersion());
if (job.getSignedObjectBucketName() != null) {
ObjectNode signed = node.putObject("signedObject").putObject("s3");
signed.put("bucketName", job.getSignedObjectBucketName());
signed.put("key", job.getSignedObjectKey());
}
node.put("profileName", job.getProfileName());
node.put("profileVersion", job.getProfileVersion());
node.put("platformId", job.getPlatformId());
node.put("platformDisplayName", job.getPlatformDisplayName());
node.put("status", job.getStatus());
node.put("isRevoked", job.isRevoked());
node.put("createdAt", job.getCreatedAt());
node.put("jobOwner", job.getJobOwner());
node.put("jobInvoker", job.getJobInvoker());
if (job.getSignatureExpiresAt() != null) {
node.put("signatureExpiresAt", job.getSignatureExpiresAt());
}
if (detail) {
if (job.getCompletedAt() != null) {
node.put("completedAt", job.getCompletedAt());
}
if (job.getStatusReason() != null) {
node.put("statusReason", job.getStatusReason());
}
if (job.getRequestedBy() != null) {
node.put("requestedBy", job.getRequestedBy());
}
if (job.isRevoked()) {
ObjectNode record = node.putObject("revocationRecord");
record.put("reason", job.getRevocationReason());
record.put("revokedAt", job.getRevokedAt());
record.put("revokedBy", job.getRevokedBy());
}
}
return node;
}
private ObjectNode platformNode(SignerPlatforms.Platform platform) {
ObjectNode node = objectMapper.createObjectNode();
node.put("platformId", platform.platformId());
node.put("displayName", platform.displayName());
node.put("partner", platform.partner());
node.put("target", platform.target());
node.put("category", platform.category());
ObjectNode configuration = node.putObject("signingConfiguration");
ObjectNode encryption = configuration.putObject("encryptionAlgorithmOptions");
encryption.set("allowedValues", objectMapper.valueToTree(platform.encryptionAlgorithms()));
encryption.put("defaultValue", platform.defaultEncryptionAlgorithm());
ObjectNode hash = configuration.putObject("hashAlgorithmOptions");
hash.set("allowedValues", objectMapper.valueToTree(platform.hashAlgorithms()));
hash.put("defaultValue", platform.defaultHashAlgorithm());
ObjectNode imageFormat = node.putObject("signingImageFormat");
imageFormat.set("supportedFormats", objectMapper.valueToTree(platform.imageFormats()));
imageFormat.put("defaultFormat", platform.defaultImageFormat());
node.put("maxSizeInMB", platform.maxSizeInMB());
node.put("revocationSupported", platform.revocationSupported());
return node;
}
private JsonNode readTree(String body) {
try {
return objectMapper.readTree(body == null || body.isBlank() ? "{}" : body);
} catch (Exception e) {
throw new WebApplicationException(JsonErrorResponseUtils.createSerializationErrorResponse());
}
}
}
@@ -0,0 +1,101 @@
package io.floci.aws.services.signer;
import java.util.List;
import java.util.Optional;
/**
* The signing platforms AWS publishes, with the configuration and image formats each accepts.
*
* <p>Signer does not discover platforms from AWS: the list is fixed for a given API version and the
* AWS SDK never sends it, so a profile names one of these ids and Floci answers the matching
* description. The values follow the published platform descriptions; only the three platforms an
* emulated workflow can reach are listed.
*/
public final class SignerPlatforms {
/** One published signing platform and the options a profile may override. */
public record Platform(
String platformId,
String displayName,
String partner,
String target,
String category,
List<String> hashAlgorithms,
String defaultHashAlgorithm,
List<String> encryptionAlgorithms,
String defaultEncryptionAlgorithm,
List<String> imageFormats,
String defaultImageFormat,
int maxSizeInMB,
boolean revocationSupported,
/**
* The period Signer applies when a profile sets none: 135 months on the platforms that
* expire signatures. Zero on a platform whose signatures do not carry a validity.
*/
int defaultValidityMonths) {
}
public static final Platform AWS_LAMBDA = new Platform(
"AWSLambda-SHA384-ECDSA",
"AWS Lambda",
"AWS",
"Lambda",
"AWSLambda",
List.of("SHA-256", "SHA-384"),
"SHA-384",
List.of("ECDSA"),
"ECDSA",
List.of("JSON"),
"JSON",
50,
true,
135);
public static final Platform NOTATION_OCI = new Platform(
"Notation-OCI-SHA384-ECDSA",
"Notation OCI",
"AWS",
"OCI",
"Notation-OCI",
List.of("SHA-384"),
"SHA-384",
List.of("ECDSA"),
"ECDSA",
List.of("JSON"),
"JSON",
500,
true,
135);
public static final Platform IOT_SHA256 = new Platform(
"AWSIoTDeviceManagement-SHA256-ECDSA",
"AWS IoT Device Management SHA256 ECDSA",
"AWS",
"IoT",
"AWSIoT",
List.of("SHA-256"),
"SHA-256",
List.of("ECDSA"),
"ECDSA",
List.of("JSONEmbedded", "JSONDetached"),
"JSONEmbedded",
50,
false,
0);
private static final List<Platform> ALL = List.of(AWS_LAMBDA, NOTATION_OCI, IOT_SHA256);
private SignerPlatforms() {
}
public static List<Platform> all() {
return ALL;
}
public static Optional<Platform> find(String platformId) {
if (platformId == null) {
return Optional.empty();
}
return ALL.stream().filter(platform -> platform.platformId().equals(platformId)).findFirst();
}
}
@@ -0,0 +1,43 @@
package io.floci.aws.services.signer;
import io.floci.aws.core.common.ResolvedServiceCatalog;
import io.floci.aws.core.common.SignedServiceRoute;
import jakarta.inject.Inject;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerRequestFilter;
import jakarta.ws.rs.container.PreMatching;
import jakarta.ws.rs.ext.Provider;
import java.util.function.Predicate;
/**
* Rewrites Signer requests to an internal prefix before JAX-RS route matching.
*
* <p>Signer's paths are literal and S3's path-style routes claim any first segment as a bucket, so a
* request for {@code /signing-profiles} would otherwise read as bucket {@code signing-profiles}. The
* rewrite is keyed on the SigV4 credential scope, so a request signed for S3 keeps its path and
* reaches S3: only a request signed for {@code signer} is moved.
*/
@Provider
@PreMatching
public class SignerRouteFilter implements ContainerRequestFilter {
static final String INTERNAL_PREFIX = "/_signer";
private static final Predicate<String> PUBLIC_PATHS = SignedServiceRoute.under("/signing-profiles")
.or(SignedServiceRoute.under("/signing-jobs"))
.or(SignedServiceRoute.under("/signing-platforms"))
.or(SignedServiceRoute.under("/revocations"));
private final SignedServiceRoute route;
@Inject
public SignerRouteFilter(ResolvedServiceCatalog catalog) {
this.route = new SignedServiceRoute(catalog, "signer", INTERNAL_PREFIX, PUBLIC_PATHS);
}
@Override
public void filter(ContainerRequestContext ctx) {
route.apply(ctx);
}
}
@@ -0,0 +1,905 @@
package io.floci.aws.services.signer;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.PaginatedResult;
import io.floci.aws.core.common.Pagination;
import io.floci.aws.core.common.Resettable;
import io.floci.aws.core.common.TagHandler;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.signer.model.SigningJob;
import io.floci.aws.services.signer.model.SigningProfile;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import java.security.SecureRandom;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* The AWS Signer control plane: signing profiles, their cross-account permissions, and the signing
* jobs started against a profile.
*
* <p>Signing profiles and jobs are metadata. Floci keeps the platform, the certificate a profile
* signs with, the overrides and the S3 source and destination a job names, so SDK calls and
* infrastructure-as-code round-trip, but no cryptographic signature is produced. A job started here
* therefore ends as {@code Failed} with a {@code statusReason} saying so, and carries no
* {@code signedObject}: nothing that has not been signed is reported as signed. Setting
* {@code floci.services.signer.mock-signing-jobs=true} (or
* {@code FLOCI_SERVICES_SIGNER_MOCK_SIGNING_JOBS}) opts into the other behaviour, where the job ends
* {@code Succeeded} with the destination recorded as its signed object and no object is written to
* S3. Both are documented on the service page and asserted by the service tests.
*/
@ApplicationScoped
public class SignerService implements Resettable, TagHandler {
private static final Logger LOG = Logger.getLogger(SignerService.class);
private static final String SERVICE = "signer";
private static final String PROFILE_RESOURCE = "/signing-profiles/";
private static final String JOB_RESOURCE = "/signing-jobs/";
private static final Pattern PROFILE_NAME = Pattern.compile("[0-9a-zA-Z_]{2,64}");
private static final Pattern PROFILE_VERSION = Pattern.compile("[0-9a-zA-Z]{10}");
private static final Pattern TAG_KEY = Pattern.compile("^(?!aws:)[a-zA-Z+-=._:/]+$");
private static final Pattern STATEMENT_ID = Pattern.compile("[a-zA-Z0-9_-]{1,64}");
private static final Pattern CERTIFICATE_ARN = Pattern.compile(
"arn:" + AwsArnUtils.PARTITION_REGEX + ":acm:[a-z0-9-]+:[0-9]+:certificate/.+");
private static final Set<String> VALIDITY_TYPES = Set.of("DAYS", "MONTHS", "YEARS");
private static final Map<String, Integer> MAX_VALIDITY =
Map.of("DAYS", 4105, "MONTHS", 135, "YEARS", 11);
private static final Set<String> PROFILE_STATUSES = Set.of("Active", "Canceled", "Revoked");
private static final Set<String> JOB_STATUSES = Set.of("InProgress", "Failed", "Succeeded");
private static final Set<String> CATEGORIES = Set.of("AWSIoT", "AWSLambda", "Notation-OCI");
/**
* The actions AWS lets a profile permission name. {@code signer:SignPayload} is grantable even
* though the operation itself is not served: a policy that allows signing a payload is valid,
* and refusing the grant would break templates that provision it.
*/
private static final Set<String> PROFILE_PERMISSION_ACTIONS = Set.of("signer:StartSigningJob",
"signer:SignPayload", "signer:GetSigningProfile", "signer:RevokeSignature");
private static final int MAX_TAGS = 50;
/** botocore caps both list operations' {@code maxResults} at 25, which is also their page size. */
private static final int MAX_PAGE_SIZE = 25;
private static final String ALPHANUMERIC =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private final AccountAwareStorageBackend<SigningProfile> profiles;
private final AccountAwareStorageBackend<SigningJob> jobs;
private final boolean mockSigningJobs;
private final SecureRandom random = new SecureRandom();
@Inject
public SignerService(StorageFactory storageFactory, EmulatorConfig config) {
this(storageFactory.create(SERVICE, "signer-signing-profiles.json",
new TypeReference<Map<String, SigningProfile>>() {}),
storageFactory.create(SERVICE, "signer-signing-jobs.json",
new TypeReference<Map<String, SigningJob>>() {}),
config.services().signer().mockSigningJobs());
}
SignerService(AccountAwareStorageBackend<SigningProfile> profiles,
AccountAwareStorageBackend<SigningJob> jobs) {
this(profiles, jobs, false);
}
SignerService(AccountAwareStorageBackend<SigningProfile> profiles,
AccountAwareStorageBackend<SigningJob> jobs, boolean mockSigningJobs) {
this.profiles = profiles;
this.jobs = jobs;
this.mockSigningJobs = mockSigningJobs;
}
/** A page of results, with the token a caller passes back to continue. */
public record Page<T>(List<T> items, String nextToken) {
}
// ---------------------------------------------------------------- profiles
public SigningProfile putSigningProfile(String profileName, JsonNode request, String region) {
validateProfileName(profileName);
requireObject(request, "Request payload");
SignerPlatforms.Platform platform = requirePlatform(requiredText(request, "platformId"));
String certificateArn = optionalCertificateArn(request);
String[] validity = optionalValidityPeriod(request);
JsonNode overrides = optionalOverrides(request, platform);
Map<String, String> signingParameters = optionalStringMap(request, "signingParameters");
Map<String, String> requestedTags = optionalTags(request);
return applyProfile(profileName, platform, certificateArn, validity, overrides,
signingParameters, requestedTags, region);
}
/**
* Creates or updates a profile from typed values, for a caller that does not speak the wire
* protocol: the CloudFormation provisioner for {@code AWS::Signer::SigningProfile}. A template
* cannot set signing material, overrides or signing parameters, so those stay empty. Validation
* is the same one the API applies, so a template that names an unknown platform or an
* out-of-range validity period fails the stack with the Signer message.
*/
public SigningProfile putSigningProfile(String profileName, String platformId, String validityType,
Integer validityValue, Map<String, String> tags,
String region) {
validateProfileName(profileName);
SignerPlatforms.Platform platform = requirePlatform(platformId);
String[] validity = typedValidityPeriod(validityType, validityValue);
Map<String, String> requestedTags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags);
validateTags(requestedTags);
return applyProfile(profileName, platform, null, validity, null,
new LinkedHashMap<>(), requestedTags, region);
}
private SigningProfile applyProfile(String profileName, SignerPlatforms.Platform platform,
String certificateArn, String[] validity, JsonNode overrides,
Map<String, String> signingParameters,
Map<String, String> requestedTags, String region) {
SigningProfile profile = profiles.get(storageKey(region, profileName)).orElse(null);
boolean created = profile == null;
if (created) {
profile = new SigningProfile();
profile.setProfileName(profileName);
profile.setStatus("Active");
profile.setRevisionId(newRevisionId());
profile.setTags(new LinkedHashMap<>(requestedTags));
} else if (!requestedTags.isEmpty()) {
profile.setTags(new LinkedHashMap<>(requestedTags));
}
String accountId = profiles.accountId();
String arn = AwsArnUtils.Arn.of(SERVICE, region, accountId, PROFILE_RESOURCE + profileName)
.toString();
String version = newProfileVersion();
profile.setArn(arn);
profile.setPlatformId(platform.platformId());
profile.setPlatformDisplayName(platform.displayName());
profile.setProfileVersion(version);
profile.setProfileVersionArn(arn + "/" + version);
if (certificateArn != null) {
profile.setSigningMaterialCertificateArn(certificateArn);
}
if (validity[0] != null) {
profile.setSignatureValidityPeriodType(validity[0]);
profile.setSignatureValidityPeriodValue(Integer.valueOf(validity[1]));
}
if (overrides != null) {
profile.setOverrides(overrides);
}
if (!signingParameters.isEmpty()) {
profile.setSigningParameters(signingParameters);
}
profile.setStatus("Active");
profile.setStatusReason(null);
profile.setRevocationEffectiveFrom(null);
profile.setRevokedAt(null);
profile.setRevokedBy(null);
profiles.put(storageKey(region, profileName), profile);
LOG.debugv("{0} signing profile {1} version {2}", created ? "Created" : "Updated",
profileName, version);
return profile;
}
public SigningProfile getSigningProfile(String profileName, String region) {
validateProfileName(profileName);
return requireProfile(profileName, region);
}
public Page<SigningProfile> listSigningProfiles(String region, String platformId,
List<String> statuses, Boolean includeCanceled,
Integer maxResults, String nextToken) {
List<String> requestedStatuses = statuses == null ? List.of() : statuses;
for (String status : requestedStatuses) {
if (!PROFILE_STATUSES.contains(status)) {
throw validation("status " + status + " is not one of " + PROFILE_STATUSES + ".");
}
}
boolean canceledWanted = Boolean.TRUE.equals(includeCanceled);
List<SigningProfile> matching = new ArrayList<>();
for (SigningProfile profile : sortedProfiles(region)) {
if (platformId != null && !platformId.equals(profile.getPlatformId())) {
continue;
}
if (!requestedStatuses.isEmpty() && !requestedStatuses.contains(profile.getStatus())) {
continue;
}
if ("Canceled".equals(profile.getStatus()) && !canceledWanted
&& !requestedStatuses.contains("Canceled")) {
continue;
}
matching.add(profile);
}
PaginatedResult<SigningProfile> page = Pagination.paginate(matching,
SigningProfile::getProfileName, maxResults, nextToken, MAX_PAGE_SIZE,
"ValidationException");
return new Page<>(page.items(), page.nextToken());
}
/** The profile, when it exists, for a caller that has to tell a first create from a takeover. */
public Optional<SigningProfile> findSigningProfile(String profileName, String region) {
return profiles.get(storageKey(region, profileName));
}
/**
* Writes a profile record for a CloudFormation resource that was provisioned before this
* service existed, keeping the identifiers that stack already handed out instead of minting a
* version: the adoption a later tags-only update needs.
*/
public SigningProfile adoptSigningProfile(String profileName, String platformId, String version,
String validityType, Integer validityValue,
String region) {
validateProfileName(profileName);
SignerPlatforms.Platform platform = platformOf(platformId);
String arn = AwsArnUtils.Arn.of(SERVICE, region, profiles.accountId(),
PROFILE_RESOURCE + profileName).toString();
SigningProfile profile = new SigningProfile();
profile.setProfileName(profileName);
profile.setArn(arn);
profile.setPlatformId(platform.platformId());
profile.setPlatformDisplayName(platform.displayName());
profile.setProfileVersion(version);
profile.setProfileVersionArn(arn + "/" + version);
profile.setSignatureValidityPeriodType(validityType);
profile.setSignatureValidityPeriodValue(validityValue);
profile.setStatus("Active");
profile.setRevisionId(newRevisionId());
profiles.put(storageKey(region, profileName), profile);
LOG.debugv("Adopted signing profile {0} version {1} from CloudFormation", profileName, version);
return profile;
}
/**
* Cancels a profile, which AWS keeps rather than deletes: {@code GetSigningProfile} still
* answers it, with the same ARN and version, as {@code Canceled}, and it stops accepting jobs
* until {@code PutSigningProfile} creates a new version of it. Listing hides it unless the
* caller asks for canceled profiles.
*/
public void cancelSigningProfile(String profileName, String region) {
validateProfileName(profileName);
SigningProfile profile = requireProfile(profileName, region);
if ("Revoked".equals(profile.getStatus())) {
throw conflict("Signing profile " + profileName + " is revoked and cannot be canceled.");
}
if ("Canceled".equals(profile.getStatus())) {
return;
}
profile.setStatus("Canceled");
profiles.put(storageKey(region, profileName), profile);
LOG.debugv("Canceled signing profile {0} version {1}", profileName,
profile.getProfileVersion());
}
public SigningProfile revokeSigningProfile(String profileName, JsonNode request, String region) {
validateProfileName(profileName);
requireObject(request, "Request payload");
SigningProfile profile = requireProfile(profileName, region);
String profileVersion = requiredText(request, "profileVersion");
String reason = requiredText(request, "reason");
long effectiveTime = requiredTimestamp(request, "effectiveTime");
if (!profileVersionMatches(profile, profileVersion)) {
throw validation("profileVersion " + profileVersion
+ " is not the profile's current version.");
}
if ("Revoked".equals(profile.getStatus())) {
throw conflict("Signing profile " + profileName + " is already revoked.");
}
profile.setStatus("Revoked");
profile.setStatusReason(reason);
profile.setRevocationEffectiveFrom(effectiveTime);
profile.setRevokedAt(Instant.now().getEpochSecond());
profile.setRevokedBy(profiles.accountId());
profiles.put(storageKey(region, profileName), profile);
return profile;
}
// ------------------------------------------------------------- permissions
public String addProfilePermission(String profileName, JsonNode request, String region) {
validateProfileName(profileName);
requireObject(request, "Request payload");
SigningProfile profile = requireProfile(profileName, region);
String action = requiredText(request, "action");
if (!PROFILE_PERMISSION_ACTIONS.contains(action)) {
throw validation("action " + action + " is not one of " + PROFILE_PERMISSION_ACTIONS
+ ".");
}
String principal = requiredText(request, "principal");
String statementId = requiredText(request, "statementId");
if (!STATEMENT_ID.matcher(statementId).matches()) {
throw validation("statementId must be 1 to 64 characters from [a-zA-Z0-9_-], got "
+ statementId + ".");
}
String requestedRevision = optionalText(request, "revisionId");
if (requestedRevision != null && !requestedRevision.equals(profile.getRevisionId())) {
throw conflict("revisionId " + requestedRevision + " is not the profile's current revision.");
}
String profileVersion = optionalText(request, "profileVersion");
if (profileVersion != null && !profileVersionMatches(profile, profileVersion)) {
throw validation("profileVersion " + profileVersion
+ " is not the profile's current version.");
}
for (SigningProfile.ProfilePermission permission : profile.getPermissions()) {
if (permission.getStatementId().equals(statementId)) {
throw conflict("A permission with statementId " + statementId + " already exists.");
}
}
if (profile.getPermissions().size() >= 20) {
throw validation("A signing profile supports at most 20 permissions.");
}
profile.getPermissions().add(new SigningProfile.ProfilePermission(
action, principal, statementId, profile.getProfileVersion()));
profile.setRevisionId(newRevisionId());
profiles.put(storageKey(region, profileName), profile);
return profile.getRevisionId();
}
public List<SigningProfile.ProfilePermission> listProfilePermissions(String profileName,
String region) {
validateProfileName(profileName);
return requireProfile(profileName, region).getPermissions();
}
public String removeProfilePermission(String profileName, String statementId, String revisionId,
String region) {
validateProfileName(profileName);
SigningProfile profile = requireProfile(profileName, region);
if (revisionId == null || revisionId.isBlank()) {
throw validation("revisionId is required.");
}
if (!revisionId.equals(profile.getRevisionId())) {
throw conflict("revisionId " + revisionId + " is not the profile's current revision.");
}
boolean removed = profile.getPermissions()
.removeIf(permission -> permission.getStatementId().equals(statementId));
if (!removed) {
throw notFound("Permission " + statementId + " does not exist on profile "
+ profileName + ".");
}
profile.setRevisionId(newRevisionId());
profiles.put(storageKey(region, profileName), profile);
return profile.getRevisionId();
}
// ------------------------------------------------------------------- jobs
public SigningJob startSigningJob(JsonNode request, String region) {
requireObject(request, "Request payload");
String profileName = requiredText(request, "profileName");
validateProfileName(profileName);
String clientRequestToken = requiredText(request, "clientRequestToken");
for (SigningJob existing : sortedJobs(region)) {
if (clientRequestToken.equals(existing.getClientRequestToken())) {
return existing;
}
}
SigningProfile profile = requireProfile(profileName, region);
if (!"Active".equals(profile.getStatus())) {
throw validation("Signing profile " + profileName
+ " is " + profile.getStatus() + " and cannot start a signing job.");
}
JsonNode source = requireObject(request.path("source"), "source");
JsonNode sourceS3 = requireObject(source.path("s3"), "source.s3");
String sourceBucket = requiredText(sourceS3, "bucketName");
String sourceKey = requiredText(sourceS3, "key");
String sourceVersion = requiredText(sourceS3, "version");
JsonNode destination = requireObject(request.path("destination"), "destination");
JsonNode destinationS3 = requireObject(destination.path("s3"), "destination.s3");
String destinationBucket = requiredText(destinationS3, "bucketName");
String destinationPrefix = optionalText(destinationS3, "prefix");
String jobId = UUID.randomUUID().toString();
long now = Instant.now().getEpochSecond();
String accountId = jobs.accountId();
SigningJob job = new SigningJob();
job.setJobId(jobId);
job.setClientRequestToken(clientRequestToken);
job.setJobArn(AwsArnUtils.Arn.of(SERVICE, region, accountId, JOB_RESOURCE + jobId).toString());
job.setProfileName(profileName);
job.setProfileVersion(profile.getProfileVersion());
job.setPlatformId(profile.getPlatformId());
job.setPlatformDisplayName(profile.getPlatformDisplayName());
job.setCreatedAt(now);
job.setCompletedAt(now);
job.setRequestedBy(accountId);
job.setJobOwner(accountId);
job.setJobInvoker(accountId);
job.setSourceBucketName(sourceBucket);
job.setSourceKey(sourceKey);
job.setSourceVersion(sourceVersion);
job.setDestinationBucketName(destinationBucket);
job.setDestinationPrefix(destinationPrefix);
if (mockSigningJobs) {
job.setStatus("Succeeded");
job.setSignedObjectBucketName(destinationBucket);
job.setSignedObjectKey(signedObjectKey(destinationPrefix, sourceKey));
job.setSignatureExpiresAt(
signatureExpiresAt(profile, platformOf(profile.getPlatformId()), now));
LOG.debugv("Recorded signing job {0} for profile {1} as succeeded, as configured",
jobId, profileName);
} else {
// Nothing signs the artifact, so a succeeded job would advertise a key that is not
// there and every download of it would fail. AWS fails a job the same way, with the
// reason on the job, and Floci keeps that shape rather than an empty success.
job.setStatus("Failed");
job.setStatusReason("Floci does not sign artifacts: no signed object was written to "
+ "s3://" + destinationBucket + "/"
+ signedObjectKey(destinationPrefix, sourceKey)
+ ". Set floci.services.signer.mock-signing-jobs=true to record jobs as "
+ "succeeded without an artifact.");
LOG.debugv("Signing job {0} for profile {1} failed: signing is not emulated", jobId,
profileName);
}
jobs.put(storageKey(region, jobId), job);
return job;
}
public SigningJob describeSigningJob(String jobId, String region) {
return requireJob(jobId, region);
}
public Page<SigningJob> listSigningJobs(String region, String status, String platformId,
Boolean isRevoked, Integer maxResults, String nextToken) {
if (status != null && !JOB_STATUSES.contains(status)) {
throw validation("status " + status + " is not one of " + JOB_STATUSES + ".");
}
List<SigningJob> matching = new ArrayList<>();
for (SigningJob job : sortedJobs(region)) {
if (status != null && !status.equals(job.getStatus())) {
continue;
}
if (platformId != null && !platformId.equals(job.getPlatformId())) {
continue;
}
if (isRevoked != null && isRevoked.booleanValue() != job.isRevoked()) {
continue;
}
matching.add(job);
}
PaginatedResult<SigningJob> page = Pagination.paginate(matching,
SignerService::jobCursor, maxResults, nextToken, MAX_PAGE_SIZE, "ValidationException");
return new Page<>(page.items(), page.nextToken());
}
public SigningJob revokeSignature(String jobId, JsonNode request, String region) {
requireObject(request, "Request payload");
SigningJob job = requireJob(jobId, region);
String reason = requiredText(request, "reason");
SignerPlatforms.Platform platform = platformOf(job.getPlatformId());
if (!platform.revocationSupported()) {
throw validation("Signing platform " + platform.platformId()
+ " does not support revocation.");
}
if (!"Succeeded".equals(job.getStatus())) {
throw validation("Signing job " + jobId + " is " + job.getStatus()
+ " and has no signature to revoke.");
}
if (job.isRevoked()) {
throw conflict("Signing job " + jobId + " is already revoked.");
}
job.setRevoked(true);
job.setRevocationReason(reason);
job.setRevokedAt(Instant.now().getEpochSecond());
job.setRevokedBy(jobs.accountId());
jobs.put(storageKey(region, jobId), job);
return job;
}
/**
* The revocation status of the signatures a caller asks about. Every signature a Floci job
* records is one Floci did not produce, so nothing this service issued can be revoked: the
* answer is always an empty list, which is what AWS answers for signatures it cannot match.
*/
public List<String> getRevocationStatus() {
return List.of();
}
// -------------------------------------------------------------- platforms
public List<SignerPlatforms.Platform> listSigningPlatforms(String category) {
if (category != null && !CATEGORIES.contains(category)) {
throw validation("category " + category + " is not one of " + CATEGORIES + ".");
}
if (category == null) {
return SignerPlatforms.all();
}
return SignerPlatforms.all().stream()
.filter(platform -> platform.category().equals(category))
.toList();
}
public SignerPlatforms.Platform getSigningPlatform(String platformId) {
return SignerPlatforms.find(platformId)
.orElseThrow(() -> notFound("Signing platform " + platformId + " does not exist."));
}
// ------------------------------------------------------------------- tags
/**
* Sets a profile's tags to exactly the given set, which is what CloudFormation does with the
* {@code Tags} property on an update that changed nothing else. Unlike {@link #tagResource}, it
* removes the tags the caller left out.
*/
public void replaceTags(String profileName, Map<String, String> tags, String region) {
validateProfileName(profileName);
SigningProfile profile = requireProfile(profileName, region);
Map<String, String> resolved = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags);
validateTags(resolved);
profile.setTags(resolved);
profiles.put(storageKey(region, profileName), profile);
}
@Override
public String serviceKey() {
return SERVICE;
}
@Override
public Map<String, String> listTags(String region, String arn) {
return new LinkedHashMap<>(requireProfileFromArn(region, arn).getTags());
}
@Override
public void tagResource(String region, String arn, Map<String, String> tags) {
validateTags(tags);
SigningProfile profile = requireProfileFromArn(region, arn);
Map<String, String> merged = new LinkedHashMap<>(profile.getTags());
merged.putAll(tags);
if (merged.size() > MAX_TAGS) {
throw validation("A signing profile supports at most " + MAX_TAGS + " tags.");
}
profile.setTags(merged);
profiles.put(storageKey(region, profile.getProfileName()), profile);
}
@Override
public void untagResource(String region, String arn, List<String> tagKeys) {
SigningProfile profile = requireProfileFromArn(region, arn);
Map<String, String> remaining = new LinkedHashMap<>(profile.getTags());
tagKeys.forEach(remaining::remove);
profile.setTags(remaining);
profiles.put(storageKey(region, profile.getProfileName()), profile);
}
@Override
public void clear() {
profiles.clear();
jobs.clear();
}
// ---------------------------------------------------------------- helpers
private SigningProfile requireProfile(String profileName, String region) {
return profiles.get(storageKey(region, profileName))
.orElseThrow(() -> notFound("Signing profile " + profileName + " does not exist."));
}
private SigningProfile requireProfileFromArn(String region, String arn) {
AwsArnUtils.Arn parsed;
try {
parsed = AwsArnUtils.parse(arn);
} catch (RuntimeException e) {
throw validation("The ARN " + arn + " is not a signing profile ARN.");
}
if (!SERVICE.equals(parsed.service()) || !region.equals(parsed.region())) {
throw notFound("No signing profile matches the ARN " + arn + " in " + region + ".");
}
if (!profiles.accountId().equals(parsed.accountId())) {
throw notFound("No signing profile matches the ARN " + arn + " in account "
+ profiles.accountId() + ".");
}
String resource = parsed.resource().startsWith("/") ? parsed.resource() : "/" + parsed.resource();
if (!resource.startsWith(PROFILE_RESOURCE)) {
throw validation("The ARN " + arn + " does not identify a signing profile.");
}
return requireProfile(resource.substring(PROFILE_RESOURCE.length()), region);
}
private SigningJob requireJob(String jobId, String region) {
return jobs.get(storageKey(region, jobId))
.orElseThrow(() -> notFound("Signing job " + jobId + " does not exist."));
}
private List<SigningProfile> sortedProfiles(String region) {
List<SigningProfile> result =
profiles.scan(key -> key.startsWith(region + "::")).stream().toList();
List<SigningProfile> sorted = new ArrayList<>(result);
sorted.sort((left, right) -> left.getProfileName().compareTo(right.getProfileName()));
return sorted;
}
private List<SigningJob> sortedJobs(String region) {
List<SigningJob> result = jobs.scan(key -> key.startsWith(region + "::")).stream().toList();
List<SigningJob> sorted = new ArrayList<>(result);
sorted.sort((left, right) -> {
int byCreation = left.getCreatedAt().compareTo(right.getCreatedAt());
return byCreation != 0 ? byCreation : left.getJobId().compareTo(right.getJobId());
});
return sorted;
}
private static String storageKey(String region, String id) {
return region + "::" + id;
}
/** A job's position in the list: its creation time and id, which no two jobs share. */
private static String jobCursor(SigningJob job) {
return job.getCreatedAt() + ":" + job.getJobId();
}
private void validateProfileName(String profileName) {
if (profileName == null || !PROFILE_NAME.matcher(profileName).matches()) {
throw validation("profileName must be 2 to 64 characters from [0-9a-zA-Z_], got "
+ profileName + ".");
}
}
private boolean profileVersionMatches(SigningProfile profile, String profileVersion) {
if (!PROFILE_VERSION.matcher(profileVersion).matches()) {
return false;
}
return profileVersion.equals(profile.getProfileVersion());
}
private String newProfileVersion() {
StringBuilder version = new StringBuilder(10);
for (int i = 0; i < 10; i++) {
version.append(ALPHANUMERIC.charAt(random.nextInt(ALPHANUMERIC.length())));
}
return version.toString();
}
private String newRevisionId() {
return UUID.randomUUID().toString();
}
/**
* The form the Signer model unmarshals for its timestamp members: epoch seconds, as a JSON
* number. An ISO 8601 string is coerced by the AWS CLI, which hides the mismatch, but every
* strict SDK rejects the whole response, so nothing here emits one.
*/
private static long epochSeconds(Instant instant) {
return instant.getEpochSecond();
}
private static String signedObjectKey(String prefix, String sourceKey) {
return prefix == null || prefix.isEmpty() ? sourceKey : prefix + sourceKey;
}
/**
* When the signature a job produces expires: the profile's validity period, or the one Signer
* applies by default when the profile sets none (135 months, on the platforms that expire
* signatures). A platform whose signatures carry no validity answers nothing.
*/
private static Long signatureExpiresAt(SigningProfile profile, SignerPlatforms.Platform platform,
long now) {
Instant created = Instant.ofEpochSecond(now);
String type = profile.getSignatureValidityPeriodType();
int value;
if (type == null) {
if (platform.defaultValidityMonths() < 1) {
return null;
}
type = "MONTHS";
value = platform.defaultValidityMonths();
} else {
value = profile.getSignatureValidityPeriodValue().intValue();
}
return switch (type) {
case "DAYS" -> epochSeconds(created.plus(value, ChronoUnit.DAYS));
case "MONTHS" -> epochSeconds(created.plus(value * 30L, ChronoUnit.DAYS));
case "YEARS" -> epochSeconds(created.plus(value * 365L, ChronoUnit.DAYS));
default -> null;
};
}
private static SignerPlatforms.Platform platformOf(String platformId) {
return SignerPlatforms.find(platformId)
.orElseThrow(() -> validation("Signing platform "
+ platformId + " is not a platform Floci serves."));
}
private static String optionalCertificateArn(JsonNode request) {
JsonNode material = request.path("signingMaterial");
if (material.isMissingNode() || material.isNull()) {
return null;
}
requireObject(material, "signingMaterial");
String certificateArn = requiredText(material, "certificateArn");
if (!CERTIFICATE_ARN.matcher(certificateArn).matches()) {
throw validation("signingMaterial.certificateArn must be an ACM certificate ARN, got "
+ certificateArn + ".");
}
return certificateArn;
}
private static String[] optionalValidityPeriod(JsonNode request) {
JsonNode period = request.path("signatureValidityPeriod");
if (period.isMissingNode() || period.isNull()) {
return new String[] {null, null};
}
requireObject(period, "signatureValidityPeriod");
String type = requiredText(period, "type");
if (!VALIDITY_TYPES.contains(type)) {
throw validation("signatureValidityPeriod.type must be one of " + VALIDITY_TYPES
+ ", got " + type + ".");
}
JsonNode valueNode = period.path("value");
if (!valueNode.isIntegralNumber()) {
throw validation("signatureValidityPeriod.value must be an integer.");
}
int value = valueNode.intValue();
int maximum = MAX_VALIDITY.get(type).intValue();
if (value < 1 || value > maximum) {
throw validation("signatureValidityPeriod.value must be between 1 and " + maximum
+ " for " + type + ", got " + value + ".");
}
return new String[] {type, String.valueOf(value)};
}
private static SignerPlatforms.Platform requirePlatform(String platformId) {
return SignerPlatforms.find(platformId)
.orElseThrow(() -> validation("Signing platform "
+ platformId + " is not a platform Floci serves."));
}
private static String[] typedValidityPeriod(String type, Integer value) {
if (type == null && value == null) {
return new String[] {null, null};
}
if (type == null || !VALIDITY_TYPES.contains(type)) {
throw validation("signatureValidityPeriod.type must be one of " + VALIDITY_TYPES
+ ", got " + type + ".");
}
if (value == null) {
throw validation("signatureValidityPeriod.value must be an integer.");
}
int maximum = MAX_VALIDITY.get(type).intValue();
if (value.intValue() < 1 || value.intValue() > maximum) {
throw validation("signatureValidityPeriod.value must be between 1 and " + maximum
+ " for " + type + ", got " + value + ".");
}
return new String[] {type, String.valueOf(value)};
}
private static JsonNode optionalOverrides(JsonNode request, SignerPlatforms.Platform platform) {
JsonNode overrides = request.path("overrides");
if (overrides.isMissingNode() || overrides.isNull()) {
return null;
}
requireObject(overrides, "overrides");
JsonNode configuration = overrides.path("signingConfiguration");
if (!configuration.isMissingNode() && !configuration.isNull()) {
requireObject(configuration, "overrides.signingConfiguration");
String hashAlgorithm = optionalText(configuration, "hashAlgorithm");
if (hashAlgorithm != null && !platform.hashAlgorithms().contains(hashAlgorithm)) {
throw validation("hashAlgorithm " + hashAlgorithm + " is not accepted by platform "
+ platform.platformId() + ", which allows " + platform.hashAlgorithms() + ".");
}
String encryptionAlgorithm = optionalText(configuration, "encryptionAlgorithm");
if (encryptionAlgorithm != null
&& !platform.encryptionAlgorithms().contains(encryptionAlgorithm)) {
throw validation("encryptionAlgorithm " + encryptionAlgorithm
+ " is not accepted by platform " + platform.platformId()
+ ", which allows " + platform.encryptionAlgorithms() + ".");
}
}
String imageFormat = optionalText(overrides, "signingImageFormat");
if (imageFormat != null && !platform.imageFormats().contains(imageFormat)) {
throw validation("signingImageFormat " + imageFormat + " is not accepted by platform "
+ platform.platformId() + ", which allows " + platform.imageFormats() + ".");
}
return overrides;
}
private static Map<String, String> optionalStringMap(JsonNode request, String member) {
JsonNode node = request.path(member);
if (node.isMissingNode() || node.isNull()) {
return new LinkedHashMap<>();
}
requireObject(node, member);
Map<String, String> values = new LinkedHashMap<>();
node.fields().forEachRemaining(entry -> {
if (!entry.getValue().isValueNode()) {
throw validation(member + "." + entry.getKey() + " must be a string.");
}
values.put(entry.getKey(), entry.getValue().asText());
});
return values;
}
private static Map<String, String> optionalTags(JsonNode request) {
JsonNode tags = request.path("tags");
if (tags.isMissingNode() || tags.isNull()) {
return new LinkedHashMap<>();
}
Map<String, String> values = optionalStringMap(request, "tags");
validateTags(values);
return values;
}
private static void validateTags(Map<String, String> tags) {
for (Map.Entry<String, String> tag : tags.entrySet()) {
String key = tag.getKey() == null ? "" : tag.getKey();
if (!TAG_KEY.matcher(key).matches()) {
throw validation("Tag key " + key
+ " must be 1 to 128 characters and must not use the aws: prefix.");
}
if (tag.getValue() == null || tag.getValue().length() > 256) {
throw validation("Tag value for " + key + " must be at most 256 characters.");
}
}
if (tags.size() > MAX_TAGS) {
throw validation("A signing profile supports at most " + MAX_TAGS + " tags.");
}
}
private static JsonNode requireObject(JsonNode node, String name) {
if (node == null || !node.isObject()) {
throw validation(name + " must be a JSON object.");
}
return node;
}
private static String requiredText(JsonNode request, String member) {
String value = optionalText(request, member);
if (value == null) {
throw validation(member + " is required.");
}
return value;
}
private static String optionalText(JsonNode request, String member) {
JsonNode node = request.path(member);
if (node.isMissingNode() || node.isNull()) {
return null;
}
if (!node.isTextual()) {
throw validation(member + " must be a string.");
}
String value = node.asText();
if (value.isEmpty()) {
throw validation(member + " must not be empty.");
}
return value;
}
private static long requiredTimestamp(JsonNode request, String member) {
JsonNode node = request.path(member);
if (node.isMissingNode() || node.isNull()) {
throw validation(member + " is required.");
}
if (node.isNumber()) {
return node.longValue();
}
if (!node.isTextual()) {
throw validation(member + " must be an ISO 8601 timestamp or epoch seconds.");
}
try {
return Instant.parse(node.asText()).getEpochSecond();
} catch (RuntimeException e) {
throw validation(member + " must be an ISO 8601 timestamp, got " + node.asText() + ".");
}
}
private static AwsException validation(String message) {
return new AwsException("ValidationException", message, 400);
}
private static AwsException notFound(String message) {
return new AwsException("ResourceNotFoundException", message, 404);
}
private static AwsException conflict(String message) {
return new AwsException("ConflictException", message, 409);
}
}
@@ -0,0 +1,250 @@
package io.floci.aws.services.signer.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* One {@code StartSigningJob} record, as {@code DescribeSigningJob} and {@code ListSigningJobs}
* report it.
*
* <p>The job keeps the S3 source, the S3 destination and the profile version it was started
* against. Floci completes a job without signing anything: see {@code SignerService} for what that
* means for the fields a real job would fill in from the signed object.
*/
@RegisterForReflection
public class SigningJob {
private String jobId;
private String jobArn;
private String clientRequestToken;
private String profileName;
private String profileVersion;
private String platformId;
private String platformDisplayName;
private String status;
private String statusReason;
private Long createdAt;
private Long completedAt;
private Long signatureExpiresAt;
private String requestedBy;
private String jobOwner;
private String jobInvoker;
private String sourceBucketName;
private String sourceKey;
private String sourceVersion;
private String destinationBucketName;
private String destinationPrefix;
private String signedObjectBucketName;
private String signedObjectKey;
private boolean revoked;
private String revocationReason;
private Long revokedAt;
private String revokedBy;
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getJobArn() {
return jobArn;
}
public void setJobArn(String jobArn) {
this.jobArn = jobArn;
}
public String getClientRequestToken() {
return clientRequestToken;
}
public void setClientRequestToken(String clientRequestToken) {
this.clientRequestToken = clientRequestToken;
}
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
public String getProfileVersion() {
return profileVersion;
}
public void setProfileVersion(String profileVersion) {
this.profileVersion = profileVersion;
}
public String getPlatformId() {
return platformId;
}
public void setPlatformId(String platformId) {
this.platformId = platformId;
}
public String getPlatformDisplayName() {
return platformDisplayName;
}
public void setPlatformDisplayName(String platformDisplayName) {
this.platformDisplayName = platformDisplayName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatusReason() {
return statusReason;
}
public void setStatusReason(String statusReason) {
this.statusReason = statusReason;
}
public Long getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Long createdAt) {
this.createdAt = createdAt;
}
public Long getCompletedAt() {
return completedAt;
}
public void setCompletedAt(Long completedAt) {
this.completedAt = completedAt;
}
public Long getSignatureExpiresAt() {
return signatureExpiresAt;
}
public void setSignatureExpiresAt(Long signatureExpiresAt) {
this.signatureExpiresAt = signatureExpiresAt;
}
public String getRequestedBy() {
return requestedBy;
}
public void setRequestedBy(String requestedBy) {
this.requestedBy = requestedBy;
}
public String getJobOwner() {
return jobOwner;
}
public void setJobOwner(String jobOwner) {
this.jobOwner = jobOwner;
}
public String getJobInvoker() {
return jobInvoker;
}
public void setJobInvoker(String jobInvoker) {
this.jobInvoker = jobInvoker;
}
public String getSourceBucketName() {
return sourceBucketName;
}
public void setSourceBucketName(String sourceBucketName) {
this.sourceBucketName = sourceBucketName;
}
public String getSourceKey() {
return sourceKey;
}
public void setSourceKey(String sourceKey) {
this.sourceKey = sourceKey;
}
public String getSourceVersion() {
return sourceVersion;
}
public void setSourceVersion(String sourceVersion) {
this.sourceVersion = sourceVersion;
}
public String getDestinationBucketName() {
return destinationBucketName;
}
public void setDestinationBucketName(String destinationBucketName) {
this.destinationBucketName = destinationBucketName;
}
public String getDestinationPrefix() {
return destinationPrefix;
}
public void setDestinationPrefix(String destinationPrefix) {
this.destinationPrefix = destinationPrefix;
}
public String getSignedObjectBucketName() {
return signedObjectBucketName;
}
public void setSignedObjectBucketName(String signedObjectBucketName) {
this.signedObjectBucketName = signedObjectBucketName;
}
public String getSignedObjectKey() {
return signedObjectKey;
}
public void setSignedObjectKey(String signedObjectKey) {
this.signedObjectKey = signedObjectKey;
}
public boolean isRevoked() {
return revoked;
}
public void setRevoked(boolean revoked) {
this.revoked = revoked;
}
public String getRevocationReason() {
return revocationReason;
}
public void setRevocationReason(String revocationReason) {
this.revocationReason = revocationReason;
}
public Long getRevokedAt() {
return revokedAt;
}
public void setRevokedAt(Long revokedAt) {
this.revokedAt = revokedAt;
}
public String getRevokedBy() {
return revokedBy;
}
public void setRevokedBy(String revokedBy) {
this.revokedBy = revokedBy;
}
}
@@ -0,0 +1,244 @@
package io.floci.aws.services.signer.model;
import com.fasterxml.jackson.databind.JsonNode;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* One signing profile, as {@code GetSigningProfile} and {@code ListSigningProfiles} report it.
*
* <p>AWS keeps a version per {@code PutSigningProfile} call, and a profile carries exactly one
* current version. Floci keeps the current version only: {@code profileVersion} and
* {@code profileVersionArn} identify it, and the version fields of {@link ProfilePermission} are the
* version a grant was made against.
*/
@RegisterForReflection
public class SigningProfile {
/** One grant of a cross-account signing permission on the profile. */
@RegisterForReflection
public static class ProfilePermission {
private String action;
private String principal;
private String statementId;
private String profileVersion;
public ProfilePermission() {
}
public ProfilePermission(String action, String principal, String statementId, String profileVersion) {
this.action = action;
this.principal = principal;
this.statementId = statementId;
this.profileVersion = profileVersion;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getPrincipal() {
return principal;
}
public void setPrincipal(String principal) {
this.principal = principal;
}
public String getStatementId() {
return statementId;
}
public void setStatementId(String statementId) {
this.statementId = statementId;
}
public String getProfileVersion() {
return profileVersion;
}
public void setProfileVersion(String profileVersion) {
this.profileVersion = profileVersion;
}
}
private String profileName;
private String profileVersion;
private String profileVersionArn;
private String arn;
private String platformId;
private String platformDisplayName;
private String signingMaterialCertificateArn;
private String signatureValidityPeriodType;
private Integer signatureValidityPeriodValue;
private JsonNode overrides;
private Map<String, String> signingParameters = new LinkedHashMap<>();
private Map<String, String> tags = new LinkedHashMap<>();
private String status;
private String statusReason;
private Long revocationEffectiveFrom;
private Long revokedAt;
private String revokedBy;
private String revisionId;
private List<ProfilePermission> permissions = new ArrayList<>();
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
public String getProfileVersion() {
return profileVersion;
}
public void setProfileVersion(String profileVersion) {
this.profileVersion = profileVersion;
}
public String getProfileVersionArn() {
return profileVersionArn;
}
public void setProfileVersionArn(String profileVersionArn) {
this.profileVersionArn = profileVersionArn;
}
public String getArn() {
return arn;
}
public void setArn(String arn) {
this.arn = arn;
}
public String getPlatformId() {
return platformId;
}
public void setPlatformId(String platformId) {
this.platformId = platformId;
}
public String getPlatformDisplayName() {
return platformDisplayName;
}
public void setPlatformDisplayName(String platformDisplayName) {
this.platformDisplayName = platformDisplayName;
}
public String getSigningMaterialCertificateArn() {
return signingMaterialCertificateArn;
}
public void setSigningMaterialCertificateArn(String signingMaterialCertificateArn) {
this.signingMaterialCertificateArn = signingMaterialCertificateArn;
}
public String getSignatureValidityPeriodType() {
return signatureValidityPeriodType;
}
public void setSignatureValidityPeriodType(String signatureValidityPeriodType) {
this.signatureValidityPeriodType = signatureValidityPeriodType;
}
public Integer getSignatureValidityPeriodValue() {
return signatureValidityPeriodValue;
}
public void setSignatureValidityPeriodValue(Integer signatureValidityPeriodValue) {
this.signatureValidityPeriodValue = signatureValidityPeriodValue;
}
public JsonNode getOverrides() {
return overrides;
}
public void setOverrides(JsonNode overrides) {
this.overrides = overrides;
}
public Map<String, String> getSigningParameters() {
return signingParameters;
}
public void setSigningParameters(Map<String, String> signingParameters) {
this.signingParameters = signingParameters == null ? new LinkedHashMap<>() : signingParameters;
}
public Map<String, String> getTags() {
return tags;
}
public void setTags(Map<String, String> tags) {
this.tags = tags == null ? new LinkedHashMap<>() : tags;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatusReason() {
return statusReason;
}
public void setStatusReason(String statusReason) {
this.statusReason = statusReason;
}
public Long getRevocationEffectiveFrom() {
return revocationEffectiveFrom;
}
public void setRevocationEffectiveFrom(Long revocationEffectiveFrom) {
this.revocationEffectiveFrom = revocationEffectiveFrom;
}
public Long getRevokedAt() {
return revokedAt;
}
public void setRevokedAt(Long revokedAt) {
this.revokedAt = revokedAt;
}
public String getRevokedBy() {
return revokedBy;
}
public void setRevokedBy(String revokedBy) {
this.revokedBy = revokedBy;
}
public String getRevisionId() {
return revisionId;
}
public void setRevisionId(String revisionId) {
this.revisionId = revisionId;
}
public List<ProfilePermission> getPermissions() {
return permissions;
}
public void setPermissions(List<ProfilePermission> permissions) {
this.permissions = permissions == null ? new ArrayList<>() : permissions;
}
}