This commit is contained in:
2026-04-18 21:40:07 +02:00
parent 8c0bb2ce4a
commit a4c0a4702a
3 changed files with 5 additions and 7 deletions

View File

@@ -8,7 +8,6 @@ import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Named; import jakarta.inject.Named;
import sh.rhiobet.lalafin.access.AccessService; import sh.rhiobet.lalafin.access.AccessService;
import sh.rhiobet.lalafin.advent.AdventConfiguration.AdventEvent;
import sh.rhiobet.lalafin.path.Path; import sh.rhiobet.lalafin.path.Path;
@ApplicationScoped @ApplicationScoped
@@ -22,7 +21,7 @@ public class AdventAccessService implements AccessService {
public boolean checkAccess(Path path) { public boolean checkAccess(Path path) {
String pathUri = path.getURI(); String pathUri = path.getURI();
Optional<AdventEvent> matchingAdvent = adventConfiguration.events().stream() Optional<AdventConfiguration.AdventEvent> matchingAdvent = adventConfiguration.events().stream()
.filter(e -> pathUri.startsWith(e.path())) .filter(e -> pathUri.startsWith(e.path()))
.findFirst(); .findFirst();
@@ -31,7 +30,7 @@ public class AdventAccessService implements AccessService {
} }
String dayString = pathUri.replaceAll( String dayString = pathUri.replaceAll(
"^" + Pattern.quote(matchingAdvent.get().path()) + "/?($1)\\.?[^.]*$", "^" + Pattern.quote(matchingAdvent.get().path()) + "/?([^.]+)\\.?[^.]*$",
"$1"); "$1");
try { try {
int day = Integer.parseInt(dayString); int day = Integer.parseInt(dayString);

View File

@@ -7,8 +7,6 @@ import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Named; import jakarta.inject.Named;
import sh.rhiobet.lalafin.access.AccessService; import sh.rhiobet.lalafin.access.AccessService;
import sh.rhiobet.lalafin.api.configuration.FileApiConfiguration;
import sh.rhiobet.lalafin.api.configuration.FileApiConfiguration.Route;
import sh.rhiobet.lalafin.path.Path; import sh.rhiobet.lalafin.path.Path;
@ApplicationScoped @ApplicationScoped
@@ -18,11 +16,11 @@ public class FileRoleAccessService implements AccessService {
SecurityIdentity securityIdentity; SecurityIdentity securityIdentity;
@Inject @Inject
FileApiConfiguration fileApiConfiguration; FileConfiguration fileConfiguration;
public boolean checkAccess(Path path) { public boolean checkAccess(Path path) {
String pathUri = path.getURI(); String pathUri = path.getURI();
List<Route> matchingRoutes = fileApiConfiguration.routes().stream() List<FileConfiguration.Route> matchingRoutes = fileConfiguration.routes().stream()
.filter(r -> pathUri.startsWith(r.path())) .filter(r -> pathUri.startsWith(r.path()))
.toList(); .toList();

View File

@@ -78,6 +78,7 @@ public final class ZipEntryPath implements Path {
if (zipEntry != null) { if (zipEntry != null) {
return new ZipEntryInputStream(zipFile, zipFile.getInputStream(zipEntry)); return new ZipEntryInputStream(zipFile, zipFile.getInputStream(zipEntry));
} else { } else {
zipFile.close();
throw new IOException("Zip entry does not exist."); throw new IOException("Zip entry does not exist.");
} }
} else { } else {