🚧 Add pom hashes

This commit is contained in:
Andreas Dinauer 2026-04-14 20:13:45 +02:00
parent 1545a2c70d
commit aec2a3b194
4 changed files with 101 additions and 146 deletions

View File

@ -7,6 +7,7 @@ import dev.dinauer.maven.maven.token.TokenService;
import io.quarkus.security.identity.SecurityIdentity;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.commons.codec.digest.DigestUtils;
@ -37,6 +38,23 @@ public class PomService
return Response.status(Response.Status.CONFLICT).build();
}
public Response findHash(MavenContext context)
{
Version version = versionService.findOptional(context.groupId(), context.artifactId(), context.version().getRaw()).orElseThrow();
switch (context.file().getHash())
{
case SHA1 ->
{
return Response.status(Response.Status.OK).type(MediaType.TEXT_PLAIN).entity(version.getPom().getSha1()).build();
}
case MD5 ->
{
return Response.status(Response.Status.OK).type(MediaType.TEXT_PLAIN).entity(version.getPom().getMd5()).build();
}
}
throw new BadRequestException();
}
public Response find(MavenContext mavenContext)
{
Version version = versionService.findOptional(mavenContext.groupId(), mavenContext.artifactId(), mavenContext.version().getRaw()).orElseThrow();

View File

@ -89,7 +89,7 @@ public class Service
{
return pomService.find(mavenContext);
}
throw new NotImplementedException();
return pomService.findHash(mavenContext);
}
case XML ->
{

View File

@ -1,147 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.dinauer.maven</groupId>
<artifactId>demo</artifactId>
<version>1.0.3</version>
<properties>
<compiler-plugin.version>3.14.1</compiler-plugin.version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.30.8</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.5.4</surefire-plugin.version>
</properties>
<distributionManagement>
<repository>
<id>demo</id>
<url>http://localhost:8080/maven2</url>
</repository>
</distributionManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
<goal>native-image-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.jar.enabled>false</quarkus.package.jar.enabled>
<skipITs>false</skipITs>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
</profile>
</profiles>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.9</version>
<name>PostgreSQL JDBC Driver</name>
<description>PostgreSQL JDBC Driver Postgresql</description>
<url>https://jdbc.postgresql.org</url>
<inceptionYear>1997</inceptionYear>
<organization>
<name>PostgreSQL Global Development Group</name>
<url>https://jdbc.postgresql.org/</url>
</organization>
<licenses>
<license>
<name>BSD-2-Clause</name>
<url>https://jdbc.postgresql.org/about/license.html</url>
<distribution>repo</distribution>
<comments>BSD-2-Clause, copyright PostgreSQL Global Development Group</comments>
</license>
</licenses>
<developers>
<developer>
<id>davecramer</id>
<name>Dave Cramer</name>
</developer>
<developer>
<id>jurka</id>
<name>Kris Jurka</name>
</developer>
<developer>
<id>oliver</id>
<name>Oliver Jowett</name>
</developer>
<developer>
<id>ringerc</id>
<name>Craig Ringer</name>
</developer>
<developer>
<id>vlsi</id>
<name>Vladimir Sitnikov</name>
</developer>
<developer>
<id>bokken</id>
<name>Brett Okken</name>
</developer>
</developers>
<mailingLists>
<mailingList>
<name>PostgreSQL JDBC development list</name>
<subscribe>https://lists.postgresql.org/</subscribe>
<unsubscribe>https://lists.postgresql.org/unsubscribe/</unsubscribe>
<post>pgsql-jdbc@postgresql.org</post>
<archive>https://www.postgresql.org/list/pgsql-jdbc/</archive>
</mailingList>
</mailingLists>
<scm>
<connection>scm:git:https://github.com/pgjdbc/pgjdbc.git</connection>
<developerConnection>scm:git:https://github.com/pgjdbc/pgjdbc.git</developerConnection>
<url>https://github.com/pgjdbc/pgjdbc</url>
</scm>
<issueManagement>
<system>GitHub issues</system>
<url>https://github.com/pgjdbc/pgjdbc/issues</url>
</issueManagement>
<dependencies>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.52.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.waffle</groupId>
<artifactId>waffle-jna</artifactId>
<version>1.9.1</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -37,12 +37,14 @@ public class ResourceTest
RestAssured.given().body(readFile("/jar/postgresql-42.7.9.pom")).put("/maven2/org/postgresql/postgresql/42.7.9/postgresql-42.7.9.pom");
byte[] responseJar = RestAssured.given().get("/maven2/org/postgresql/postgresql/42.7.9/postgresql-42.7.9.jar").getBody().asByteArray();
String responsePom = RestAssured.given().get("/maven2/org/postgresql/postgresql/42.7.9/postgresql-42.7.9.pom").getBody().asString();
String responsePomMd5 = RestAssured.given().get("/maven2/org/postgresql/postgresql/42.7.9/postgresql-42.7.9.pom.md5").getBody().asString();
Optional<Version> version = versionService.findOptional("org.postgresql", "postgresql", "42.7.9");
Assertions.assertTrue(version.isPresent());
Assertions.assertTrue(responseJar.length > 0);
Assertions.assertTrue(responsePom !=null && responsePom.startsWith("<?xml"));
Assertions.assertEquals("a6b97b8d22c55f296040344dd75641b2", responsePomMd5);
}
private InputStream readFile(String path)