Skip to content

Commit

Permalink
Add option to use Signature Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
spyrkob committed Sep 13, 2024
1 parent c7c6a9b commit dae909a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<version.org.mockito>5.13.0</version.org.mockito>
<version.junit>4.13.2</version.junit>
<version.org.wildfly.channel>1.1.0.Final</version.org.wildfly.channel>
<version.org.wildfly.channel>1.1.1.Final-SNAPSHOT</version.org.wildfly.channel>
<version.assertj>3.26.3</version.assertj>

<version.org.apache.maven.plugins.pmd>3.25.0</version.org.apache.maven.plugins.pmd>
<version.org.wildfly.checkstyle-config>1.0.8.Final</version.org.wildfly.checkstyle-config>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.wildfly.channel.Repository;
import org.wildfly.channel.maven.VersionResolverFactory;
import org.wildfly.channel.spi.MavenVersionsResolver;
import org.wildfly.channel.spi.SignatureValidator;
import org.wildfly.channel.version.VersionMatcher;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -62,11 +63,15 @@ public class ManifestVersionResolver {
* @param system
*/
public ManifestVersionResolver(Path localMavenCache, RepositorySystem system) {
this(localMavenCache, system, null);
}

public ManifestVersionResolver(Path localMavenCache, RepositorySystem system, SignatureValidator signatureValidator) {
Objects.requireNonNull(localMavenCache);
Objects.requireNonNull(system);

final DefaultRepositorySystemSession session = newRepositorySystemSession(system, localMavenCache);
this.resolverFactory = new VersionResolverFactory(system, session);
this.resolverFactory = new VersionResolverFactory(system, session, signatureValidator);
}

// used in tests only
Expand Down Expand Up @@ -96,14 +101,14 @@ public ManifestVersionRecord getCurrentVersions(List<Channel> channels) throws I
final ChannelManifest manifest = ChannelManifestMapper.from(manifestCoordinate.getUrl());
manifestVersionRecord.addManifest(new ManifestVersionRecord.UrlManifest(manifestCoordinate.getUrl().toExternalForm(), hashCode, manifest.getName()));
} else if (manifestCoordinate.getVersion() != null) {
final String description = getManifestDescription(manifestCoordinate, resolverFactory.create(channel.getRepositories()));
final String description = getManifestDescription(manifestCoordinate, resolverFactory.create(channel));
manifestVersionRecord.addManifest(new ManifestVersionRecord.MavenManifest(
manifestCoordinate.getGroupId(),
manifestCoordinate.getArtifactId(),
manifestCoordinate.getVersion(),
description));
} else {
final MavenVersionsResolver mavenVersionsResolver = resolverFactory.create(channel.getRepositories());
final MavenVersionsResolver mavenVersionsResolver = resolverFactory.create(channel);
final Optional<String> latestVersion = VersionMatcher.getLatestVersion(mavenVersionsResolver.getAllVersions(manifestCoordinate.getGroupId(), manifestCoordinate.getArtifactId(),
manifestCoordinate.getExtension(), manifestCoordinate.getClassifier()));
if (latestVersion.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ public static void writeChannelsConfiguration(Path channelPath, List<Channel> ch
final List<Channel> namedChannels = channels.stream().map(c -> {
if (c.getName() == null || c.getName().isEmpty()) {
final String name = nextAvailableName(c, counter, definedChannelNames);
return new Channel(c.getSchemaVersion(), name, c.getDescription(), c.getVendor(), c.getRepositories(), c.getManifestCoordinate(),
c.getBlocklistCoordinate(), c.getNoStreamStrategy());
return new Channel.Builder(c)
.setName(name)
.build();
} else {
return c;
}
Expand Down

0 comments on commit dae909a

Please sign in to comment.