59 lines
2.0 KiB
Java
Raw Normal View History

2023-08-13 01:15:26 +01:00
package stirling.software.SPDF.config;
2023-08-26 17:30:49 +01:00
import java.util.Arrays;
2023-08-26 12:27:52 +01:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
2023-08-13 01:15:26 +01:00
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
2023-08-26 12:27:52 +01:00
import org.springframework.core.env.Environment;
2023-08-13 01:15:26 +01:00
2023-08-26 17:30:49 +01:00
import stirling.software.SPDF.utils.PropertyConfigs;
import stirling.software.SPDF.model.ApplicationProperties;
2023-08-13 01:15:26 +01:00
@Configuration
public class AppConfig {
2023-08-26 12:27:52 +01:00
2023-08-26 17:30:49 +01:00
@Autowired
ApplicationProperties applicationProperties;
2023-08-26 12:27:52 +01:00
@Bean(name = "loginEnabled")
2023-08-13 01:15:26 +01:00
public boolean loginEnabled() {
2023-08-26 17:30:49 +01:00
System.out.println(applicationProperties.toString());
return applicationProperties.getSecurity().getEnableLogin();
2023-08-13 01:15:26 +01:00
}
2023-08-26 12:27:52 +01:00
2023-08-13 01:15:26 +01:00
@Bean(name = "appName")
public String appName() {
2023-08-26 23:33:35 +01:00
String homeTitle = applicationProperties.getUi().getHomeName();
return (homeTitle != null) ? homeTitle : "Stirling PDF";
2023-08-13 01:15:26 +01:00
}
@Bean(name = "appVersion")
public String appVersion() {
String version = getClass().getPackage().getImplementationVersion();
return (version != null) ? version : "0.0.0";
}
@Bean(name = "homeText")
public String homeText() {
2023-08-26 17:30:49 +01:00
return applicationProperties.getUi().getHomeDescription();
2023-08-13 01:15:26 +01:00
}
2023-08-26 17:30:49 +01:00
2023-08-13 01:15:26 +01:00
@Bean(name = "navBarText")
public String navBarText() {
2023-08-26 17:30:49 +01:00
String defaultNavBar = applicationProperties.getUi().getNavbarName() != null ? applicationProperties.getUi().getNavbarName() : applicationProperties.getUi().getHomeName();
2023-08-26 23:33:35 +01:00
return (defaultNavBar != null) ? defaultNavBar : "Stirling PDF";
2023-08-26 12:27:52 +01:00
}
@Bean(name = "rateLimit")
public boolean rateLimit() {
String appName = System.getProperty("rateLimit");
if (appName == null)
appName = System.getenv("rateLimit");
System.out.println("rateLimit=" + appName);
return (appName != null) ? Boolean.valueOf(appName) : false;
2023-08-13 01:15:26 +01:00
}
2023-08-26 12:27:52 +01:00
}