Java Code Examples for org.springframework.web.cors.UrlBasedCorsConfigurationSource#setCorsConfigurations()
The following examples show how to use
org.springframework.web.cors.UrlBasedCorsConfigurationSource#setCorsConfigurations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractHandlerMapping.java From spring-analysis-note with MIT License | 5 votes |
/** * Set the "global" CORS configurations based on URL patterns. By default the first * matching URL pattern is combined with the CORS configuration for the handler, if any. * @since 4.2 * @see #setCorsConfigurationSource(CorsConfigurationSource) */ public void setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations) { Assert.notNull(corsConfigurations, "corsConfigurations must not be null"); if (!corsConfigurations.isEmpty()) { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.setCorsConfigurations(corsConfigurations); source.setPathMatcher(this.pathMatcher); source.setUrlPathHelper(this.urlPathHelper); source.setLookupPathAttributeName(LOOKUP_PATH); this.corsConfigurationSource = source; } else { this.corsConfigurationSource = null; } }
Example 2
Source File: AbstractHandlerMapping.java From java-technology-stack with MIT License | 5 votes |
/** * Set the "global" CORS configurations based on URL patterns. By default the first * matching URL pattern is combined with the CORS configuration for the handler, if any. * @since 4.2 * @see #setCorsConfigurationSource(CorsConfigurationSource) */ public void setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations) { Assert.notNull(corsConfigurations, "corsConfigurations must not be null"); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.setCorsConfigurations(corsConfigurations); source.setPathMatcher(this.pathMatcher); source.setUrlPathHelper(this.urlPathHelper); this.corsConfigurationSource = source; }
Example 3
Source File: GrozaSecurityConfiguration.java From Groza with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(CorsFilter.class) public CorsFilter corsFilter(@Autowired MvcCorsProperties mvcCorsProperties) { if (mvcCorsProperties.getMappings().size() == 0) { return new CorsFilter(new UrlBasedCorsConfigurationSource()); } else { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.setCorsConfigurations(mvcCorsProperties.getMappings()); return new CorsFilter(source); } }
Example 4
Source File: IoTPSecurityConfiguration.java From iotplatform with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(CorsFilter.class) public CorsFilter corsFilter(@Autowired MvcCorsProperties mvcCorsProperties) { if (mvcCorsProperties.getMappings().size() == 0) { return new CorsFilter(new UrlBasedCorsConfigurationSource()); } else { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.setCorsConfigurations(mvcCorsProperties.getMappings()); return new CorsFilter(source); } }
Example 5
Source File: CorsFilterConfiguration.java From onetwo with Apache License 2.0 | 4 votes |
@Bean public UrlBasedCorsConfigurationSource corsConfigurationSource(ExtCorsRegistry corsRegistry) { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.setCorsConfigurations(corsRegistry.getCorsConfigurations()); return source; }