v 1.5.0 RC2

v 1.5.0 RC2
This commit is contained in:
shimingxy 2020-05-16 13:42:52 +08:00
parent e33c6dfd0b
commit f4318a784d
6 changed files with 64 additions and 53 deletions

View File

@ -1,14 +1,18 @@
package org.maxkey.config;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@ -25,22 +29,39 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
@Configuration
@PropertySource("classpath:/application.properties")
@PropertySource("classpath:/config/applicationConfig.properties")
public class MvcAutoConfiguration {
public class MvcAutoConfiguration implements InitializingBean {
private static final Logger _logger = LoggerFactory.getLogger(MvcAutoConfiguration.class);
@Value("${config.server.domain.sub}")
String subDomainName;
@Value("${spring.servlet.multipart.max-file-size:4194304}")
int maxUploadSize;
@Value("${spring.messages.basename:classpath:messages/message}")
String messagesBasename;
/**
* propertySourcesPlaceholderConfigurer .
* @return propertySourcesPlaceholderConfigurer
* @throws IOException null
*/
@Bean (name = "propertySourcesPlaceholderConfigurer")
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer()
throws IOException {
ClassPathResource classPathResource1 =
new ClassPathResource("/config/applicationConfig.properties");
ClassPathResource classPathResource2 = new ClassPathResource("/application.properties");
PropertySourcesPlaceholderConfigurer configurer =
new PropertySourcesPlaceholderConfigurer();
configurer.setLocations(
classPathResource1,
classPathResource2
);
configurer.setIgnoreUnresolvablePlaceholders(true);
return configurer;
}
/**
* cookieLocaleResolver .
* @return cookieLocaleResolver
*/
@Bean (name = "localeResolver")
public CookieLocaleResolver cookieLocaleResolver() {
public CookieLocaleResolver cookieLocaleResolver(
@Value("${config.server.domain.sub:maxkey.top}")String subDomainName) {
_logger.debug("subDomainName " + subDomainName);
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
cookieLocaleResolver.setCookieName("maxkey_lang");
@ -55,8 +76,11 @@ public class MvcAutoConfiguration {
* @return messageSource
*/
@Bean (name = "messageSource")
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource() {
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource(
@Value("${spring.messages.basename:classpath:messages/message}")
String messagesBasename) {
_logger.debug("Basename " + messagesBasename);
ReloadableResourceBundleMessageSource messageSource =
new ReloadableResourceBundleMessageSource();
messageSource.setBasename(messagesBasename);
@ -82,7 +106,8 @@ public class MvcAutoConfiguration {
* @return multipartResolver
*/
@Bean (name = "multipartResolver")
public CommonsMultipartResolver commonsMultipartResolver() {
public CommonsMultipartResolver commonsMultipartResolver(
@Value("${spring.servlet.multipart.max-file-size:0}") int maxUploadSize) {
_logger.debug("maxUploadSize " + maxUploadSize);
CommonsMultipartResolver multipartResolver =
new CommonsMultipartResolver();
@ -181,7 +206,11 @@ public class MvcAutoConfiguration {
return restTemplate;
}
@Override
public void afterPropertiesSet() throws Exception {
// TODO Auto-generated method stub
}
}

View File

@ -202,4 +202,11 @@ public class KeyUriFormat {
return uri.toString();
}
@Override
public String toString() {
return "KeyUriFormat [crypto=" + crypto + ", type=" + type + ", secret=" + secret + ", issuer=" + issuer
+ ", domain=" + domain + ", digits=" + digits + ", counter=" + counter + ", period=" + period
+ ", account=" + account + "]";
}
}

View File

@ -47,5 +47,7 @@ spring.freemarker.suffix=.ftl
#static resources
spring.mvc.static-path-pattern=/static/**
spring.messages.basename=classpath:messages/message
spring.messages.encoding=UTF-8
spring.main.allow-bean-definition-overriding=true

View File

@ -22,17 +22,6 @@
<!-- language select must remove -->
<mvc:annotation-driven />
<!-- Application properties configs -->
<bean id="propertySourcesPlaceholderConfigurer" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/applicationConfig.properties</value>
<value>classpath:application.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<context:component-scan base-package="org.maxkey.config" />
<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
@Controller and @Service. Make sure to set the correct base-package-->

View File

@ -120,24 +120,19 @@ public class MaxKeyConfig {
return new SavedRequestAwareAuthenticationSuccessHandler();
}
@Value("${config.otp.keyuri.format.type:totp}")
String keyuriFormatType;
@Value("${config.otp.keyuri.format.domain:MaxKey.top}")
String keyuriFormatDomain;
@Value("${config.otp.keyuri.format.issuer:MaxKey}")
String keyuriFormatIssuer;
@Value("${config.otp.keyuri.format.digits:6}")
int keyuriFormatDigits;
@Value("${config.otp.keyuri.format.period:30}")
int keyuriFormatPeriod;
@Bean(name = "keyUriFormat")
public KeyUriFormat keyUriFormat() {
public KeyUriFormat keyUriFormat(
@Value("${config.otp.keyuri.format.type:totp}")
String keyuriFormatType,
@Value("${config.otp.keyuri.format.domain:MaxKey.top}")
String keyuriFormatDomain,
@Value("${config.otp.keyuri.format.issuer:MaxKey}")
String keyuriFormatIssuer,
@Value("${config.otp.keyuri.format.digits:6}")
int keyuriFormatDigits,
@Value("${config.otp.keyuri.format.period:30}")
int keyuriFormatPeriod) {
KeyUriFormat keyUriFormat=new KeyUriFormat();
keyUriFormat.setType(keyuriFormatType);
keyUriFormat.setDomain(keyuriFormatDomain);

View File

@ -18,17 +18,6 @@
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Application properties configs -->
<bean id="propertySourcesPlaceholderConfigurer" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/applicationConfig.properties</value>
<value>classpath:application.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
@Controller and @Service. Make sure to set the correct base-package-->
<context:component-scan base-package="org.maxkey.config" />