properties优化

properties优化
This commit is contained in:
shimingxy
2020-05-30 10:07:38 +08:00
parent 73b6625294
commit 38164a50b4
20 changed files with 87 additions and 43 deletions

View File

@@ -4,6 +4,7 @@ import java.util.Date;
import javax.servlet.ServletException;
import org.apache.ibatis.io.VFS;
import org.apache.mybatis.jpa.SpringBootVFS;
import org.maxkey.config.ApplicationConfig;
import org.maxkey.web.InitializeContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,7 +36,7 @@ public class MaxKeyApplication extends SpringBootServletInitializer {
}
_logger.info("MaxKey at " + new Date(applicationContext.getStartupDate()));
_logger.info("MaxKey Server Port "
+ applicationContext.getBean(MaxKeyConfig.class).getPort());
+ applicationContext.getBean(ApplicationConfig.class).getPort());
_logger.info("MaxKey started.");
}

View File

@@ -21,6 +21,7 @@ import org.maxkey.authn.support.socialsignon.service.JdbcSocialsAssociateService
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProvider;
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService;
import org.maxkey.authz.oauth2.provider.endpoint.TokenEndpointAuthenticationFilter;
import org.maxkey.constants.ConstantsProperties;
import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat;
import org.maxkey.crypto.password.opt.impl.MailOtpAuthn;
import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
@@ -50,8 +51,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
@Configuration
//@ImportResource(locations = { "classpath:spring/maxkey.xml" })
@PropertySource("classpath:/application.properties")
@PropertySource("classpath:/config/applicationConfig.properties")
@PropertySource(ConstantsProperties.applicationPropertySource)
@PropertySource(ConstantsProperties.maxKeyPropertySource)
@MapperScan("org.maxkey.dao.persistence,")
@ComponentScan(basePackages = {
"org.maxkey.config",
@@ -74,13 +75,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
public class MaxKeyConfig implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyConfig.class);
@Value("${server.port:8080}")
private int port;
public int getPort() {
return port;
}
@Bean
public FilterRegistrationBean<TokenEndpointAuthenticationFilter> TokenEndpointAuthenticationFilter() {
_logger.debug("TokenEndpointAuthenticationFilter init ");
@@ -250,7 +244,8 @@ public class MaxKeyConfig implements InitializingBean {
public SocialSignOnProviderService socialSignOnProviderService() throws IOException {
SocialSignOnProviderService socialSignOnProviderService = new SocialSignOnProviderService();
Resource resource = new ClassPathResource("/config/applicationConfig.properties");
Resource resource = new ClassPathResource(
ConstantsProperties.classPathResource(ConstantsProperties.classPathResource(ConstantsProperties.maxKeyPropertySource)));
Properties properties = new Properties();
properties.load(resource.getInputStream());
String [] providerList =properties.get("config.login.socialsignon.providers").toString().split(",");

View File

@@ -2,6 +2,7 @@ package org.maxkey;
import org.maxkey.authn.support.basic.BasicEntryPoint;
import org.maxkey.authn.support.httpheader.HttpHeaderEntryPoint;
import org.maxkey.constants.ConstantsProperties;
import org.maxkey.web.interceptor.HistoryLoginAppAdapter;
import org.maxkey.web.interceptor.HistoryLogsAdapter;
import org.maxkey.web.interceptor.PermissionAdapter;
@@ -20,7 +21,7 @@ import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
@Configuration
@EnableWebMvc
@PropertySource("classpath:/config/applicationConfig.properties")
@PropertySource(ConstantsProperties.maxKeyPropertySource)
public class MaxKeyMvcConfig implements WebMvcConfigurer {
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyMvcConfig.class);
@Autowired

View File

@@ -4,6 +4,7 @@ import org.maxkey.authz.cas.endpoint.ticket.service.InMemoryTicketServices;
import org.maxkey.authz.cas.endpoint.ticket.service.JdbcTicketServices;
import org.maxkey.authz.cas.endpoint.ticket.service.RedisTicketServices;
import org.maxkey.authz.cas.endpoint.ticket.service.TicketServices;
import org.maxkey.constants.ConstantsProperties;
import org.maxkey.persistence.redis.RedisConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -19,7 +20,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
@ComponentScan(basePackages = {
"org.maxkey.authz.cas.endpoint"
})
@PropertySource("classpath:/application.properties")
@PropertySource(ConstantsProperties.maxKeyPropertySource)
public class CasAutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(CasAutoConfiguration.class);

View File

@@ -25,6 +25,7 @@ import org.maxkey.authz.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.maxkey.authz.oauth2.provider.token.store.RedisTokenStore;
import org.maxkey.authz.oidc.idtoken.OIDCIdTokenEnhancer;
import org.maxkey.config.oidc.OIDCProviderMetadataDetails;
import org.maxkey.constants.ConstantsProperties;
import org.maxkey.crypto.jose.keystore.JWKSetKeyStore;
import org.maxkey.crypto.jwt.encryption.service.impl.DefaultJwtEncryptionAndDecryptionService;
import org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService;
@@ -53,8 +54,8 @@ import com.nimbusds.jose.JWEAlgorithm;
"org.maxkey.authz.oauth2.provider.userinfo.endpoint",
"org.maxkey.authz.oauth2.provider.approval.controller"
})
@PropertySource("classpath:/application.properties")
@PropertySource("classpath:/config/applicationConfig.properties")
@PropertySource(ConstantsProperties.applicationPropertySource)
@PropertySource(ConstantsProperties.maxKeyPropertySource)
public class Oauth20AutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(Oauth20AutoConfiguration.class);

View File

@@ -17,6 +17,7 @@ import org.maxkey.authz.saml20.binding.impl.PostBindingAdapter;
import org.maxkey.authz.saml20.binding.impl.PostSimpleSignBindingAdapter;
import org.maxkey.authz.saml20.provider.xml.AuthnResponseGenerator;
import org.maxkey.authz.saml20.xml.SAML2ValidatorSuite;
import org.maxkey.constants.ConstantsProperties;
import org.maxkey.crypto.keystore.KeyStoreLoader;
import org.maxkey.domain.Saml20Metadata;
import org.opensaml.common.binding.security.IssueInstantRule;
@@ -40,8 +41,8 @@ import org.springframework.ui.velocity.VelocityEngineFactoryBean;
"org.maxkey.authz.saml20.provider.endpoint",
"org.maxkey.authz.saml20.metadata.endpoint",
})
@PropertySource("classpath:/application.properties")
@PropertySource("classpath:/config/applicationConfig.properties")
@PropertySource(ConstantsProperties.applicationPropertySource)
@PropertySource(ConstantsProperties.maxKeyPropertySource)
public class Saml20AutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(Saml20AutoConfiguration.class);