mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 09:28:49 +08:00
v 1.5.0 RC2
v 1.5.0 RC2
This commit is contained in:
parent
e33c6dfd0b
commit
f4318a784d
@ -1,14 +1,18 @@
|
|||||||
package org.maxkey.config;
|
package org.maxkey.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
@ -25,22 +29,39 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
|||||||
@Configuration
|
@Configuration
|
||||||
@PropertySource("classpath:/application.properties")
|
@PropertySource("classpath:/application.properties")
|
||||||
@PropertySource("classpath:/config/applicationConfig.properties")
|
@PropertySource("classpath:/config/applicationConfig.properties")
|
||||||
public class MvcAutoConfiguration {
|
public class MvcAutoConfiguration implements InitializingBean {
|
||||||
private static final Logger _logger = LoggerFactory.getLogger(MvcAutoConfiguration.class);
|
private static final Logger _logger = LoggerFactory.getLogger(MvcAutoConfiguration.class);
|
||||||
|
|
||||||
@Value("${config.server.domain.sub}")
|
/**
|
||||||
String subDomainName;
|
* propertySourcesPlaceholderConfigurer .
|
||||||
@Value("${spring.servlet.multipart.max-file-size:4194304}")
|
* @return propertySourcesPlaceholderConfigurer
|
||||||
int maxUploadSize;
|
* @throws IOException null
|
||||||
@Value("${spring.messages.basename:classpath:messages/message}")
|
*/
|
||||||
String messagesBasename;
|
@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 .
|
* cookieLocaleResolver .
|
||||||
* @return cookieLocaleResolver
|
* @return cookieLocaleResolver
|
||||||
*/
|
*/
|
||||||
@Bean (name = "localeResolver")
|
@Bean (name = "localeResolver")
|
||||||
public CookieLocaleResolver cookieLocaleResolver() {
|
public CookieLocaleResolver cookieLocaleResolver(
|
||||||
|
@Value("${config.server.domain.sub:maxkey.top}")String subDomainName) {
|
||||||
_logger.debug("subDomainName " + subDomainName);
|
_logger.debug("subDomainName " + subDomainName);
|
||||||
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
|
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
|
||||||
cookieLocaleResolver.setCookieName("maxkey_lang");
|
cookieLocaleResolver.setCookieName("maxkey_lang");
|
||||||
@ -55,8 +76,11 @@ public class MvcAutoConfiguration {
|
|||||||
* @return messageSource
|
* @return messageSource
|
||||||
*/
|
*/
|
||||||
@Bean (name = "messageSource")
|
@Bean (name = "messageSource")
|
||||||
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource() {
|
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource(
|
||||||
|
@Value("${spring.messages.basename:classpath:messages/message}")
|
||||||
|
String messagesBasename) {
|
||||||
_logger.debug("Basename " + messagesBasename);
|
_logger.debug("Basename " + messagesBasename);
|
||||||
|
|
||||||
ReloadableResourceBundleMessageSource messageSource =
|
ReloadableResourceBundleMessageSource messageSource =
|
||||||
new ReloadableResourceBundleMessageSource();
|
new ReloadableResourceBundleMessageSource();
|
||||||
messageSource.setBasename(messagesBasename);
|
messageSource.setBasename(messagesBasename);
|
||||||
@ -82,7 +106,8 @@ public class MvcAutoConfiguration {
|
|||||||
* @return multipartResolver
|
* @return multipartResolver
|
||||||
*/
|
*/
|
||||||
@Bean (name = "multipartResolver")
|
@Bean (name = "multipartResolver")
|
||||||
public CommonsMultipartResolver commonsMultipartResolver() {
|
public CommonsMultipartResolver commonsMultipartResolver(
|
||||||
|
@Value("${spring.servlet.multipart.max-file-size:0}") int maxUploadSize) {
|
||||||
_logger.debug("maxUploadSize " + maxUploadSize);
|
_logger.debug("maxUploadSize " + maxUploadSize);
|
||||||
CommonsMultipartResolver multipartResolver =
|
CommonsMultipartResolver multipartResolver =
|
||||||
new CommonsMultipartResolver();
|
new CommonsMultipartResolver();
|
||||||
@ -180,8 +205,12 @@ public class MvcAutoConfiguration {
|
|||||||
restTemplate.setMessageConverters(httpMessageConverterList);
|
restTemplate.setMessageConverters(httpMessageConverterList);
|
||||||
return restTemplate;
|
return restTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -202,4 +202,11 @@ public class KeyUriFormat {
|
|||||||
return uri.toString();
|
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 + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,5 +47,7 @@ spring.freemarker.suffix=.ftl
|
|||||||
|
|
||||||
#static resources
|
#static resources
|
||||||
spring.mvc.static-path-pattern=/static/**
|
spring.mvc.static-path-pattern=/static/**
|
||||||
|
spring.messages.basename=classpath:messages/message
|
||||||
|
spring.messages.encoding=UTF-8
|
||||||
|
|
||||||
spring.main.allow-bean-definition-overriding=true
|
spring.main.allow-bean-definition-overriding=true
|
||||||
@ -21,18 +21,7 @@
|
|||||||
<context:annotation-config />
|
<context:annotation-config />
|
||||||
<!-- language select must remove -->
|
<!-- language select must remove -->
|
||||||
<mvc:annotation-driven />
|
<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" />
|
<context:component-scan base-package="org.maxkey.config" />
|
||||||
<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
|
<!-- 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-->
|
@Controller and @Service. Make sure to set the correct base-package-->
|
||||||
|
|||||||
@ -120,24 +120,19 @@ public class MaxKeyConfig {
|
|||||||
return new SavedRequestAwareAuthenticationSuccessHandler();
|
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")
|
@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 keyUriFormat=new KeyUriFormat();
|
||||||
keyUriFormat.setType(keyuriFormatType);
|
keyUriFormat.setType(keyuriFormatType);
|
||||||
keyUriFormat.setDomain(keyuriFormatDomain);
|
keyUriFormat.setDomain(keyuriFormatDomain);
|
||||||
|
|||||||
@ -17,17 +17,6 @@
|
|||||||
http://www.springframework.org/schema/util/spring-util.xsd
|
http://www.springframework.org/schema/util/spring-util.xsd
|
||||||
http://www.springframework.org/schema/mvc
|
http://www.springframework.org/schema/mvc
|
||||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
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.
|
<!-- 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-->
|
@Controller and @Service. Make sure to set the correct base-package-->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user