Update to Quarkus 2.5.1 and resteasy reactive
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = "";
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user