File tree Expand file tree Collapse file tree 4 files changed +53
-9
lines changed
core/src/main/java/eu/maveniverse/maven/njord/shared Expand file tree Collapse file tree 4 files changed +53
-9
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,20 @@ private void validateSignature(
7070 in .transferTo (bos );
7171 signatureContent = new ByteArrayInputStream (bos .toByteArray ());
7272 }
73- if (signatureValidator .verifySignature (
74- artifactStore .artifactContent (artifact ).orElseThrow (), signatureContent )) {
73+ SignatureValidator .Outcome outcome = signatureValidator .verifySignature (
74+ artifactStore ,
75+ artifact ,
76+ signature ,
77+ artifactStore .artifactContent (artifact ).orElseThrow (),
78+ signatureContent ,
79+ chkCollector );
80+ if (outcome == SignatureValidator .Outcome .VALID ) {
7581 chkCollector .addInfo ("VALID " + signatureValidator .type ().name ());
82+ } else if (outcome == SignatureValidator .Outcome .INVALID ) {
83+ chkCollector .addError ("INVALID " + signatureValidator .type ().name ());
7684 } else {
77- chkCollector .addError (
78- "MISMATCH " + signatureValidator .type ().name ());
85+ chkCollector .addInfo ( "PRESENT (not validated) "
86+ + signatureValidator .type ().name ());
7987 }
8088 } else {
8189 if (mandatory ) {
Original file line number Diff line number Diff line change 77 */
88package eu .maveniverse .maven .njord .shared .impl .publisher .signature ;
99
10+ import eu .maveniverse .maven .njord .shared .publisher .spi .ValidationResultCollector ;
11+ import eu .maveniverse .maven .njord .shared .store .ArtifactStore ;
1012import java .io .IOException ;
1113import java .io .InputStream ;
14+ import org .eclipse .aether .artifact .Artifact ;
1215
1316public class GpgSignatureValidator extends SignatureValidatorSupport {
1417 public GpgSignatureValidator () {
1518 super (new GpgSignatureType ());
1619 }
1720
1821 @ Override
19- public boolean verifySignature (InputStream content , InputStream signature ) throws IOException {
20- return true ;
22+ public Outcome verifySignature (
23+ ArtifactStore artifactStore ,
24+ Artifact artifact ,
25+ Artifact signatureArtifact ,
26+ InputStream artifactContent ,
27+ InputStream signatureContent ,
28+ ValidationResultCollector collector )
29+ throws IOException {
30+ return Outcome .SKIPPED ;
2131 }
2232}
Original file line number Diff line number Diff line change 77 */
88package eu .maveniverse .maven .njord .shared .impl .publisher .signature ;
99
10+ import eu .maveniverse .maven .njord .shared .publisher .spi .ValidationResultCollector ;
11+ import eu .maveniverse .maven .njord .shared .store .ArtifactStore ;
1012import java .io .IOException ;
1113import java .io .InputStream ;
14+ import org .eclipse .aether .artifact .Artifact ;
1215
1316public class SigstoreSignatureValidator extends SignatureValidatorSupport {
1417 public SigstoreSignatureValidator () {
1518 super (new SigstoreSignatureType ());
1619 }
1720
1821 @ Override
19- public boolean verifySignature (InputStream content , InputStream signature ) throws IOException {
20- return false ;
22+ public Outcome verifySignature (
23+ ArtifactStore artifactStore ,
24+ Artifact artifact ,
25+ Artifact signatureArtifact ,
26+ InputStream artifactContent ,
27+ InputStream signatureContent ,
28+ ValidationResultCollector collector )
29+ throws IOException {
30+ return Outcome .SKIPPED ;
2131 }
2232}
Original file line number Diff line number Diff line change 77 */
88package eu .maveniverse .maven .njord .shared .publisher .spi .signature ;
99
10+ import eu .maveniverse .maven .njord .shared .publisher .spi .ValidationResultCollector ;
11+ import eu .maveniverse .maven .njord .shared .store .ArtifactStore ;
1012import java .io .Closeable ;
1113import java .io .IOException ;
1214import java .io .InputStream ;
15+ import org .eclipse .aether .artifact .Artifact ;
1316
1417public interface SignatureValidator extends Closeable {
1518 /**
1619 * The type this validator validates.
1720 */
1821 SignatureType type ();
1922
23+ enum Outcome {
24+ SKIPPED ,
25+ VALID ,
26+ INVALID
27+ }
28+
2029 /**
2130 * Verifies received content against received signature. May perform much more, like fetching key and so on.
2231 * If it returns {@code true}, then and only then is signature accepted as "verified".
2332 */
24- boolean verifySignature (InputStream content , InputStream signature ) throws IOException ;
33+ Outcome verifySignature (
34+ ArtifactStore artifactStore ,
35+ Artifact artifact ,
36+ Artifact signatureArtifact ,
37+ InputStream artifactContent ,
38+ InputStream signatureContent ,
39+ ValidationResultCollector collector )
40+ throws IOException ;
2541}
You can’t perform that action at this time.
0 commit comments