|
26 | 26 | import java.time.ZoneOffset; |
27 | 27 | import java.util.ArrayList; |
28 | 28 | import java.util.Collections; |
29 | | -import java.util.HashMap; |
30 | 29 | import java.util.List; |
31 | | -import java.util.Map; |
32 | 30 |
|
33 | 31 | import javax.inject.Inject; |
34 | 32 |
|
@@ -224,24 +222,18 @@ private Path ensureOutputDirectory() throws MojoExecutionException { |
224 | 222 |
|
225 | 223 | @Override |
226 | 224 | public void execute() throws MojoFailureException, MojoExecutionException { |
227 | | - // Build definition |
228 | | - final BuildDefinition buildDefinition = new BuildDefinition(); |
229 | | - buildDefinition.setExternalParameters(BuildDefinitions.externalParameters(session)); |
230 | | - buildDefinition.setResolvedDependencies(getBuildDependencies()); |
231 | | - // Builder |
232 | | - final Builder builder = new Builder(); |
233 | | - // RunDetails |
234 | | - final RunDetails runDetails = new RunDetails(); |
235 | | - runDetails.setBuilder(builder); |
236 | | - runDetails.setMetadata(getBuildMetadata()); |
237 | | - // Provenance |
238 | | - final Provenance provenance = new Provenance(); |
239 | | - provenance.setBuildDefinition(buildDefinition); |
240 | | - provenance.setRunDetails(runDetails); |
241 | | - // Statement |
242 | | - final Statement statement = new Statement(); |
243 | | - statement.setSubject(getSubjects()); |
244 | | - statement.setPredicate(provenance); |
| 225 | + final BuildDefinition buildDefinition = new BuildDefinition() |
| 226 | + .setExternalParameters(BuildDefinitions.externalParameters(session)) |
| 227 | + .setResolvedDependencies(getBuildDependencies()); |
| 228 | + final RunDetails runDetails = new RunDetails() |
| 229 | + .setBuilder(new Builder()) |
| 230 | + .setMetadata(getBuildMetadata()); |
| 231 | + final Provenance provenance = new Provenance() |
| 232 | + .setBuildDefinition(buildDefinition) |
| 233 | + .setRunDetails(runDetails); |
| 234 | + final Statement statement = new Statement() |
| 235 | + .setSubject(getSubjects()) |
| 236 | + .setPredicate(provenance); |
245 | 237 |
|
246 | 238 | final Path outputPath = ensureOutputDirectory(); |
247 | 239 | final Path artifactPath = outputPath.resolve(ArtifactUtils.getFileName(project.getArtifact(), ATTESTATION_EXTENSION)); |
@@ -305,14 +297,9 @@ private List<ResourceDescriptor> getProjectDependencies() throws MojoExecutionEx |
305 | 297 | * @throws MojoExecutionException If the SCM revision cannot be retrieved. |
306 | 298 | */ |
307 | 299 | private ResourceDescriptor getScmDescriptor() throws IOException, MojoExecutionException { |
308 | | - final ResourceDescriptor scmDescriptor = new ResourceDescriptor(); |
309 | | - final String scmUri = GitUtils.scmToDownloadUri(scmConnectionUrl, scmDirectory.toPath()); |
310 | | - scmDescriptor.setUri(scmUri); |
311 | | - // Compute the revision |
312 | | - final Map<String, String> digest = new HashMap<>(); |
313 | | - digest.put("gitCommit", getScmRevision()); |
314 | | - scmDescriptor.setDigest(digest); |
315 | | - return scmDescriptor; |
| 300 | + return new ResourceDescriptor() |
| 301 | + .setUri(GitUtils.scmToDownloadUri(scmConnectionUrl, scmDirectory.toPath())) |
| 302 | + .setDigest(Collections.singletonMap("gitCommit", getScmRevision())); |
316 | 303 | } |
317 | 304 |
|
318 | 305 | /** |
@@ -494,13 +481,12 @@ private void signAndWriteStatement(final Statement statement, final Path outputP |
494 | 481 | final Path paeFile = DsseUtils.writePaeFile(statementBytes, outputPath); |
495 | 482 | final byte[] sigBytes = DsseUtils.signFile(signer, paeFile); |
496 | 483 |
|
497 | | - final Signature sig = new Signature(); |
498 | | - sig.setKeyid(DsseUtils.getKeyId(sigBytes)); |
499 | | - sig.setSig(sigBytes); |
500 | | - |
501 | | - final DsseEnvelope envelope = new DsseEnvelope(); |
502 | | - envelope.setPayload(statementBytes); |
503 | | - envelope.setSignatures(Collections.singletonList(sig)); |
| 484 | + final Signature sig = new Signature() |
| 485 | + .setKeyid(DsseUtils.getKeyId(sigBytes)) |
| 486 | + .setSig(sigBytes); |
| 487 | + final DsseEnvelope envelope = new DsseEnvelope() |
| 488 | + .setPayload(statementBytes) |
| 489 | + .setSignatures(Collections.singletonList(sig)); |
504 | 490 |
|
505 | 491 | getLog().info("Writing signed attestation envelope to: " + artifactPath); |
506 | 492 | writeAndAttach(envelope, artifactPath); |
|
0 commit comments