Files
Athou_commafeed/commafeed-server/src/main/java/com/commafeed/CommaFeedApplication.java

60 lines
1.9 KiB
Java
Raw Normal View History

2025-03-10 08:38:21 +01:00
package com.commafeed;
import com.commafeed.backend.feed.FeedRefreshEngine;
import com.commafeed.backend.feed.ImageProxyUrl;
2025-03-10 08:38:21 +01:00
import com.commafeed.backend.task.TaskScheduler;
import com.commafeed.security.password.PasswordConstraintValidator;
2025-03-10 08:38:21 +01:00
import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Singleton;
2025-03-10 08:38:21 +01:00
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
2025-03-10 08:38:21 +01:00
import org.apache.commons.lang3.SystemProperties;
@Slf4j
2025-03-10 08:38:21 +01:00
@Singleton
@RequiredArgsConstructor
public class CommaFeedApplication {
private final FeedRefreshEngine feedRefreshEngine;
private final TaskScheduler taskScheduler;
private final CommaFeedConfiguration config;
public void start(@Observes StartupEvent ev) {
log.info("starting up...");
2025-03-10 08:38:21 +01:00
// disable entity expansion limits added in JDK24+ (#1961)
// we already strip doctype declarations in XMLCleaner to prevent xxe attacks
// we also already limit the size of feeds we download in HttpGetter
System.setProperty(SystemProperties.JDK_XML_MAX_GENERAL_ENTITY_SIZE_LIMIT, "0");
System.setProperty(SystemProperties.JDK_XML_TOTAL_ENTITY_SIZE_LIMIT, "0");
PasswordConstraintValidator.setMinimumPasswordLength(
config.users().minimumPasswordLength());
if (config.imageProxyEnabled()) {
ImageProxyUrl.generateKey();
}
2025-03-10 08:38:21 +01:00
2026-08-17 22:18:59 +02:00
if (config.passwordRecoveryEnabled() && config.passwordRecoveryPublicBaseUrl().isEmpty()) {
throw new IllegalStateException(
"password recovery is enabled but no public base url is set");
}
feedRefreshEngine.start();
taskScheduler.start();
}
public void stop(@Observes ShutdownEvent ev) {
log.info("shutting down...");
2025-03-10 08:38:21 +01:00
feedRefreshEngine.stop();
taskScheduler.stop();
}
2025-03-10 08:38:21 +01:00
}