diff --git a/wise-webapp/src/main/java/com/wisemapping/config/Application.java b/wise-webapp/src/main/java/com/wisemapping/config/Application.java index 0c5a8502..e129bf45 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/Application.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/Application.java @@ -2,26 +2,23 @@ package com.wisemapping.config; import com.wisemapping.config.common.CommonConfig; import com.wisemapping.config.common.HibernateConfig; -import com.wisemapping.config.common.InterceptorsConfig; -import com.wisemapping.config.common.SecurityConfig; import com.wisemapping.config.mvc.MvcAppConfig; -import com.wisemapping.config.mvc.MvcSecurityConfig; +import com.wisemapping.config.rest.InterceptorsConfig; +import com.wisemapping.config.common.SecurityConfig; import com.wisemapping.config.rest.ServletConfig; import com.wisemapping.config.rest.RestAppConfig; import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Bean; import org.springframework.security.web.firewall.StrictHttpFirewall; -@SpringBootApplication public class Application { public static void main(String[] args) { new SpringApplicationBuilder() - .parent(HibernateConfig.class, ServletConfig.class, CommonConfig.class, SecurityConfig.class).web(WebApplicationType.NONE) - .child(MvcAppConfig.class, MvcSecurityConfig.class, SecurityConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET) - .sibling(RestAppConfig.class, ServletConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET) + .parent(CommonConfig.class).web(WebApplicationType.NONE) + .child(MvcAppConfig.class).web(WebApplicationType.SERVLET) + .sibling(RestAppConfig.class).web(WebApplicationType.SERVLET) .run(args); } diff --git a/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java index 6b2ec206..42f4266b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java @@ -1,11 +1,17 @@ package com.wisemapping.config.common; +import com.wisemapping.config.rest.ServletConfig; +import com.wisemapping.dao.LabelManagerImpl; +import com.wisemapping.model.Mindmap; +import com.wisemapping.security.AuthenticationProvider; +import com.wisemapping.service.MindmapServiceImpl; +import com.wisemapping.util.VelocityEngineUtils; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource(value = {"classpath:spring/wisemapping-mail.xml"}) -@ComponentScan({"com.wisemapping.security", "com.wisemapping.service", "com.wisemapping.dao", "com.wisemapping.util", "com.wisemapping.model"}) +@ComponentScan(basePackageClasses = {HibernateConfig.class, SecurityConfig.class, AuthenticationProvider.class, MindmapServiceImpl.class, LabelManagerImpl.class, VelocityEngineUtils.class}) public class CommonConfig { } diff --git a/wise-webapp/src/main/java/com/wisemapping/config/mvc/InterceptorsConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/mvc/InterceptorsConfig.java new file mode 100644 index 00000000..8504a163 --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/config/mvc/InterceptorsConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright [2022] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.wisemapping.config.mvc; + +import com.wisemapping.filter.RequestPropertiesInterceptor; +import com.wisemapping.filter.UserLocaleInterceptor; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@ComponentScan(basePackageClasses = UserLocaleInterceptor.class) +public class InterceptorsConfig implements WebMvcConfigurer { + @Autowired + private UserLocaleInterceptor userLocaleInterceptor; + + @Autowired + private RequestPropertiesInterceptor requestPropertiesInterceptor; + + @Override + public void addInterceptors(@NotNull final InterceptorRegistry registry) { + registry.addInterceptor(userLocaleInterceptor); + registry.addInterceptor(requestPropertiesInterceptor); + } +} \ No newline at end of file diff --git a/wise-webapp/src/main/java/com/wisemapping/config/mvc/MvcAppConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/mvc/MvcAppConfig.java index 6cb0ae40..b9ec21fe 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/mvc/MvcAppConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/mvc/MvcAppConfig.java @@ -1,5 +1,6 @@ package com.wisemapping.config.mvc; +import com.wisemapping.webmvc.MvcMindmapController; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -15,10 +16,8 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; -@Configuration -@EnableAutoConfiguration +@SpringBootApplication(scanBasePackageClasses = {MvcMindmapController.class, MvcSecurityConfig.class}) @EnableWebMvc -@ComponentScan("com.wisemapping.webmvc") public class MvcAppConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { diff --git a/wise-webapp/src/main/java/com/wisemapping/config/common/InterceptorsConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/rest/InterceptorsConfig.java similarity index 94% rename from wise-webapp/src/main/java/com/wisemapping/config/common/InterceptorsConfig.java rename to wise-webapp/src/main/java/com/wisemapping/config/rest/InterceptorsConfig.java index 3d79186f..e5baf5d5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/common/InterceptorsConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/rest/InterceptorsConfig.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.wisemapping.config.common; +package com.wisemapping.config.rest; import com.wisemapping.filter.RequestPropertiesInterceptor; import com.wisemapping.filter.UserLocaleInterceptor; @@ -28,7 +28,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -@ComponentScan("com.wisemapping.filter") +@ComponentScan(basePackageClasses = UserLocaleInterceptor.class) public class InterceptorsConfig implements WebMvcConfigurer { @Autowired private UserLocaleInterceptor userLocaleInterceptor; diff --git a/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java index f1df387b..52b2db4d 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java @@ -1,7 +1,9 @@ package com.wisemapping.config.rest; +import com.wisemapping.rest.MindmapController; import org.jetbrains.annotations.NotNull; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -15,14 +17,13 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector; import static org.springframework.security.config.Customizer.withDefaults; -@Configuration -@EnableAutoConfiguration -@ComponentScan({"com.wisemapping.rest"}) +@SpringBootApplication(scanBasePackageClasses = {MindmapController.class, ServletConfig.class}) public class RestAppConfig { @Bean MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) { return new MvcRequestMatcher.Builder(introspector); } + @Bean SecurityFilterChain apiSecurityFilterChain(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception { return http diff --git a/wise-webapp/src/main/resources/spring/wisemapping-mail.xml b/wise-webapp/src/main/resources/spring/wisemapping-mail.xml index 7cebddbe..7a097fe9 100755 --- a/wise-webapp/src/main/resources/spring/wisemapping-mail.xml +++ b/wise-webapp/src/main/resources/spring/wisemapping-mail.xml @@ -4,6 +4,22 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> + + + + + + + + + + ${mail.smtp.auth:false} + ${mail.smtp.starttls.enable:false} + ${mail.smtp.quitwait:true} + + + + diff --git a/wise-webapp/src/main/resources/spring/wisemapping-messages.xml b/wise-webapp/src/main/resources/spring/wisemapping-messages.xml index 7a097fe9..7cebddbe 100755 --- a/wise-webapp/src/main/resources/spring/wisemapping-messages.xml +++ b/wise-webapp/src/main/resources/spring/wisemapping-messages.xml @@ -4,22 +4,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - - - - - - - - - ${mail.smtp.auth:false} - ${mail.smtp.starttls.enable:false} - ${mail.smtp.quitwait:true} - - - -