mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-23 03:43:48 +01:00
Compare commits
2 Commits
a69256b793
...
a3b289a738
Author | SHA1 | Date | |
---|---|---|---|
|
a3b289a738 | ||
|
9dcb139169 |
@ -2,27 +2,23 @@ package com.wisemapping.config;
|
|||||||
|
|
||||||
import com.wisemapping.config.common.CommonConfig;
|
import com.wisemapping.config.common.CommonConfig;
|
||||||
import com.wisemapping.config.common.HibernateConfig;
|
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.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.ServletConfig;
|
||||||
import com.wisemapping.config.rest.RestAppConfig;
|
import com.wisemapping.config.rest.RestAppConfig;
|
||||||
import org.springframework.boot.WebApplicationType;
|
import org.springframework.boot.WebApplicationType;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.security.web.firewall.StrictHttpFirewall;
|
import org.springframework.security.web.firewall.StrictHttpFirewall;
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
new SpringApplicationBuilder()
|
new SpringApplicationBuilder()
|
||||||
.parent(HibernateConfig.class, ServletConfig.class, CommonConfig.class, SecurityConfig.class).web(WebApplicationType.NONE)
|
.parent(CommonConfig.class).web(WebApplicationType.NONE)
|
||||||
// .child(MvcAppConfig.class, MvcSecurityConfig.class, SecurityConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET)
|
.child(MvcAppConfig.class).web(WebApplicationType.SERVLET)
|
||||||
.child(RestAppConfig.class, ServletConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET)
|
.sibling(RestAppConfig.class).web(WebApplicationType.SERVLET)
|
||||||
.run(args);
|
.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package com.wisemapping.config.common;
|
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.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.ImportResource;
|
import org.springframework.context.annotation.ImportResource;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ImportResource(value = {"classpath:spring/wisemapping-mail.xml"})
|
@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 {
|
public class CommonConfig {
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
package com.wisemapping.config.mvc;
|
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.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.ImportResource;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||||
import org.springframework.web.servlet.ViewResolver;
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
@ -14,9 +16,8 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|||||||
import org.springframework.web.servlet.view.JstlView;
|
import org.springframework.web.servlet.view.JstlView;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication(scanBasePackageClasses = {MvcMindmapController.class, MvcSecurityConfig.class})
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan("com.wisemapping.webmvc")
|
|
||||||
public class MvcAppConfig implements WebMvcConfigurer {
|
public class MvcAppConfig implements WebMvcConfigurer {
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
@ -14,7 +14,6 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class MvcSecurityConfig {
|
public class MvcSecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Order(1)
|
@Order(1)
|
||||||
public SecurityFilterChain embeddedDisabledXOrigin(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
public SecurityFilterChain embeddedDisabledXOrigin(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
||||||
|
@ -15,19 +15,20 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.wisemapping.config.common;
|
package com.wisemapping.config.rest;
|
||||||
|
|
||||||
import com.wisemapping.filter.RequestPropertiesInterceptor;
|
import com.wisemapping.filter.RequestPropertiesInterceptor;
|
||||||
import com.wisemapping.filter.UserLocaleInterceptor;
|
import com.wisemapping.filter.UserLocaleInterceptor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Component
|
@Configuration
|
||||||
@ComponentScan("com.wisemapping.filter")
|
@ComponentScan(basePackageClasses = UserLocaleInterceptor.class)
|
||||||
public class InterceptorsConfig implements WebMvcConfigurer {
|
public class InterceptorsConfig implements WebMvcConfigurer {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserLocaleInterceptor userLocaleInterceptor;
|
private UserLocaleInterceptor userLocaleInterceptor;
|
@ -1,11 +1,13 @@
|
|||||||
package com.wisemapping.config.rest;
|
package com.wisemapping.config.rest;
|
||||||
|
|
||||||
|
import com.wisemapping.rest.MindmapController;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
@ -15,14 +17,13 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
|||||||
import static org.springframework.security.config.Customizer.withDefaults;
|
import static org.springframework.security.config.Customizer.withDefaults;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication(scanBasePackageClasses = {MindmapController.class, ServletConfig.class})
|
||||||
@EnableWebSecurity
|
|
||||||
@ComponentScan({"com.wisemapping.rest"})
|
|
||||||
public class RestAppConfig {
|
public class RestAppConfig {
|
||||||
@Bean
|
@Bean
|
||||||
MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
||||||
return new MvcRequestMatcher.Builder(introspector);
|
return new MvcRequestMatcher.Builder(introspector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
SecurityFilterChain apiSecurityFilterChain(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
SecurityFilterChain apiSecurityFilterChain(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
||||||
return http
|
return http
|
||||||
|
@ -4,6 +4,22 @@
|
|||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
|
|
||||||
|
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||||
|
<property name="host" value="${mail.smtp.host}"/>
|
||||||
|
<property name="port" value="${mail.smtp.port}"/>
|
||||||
|
<property name="protocol" value="smtp"/>
|
||||||
|
<property name="username" value="${mail.username}"/>
|
||||||
|
<property name="password" value="${mail.password}"/>
|
||||||
|
<property name="javaMailProperties">
|
||||||
|
<props>
|
||||||
|
<prop key="mail.smtp.auth">${mail.smtp.auth:false}</prop>
|
||||||
|
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable:false}</prop>
|
||||||
|
<prop key="mail.smtp.quitwait">${mail.smtp.quitwait:true}</prop>
|
||||||
|
</props>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||||
<property name="defaultEncoding" value="UTF-8"/>
|
<property name="defaultEncoding" value="UTF-8"/>
|
||||||
<property name="basenames">
|
<property name="basenames">
|
||||||
|
@ -4,22 +4,6 @@
|
|||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
|
|
||||||
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
|
||||||
<property name="host" value="${mail.smtp.host}"/>
|
|
||||||
<property name="port" value="${mail.smtp.port}"/>
|
|
||||||
<property name="protocol" value="smtp"/>
|
|
||||||
<property name="username" value="${mail.username}"/>
|
|
||||||
<property name="password" value="${mail.password}"/>
|
|
||||||
<property name="javaMailProperties">
|
|
||||||
<props>
|
|
||||||
<prop key="mail.smtp.auth">${mail.smtp.auth:false}</prop>
|
|
||||||
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable:false}</prop>
|
|
||||||
<prop key="mail.smtp.quitwait">${mail.smtp.quitwait:true}</prop>
|
|
||||||
</props>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||||
<property name="defaultEncoding" value="UTF-8"/>
|
<property name="defaultEncoding" value="UTF-8"/>
|
||||||
<property name="basenames">
|
<property name="basenames">
|
||||||
|
@ -19,24 +19,27 @@
|
|||||||
package com.wisemapping.test.rest;
|
package com.wisemapping.test.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.config.Application;
|
||||||
import com.wisemapping.rest.model.RestUser;
|
import com.wisemapping.rest.model.RestUser;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import static com.wisemapping.test.rest.RestHelper.*;
|
import static com.wisemapping.test.rest.RestHelper.*;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
|
@SpringBootTest(classes = Application.class)
|
||||||
public class RestAccountITCase {
|
public class RestAccountITCase {
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
public void deleteUser() { // Configure media types ...
|
||||||
public void deleteUser(final @NotNull MediaType mediaType) { // Configure media types ...
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate adminTemplate = createTemplate(ADMIN_CREDENTIALS);
|
final RestTemplate adminTemplate = createTemplate(ADMIN_CREDENTIALS);
|
||||||
|
|
||||||
final RestUser dummyUser = createDummyUser();
|
final RestUser dummyUser = createDummyUser();
|
Loading…
Reference in New Issue
Block a user