Update to Quarkus 2.5.1 and resteasy reactive

This commit is contained in:
2021-12-07 20:48:48 +01:00
parent a3f3108e87
commit cdd1f1b7dd
11 changed files with 28 additions and 30 deletions

12
pom.xml
View File

@@ -12,10 +12,10 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.13.4.Final</quarkus-plugin.version>
<quarkus-plugin.version>2.5.1.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.13.4.Final</quarkus.platform.version>
<quarkus.platform.version>2.5.1.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement>
@@ -32,19 +32,19 @@
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-qute</artifactId>
<artifactId>quarkus-resteasy-reactive-qute</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-multipart</artifactId>
<artifactId>quarkus-resteasy-reactive-jaxb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>

View File

@@ -10,7 +10,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
import io.quarkus.security.Authenticated;
import io.quarkus.security.identity.SecurityIdentity;
import io.vertx.core.http.HttpServerRequest;
@@ -48,7 +47,7 @@ public class FilePrivateAPI {
@GET
@Path("/{names: .+}")
@Produces(MediaType.APPLICATION_JSON)
public Response getFileInfo(@PathParam List<PathSegment> names) {
public Response getFileInfo(List<PathSegment> names) {
if (!roleAccessService.checkRouteAccess(securityIdentity.getRoles(), names)
|| !adventAccessService.checkEventAccess(names)) {
return Response.status(Response.Status.FORBIDDEN).build();

View File

@@ -12,7 +12,7 @@ import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
import io.quarkus.runtime.annotations.RegisterForReflection;
import io.vertx.core.http.HttpServerRequest;
import sh.rhiobet.lalafin.api.model.FileInfo;
import sh.rhiobet.lalafin.api.model.FileInfoBase;
@@ -24,6 +24,7 @@ import sh.rhiobet.lalafin.api.configuration.FolderApiConfiguration;
import sh.rhiobet.lalafin.api.configuration.FolderApiConfiguration.Token;
import sh.rhiobet.lalafin.api.internal.RSAKey;
@RegisterForReflection
@Path("/api/public/file")
public class FilePublicAPI {
@Context
@@ -40,7 +41,7 @@ public class FilePublicAPI {
@GET
@Path("/token/{fileToken}{fileName: (/.*)?}")
public Response getFileFromToken(@PathParam String fileToken,
public Response getFileFromToken(String fileToken,
@HeaderParam("Range") String range) throws JsonProcessingException {
String decryptedToken = RSAKey.decrypt(fileToken);
ObjectMapper obj = new ObjectMapper();
@@ -61,7 +62,7 @@ public class FilePublicAPI {
@GET
@Path("/folder/{folderToken}/{names: .+}")
public Response getFolderFile(@PathParam String folderToken, @PathParam List<PathSegment> names,
public Response getFolderFile(String folderToken, List<PathSegment> names,
@HeaderParam("Range") String range) {
for (Token token : folderApiConfiguration.tokens()) {
if (token.value().equals(folderToken)) {

View File

@@ -9,8 +9,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
import org.jboss.resteasy.reactive.MultipartForm;
import io.quarkus.security.Authenticated;
import io.quarkus.security.identity.SecurityIdentity;
import sh.rhiobet.lalafin.api.model.UploadForm;
@@ -41,7 +40,7 @@ public class UploadPrivateAPI {
@DELETE
@Path("/{iv}")
public Response getFile(@PathParam String iv) {
public Response getFile(String iv) {
return uploadService.delete(securityIdentity.getPrincipal().getName(), iv);
}
}

View File

@@ -5,9 +5,10 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
import io.quarkus.runtime.annotations.RegisterForReflection;
import sh.rhiobet.lalafin.upload.UploadService;
@RegisterForReflection
@Path("/api/public/upload")
public class UploadPublicAPI {
@Inject
@@ -15,7 +16,7 @@ public class UploadPublicAPI {
@GET
@Path("/{user}/{iv}")
public Response getFile(@PathParam String user, @PathParam String iv,
public Response getFile(String user, String iv,
@QueryParam("password") String password) {
if (password == null) {
password = "";

View File

@@ -1,9 +1,9 @@
package sh.rhiobet.lalafin.api.model;
import java.io.InputStream;
import javax.ws.rs.FormParam;
import javax.ws.rs.core.MediaType;
import org.jboss.resteasy.annotations.providers.multipart.PartType;
import org.jboss.resteasy.reactive.PartType;
import org.jboss.resteasy.reactive.multipart.FileUpload;
public class UploadForm {
@@ -13,7 +13,7 @@ public class UploadForm {
@FormParam("file")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
public InputStream file;
public FileUpload file;
@FormParam("password")
@PartType(MediaType.TEXT_PLAIN)

View File

@@ -12,7 +12,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
import io.quarkus.security.Authenticated;
import io.quarkus.security.identity.SecurityIdentity;
import io.vertx.core.http.HttpServerRequest;
@@ -55,7 +54,7 @@ public class FileResource {
@GET
@Path("/{names: .+}")
public Response serve(@PathParam List<PathSegment> names, @HeaderParam("Range") String range) {
public Response serve(List<PathSegment> names, @HeaderParam("Range") String range) {
if (!roleAccessService.checkRouteAccess(securityIdentity.getRoles(), names)
|| !adventAccessService.checkEventAccess(names)) {
return Response.status(Response.Status.FORBIDDEN).build();

View File

@@ -9,7 +9,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
import io.quarkus.security.Authenticated;
import io.quarkus.security.identity.SecurityIdentity;
import io.vertx.core.http.HttpServerRequest;
@@ -41,7 +40,7 @@ public class ViewerResource {
@GET
@Path("/{names: .+}/{page}")
public Response view(@PathParam List<PathSegment> names, @PathParam int page) {
public Response view(List<PathSegment> names, int page) {
if (!roleAccessService.checkRouteAccess(securityIdentity.getRoles(), names)
|| !adventAccessService.checkEventAccess(names)) {
return Response.status(Response.Status.FORBIDDEN).build();

View File

@@ -6,8 +6,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.annotations.jaxrs.PathParam;
@RolesAllowed("japan7")
@Path("/nzb")
public class NzbResource {
@@ -17,7 +15,7 @@ public class NzbResource {
@GET
@Path("/id/{id}")
public Response getResult(@PathParam String id) {
public Response getResult(String id) {
return resultService.getResult(id);
}

View File

@@ -29,6 +29,7 @@ import javax.inject.Inject;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.xml.bind.DatatypeConverter;
import org.jboss.resteasy.reactive.multipart.FileUpload;
import io.quarkus.qute.Location;
import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateInstance;
@@ -46,7 +47,7 @@ public class UploadService {
Template uploadTemplate;
public Response upload(String user, String filename, String passphrase,
InputStream inputStream) {
FileUpload file) {
SecureRandom random = new SecureRandom();
byte ivBytes[] = new byte[16];
random.nextBytes(ivBytes);
@@ -62,7 +63,8 @@ public class UploadService {
IvParameterSpec iv = new IvParameterSpec(ivBytes);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, aesKey, iv);
CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher);
CipherInputStream cipherInputStream = new CipherInputStream(Files.newInputStream(
file.uploadedFile()), cipher);
filePath.getParent().toFile().mkdirs();
Files.copy(cipherInputStream, filePath);

View File

@@ -17,7 +17,7 @@
<hr />
<table style="table-layout: fixed; text-align: center">
{#each info.content}
{#if count.mod(3) == 1}
{#if it_count.mod(3) == 1}
<tr>
{/if}
<td>
@@ -38,7 +38,7 @@
<a href="{it.directUrl}">
{/if}{it.filename}</a>
</td>
{#if count.mod(3) == 0}
{#if it_count.mod(3) == 0}
</tr>
{/if}
{/each}