1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.generator.sigstore;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.inject.Singleton;
24
25 import java.util.Collection;
26
27 import org.eclipse.aether.RepositorySystemSession;
28 import org.eclipse.aether.artifact.Artifact;
29 import org.eclipse.aether.deployment.DeployRequest;
30 import org.eclipse.aether.installation.InstallRequest;
31 import org.eclipse.aether.spi.artifact.ArtifactPredicateFactory;
32 import org.eclipse.aether.spi.artifact.generator.ArtifactGenerator;
33 import org.eclipse.aether.spi.artifact.generator.ArtifactGeneratorFactory;
34 import org.eclipse.aether.util.ConfigUtils;
35
36 @Singleton
37 @Named(SigstoreSignatureArtifactGeneratorFactory.NAME)
38 public final class SigstoreSignatureArtifactGeneratorFactory implements ArtifactGeneratorFactory {
39
40 public static final String NAME = "sigstore";
41
42 private final ArtifactPredicateFactory artifactPredicateFactory;
43
44 @Inject
45 public SigstoreSignatureArtifactGeneratorFactory(ArtifactPredicateFactory artifactPredicateFactory) {
46 this.artifactPredicateFactory = artifactPredicateFactory;
47 }
48
49 @Override
50 public ArtifactGenerator newInstance(RepositorySystemSession session, InstallRequest request) {
51 return null;
52 }
53
54 @Override
55 public ArtifactGenerator newInstance(RepositorySystemSession session, DeployRequest request) {
56 return newInstance(session, request.getArtifacts());
57 }
58
59 private ArtifactGenerator newInstance(RepositorySystemSession session, Collection<Artifact> artifacts) {
60 final boolean enabled = ConfigUtils.getBoolean(
61 session, SigstoreConfigurationKeys.DEFAULT_ENABLED, SigstoreConfigurationKeys.CONFIG_PROP_ENABLED);
62 if (!enabled) {
63 return null;
64 }
65 final boolean publicStaging = ConfigUtils.getBoolean(
66 session,
67 SigstoreConfigurationKeys.DEFAULT_PUBLIC_STAGING,
68 SigstoreConfigurationKeys.CONFIG_PROP_PUBLIC_STAGING);
69
70 return new SigstoreSignatureArtifactGenerator(
71 artifacts, artifactPredicateFactory.newInstance(session)::hasChecksums, publicStaging);
72 }
73
74 @Override
75 public float getPriority() {
76 return 150;
77 }
78 }