From 2f0f0ed8ebf390862499805a7805c154f74cae18 Mon Sep 17 00:00:00 2001 From: shimingxy Date: Sat, 16 May 2020 14:32:27 +0800 Subject: [PATCH] v 1.5.0 RC2 v 1.5.0 RC2 --- .../autoconfigure/MvcAutoConfiguration.java | 29 +++++++++++++-- .../main/java/org/maxkey/MaxKeyMgtConfig.java | 26 ------------- .../main/java/org/maxkey/MaxKeyConfig.java | 37 +------------------ 3 files changed, 27 insertions(+), 65 deletions(-) diff --git a/maxkey-core/src/main/java/org/maxkey/autoconfigure/MvcAutoConfiguration.java b/maxkey-core/src/main/java/org/maxkey/autoconfigure/MvcAutoConfiguration.java index 09ce1d59f..9011f5207 100644 --- a/maxkey-core/src/main/java/org/maxkey/autoconfigure/MvcAutoConfiguration.java +++ b/maxkey-core/src/main/java/org/maxkey/autoconfigure/MvcAutoConfiguration.java @@ -1,18 +1,19 @@ package org.maxkey.autoconfigure; -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.boot.web.server.ConfigurableWebServerFactory; +import org.springframework.boot.web.server.ErrorPage; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; 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.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; @@ -183,6 +184,28 @@ public class MvcAutoConfiguration implements InitializingBean { return restTemplate; } + /** + * 配置默认错误页面(仅用于内嵌tomcat启动时) 使用这种方式,在打包为war后不起作用. + * + * @return webServerFactoryCustomizer + */ + @Bean + public WebServerFactoryCustomizer webServerFactoryCustomizer() { + return new WebServerFactoryCustomizer() { + @Override + public void customize(ConfigurableWebServerFactory factory) { + _logger.debug("WebServerFactoryCustomizer ... "); + ErrorPage errorPage400 = + new ErrorPage(HttpStatus.BAD_REQUEST, "/exception/error/400"); + ErrorPage errorPage404 = + new ErrorPage(HttpStatus.NOT_FOUND, "/exception/error/404"); + ErrorPage errorPage500 = + new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/exception/error/500"); + factory.addErrorPages(errorPage400, errorPage404, errorPage500); + } + }; + } + @Override public void afterPropertiesSet() throws Exception { // TODO Auto-generated method stub diff --git a/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java b/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java index a5c4e3daa..c8d49514b 100644 --- a/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java +++ b/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java @@ -4,13 +4,8 @@ import org.mybatis.spring.annotation.MapperScan; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.server.ConfigurableWebServerFactory; -import org.springframework.boot.web.server.ErrorPage; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import org.springframework.http.HttpStatus; @Configuration @PropertySource("classpath:/application.properties") @@ -29,25 +24,4 @@ public class MaxKeyMgtConfig { this.port = port; } - /** - * 配置默认错误页面(仅用于内嵌tomcat启动时) - * 使用这种方式,在打包为war后不起作用 - * - * @return - */ - @Bean - public WebServerFactoryCustomizer webServerFactoryCustomizer() { - return new WebServerFactoryCustomizer() { - @Override - public void customize(ConfigurableWebServerFactory factory) { - _logger.debug("WebServerFactoryCustomizer ... "); - ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/exception/error/400"); - ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/exception/error/404"); - ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/exception/error/500"); - factory.addErrorPages(errorPage400, errorPage404,errorPage500); - - } - }; - } - } diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java b/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java index 8580adc20..b2dfafdfc 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java @@ -1,36 +1,21 @@ package org.maxkey; -import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; -import javax.sql.DataSource; import org.apache.catalina.Context; import org.apache.catalina.connector.Connector; -import org.apache.ibatis.session.SqlSessionFactory; import org.apache.tomcat.util.descriptor.web.SecurityCollection; import org.apache.tomcat.util.descriptor.web.SecurityConstraint; import org.maxkey.authz.oauth2.provider.endpoint.TokenEndpointAuthenticationFilter; -import org.maxkey.authn.RealmAuthenticationProvider; -import org.maxkey.authn.SavedRequestAwareAuthenticationSuccessHandler; -import org.maxkey.crypto.password.PasswordReciprocal; import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat; -import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.annotation.MapperScan; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.server.ConfigurableWebServerFactory; -import org.springframework.boot.web.server.ErrorPage; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; -import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.PropertySource; -import org.springframework.http.HttpStatus; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; @Configuration @ImportResource(locations = { "classpath:spring/maxkey.xml" }) @@ -47,10 +32,9 @@ public class MaxKeyConfig { return port; } - - @Bean public FilterRegistrationBean TokenEndpointAuthenticationFilter() { + _logger.debug("TokenEndpointAuthenticationFilter init "); FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new TokenEndpointAuthenticationFilter()); registration.addUrlPatterns("/oauth/v20/token/*"); @@ -59,25 +43,6 @@ public class MaxKeyConfig { return registration; } - /** - * 配置默认错误页面(仅用于内嵌tomcat启动时) 使用这种方式,在打包为war后不起作用 - * - * @return - */ - @Bean - public WebServerFactoryCustomizer webServerFactoryCustomizer() { - return new WebServerFactoryCustomizer() { - @Override - public void customize(ConfigurableWebServerFactory factory) { - _logger.debug("WebServerFactoryCustomizer ... "); - ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/exception/error/400"); - ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/exception/error/404"); - ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/exception/error/500"); - factory.addErrorPages(errorPage400, errorPage404, errorPage500); - } - }; - } - @Bean public Connector connector() { Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");