Remove trailing whitespace in Java source code
This commit is contained in:
@@ -26,19 +26,19 @@ import org.springframework.web.cors.CorsConfiguration;
|
||||
/**
|
||||
* Assist with the registration of {@link CorsConfiguration} mapped to one or more path patterns.
|
||||
* @author Sebastien Deleuze
|
||||
*
|
||||
*
|
||||
* @since 4.2
|
||||
* @see CorsRegistration
|
||||
*/
|
||||
public class CorsConfigurer {
|
||||
|
||||
|
||||
private final List<CorsRegistration> registrations = new ArrayList<CorsRegistration>();
|
||||
|
||||
|
||||
/**
|
||||
* Enable cross origin requests on the specified path patterns. If no path pattern is specified,
|
||||
* cross-origin request handling is mapped on "/**" .
|
||||
*
|
||||
*
|
||||
* <p>By default, all origins, all headers and credentials are allowed. Max age is set to 30 minutes.</p>
|
||||
*/
|
||||
public CorsRegistration enableCors(String... pathPatterns) {
|
||||
@@ -46,7 +46,7 @@ public class CorsConfigurer {
|
||||
this.registrations.add(registration);
|
||||
return registration;
|
||||
}
|
||||
|
||||
|
||||
protected Map<String, CorsConfiguration> getCorsConfigurations() {
|
||||
Map<String, CorsConfiguration> configs = new LinkedHashMap<String, CorsConfiguration>(this.registrations.size());
|
||||
for (CorsRegistration registration : this.registrations) {
|
||||
|
||||
@@ -25,19 +25,19 @@ import org.springframework.web.cors.CorsConfiguration;
|
||||
/**
|
||||
* Assists with the creation of a {@link CorsConfiguration} mapped to one or more path patterns.
|
||||
* If no path pattern is specified, cross-origin request handling is mapped on "/**" .
|
||||
*
|
||||
*
|
||||
* <p>By default, all origins, all headers, credentials and GET, HEAD, POST methods are allowed.
|
||||
* Max age is set to 30 minutes.</p>
|
||||
*
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 4.2
|
||||
*/
|
||||
public class CorsRegistration {
|
||||
|
||||
|
||||
private final String[] pathPatterns;
|
||||
|
||||
|
||||
private final CorsConfiguration config;
|
||||
|
||||
|
||||
public CorsRegistration(String... pathPatterns) {
|
||||
this.pathPatterns = (pathPatterns.length == 0 ? new String[]{ "/**" } : pathPatterns);
|
||||
// Same default values than @CrossOrigin annotation + allows simple methods
|
||||
@@ -50,43 +50,43 @@ public class CorsRegistration {
|
||||
this.config.setAllowCredentials(true);
|
||||
this.config.setMaxAge(1800L);
|
||||
}
|
||||
|
||||
|
||||
public CorsRegistration allowedOrigins(String... origins) {
|
||||
this.config.setAllowedOrigins(new ArrayList<String>(Arrays.asList(origins)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CorsRegistration allowedMethods(String... methods) {
|
||||
this.config.setAllowedMethods(new ArrayList<String>(Arrays.asList(methods)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CorsRegistration allowedHeaders(String... headers) {
|
||||
this.config.setAllowedHeaders(new ArrayList<String>(Arrays.asList(headers)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CorsRegistration exposedHeaders(String... headers) {
|
||||
this.config.setExposedHeaders(new ArrayList<String>(Arrays.asList(headers)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CorsRegistration maxAge(long maxAge) {
|
||||
this.config.setMaxAge(maxAge);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CorsRegistration allowCredentials(boolean allowCredentials) {
|
||||
this.config.setAllowCredentials(allowCredentials);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
protected String[] getPathPatterns() {
|
||||
return this.pathPatterns;
|
||||
}
|
||||
|
||||
|
||||
protected CorsConfiguration getCorsConfiguration() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -136,5 +136,5 @@ public class DelegatingWebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||
protected void configureCors(CorsConfigurer configurer) {
|
||||
this.configurers.configureCors(configurer);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
private ContentNegotiationManager contentNegotiationManager;
|
||||
|
||||
private List<HttpMessageConverter<?>> messageConverters;
|
||||
|
||||
|
||||
private Map<String, CorsConfiguration> corsConfigurations;
|
||||
|
||||
|
||||
@@ -881,7 +881,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
}
|
||||
return this.corsConfigurations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override this method to configure cross-origin requests handling.
|
||||
* @since 4.2
|
||||
|
||||
@@ -172,5 +172,5 @@ public abstract class WebMvcConfigurerAdapter implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void configureCors(CorsConfigurer configurer) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
private final List<HandlerInterceptor> adaptedInterceptors = new ArrayList<HandlerInterceptor>();
|
||||
|
||||
private CorsProcessor corsProcessor = new DefaultCorsProcessor();
|
||||
|
||||
|
||||
private final Map<String, CorsConfiguration> corsConfiguration =
|
||||
new LinkedHashMap<String, CorsConfiguration>();
|
||||
|
||||
|
||||
@@ -678,7 +678,7 @@ public class MvcUriComponentsBuilder {
|
||||
ControllerMethodInvocationInterceptor(Class<?> controllerType) {
|
||||
this.controllerType = controllerType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) {
|
||||
if (getControllerMethod.equals(method)) {
|
||||
|
||||
@@ -28,30 +28,30 @@ import org.springframework.web.cors.CorsConfiguration;
|
||||
|
||||
/**
|
||||
* Test fixture with a {@link CorsConfigurer}.
|
||||
*
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class CorsConfigurerTests {
|
||||
|
||||
|
||||
private CorsConfigurer configurer;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.configurer = new CorsConfigurer();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noCorsConfigured() {
|
||||
assertTrue(this.configurer.getCorsConfigurations().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void multipleCorsConfigured() {
|
||||
this.configurer.enableCors("/foo");
|
||||
this.configurer.enableCors("/bar");
|
||||
assertEquals(2, this.configurer.getCorsConfigurations().size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void defaultCorsRegistration() {
|
||||
this.configurer.enableCors();
|
||||
@@ -64,7 +64,7 @@ public class CorsConfigurerTests {
|
||||
assertEquals(true, config.getAllowCredentials());
|
||||
assertEquals(Long.valueOf(1800), config.getMaxAge());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void customizedCorsRegistration() {
|
||||
this.configurer.enableCors("/foo").allowedOrigins("http://domain2.com", "http://domain2.com")
|
||||
@@ -80,5 +80,5 @@ public class CorsConfigurerTests {
|
||||
assertEquals(false, config.getAllowCredentials());
|
||||
assertEquals(Long.valueOf(3600), config.getMaxAge());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ public class WebMvcConfigurationSupportExtensionTests {
|
||||
assertEquals("/", accessor.getPropertyValue("prefix"));
|
||||
assertEquals(".jsp", accessor.getPropertyValue("suffix"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void crossOrigin() {
|
||||
Map<String, CorsConfiguration> configs = this.config.getCorsConfigurations();
|
||||
@@ -407,7 +407,7 @@ public class WebMvcConfigurationSupportExtensionTests {
|
||||
public void configureCors(CorsConfigurer registry) {
|
||||
registry.enableCors("/resources/**");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private class TestPathHelper extends UrlPathHelper {}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class CorsAbstractHandlerMappingTests {
|
||||
assertNotNull(config);
|
||||
assertArrayEquals(config.getAllowedOrigins().toArray(), new String[]{"*"});
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void actualRequestWithMappedCorsConfiguration() throws Exception {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
|
||||
@@ -236,7 +236,7 @@ public class MvcUriComponentsBuilderTests {
|
||||
assertThat(uriComponents.toUriString(), startsWith("http://localhost"));
|
||||
assertThat(uriComponents.toUriString(), endsWith("/extended/else"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFromMethodCallWithTypeLevelUriVars() {
|
||||
UriComponents uriComponents = fromMethodCall(on(
|
||||
@@ -430,7 +430,7 @@ public class MvcUriComponentsBuilderTests {
|
||||
static class ExtendedController extends ControllerWithMethods {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/user/{userId}/contacts")
|
||||
static class UserContactController {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user