Test
This commit is contained in:
@@ -136,16 +136,6 @@ public class AppConfig {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Bean(name = "watchedFoldersDir")
|
||||
public String watchedFoldersDir() {
|
||||
return "./pipeline/watchedFolders/";
|
||||
}
|
||||
|
||||
@Bean(name = "finishedFoldersDir")
|
||||
public String finishedFoldersDir() {
|
||||
return "./pipeline/finishedFolders/";
|
||||
}
|
||||
|
||||
@Bean(name = "directoryFilter")
|
||||
public Predicate<Path> processOnlyFiles() {
|
||||
return path -> {
|
||||
|
||||
@@ -28,6 +28,7 @@ public class ConfigInitializer
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
try {
|
||||
log.info("Setting up configs from templates");
|
||||
ensureConfigExists();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to initialize application configuration", e);
|
||||
@@ -36,7 +37,7 @@ public class ConfigInitializer
|
||||
|
||||
public void ensureConfigExists() throws IOException, URISyntaxException {
|
||||
// Define the path to the external config directory
|
||||
Path destPath = Paths.get("configs", "settings.yml");
|
||||
Path destPath = Paths.get(InstallationPathConfig.getSettingsPath());
|
||||
|
||||
// Check if the file already exists
|
||||
if (Files.notExists(destPath)) {
|
||||
@@ -56,7 +57,7 @@ public class ConfigInitializer
|
||||
} else {
|
||||
|
||||
// Define the path to the config settings file
|
||||
Path settingsPath = Paths.get("configs", "settings.yml");
|
||||
Path settingsPath = Paths.get(InstallationPathConfig.getSettingsPath());
|
||||
// Load the template resource
|
||||
URL settingsTemplateResource =
|
||||
getClass().getClassLoader().getResource("settings.yml.template");
|
||||
@@ -120,7 +121,7 @@ public class ConfigInitializer
|
||||
}
|
||||
|
||||
// Create custom settings file if it doesn't exist
|
||||
Path customSettingsPath = Paths.get("configs", "custom_settings.yml");
|
||||
Path customSettingsPath = Paths.get(InstallationPathConfig.getCustomSettingsPath());
|
||||
if (!Files.exists(customSettingsPath)) {
|
||||
Files.createFile(customSettingsPath);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateRe
|
||||
String characterEncoding,
|
||||
Map<String, Object> templateResolutionAttributes) {
|
||||
Resource resource =
|
||||
resourceLoader.getResource("file:./customFiles/templates/" + resourceName);
|
||||
resourceLoader.getResource(
|
||||
"file:" + InstallationPathConfig.getTemplatesPath() + resourceName);
|
||||
try {
|
||||
if (resource.exists() && resource.isReadable()) {
|
||||
return new FileTemplateResource(resource.getFile().getPath(), characterEncoding);
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package stirling.software.SPDF.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class InstallationPathConfig {
|
||||
|
||||
public static String getPath() {
|
||||
if (Boolean.parseBoolean(
|
||||
java.lang.System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) {
|
||||
|
||||
String os = java.lang.System.getProperty("os.name").toLowerCase();
|
||||
if (os.contains("win")) {
|
||||
return java.lang.System.getenv("APPDATA")
|
||||
+ File.separator
|
||||
+ "Stirling-PDF"
|
||||
+ File.separator;
|
||||
} else if (os.contains("mac")) {
|
||||
return java.lang.System.getProperty("user.home")
|
||||
+ File.separator
|
||||
+ "Library"
|
||||
+ File.separator
|
||||
+ "Application Support"
|
||||
+ File.separator
|
||||
+ "Stirling-PDF"
|
||||
+ File.separator;
|
||||
} else {
|
||||
return java.lang.System.getProperty("user.home")
|
||||
+ File.separator
|
||||
+ ".config"
|
||||
+ File.separator
|
||||
+ "Stirling-PDF"
|
||||
+ File.separator;
|
||||
}
|
||||
}
|
||||
return "./";
|
||||
}
|
||||
|
||||
// Root paths
|
||||
public static String getLogPath() {
|
||||
return getPath() + "logs" + File.separator;
|
||||
}
|
||||
|
||||
public static String getConfigPath() {
|
||||
return getPath() + "configs" + File.separator;
|
||||
}
|
||||
|
||||
public static String getPipelinePath() {
|
||||
return getPath() + "pipeline" + File.separator;
|
||||
}
|
||||
|
||||
public static String getCustomFilesPath() {
|
||||
return getPath() + "customFiles" + File.separator;
|
||||
}
|
||||
|
||||
public static String getClientWebUIPath() {
|
||||
return getPath() + "clientWebUI" + File.separator;
|
||||
}
|
||||
|
||||
// configs
|
||||
public static String getSettingsPath() {
|
||||
log.info(getConfigPath() + "settings.yml");
|
||||
return getConfigPath() + "settings.yml";
|
||||
}
|
||||
|
||||
public static String getCustomSettingsPath() {
|
||||
return getConfigPath() + "custom_settings.yml";
|
||||
}
|
||||
|
||||
// pipeline
|
||||
public static String getPipelineWatchedFoldersDir() {
|
||||
return getPipelinePath() + "watchedFolders" + File.separator;
|
||||
}
|
||||
|
||||
public static String getPipelineFinishedFoldersDir() {
|
||||
return getPipelinePath() + "finishedFolders" + File.separator;
|
||||
}
|
||||
|
||||
// custom files
|
||||
public static String getStaticPath() {
|
||||
return getCustomFilesPath() + "static" + File.separator;
|
||||
}
|
||||
|
||||
public static String getTemplatesPath() {
|
||||
return getCustomFilesPath() + "templates" + File.separator;
|
||||
}
|
||||
|
||||
public static String getSignaturesPath() {
|
||||
return getCustomFilesPath() + "signatures" + File.separator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package stirling.software.SPDF.config;
|
||||
|
||||
import ch.qos.logback.core.PropertyDefinerBase;
|
||||
|
||||
public class LogbackPropertyLoader extends PropertyDefinerBase {
|
||||
@Override
|
||||
public String getPropertyValue() {
|
||||
return InstallationPathConfig.getLogPath();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package stirling.software.SPDF.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
@Configuration
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class LoggingInitializer extends ConfigInitializer {
|
||||
static {
|
||||
String logPath = InstallationPathConfig.getLogPath();
|
||||
System.setProperty("LOG_PATH", logPath);
|
||||
new File(logPath).mkdirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
super.initialize(applicationContext);
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
environment.getSystemProperties().put("LOG_PATH", System.getProperty("LOG_PATH"));
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// Handler for external static resources
|
||||
registry.addResourceHandler("/**")
|
||||
.addResourceLocations("file:customFiles/static/", "classpath:/static/");
|
||||
.addResourceLocations(
|
||||
"file:" + InstallationPathConfig.getStaticPath(), "classpath:/static/");
|
||||
// .setCachePeriod(0); // Optional: disable caching
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@ import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.saml2.provider.service.authentication.OpenSaml4AuthenticationProvider.ResponseToken;
|
||||
import org.springframework.security.saml2.provider.service.authentication.Saml2Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import stirling.software.SPDF.config.security.UserService;
|
||||
import stirling.software.SPDF.model.User;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CustomSaml2ResponseAuthenticationConverter
|
||||
implements Converter<ResponseToken, Saml2Authentication> {
|
||||
|
||||
Reference in New Issue
Block a user